Resolv.conf keeps being overwritten

After disabling systemd-resolved (And keeping and/or enabling NetworkManager) my resolv.conf file keeps being overwrriten by a symlink to …/run/systemd/resolve/resolv.conf

My idea would be managing resolv.conf file manually.

So far I have disabled systemd-resolved by running the following commands:

sudo systemctl disable systemd-resolved
sudo systemctl mask systemd-resolved

Also tried restarting the NetworkManager service to check if that was replacing resolv.conf file, but nothing changed, I just loose it on every reboot.

Thanks in advance!

EDIT #1:

Tried creating file /etc/NetworkManager/NetworkManager.conf and appending single line dns=none , this broke my network completely with no IP assignation. After file removal and rebooting resolv.conf issue continues.

WORKAROUND:

Checking some systemd news file learned about the chattr +i command that avoid filechanges even for sudo/root privileges.

sudo -s
unlink /etc/resolv.conf
echo $'nameserver 8.8.8.8\nsearch .' > /etc/resolv.conf
chattr +i /etc/resolv.conf
3 Likes

Keep in mind that some DHCP clients (udhcpc, dhclient) stall during boot using this trick.

3 Likes