NetworkManager modifies the resolv.conf file and any manual changes there are lost. How to prevent the /etc/resolv.conf file from being overwritten by NetworkManager?
Per the NetworkManager.conf man page:
# man NetworkManager.conf ... dns Set the DNS (resolv.conf) processing mode. If the key is unspecified, default is used, unless /etc/resolv.conf is a symlink to /run/systemd/resolve/resolv.conf, /lib/systemd/resolv.conf or /usr/lib/systemd/resolv.conf. In that case, systemd-resolved is chosen automatically. default: NetworkManager will update /etc/resolv.conf to reflect the nameservers provided by currently active connections. dnsmasq: NetworkManager will run dnsmasq as a local caching nameserver, using a "split DNS" configuration if you are connected to a VPN, and then update resolv.conf to point to the local nameserver. It is possible to pass custom options to the dnsmasq instance by adding them to files in the "/etc/NetworkManager/dnsmasq.d/" directory. Note that when multiple upstream servers are available, dnsmasq will initially contact them in parallel and then use the fastest to respond, probing again other servers after some time. This behavior can be modified passing the 'all-servers' or 'strict-order' options to dnsmasq (see the manual page for more details). unbound: NetworkManager will talk to unbound and dnssec-triggerd, providing a "split DNS" configuration with DNSSEC support. /etc/resolv.conf will be managed by dnssec-trigger daemon. systemd-resolved: NetworkManager will push the DNS configuration to systemd-resolved none: NetworkManager will not modify resolv.conf. This implies rc-manager unmanaged
As you can see, the NetworkManager will by default update the /etc/resolv.conf to reflect the nameservers provided by currently active connections. This will overwrite any changes you have manually done to the file. In order to avoid this, follow the steps outlined below:
1. In the /etc/NetworkManager/NetworkManager.conf file, define the dns parameter with a value of none:
# cat /etc/NetworkManager/NetworkManager.conf [main] plugins=ifcfg-rh dns=none
2. Restart the NetworkManager service:
# systemctl restart NetworkManager.service