I'm working on centos 7, and having problematic behaviour when setting network interface from dhcp to static ip configuration.
/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.
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.