Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I very recently came to realize that the caching is disabled by default on the dnsmasq that is integrated with NetworkManager. In my mind, that defeats the point and makes dnsmasq a redundant layer in name resolution.

Obviously, I must be missing something - what is the purpose of dnsmasq in NM?

share|improve this question
up vote 2 down vote accepted

The point is that switching nameservers is annoying. /etc/resolv.conf only gets read once when you start an application (technically when you do the first lookup), so if you change nameservers (because you moved from wireless to wired to 3g and back etc.), you will need to restart applications that need to look up names (such as browsers).

This is mitigated by using the local resolver, which does respond to these changes in a timely fashion, allowing applications to remain stupid and only query the nameserver on localhost.

share|improve this answer
That mostly brings up new questions. Why would an application read resolv.conf for name resolution? Shouldn't any user space application simply use the proper system calls (eg. gethostbyname()/getnameinfo()), so that yellow pages, files, dns servers or whichever name resolution services that are configured on the system, are queried in the defined order? – Roy Mar 26 '13 at 16:22
What do you think gethostbyname does? :) It doesn't contact anything magical that tells it names, it does the work of reading nsswitch.conf to find out which system to query, and, when querying dns, reads resolv.conf and does the querying. – Dennis Kaarsemaker Mar 26 '13 at 16:24
I thought you meant that applications are now in the habit of bypassing nsswitch and going directly for resolv.conf. I certainly hope that's not the case. So, even if an application makes proper use of the system's name resolution, it might still only check resolv.conf on the first call or when the application is started? – Roy Mar 26 '13 at 16:34
What that code says is "unless an application specifically requests reinitialization, I won't do it". No applications ever do this, as it's an unportable glibc implementation detail. And yes, I know this because it's bitten me badly. Lots of mysql servers that needed to be restarted because we were cleaning up our DNS infrastucture. – Dennis Kaarsemaker Mar 26 '13 at 16:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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