A CentOS6.2 instance was installed in the previous week and the IP address was manually assigned. DNS is set in/etc/resolv. conf. Then you can access the Internet. After the machine is restarted, the website can be pinged. open/etc/resolv. conf and you will find that it is not tested again. The original direct modification of/etc...
A CentOS 6.2 IP address was manually assigned to the ECS instance and DNS was set in/etc/resolv. conf. Then you can access the Internet. After the machine is restarted, the website can be pinged. open/etc/resolv. conf and you will find that it is not tested again.
It turns out that 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
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:
.
Example:
216.239.37.99 www.2cto.com
After editing, you need to restart your network.
/Etc/init. d/networking restart