You can tell NetworkManager
not to modify some of the /etc/resolv.conf entries by making changes to the file /etc/NetworkManager/NetworkManager.conf
.
For instance, GCP uses the metadata sever, IP address 169.254.169.254 as the default name sever. You can override the nameserver
entry of resolv.conf by following below steps -
- Add
dns=none
entry to /etc/NetworkManager/NetworkManager.conf file as below -
[main]
#plugins=ifcfg-rh
dns=none
- Restart NetworkManager service
sudo systemctl restart NetworkManager.service
- Modify
/etc/resolv.conf
with your custom nameserver
nameserver 127.0.0.1
After making these changes, restarting NetworkManger should not override your custom entry.