NetworkManager and dnsmasq

Recent Ubuntu versions use NetworkManager to manage ethernet, wireless and VPN connections. One problem with multiple connections, especially when VPNs are involved, is name resolution: Company-internal host names are often only resolvable via the company's internal DNS server, but /etc/resolv.conf only allows a serial definition of nameserver entries - only if one is not reachable (queries time out), the next is used.

Ubuntu solves this by not relying on /etc/resolv.conf anymore; it runs a local name server to do the resolution, dnsmasq. resolv.conf contains only the line nameserver

Ubuntu 12.04

This change was introduced in Ubuntu 12.04 :

Network Manager now uses dnsmasq for improved DNS reliability and support for split-DNS on VPN links.

Ubuntu Desktop 12.04 Release Notes

It caused quite an uproar because it was unreliable at this time, and broke with the traditional way of defining more or simply replacing the DNS server setting, and did not respect /etc/hosts.

Whenever something changed with the network connections, the dnsmasq configuration file in /var/run/nm-dns-dnsmasq.conf would be regenerated, and the dnsmasq process restarted.

Ubuntu 12.10

The way it worked was changed again in Ubuntu's 12.10 release. NetworkManager now talks with dnsmasq via dbus and the dnsmasq dbus interface . The configuration file, now located at /var/run/NetworkManager/dnsmasq.conf, is permanently empty.

There is no full configuration file anymore, and you have to look into /var/log/syslog for dnsmasq configuration log lines:

Jan 22 23:13:13 bogo dnsmasq[5247]: vorgelagerte Server von DBus gesetzt
Jan 22 23:13:13 bogo dnsmasq[5247]: Benutze Namensserver

The behavior is still the same on Ubuntu 13.10..

Another way to get a glimpse at the current state is using nm-tool or nmcli .

Written by Christian Weiske.

Comments? Please send an e-mail.