4

I've got a local server (192.168.0.10) running dnsmasq to provide DHCP for my LAN, and a DNS server to resolve hostnames for the DHCP clients.

When I was running 16.04, this worked fine. Any machine getting a DHCP address from the server used the DNS server, and could resolve other hostnames on the network.

However, since upgrading to 18.04, I can't resolve hostnames any more. I understand that 18.04 now uses systemd-resolve. It appears that it's aware of the DNS server:

mark@coachz:~$ 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 3 (wlp59s0)
      Current Scopes: DNS
       LLMNR setting: yes
MulticastDNS setting: no
      DNSSEC setting: no
    DNSSEC supported: no
         DNS Servers: 192.168.0.10

Link 2 (enp58s0f1)
      Current Scopes: none
       LLMNR setting: yes
MulticastDNS setting: no
      DNSSEC setting: no
    DNSSEC supported: no

However, it doesn't seem to use it to resolve hostnames:

mark@coachz:~$ nslookup homestar
Server:         127.0.0.53
Address:        127.0.0.53#53

** server can't find homestar: SERVFAIL

Although if I explicitly tell it to, it can:

mark@coachz:~$ nslookup homestar 192.168.0.10
Server:         192.168.0.10
Address:        192.168.0.10#53

Name:   homestar
Address: 192.168.0.101

How do I get it to use the DHCP-provided DNS server automatically?

  • 1
    Have you tried nslookup homestar{.your.domain.here}? – zwets Jun 21 '18 at 21:55
4

I succeeded as follows:

mv resolv.conf resolv.conf-old
ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
  • how do you get/create your file /run/systemd/resolve/resolv.conf? Please edit your answer to explain this trick – damadam Aug 27 '18 at 14:25
  • This worked for me! @damadam The file /run/systemd/resolve/resolv.conf is created with netplan sudo netplan apply. You can check the current config by using systemd-resolve --status – Philippe Nov 16 '18 at 17:51
  • This worked for me (although the first line I had to cd to /etc/ first to backup the original file). On inspecting the old /etc/resolv.conf file it had the nameserver set to 127.0.0.53 just like the OP. I'd be interested in anyone could flesh out this answer with some more explanation and reasons for the fix. Such as is it better to create the symbolic link to the systemd resolv.conf file like in this answer, or if just setting the correct value in the original /etc/resolve.conf would have been better? And why? – Simon P Stevens Jan 3 at 1:17
3

It turns out the problem was that I didn't have a domain suffix configured in my dnsmasq server.

I added the line: domain=lan to /etc/dnsmasq.conf and restarted the service, and I can now resolve the address for homestar or homestar.lan just fine.

  • I'm having exactly the same problem, but this solution isn't working for me. I added domain=lan in the /etc/dnsmasq.conf on my dnsmasq server, and service dnsmasq restart, but local names still don't resolve. In fact, dig @$MY_DNS_IP $HOSTNAME_ON_MY_LAN.lan also fails, even though dig @$MY_DNS_IP $HOSTNAME_ON_MY_LAN works. – Laurence Gonsalves Aug 31 '18 at 19:18
  • In addition to the domain=lan line, I also needed to add an expand-hosts line to /etc/dnsmasq.conf. Finally, I needed to set the domain on my DHCP server (my router) so that it would be added to the search path in resolv.conf – Laurence Gonsalves Sep 4 '18 at 20:30

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.