[Dnsmasq-discuss] Multiple resolv.conf files ...

Simon Kelley simon at thekelleys.org.uk
Wed Oct 14 12:03:28 BST 2009

Clinton Lee Taylor wrote:
> Greetings ...
>>>  Been looking into creating a Linux Router that can be used for
>>> internet connection fall over, when the primary internet connection
>>> fails, I would like to have the router switch to the backup.  I know
>>> that DnsMasq can't really help with this, but, I'm looking at making a
>>> second connection, using 3G ...
>>>  So, my problem is that without making very complicated scripts, could
>>> we not make DnsMasq be able to read multiple resolv.conf type files
>> Simon already has this covered, read your man page, which says
>> "Dnsmasq can be told to poll more than one resolv.conf file".
>  Arh, yes ... I did see this and hoped that it would work similar to
> other multiple options ...
>> http://www.thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html
>  Went through that, but I did not get it to work as I had hoped ...
>> You'll solve your problem a lot faster than waiting for an answer from the list.
>  Mmm, right and wrong ... If you read the little bit before, I was
> hoping that I could read multiple resolv.conf type files, but testing
> showed something that did not seem to be working as I had expected ...
> Was hoping that either what I was epxecting, could be helped or maybe
> another insight into another way to do a similar thing ...
>>>  The reason I would like this, is that each internet facing interface,
>>> using something like DHCP, would have their own DNS server list that I
>>> could get DnsMasq to read/use, so that DNS queries would be sent down
>>> each active internet interface ...
>  I added to my dnsmasq.conf file two lines as follows ...
> resolv-file=/etc/resolv.conf.dnsmasq-eth0
> resolv-file=/etc/resolv.conf.dnsmasq-3g
>  But when I restart dnsmasq, it only list the last resolv.conf file
> and the dns server there in ... Do I need to use the -r option from
> the command line ( init script ) or can this option be used in the
> dnsmasq.conf file?
> Oct 14 12:49:30 hermes dnsmasq[8652]: exiting on receipt of SIGTERM
> Oct 14 12:49:30 hermes dnsmasq[8700]: started, version 2.45 cachesize 150
> Oct 14 12:49:30 hermes dnsmasq[8700]: compile time options: IPv6
> GNU-getopt no-ISC-leasefile no-DBus no-I18N TFTP
> Oct 14 12:49:30 hermes dnsmasq[8700]: DHCP, IP range --
>, lease time 4h
> Oct 14 12:49:30 hermes dnsmasq[8700]: reading /etc/resolv.conf.dnsmasq-3g
> Oct 14 12:49:30 hermes dnsmasq[8700]: using nameserver
> Oct 14 12:49:30 hermes dnsmasq[8700]: read /etc/hosts - 8 addresses
> Thanks
> Mailed
> LeeT

Dnsmasq checks the modification times of both (all) the files, and uses 
the one that was changed last. Try this:

touch /etc/resolv.conf.dnsmasq-eth0
dig www.google.com

You should see dnsmasq read the eth0 file and start to use the 
nameservers in there.

You need to ensure that the relevant resolv.conf file is updated when a 
network link goes live and all should be well.



More information about the Dnsmasq-discuss mailing list