Score:0

nameserver goes missing from /etc/resolv.conf

ro flag

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.

Score:0
as flag

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

Ledi avatar
ro flag
I forgot to mention but this happens without rebooting. Uptime on this machine is 35days and I remember this happening a few times during this uptime.
Armageddon_0x00 avatar
as flag
Well you can change the write permission of `resolve.conf` to make sure it's not writable. Not the best solution probably but worked in my case sometime ago. You can simply use `chattr +i /etc/resolv.conf` to make it write protected, `chattr -i /etc/resolv.conf` to make it writable again. About why it happens, I can list numerous reasons. It's probably faster and easier to just overcome it rather than searching for the root cause.
user10489 avatar
in flag
using chattr on resolv.conf is fixing the wrong problem.
Score:0
in flag

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.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.