Disabling dnsmasq as Your Local DNS Server in Ubuntu

You caught me, I’m dabbling in Ubuntu again. I know! I’m weak for the pretty.

Their inclusion of dnsmasq by default, and making network-manager dependent upon it, is fine – I mean it’s their distribution. But, Ubuntu, make sure you get things right before you force it down people’s throats. Ah, pretty Ubuntu, though. It’s okay.

So, dnsmasq turns every workstation into its own caching DNS server. The cache isn’t updating very well on mine, though – I’m not even getting new additions to domain zones, let alone deletions or changes.

I don’t need my workstation to be a DNS server. I have DNS servers for that. But every time I change /etc/resolv.conf, it gets overwritten later by resolvconf (of course). You’d think resolvconf would believe my DHCP server, and use the DNS entries received from it — but no, resolvconf believes the big, nasty Network-Manager, which says DNS resolution will come from 127.0.0.1 – and dnsmasq will provide it.

And of course, since Ubuntu decided to have every person’s workstation become a name server and DHCP server, they make it destroy the whole dependency tree for Network-Manager if you remove dnsmasq.

I just want nice accurate DNS information… not stale cache… that never seems to die!

So here is what I did to wrest my name servers back from Ubuntu’s presumptuous, yet sumptuous, little fingers.

  1. sudo gedit /etc/NetworkManager/NetworkManager.conf
  2. Comment out the “dns=dnsmasq” line by putting a hash “#” in front it.
  3. sudo service network-manager restart

After that, /etc/resolv.conf was populated with the DNS servers my DHCP server wanted me to have in the first place, and DNS resolution was back to the happy mess it always is.

I have to say, out of some embarrassment, that I don’t actually use gedit for such things. I just put gedit there so I wouldn’t confuse anyone with emacs.

  • Joe Dark

    You saved my day, damm my LAMP server was extremely slow.

  • Ha! That’s good to hear – thanks Joe πŸ™‚

  • J. Carlos Muro

    Haven’t any “side effects” detected so far after ruling dnsmasq out?

  • Well, this was from some time ago – and I experienced none whatsoever at the time, except for proper and fast DNS lookups after disabling it. As long as some nameserver is listed in /etc/resolv.conf you should be golden. Well, unless network-manager is overwriting it. πŸ˜‰ Damn their easy-of-use! πŸ™‚

  • Pingback: Compiling Samba 4 on Debian Wheezy – Active Directory Domain Controllers Ho! | mark rushing's writey things()

  • nasyr

    Hello. There is no /etc/ “NetworkManager/NetworkManager.conf” ubunut server 12.04

  • Yeah – I bet! I think it only comes when you install a graphical user environment like Gnome. Usually in servers I use only static IP addresses, with a manually-created /etc/resolv.conf so this isn’t a problem.

  • Pingback: Compiling Samba 4 on Debian Wheezy – Active Directory Domain Controllers Ho! | Linux Tricks of the Trade()

  • Marius Dalacu

    Thanks. i had errors on my laptop with dnsmask. I have my dual view dns and accesing my web server from the internal network was giving me certificate errors.