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 127.0.0.1 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 "127.0.0.1" 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 "127.0.0.1" 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.
On 06/28/2010 02:33 PM, Robert Nichols wrote:
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 127.0.0.1 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 "127.0.0.1" 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 "127.0.0.1" as a nameserver in resolv.conf, then _only_ that nameserver will appear, and dnsmasq has no way to discover the upstream servers.
FWIW, I've written a C program that makes this work. The program sets up a file alteration monitor on /etc/resolv.conf. Whenever that file changes, the code ensures that "127.0.0.1" is the first nameserver listed there and passes the upstream server addresses to dnsmasq. A short script in /etc/NetworkManager/dispatcher.d makes sure this program is running whenever a network interface is started. I believe it's pretty bulletproof, and most of its configuration can be overridden from the command line.
Source is available from
http://rnicholsNOSPAM.home.comcast.net/resolvtrac.tar.gz
Comments & suggestions are welcome.
On 07/29/2010 10:05 AM, Robert Nichols wrote:
On 06/28/2010 02:33 PM, Robert Nichols wrote:
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 127.0.0.1 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 "127.0.0.1" 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 "127.0.0.1" as a nameserver in resolv.conf, then _only_ that nameserver will appear, and dnsmasq has no way to discover the upstream servers.
FWIW, I've written a C program that makes this work. The program sets up a file alteration monitor on /etc/resolv.conf. Whenever that file changes, the code ensures that "127.0.0.1" is the first nameserver listed there and passes the upstream server addresses to dnsmasq. A short script in /etc/NetworkManager/dispatcher.d makes sure this program is running whenever a network interface is started. I believe it's pretty bulletproof, and most of its configuration can be overridden from the command line.
Source is available from
http://rnicholsNOSPAM.home.comcast.net/resolvtrac.tar.gz
Word from the developers is that one of the goals for NetworkManager 0.8.2 is support for a local caching resolver. That should eliminate the need for my workaround.
On Fri, 2010-07-30 at 06:23 -0500, Robert Nichols wrote:
Word from the developers is that one of the goals for NetworkManager 0.8.2 is support for a local caching resolver. That should eliminate the need for my workaround.
I hope they do mean merely adding support for it, rather than building more into it.
Though I have to say that I have no problems with NetworkManager and using a local name server. Of course my DHCP server, properly, doles out the DNS address that the client should use.
The various messages I've read on this list seem to deal with people half using DHCP, wanting to override some of the settings. i.e. Not use the DNS server address, and/or other details, supplied from the DHCP server.
There's two approaches to resolving that: Have their DHCP server provide the wanted addresses, properly. Or have their DHCP client overrides configured, properly.
The first one's what I do. The second one always used to be possible, before NetworkManager got thrown into the mix. But is it, now, a case of NetworkManager getting in the way of your DHCP client configuration, or is something else, now, acting as the DHCP client?
On 07/31/2010 07:18 AM, Tim wrote:
On Fri, 2010-07-30 at 06:23 -0500, Robert Nichols wrote:
Word from the developers is that one of the goals for NetworkManager 0.8.2 is support for a local caching resolver. That should eliminate the need for my workaround.
I hope they do mean merely adding support for it, rather than building more into it.
Though I have to say that I have no problems with NetworkManager and using a local name server. Of course my DHCP server, properly, doles out the DNS address that the client should use.
I'm referring to a caching resolver running on the local machine, i.e. 127.0.0.1, not a nameserver running somewhere else on a local network.
The various messages I've read on this list seem to deal with people half using DHCP, wanting to override some of the settings. i.e. Not use the DNS server address, and/or other details, supplied from the DHCP server.
There's two approaches to resolving that: Have their DHCP server provide the wanted addresses, properly. Or have their DHCP client overrides configured, properly.
When I'm connecting via the WiFi hotspot at some local business, the DHCP server is not under my control. NetworkManager invokes dhclient with a custom config file that NetworkManager generates anew for each invocation, and no customization of that configuration is possible.
On Sat, Jul 31, 2010 at 08:50:50 -0500, Robert Nichols rnicholsNOSPAM@comcast.net wrote:
I'm referring to a caching resolver running on the local machine, i.e. 127.0.0.1, not a nameserver running somewhere else on a local network.
When I'm connecting via the WiFi hotspot at some local business, the DHCP server is not under my control. NetworkManager invokes dhclient with a custom config file that NetworkManager generates anew for each invocation, and no customization of that configuration is possible.
If you are running a resolver and not a forwarder, then you don't need to bother with the dns servers provided by whoever is providing you with connectivity.
On Sat, 2010-07-31 at 08:50 -0500, Robert Nichols wrote:
I'm referring to a caching resolver running on the local machine, i.e. 127.0.0.1, not a nameserver running somewhere else on a local network.
If it were your DHCP server, then it could supply 127.0.0.1 as the DNS server address to that machine (I have done this before). Though, since you say it's not, then it'd be a DHCP client overriding configuration that you'd apply to your computer.
When I'm connecting via the WiFi hotspot at some local business, the DHCP server is not under my control. NetworkManager invokes dhclient with a custom config file that NetworkManager generates anew for each invocation, and no customization of that configuration is possible.
I'm fairly sure that I read, somewhere on this list, that you could put client options into a file that NetworkManager would pay attention to. It wasn't the usual /etc/dhclient.conf that you'd use with the network service.
And people have written about customising NetworkManager settings by right-clicking the NetworkManager icon, and editing connections (such as putting in their own DNS server address). With reports from some that they were ignored, and others saying it worked. Are you one of those that tried that?
On 07/31/2010 09:52 AM, Tim wrote:
On Sat, 2010-07-31 at 08:50 -0500, Robert Nichols wrote:
I'm referring to a caching resolver running on the local machine, i.e. 127.0.0.1, not a nameserver running somewhere else on a local network.
If it were your DHCP server, then it could supply 127.0.0.1 as the DNS server address to that machine (I have done this before). Though, since you say it's not, then it'd be a DHCP client overriding configuration that you'd apply to your computer.
When I'm connecting via the WiFi hotspot at some local business, the DHCP server is not under my control. NetworkManager invokes dhclient with a custom config file that NetworkManager generates anew for each invocation, and no customization of that configuration is possible.
I'm fairly sure that I read, somewhere on this list, that you could put client options into a file that NetworkManager would pay attention to. It wasn't the usual /etc/dhclient.conf that you'd use with the network service.
And people have written about customising NetworkManager settings by right-clicking the NetworkManager icon, and editing connections (such as putting in their own DNS server address). With reports from some that they were ignored, and others saying it worked. Are you one of those that tried that?
Here's a link to my original message with all the details. I'm not going to repeat all that here.
http://lists.fedoraproject.org/pipermail/users/2010-June/376635.html
The NetworkManager developers agree that there is currently no way to configure NetworkManager and a localhost dnsmasq cache to work together, and work is under way for support in the next NM release. If you believe they are wrong, I'm sure they would be delighted to hear how it can be done so that this effort can be avoided.