[TriLUG] Revisiting local dnsmasq DNS resolution
Brian Henning
bhenning at pineinst.com
Thu Nov 8 11:27:07 EST 2012
Thomas,
Yes, I could easily configure dnsmasq with a static lease (100% guarantee
that it always gives the same, known-in-advance address to blueman, based on
blueman's MAC), and add an /etc/hosts entry. That's not the way I'd like to
handle it, though, because that band-aid(TM)s the problem without me
understanding the cause.
I tried writing a simple C program that just calls gethostbyname(3), and it
behaves just like other programs (except host(1) and dig(1)) and prints the
result (or error). It always prints out "Unknown host" for local network
hosts, even though host(1) resolves them successfully.
Can anyone offer tips on tracing the behavior of the gethostbyname(3)
function? Yes, I'm googling, but I figured I'd use the TriLUG Natural
Language Search Engine as well. ;-)
Thanks!
~Brian
-----Original Message-----
From: trilug-bounces at trilug.org [mailto:trilug-bounces at trilug.org] On Behalf
Of Thomas Gardner
Sent: Wednesday, November 07, 2012 5:53 AM
To: Triangle Linux Users Group General Discussion
Subject: Re: [TriLUG] Revisiting local dnsmasq DNS resolution
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.
More information about the TriLUG
mailing list