You cannot directly modify/etc/resolv. conf. You must add the DNS settings in/etc/sysconfig/network-scripts/ifcfg-eth0. Otherwise, after the restart, you must use the eth0 settings without DNS information to restore/etc/resolv. conf to the original state.
Vim/etc/sysconfig/network-scripts/ifcfg-eth0
Device = eth0
Bootproto = none
Hwaddr = 00: XX: 19: XX: xx
Onboot = Yes
Type = Ethernet
Userctl = No
Ipv6init = No
Peerdns = Yes
Netmask = 255.255.255.0
Ipaddr = XXX. XXX
Gateway = XXX. XXX
Dns1 = 202.96.209.5 # Shanghai DNS, changed according to the actual situation
Dns2 = 202.96.209.20.# Shanghai DNS, changed according to the actual situation
In this case, you do not need to set it in/etc/resolv. conf.
After Service Network restart, we can find that there are two DNS resolution IP addresses in/etc/resolv. conf.
CAT/etc/resolv. conf
Generated by NetworkManager
Nameserver 202.96.209.5
Nameserver 202.96.209.20.
Search localdomain
DNS resolution settings are successful.
It should be emphasized that/etc/resolv is directly modified. conf file is useless, the network service will restart according to/etc/sysconfig/network-scripts/ifcfg-eth0 to reload the configuration, if the ifcfg-eth0 does not configure DNS, then resolv. conf will be washed out and then become a null value.
Well, I don't know why this has not happened to the previously installed system?
Modify the host file
Open the host file
/Etc/hosts
Add the required items in the following format:
Format:
<Ip>
Example:
216.239.37.99 www.2cto.com
After editing, You need to restart your network.
/Etc/init. d/networking restart
Original article: http://www.2cto.com/ OS /201208/147086.html