1

my dnsmasq configuration got broken after upgrading to Ubuntu 18.04 from 16.04.

  • systemd-resolved is enabled and running
  • dnsmasq is enabled and running

Any DNS query to the outside world will hang for some 30 seconds before succeeding. Queries to my local hosts (anything.mylocal) will succeed immediately.

If I stop dnsmasq (i.e. service dnsmasq stop), then all DNS queries to the outside world will work immediately (but .mylocal, of course, not).

In: /etc/dnsmasq.conf

listen-address=127.0.0.1
address=/.mylocal/127.0.0.1

In: /etc/NetworkManager/NetworkManager.conf

[main]
...
# dns=dnsmasq
...

Uncommenting the dns= line will prevent ANY dns query.

In: /etc/systemd/resolved.conf

[Resolve]
#DNS=
#FallbackDNS=
#Domains=
#LLMNR=no
#MulticastDNS=no
#DNSSEC=no
#Cache=yes
#DNSStubListener=no

In: /etc/resolv.conf

This file is a link to: ../run/resolvconf/resolv.conf, which contains:

# 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

In: /etc/nsswitch.conf

passwd:         compat systemd
group:          compat systemd
shadow:         compat

hosts:          files mdns4_minimal [NOTFOUND=return] dns myhostname
networks:       files

protocols:      db files
services:       db files
ethers:         db files
rpc:            db files

netgroup:       nis

One noticeable difference with the output of systemd-resolve --status:

  • With dnsmasq running, the first line in Global reads: DNS Servers: 127.0.0.1
  • With dnsmasq stopped, this line is absent, there is no global DNS Server, and the first useful server is defined in the Link 2 section, which specifies my default gateway (192.168.1.1)

Any help is greatly appreciated :)

  • If resolv.conf is a link, then what does its target file contain? – grawity Aug 6 '18 at 20:44
  • It contains: nameserver 127.0.0.53 (I also edited the answer) – Palantir Aug 6 '18 at 20:45
  • What tools are you using to test DNS queries? What "hosts" modules are enabled in /etc/nsswitch.conf? – grawity Aug 6 '18 at 20:46
  • Sorry, I clicked too quickly. I reported the nsswitch.conf content. As for the tests, I just do a ping to google.com. With dnsmasq it hangs for 30 seconds, without it it returns immediately. – Palantir Aug 6 '18 at 20:47
  • Also added some output of systemd-resolve --status – Palantir Aug 6 '18 at 20:54
0

After a night's sleep ;-) this is what I came up with. I just manually added some public upstream servers (1.1.1.1 is CloudFlare's, 8.8.8.8 is Google's)

In: /etc/dnsmasq.conf:

listen-address=127.0.0.1
address=/.mylocal/127.0.0.1
server=1.1.1.1
server=8.8.8.8

All the remaining files are left as in my question. Both systemd-resolved and dnsmasq are enabled and running.

This makes DNS queries work.

I still do not consider this as the correct answer, because I would prefer to use the DNS provided by the network, but at least it works...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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