1

Ever since I installed a client from a VPN service, I'm unable to use the internet when not using a VPN connection. I figured out that this is because /etc/resolv.conf is being populated with the wrong nameserver after I disconnect the VPN session.

Instead of nameserver 192.168.8.1 and nameserver <ipv6> it's pointing to nameserver 192.168.1.1, which doesn't exist on the network.

I have tried to add different nameservers to /etc/resolv.conf.head and /etc/resolv.conf.tail with no results.

I'm unable to change /etc/resolv.conf, even with root. It fails with [ Error writing /etc/resolv.conf: Operation not permitted ].

When running sudo resolvconf -u it also fails with multiple errors:

/etc/resolvconf.conf: line 8: nameserver: command not found
/etc/resolvconf.conf: line 9: nameserver: command not found
/usr/lib/resolvconf/libc: line 230: /etc/resolv.conf: Operation not permitted

I'm guessing this is because network manager uses the file, and locks it from editing. So this leads me to believe network manager is the only way to solve this problem. Proceeded to try to edit network manager configuration sudo vim /etc/NetworkManager/NetworkManager.conf.

Changed dns=default to dns=192.168.8.1 and dns=dnsmasq, restarting with sudo systemctl restart NetworkManager.service. Unfortunately it's still populating /etc/resolv.conf to the wrong configuration.

I feel like I'm running out of options. How do I make sure that network manager populates resolv.conf with the right nameserver settings?

2 Answers 2

2

If partition is ext2/3/4, make /etc/resolv.conf inmutable. That way, vpn client will not modify it.

Fix /etc/resolv.conf content, and then run:

chattr +i /etc/resolv.conf
2
  • I'm unable to edit /etc/resolv.conf, my system doesn't allow me to save it. Even with root. Jan 28, 2017 at 3:19
  • After the removing the protection with sudo chattr -i /etc/resolv.conf I could fix my DNS, thanks. Jan 28, 2017 at 3:29
1

Thanks @Roberto Paz. I first had to remove file protection with sudo chattr -i /etc/resolv.conf and after that I could save /etc/resolv.conf normally with the correct configuration. Optionally I could save the file from being written again with sudo chattr -i /etc/resolv.conf.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .