在使用CentOS系统时,我们可能会觉得有些设置不适合我们。虽然不会造成大的错误,但是确实给我们带来了很多小麻烦。让我给你一些建议来修改你的DNS,网关和IP地址。
那我们来说明一下怎么修改吧!
1.CentOS系统修改DNS。
修改网卡对应的DNS的配置文件# vi /etc/resolv.conf,修改以下内容:名称服务器8.8.8.8 #谷歌域名服务器名称服务器8.8.4.4 #谷歌域名服务器。
2.CentOS系统修改网关
修改网卡对应网关的配置文件[root @ centos]# VI/etc/sys config/network修改以下内容NETWORKING=yes(表示系统是否使用网络,一般设置为yes。
如果设置为no,网络无法使用,很多系统服务无法启动)HOSTNAME=centos(设置本机主机名,
这里设置的主机名应该与/etc/hosts中设置的主机名相对应)GATEWAY=192.168.1.1(设置这台电脑连接的网关的IP地址。例如,网关是10.0.0.2)
3.CentOS系统修改IP地址。
通过bootp协议广播获取的Ip地址=192.168.0.255 #对应的子网广播地址HWADDR=00:07:E9:05:E8:B4 #对应的网卡物理地址ipADDR=12.168.1.2 #如果设置网卡获取IP地址的方式是静态指定,
4.重新启动网络配置。
Service network restart or /etc/init. d/network restart will take effect immediately: ifconfig eth0 192.168.0.2 network mask 255.255.0 takes effect: modify/etc/sysconfig/network-scripts/ifcfg-eth0.
Modifying the gateway default gateway takes effect immediately: adding the default gateway to the route takes effect when 192.168.0.1 dev eth0 is started: modifying /etc/sysconfig/network.
修改DNS Modify /etc/resolv.conf修改可以立即生效,启动也有效。
The modification of the host name takes effect immediately: the host name centos1 starts to take effect: the modification of /etc/sysconfig/network.
在CentOS系统中,我们完成了DNS、网关和IP地址的修改。重启网络配置后,可以看到效果。