[Dnsmasq-discuss] Enhancement idea: localhost DNS

Bill C. Riemers briemers at redhat.com
Thu Jun 5 17:07:58 BST 2008


I would like to enhance dnsmasq to work as a localhost DNS.   However,
before I start patching code I thought I should check on the list to
find out if anyone has ideas on how to implement this, or if it has been
already implemented.  First a brief description of what I am trying to
accomplish and why.

Basically, I want a DNS server running on my machine that redirects
requests to selectively to different DNS servers.   I am currently
running dnsmasq on a NSLU2, which serves all my local machines for DNS
and DHCP.   However, when I run vpnc, /etc/resolv.conf is redirected so
that my local names no longer resolve.  While I can list the names in
/etc/hosts to bypass this limitation, that defeats the whole point of
running my own DNS server.  Also, I found sometimes my etc hosts entries
are ignored by web browsers because the same name has been resolved by
the remote DNS.

As a hack, I modified both
/etc/sysconfig/network-scripts/network-functions and
/etc/vpnc/vpnc-script to write updated DNS info to
/etc/resolv.conf.dnsmasq instead of /etc/resolv.conf.  I configured
dnsmasq to read /etc/resolv.conf.dnsmasq, and I wrote as the
name server in /etc/resolv.conf.

This works.  I can do things like "nslookup hartnell.local" and have it
work as expected, even when connected via vpnc.   However, it means I
run the risk with every update that my scripts are going to be replaced,
and of course I can't very well start telling others this a good way to
do it.

So it occurred to me a simple solution would be to patch dnsmasq so that
when it detects a change in /etc/resolv.conf that after it reads in the
updated information it replaces the nameserver lines as "".  
That way dnsmasq is correctly using the information from DHCP and VPNC
for any domain I do not explicitly override.   However, all other
applications will still use dnsmasq.   I would probably activate this
feature by setting the server option in dnsmasq.conf to localhost, or
making a new option like overwrite-resolv=true.

My questions are:
   1. Does anyone have better ideas on how I can accomplish the same thing?
   2. Is anyone else working on the same thing?
   3. Is there public access to the dnsmasq source tree, or do I simply
make my change to the latest source download and let the maintainer
worry about merging
       it with the current code base?


More information about the Dnsmasq-discuss mailing list