Ubuntu – Wrong nameserver set by resolvconf and NetworkManager

17.10dhcpdnsnetworking

My DNS server is 192.168.1.152.

This DNS is provided to clients by DHCP. The windows clients on my LAN resolve names properly using that DNS, but my Ubuntu VM doesn't.

The VM is set up with bridge networking and is being properly provided the DNS server, but my local hostnames aren't being resolved by nslookup or browsers.

Here is an nslookup of one of my local domains:

# nslookup unraid.local
Server:     127.0.0.53
Address:    127.0.0.53#53

** server can't find unraid.local: SERVFAIL

Here is what it should resolve by using my DNS server:

# nslookup unraid.local 192.168.1.152
Server:     192.168.1.152
Address:    192.168.1.152#53

Name:   unraid.local
Address: 192.168.1.152

/etc/resolv.conf has a wrong nameserver:

# 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

I ran that command. Under DNS Servers, confusingly, it specifies the correct server (and my default gateway).

root@ubuntu:~# systemd-resolve --status
Global
          DNSSEC NTA: 10.in-addr.arpa
                      16.172.in-addr.arpa
                      168.192.in-addr.arpa
                      17.172.in-addr.arpa
                      18.172.in-addr.arpa
                      19.172.in-addr.arpa
                      20.172.in-addr.arpa
                      21.172.in-addr.arpa
                      22.172.in-addr.arpa
                      23.172.in-addr.arpa
                      24.172.in-addr.arpa
                      25.172.in-addr.arpa
                      26.172.in-addr.arpa
                      27.172.in-addr.arpa
                      28.172.in-addr.arpa
                      29.172.in-addr.arpa
                      30.172.in-addr.arpa
                      31.172.in-addr.arpa
                      corp
                      d.f.ip6.arpa
                      home
                      internal
                      intranet
                      lan
                      local
                      private
                      test

Link 2 (ens33)
      Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6
       LLMNR setting: yes
MulticastDNS setting: no
      DNSSEC setting: no
    DNSSEC supported: no
         DNS Servers: 192.168.1.152
                      192.168.1.1

I don't want to "hard code" the DNS server's IP in a config file because I won't be able to resolve when I change networks.

How can I get resolvconf and NetworkManager to automatically set the DHCP server's IP in /etc/resolv.conf?

Best Answer

Known systemd bug.

Temporary workaround with no need to reconfigure if the DNS IP's changes:

sudo rm -f /etc/resolv.conf
sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
reboot
Related Question