13

Just after Ubuntu upgrade to 20.04 /etc/resolv.conf contains:

nameserver 127.0.2.1

and it does not work. It works after changing to:

nameserver 127.0.0.53

But it is overridden after each restart and I have to change it all over again.

I have installed Ubuntu 15.10 in this box, upgrading it regularly and it is first time resolver misbehaving like this. Naughty!

How to fix this permanently?

Edit:

Output of $ ls -al /etc/resolv.conf:

lrwxrwxrwx 1 root root 29 lis  1  2015 /etc/resolv.conf -> ../run/resolvconf/resolv.conf

Content of /etc/resolv.conf:

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "systemd-resolve --status" to see details about the actual nameservers.

nameserver 127.0.0.53
search wroclaw.vectranet.pl

(It used to be nameserver 127.0.2.1 after restart, but without changing to 127.0.0.53 I would not be able to write this post ;).)

Content of /etc/hosts:

127.0.0.1   localhost
127.0.1.1   marcin-Lenovo

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

#188.165.239.159 wkaliszu.pl

#10.10.9.157    mskorzewski.axit.pl
X.X.X.X mskorzewski.axit.pl

(X.X.X.X is some real IP address.)

Eliah Kagan
  • 117,780

4 Answers4

16

I just installed Ubuntu 20.04, and had to remove netplan (I have my reasons). I then had a name resolution problem to solve. Here's how I fixed it:

Edit /etc/systemd/resolved.conf and change/add this line:

DNS=1.1.1.1

(I'm using CloudFlare's DNS server here.)

Then change the /etc/resolv.conf symlink like this:

sudo ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf

Last, reboot. I hope this helps!

TheMSG
  • 311
  • 2
  • 6
  • 2
    Changes to /etc/systemd/resolved.conf wasn't necessary. Removing link from /etc/resolv.conf to /run/resolvconf/resolv.conf and adding new one to /run/systemd/resolve/resolv.conf fixed the problem. Old file /run/resolvconf/resolv.conf still gets broken after each restart, but I am not using it anymore. – Marcin Skórzewski Jun 01 '20 at 19:49
3

I figured out the easiest way to resolve this.

It seems to be related to differences in how earlier versions of Ubuntu handled DNS versions to 20.04.

Something during the upgrade process doesn't handle the changes properly, so it's easiest to just force the issue by reinstalling a few packages

apt install --reinstall resolvconf network-manager libnss-resolve

Reboot the system and it should come right up.

  • Happy to see this works for you, but it does not for me :( I do not have libnss-resolve installed in my system. After executing sudo apt install --reinstall resolvconf network-manager link /etc/resolv.conf to /run/resolvconf/resolv.conf still gets broken after restart by setting DNS server to 127.0.2.1 which does not work. – Marcin Skórzewski Sep 05 '20 at 07:28
  • This worked for me with Ubuntu 20.04.3 LTS – Streamline Nov 13 '21 at 16:08
  • Check if you use systemd (currently Kubuntu 23.04): dpkg -l "systemd-resolved". If you see ii at the beginning of the line, reinstall this package instead of resolvconf: apt install --reinstall systemd-resloved. This solved my problem in october '23. – ChristophS Oct 17 '23 at 06:27
2

TheMSG / Eliah Kagan I think the second code block in this accepted answer (the line creating the symlink) has a typo.

I tried it but the file doesn't exist on my newly updated Ubuntu 20.04 machine.

I had to adapt your line to use the file mentioned by Marcin Skórzewski in the comment above:

sudo ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf

(The Markdown help doesn't say how to enter user names, apologies if I'm not doing it right. I tried to do this as a comment but I didn't have enough rep.)

shanem
  • 21
  • 1
  • Thank you for your comment. I also noticed the difference in path to systemd's resolve.conf but I wasn't sure if this is only my local system. I edited @TheMSG response. – Marcin Skórzewski Sep 05 '20 at 07:36
1

I just encountered this issue after upgrading a VM from 20.04 to 20.10. I tried the solution proposed by Loadn Abox

apt install --reinstall resolvconf network-manager libnss-resolve

Unfortunately this did not work for me. The only solution was to edit /etc/systemd/resolved.conf and add entry:

[Resolve] 
DNS=192.168.2.1
Lorenz Keel
  • 8,905
guyr
  • 141