CentOS 7 resolv.conf make changes permanent
On rebooting CentOS 7 server, changes made to resolv.conf is lost. This is becaise one of the network interface is configured to use DNS server.
1 2 3 |
[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
1 |
vi /etc/sysconfig/network-scripts/ifcfg-eno1 |
Remove the line
1 |
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
1 2 3 4 |
[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.
1 2 |
BOOTPROTO=dhcp PEERDNS=no |
Another solution is to make file immutable with
1 |
chattr +i /etc/resolv.conf |
Related Posts