Modify DNS in Linux and dns in linux
Not long ago, I encountered some problems on the server. I need to modify the dns configuration of the server and write it down. I used centos 6.5.
The DNS configuration file is in/etc/resolv. conf, but the service network restart is restarted after modification. If it is opened again, the configuration file is restored.
This is the configuration before modification:
# No nameservers found; try putting DNS servers into your
# Ifcfg files in/etc/sysconfig/network-scripts like so:
#
# DNS1 = xxx. xxx
# DNS2 = xxx. xxx
# DOMAIN = lab.foo.com bar.foo.com
Solution:
Add DNS1 = xxx. xxx directly to the ifcfg-eth0, and then add the service network restart
DEVICE = "eth0"
BOOTPROTO = "static"
HWADDR = "00: 0C: 29: B5: E4: 65"
NM_CONTROLLED = "yes"
ONBOOT = "yes"
IPADDR = 192.168.128.20.
NETMASK = 255.255.255.0
GATEWAY = 192.168.128.1
DNS1 = 222.46.120.6
Edit the configuration file/etc/resolv. conf again and add a line of namerserver xxx. xx
Nameserver 222.46.120.6