I'm having DNS issues on a new install of Ubuntu 16.04:

kqs@mycomputer:~$ nslookup localserver

** server can't find localserver: NXDOMAIN

But if I specify the DNS server (or sometimes if I just wait awhile), it works:

kqs@mycomputer:~$ nslookup localserver

Name:   localserver.localdomain

And this is the same DNS server that shows up first in Network Manager:

kqs@mycomputer:~$ nmcli device show
IP4.ROUTE[1]:       dst =, nh =, mt = 1000

It seems to be the same problem as "dnsmasq sometimes resolves things, sometimes it doesn't" and "Intranet address resolution and dnsmasq", but in that solution they disable dnsmasq by commenting out the dns=dnsmasq line in /etc/NetworkManager/NetworkManager.conf.

However, I'd like to troubleshoot dnsmasq rather than bypassing it completely.

So my questions are:

  1. My understanding is that dnsmasq is a lightweight DNS server running on my computer. Presumably, the Network Manager DNS settings are used to configure dnsmasq, but ultimately it is dnsmasq that is solely responsible for handling DNS lookups (with the help of upstream DNS servers as it deems necessary). Is this correct?
  2. Can I see how dnsmasq is handling a particular DNS lookup? i.e. is it answering it from its cache? Which upstream DNS server is it forwarding it to?
  3. Can I instruct dnsmasq to use a particular DNS server for the local domain?

1. dnsmasq and Network Manager

As yourself from a few days in the future: your understanding is correct.

Note, however, that Network Manager launches an instance of dnsmasq as a child process (not a separate daemon) and keeps its own set of dnsmasq configuration settings.

2. Can I see how dnsmasq is handling a particular DNS lookup?

Sorry, I still don't know.

3. Can I instruct dnsmasq to use a particular DNS server for the local domain?

Yes, the --server option in dnsmasq (manpage here) allows you to specify upstream DNS servers for specific domains.

You can pass this option to Network Manager's invocation of dnsmasq. I did this by creating a file in the directory /etc/NetworkManager/dnsmasq.d/ with the contents:


Normally, this line would be server=/domain/<ipaddr>; in this case the empty domain specification means "unqualified names only", such as localserver in your example (as opposed to localserver.domain).

How I fixed your immediate problem

The above change still didn't fix things. I verified that this was loaded (service NetworkManager status shows a log entry dnsmasq[<pid>]: using nameserver for unqualified names), but it still returns NXDOMAIN on lookups. So I settled on the following hack:

The local machines I'm connecting to all have static IPs, so I manually specified these in a file in /etc/NetworkManager/dnsmasq.d with the contents:

[...and so on...]

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.