I'm working on centos 7, and having problematic behaviour when setting network interface from dhcp to static ip configuration.
I edit /etc/resolv.conf
, and run systemctl restart network.service
The changes that I made are gone, and a generic file is created:
cat /etc/resolv.conf
# Generated by NetworkManager
# No nameservers found; try putting DNS servers into your
# ifcfg files in /etc/sysconfig/network-scripts like so:
#
# DNS1=xxx.xxx.xxx.xxx
# DNS2=xxx.xxx.xxx.xxx
# DOMAIN=lab.foo.com bar.foo.com
NOTICE: PEERDNS="yes" in ifcfg-ens160 file.
PEERDNS=, where is one of the following:
yes — Modify /etc/resolv.conf if the DNS directive is set. If using DHCP, then yes is the default.
no — Do not modify /etc/resolv.conf.
Taken from here: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/3/html/Reference_Guide/s1-networkscripts-interfaces.html
I guess it has something to do with it, but it's working well when setting to dhcp, so I expect that if it configures /etc/resolv.conf
automatically it will succeed.
A workaround is to edit /etc/resolv.conf
after service is restarted.
But I want to understand the behavior, and how can I avoid the file being reset to this default failure message.
DNS{1} = x.x.x.x, DNS{2}=x.x.x.x
– Ray Oct 23 '14 at 19:44systemctl
tool – csny Oct 26 '14 at 7:33DNS{1,2}=<address>, where <address> is a name server address to be placed in /etc/resolv.conf if the PEERDNS directive is set to yes.
I am willing to bet that theifcfg
file on the CentOS6.2 build you mention has the DNS servers defined orPEERDNS="no"
. – Ray Oct 27 '14 at 19:42/etc/resolv.conf
, andPEERDNS=yes
. How can it be that it worked before? – csny Oct 28 '14 at 8:33