1

Everytime I reboot my computer, resolv.conf gets:

nameserver 127.0.0.53

placed into it.

When the nameserver is set to this ip, I am unable to ping or access any website (I get the error DNS_PROBE_FINISHED_BAD_CONFIG).

I have to manually change resolve.conf to:

nameserver 8.8.8.8, and then my dns lookup works as normal.

I have tried resetting resolv.conf as per the accepted suggestion here: DNS_PROBE_FINISHED_BAD_CONFIG error in Ubuntu 14.04 , but that didn't work.

The only way to access the internet is to manually override.

My question is:

How do I make resolv.conf work properly? I am initially manually overriding it because it became faulty at one point (it's unknown why, maybe it was a vpn config, update, or something else...)

David
  • 2,101
  • 13
  • 16
  • 25
Leftover Salad
  • 219
  • 3
  • 12

3 Answers3

1

The issue isn't a 'wrong' server getting set, it's the fact that 18.04 and later use ResolveD by default now, similar to how 14.04 and older used dnsmasq to provide a DNS caching client.

127.0.0.53 is added by systemd-resolved at reboot and startup. ResolveD gets its DNS configured by however you configured your Internet configuration on Netplan or Network Manager. If you haven't configured a DNS server properly in Netplan configuration then that's why ResolveD doesn't work, and if you don't get DNS servers via DHCP via either Netplan or Network Manager that's why it isn't working because it has no DNS servers to point to.

You can either fix your configuration (which you haven't shared so I can't be certain how you did the configuration of your system), or you can give ResolveD certain configuration options that act as backup configuration options for it by changing the configuration of /etc/systemd/resolved.conf.

Edit the file as superuser, uncomment the DNS= line by removing the # at the beginning of the line, and set it to DNS=8.8.8.8. Then do sudo systemctl restart systemd-resolved and test the DNS. It should then work and default to 8.8.8.8 again for its queries, however resolv.conf will still look at 127.0.0.53 which is normal behavior in modern Ubuntu systems. systemd-resolve --status will; show what DNS servers are being used from network options or Global options based on what it got from network configurations or from your entered config in /etc/systemd/resolved.conf.

Thomas Ward
  • 74,764
  • systemd-resolve is not found and apt cant find either. Setting DNS there is ignored. It still only uses /etc/resolv.conf nameserver for dns. – Philip Rego Nov 30 '23 at 03:59
  • 1
    @PhilipRego If you're on a newer version of Ubuntu then it's resolvectl status instead of systemd-resolve --status. – Thomas Ward Nov 30 '23 at 04:25
0

If resolvconf(8) is overwritting your /etc/resolv.conf with bad configs then do this.

sudo nano /etc/resolvconf/resolv.conf.d/head
nameserver 8.8.8.8 
sudo resolvconf -u
0

Thomas Ward answer is correct and if you want to contine to use systemd-resolve then follow his instructions.

If you prefer not to use systemd and to have resolve controlled by /etc/resolv.conf the solution is simple.

delete /etc/resolv.conf that is a symbolic link to /run/resolvconf/resolv.conf

then edit /etc/resolv.conf with your prefered editor, and add

nameserver 8.8.8.8

or from the cmd line run:

echo nameserver 8.8.8.8 > /etc/resolv.conf

Now /etc/resolv.conf is a static file, that lists your name servers and any other options you want to list. systemd does not edit /etc/resolv.conf directly, therefore if it is not linked, it will not be modified by systemd.