[nSLUG] DHCP and name resolution question

Troy D. Strum ts at halifaxfilm.com
Thu May 5 11:32:23 ADT 2005

Hi Mike,

I have no idea if this is an "ideal" solution, but I had to rig 
something here to do the same thing - hostname lookups on DHCP clients. 
My router provides my DHCP, and my fixed IP Linux box needs to find them 
by a host name.

The DHCP clients are running XP (or they could be Linux+Samba), so I 
used nmblookup (part of Samba):

 > nmblookup troy
querying troy on troy<00>

(You can stop reading here if that's all you need!)

The actual command I use is this:
nmblookup troy | grep \< | awk '{ print $1"\t"$2 }' | sed s/\<00\>//g

...which prints out:    troy    # The correct format for /etc/hosts

It works for me, and it's pretty simple. My DHCP clients are almost 
always "on" so I don't have to run this very often, and when I do I run 
it manually - but you could use a cron job to do it.

If your laptop isn't running Windows (or Linux+Samba) you could probably 
do something similar with nmap by nmap-ing the DHCP address range for 
whatever you're looking for. Something like this, perhaps:

nmap -sP
nmap -sP -oG nmap.log
for a grep-able log file.

- Troy

Mike Spencer wrote:

>So I got a DHCP client working by changing one line in an rc.d file.
>Nothing to it. But there's a problem on my LAN that I don't quite get.
>(Isn't there always? :-) 
>    My main box and another (bogus & alien) are connected to a router
>    by cable and have fixed IP addresses assigned.
>    If the laptop (moby) runs a DHCP client over wireless, the
>    (wireless) *router* itself has a DHCP server and assigns an
>    address to moby.
>    So far, so good. I can reach bogus and alien *from* moby, say,
>    with ping or telnet or "mount bogus:/".
>    BUT bogus and alien have no way of knowing what IP address moby
>    has.  
>Is there some general way to deal with this? [1] Is NIS/yp* the thing
>that will do this?  I'm happy to RTFM but there are so *many* long and
>complicated FMs that I haven't read yet....  So I would be grateful
>for a pointer in the right direction.
>(This question is all about a LAN; internet connection is by
>dialup. The router isn't involved in the connection to the "real"
>- Mike
>[1] I guess I have a workaround: telling the router (through its admin
>    interface) that there is only one address it's allowed to issue to
>    clients.  Then the other 2 hosts can be configured as if that were
>    moby's fixed address.  But that isn't a general solution: it (a)
>    wouldn't allow a second wireless DCHP client to join the LAN and
>    (b) would cause a new and different DHCP client to be recognized
>    wrongly as moby.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: ts.vcf
Type: text/x-vcard
Size: 353 bytes
Desc: not available
URL: <http://nslug.ns.ca/mailman/private/nslug/attachments/20050505/54058de8/attachment.vcf>

More information about the nSLUG mailing list