How can I make local dnsmasq play nicely with NetworkManager?

Robert Nichols rnicholsNOSPAM at
Mon Jun 28 19:33:42 UTC 2010

I am trying to set up dnsmasq as a local resolver cache on my F-12
laptop, and can't find any way to pass the nameservers returned by DHCP
to dnsmasq as upstream nameservers and still have appear as
the primary nameserver in /etc/resolv.conf.

NetworkManager creates a resolv.conf file that contains only the servers
returned by DHCP.  That does not allow queries from local processes to
be routed through the local caching resolver.

Without NetworkManager, I would just put a line in dhclient.conf to
prepend "" to the list of nameservers returned by DHCP.
dnsmasq would then read resolv.conf, nicely ignore that entry, and use
the other nameserver entries as upstream servers.  NetworkManager always
invokes dhclient with a custom config file that is created anew for each
invocation, and gives no means to add this customization.

If I configure NetworkManager to put "" as a nameserver in
resolv.conf, then _only_ that nameserver will appear, and dnsmasq has
no way to discover the upstream servers.

I cannot simply hard code the upstream servers in /etc/dnsmasq.conf
because that would ignore what DHCP returns.

I can put a script in /etc/NetworkManager/dispatcher.d/ to modify
resolv.conf to my liking, but that script does not get invoked for lease
renewals, at which time dhclient would undo my changes.

Getting rid of NetworkManager really isn't a viable option for a laptop
that needs to connect to various WiFi networks.

I find it hard to believe nobody's run into this before, but my searches
on Google have been fruitless.  Looking for suggestions before I go
complain on the NetworkManager developers list.

Bob Nichols     "NOSPAM" is really part of my email address.
                 Do NOT delete it.

More information about the users mailing list