DNS resolver stopped working after upgrade to 20.04

14,124

Solution 1

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!

Solution 2

I figured out the easiest way to resolve this.

It seems to be related to differences in how earlier versions handled dns Vs 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

Solution 3

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.)

Share:
14,124
Marcin Skórzewski
Author by

Marcin Skórzewski

Updated on September 18, 2022

Comments

  • Marcin Skórzewski
    Marcin Skórzewski over 1 year

    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.)

  • Marcin Skórzewski
    Marcin Skórzewski almost 4 years
    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
    Marcin Skórzewski over 3 years
    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
    Marcin Skórzewski over 3 years
    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.
  • Streamline
    Streamline over 2 years
    This worked for me with Ubuntu 20.04.3 LTS