Velvet Star Monitor

Standout celebrity highlights with iconic style.

news

nameserver goes missing from /etc/resolv.conf

Writer Emily Wong

I have a problem where the line nameserver 8.8.8.8 just disappears from my /etc/resolv.conf.

This might happen every few days or so and I haven't noticed anything that would be linked to this issue. Then I add it back manually and restart my forever looping scripts. This is pretty annoying to do and I'd like to know why this happens.

3 Answers

To add permanent lines in /etc/resolv.conf you could install the resolvconf command line:

sudo apt install resolvconf

then you have to edit /etc/resolvconf/resolv.conf.d/head and add the permanent lines you need. For example:

nameserver 8.8.8.8
nameserver 1.1.1.1

and finally run these commands:

sudo resolvconf --enable-updates
sudo resolvconf -u

Maybe you need to restart the network interface after that, but I'm not sure.

0

At reboot /etc/resolve.conf usually regenerated and can be rewritten / created on occasion by your DHCP or other services. You can try to disable getting dns-nameservers from your DHCP server if it's the case.

dhclient usually overcomes most resolvconf files. So updating your /etc/dhcp/dhclient.conf and /etc/network/interfaces files can work.

Answers and opinions for a similar issue can be found here

3

Multiple services including netplan, network-manager, and dhcpd all need to make changes to resolv.conf to reflect current network configuration.

Typically in an ubuntu system, the systemd-resolve and resolvconf services try to juggle this, and you will find that the file /etc/resolv.conf is actually a symlink to /var/run/resolvconf/resolv.conf.

If you want to make permanent changes to this file, you need to make the changes in one of the controlling subsystems, such as netplan or network-manager.

If you don't want that file to be automatically managed, you can delete the symlink and recreate it as a regular file. However, this may break things like VPN, DHCP, and dynamic network changes you get when you move from one physical network to another.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy