Modify/etc/resolv. conf and restore it to the original state, etcresolv. conf
-
Ping: unknown host www.baidu.com ???
Modify/etc/resolv. conf. After the network adapter is restarted,/etc/resolv. conf is restored to the original state.
You cannot directly modify/etc/resolv. conf under CentOS or redhat. 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.
Modify/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.0.0.6
After this setting, 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. Restart the network after configuration. For cat/etc/resolv. conf, you can see the following parameters:
# Generated by NetworkManager
Nameserver 202.0.0.6
Search localdomain
DNS resolution settings are successful.
Note ::::It is useless to directly modify the/etc/resolv. conf file. After the network service is restarted, the configuration will be reloaded according to/etc/sysconfig/network-scripts/ifcfg-eth0.