[TriLUG] Revisiting local dnsmasq DNS resolution

Thomas Gardner tmg at pobox.com
Wed Nov 7 05:52:49 EST 2012


Never used dnsmasq before, so please bear with me.

So, if I'm understanding this right, dnsmasq (which is running on your
gateway) is acting as both DNS server and DHCP server to your internal
network, and doing a fine job at both.  I don't know about dnsmasq
specifically, but if I'm not mistooken, I believe most DHCP servers can
be counted on to give the same IP address to a given MAC address over
and over again, at least within the context of a small number of
machines in a home net like I assume this is.

I also see that your nsswitch.conf file on your gateway box (the one
that's having trouble resolving internal network names) specifies that
it'll look in /etc/hosts first.

You've said that the internal machines are not in your /etc/hosts file.

Unless I've made a mistake or false assumption above, why not just put
your internal machines in your /etc/hosts file?  Have you tried that?
If so, does that work?  I know, it ain't pretty, and you are keeping
the same information in two different places (always something to be
avoided), but it seems like that would probably work.  If you're
terribly concerned about keeping the two copies up to date
automagically, maybe you could write a little script that generates
/etc/hosts automagically (using a list of MAC/hostname pairs that you
seem to be maintaining somewhere now) whenever an address is handed
out by dnsmasq.

Just a thought.

On 11/2/12, Seva Adari <oddissyus at gmail.com> wrote:
> Part of the issue could be the configuration of dnsmasq that I don't
> understand!
>
> You stated before that making a localhost entry in /etc/resolv.conf made
> the
> dig work. Does this mean the your dns service is working off your
> loopback
> device and not the ethernet device? Can you check if there is a place in
> dnsmasq configuration where you can set the interface on which you make
> the dns to listen in on the incoming requests.  If you could make such an
> entry,
> then set it to the eth0's ip address (you may have to restart dnsmask)
> and
> reflect that ip address in your nameserver  in /etc/resolv.conf and see
> if
> that
> is going to make a difference.
>
> On Fri, Nov 2, 2012 at 5:03 PM, Brian Henning <bhenning at pineinst.com>
> wrote:
>> Hi Seva,
>>
>> Thanks for your ongoing input.  I will look at that dnsmasq bug soon.
>>
>> As far as /etc/resolv.conf, it only gets rewritten when my outside interface
>> loses its lease for whatever reason.  I had already added "nameserver
>> 127.0.0.1" at the start of its nameserver list, which is what made host and
>> dig start working.  I've also already modified the
>> /etc/sysconfig/network-scripts/ifcfg-eth0 script to make sure that change is
>> preserved when DHCP is renewed.
>>
>> I looked in /etc/nsswitch.conf and didn't see a line that STARTS with "dns",
>> but I did see this line:
>>
>> hosts: files dns
>>
>> Maybe that is what you were asking about?
>>
>> By the way:
>> $ grep blueman /etc/hosts
>> $
>>
>> so it's definitely not in there.
>>
>> Cheers,
>> ~Brian



More information about the TriLUG mailing list