CentOS 7 resolv.conf make changes permanent
On rebooting the CentOS 7 server, changes made to resolv.conf is lost. This is because one of the network interface is configured to use DNS server.
[root@server ~]# grep DNS /etc/sysconfig/network-scripts/ifcfg-*
/etc/sysconfig/network-scripts/ifcfg-eno1:DNS1="127.0.0.1"
[root@server ~]#
To fix, edit
vi /etc/sysconfig/network-scripts/ifcfg-eno1
Remove the line
DNS1="127.0.0.1"
Now NetworkManager will not modify /etc/resolv.conf file on boot.
Or you can set valid DNS servers in network config file like
[root@server ~]# cat /etc/sysconfig/network-scripts/ifcfg-eno1 | grep DNS
DNS1="1.1.1.1"
DNS2="8.8.8.8"
[root@server ~]#
If your network configuration use DHCP, set set PEERDNS=no.
BOOTPROTO=dhcp
PEERDNS=no
Another solution is to make file immutable with
chattr +i /etc/resolv.conf
Related Posts