nmbd for WINS client compatibility

Lauren P. Burka lpb at apocalypse.org
Tue Feb 16 19:25:43 GMT 1999

I've been using samba, specifically nmbd, to solve an interesting
problem, with partial success.  I haven't seen anything else on the
list about this, but I haven't been looking too hard either.

The situation:  I'm working at an all-Microsoft all the time shop.
DNS is handled by Microsoft's DNS server running on NT.  When the
typical Windows client boots, it gets a DHCP address from a Microsoft
DHCP server.  It then registers itself with WINS.  Wins then gives the
dynamic information to DNS.  Unless a machine is registered with WINS,
DNS doesn't know anything about it.  This means that I can look up a
machine and find it no matter what dynamic address it has that day.

We've been playing with Linux a bunch for some obvious reasons (it's
much cooler than Windows!).  But since Linux machines don't talk to
WINS, we have to write our IP addresses on a whiteboard each day if we
want to log into each other Linux boxes.  We could solve this with
static IP addresses, but we don't really want to do this for various

I've managed to hack up some stuff that uses samba's nmbd to fake up a
Windows-like interaction with WINS and Microsoft DNS.  It doesn't
always work, though.

NMBD registers the samba machine with WINS, but it only will do so if
it can find the machine's IP address.  But the Linux/DHCP machine
can't look up its own address from the DNS server, because the DNS
server won't know about it until WINS does, and WINS doesn't know
about it....

The trick is to put an entry in the /etc/host table for the machine
and its current IP address, and make sure that the entry is there
before nmbd starts up.  You could do this by editing /etc/hosts by
hand and then rebooting, but that's not cool.  

I created a script to create a new /etc/hosts file and copy it into
place.  I edited the file /etc/sysconfig/network-scripts/ifdhcpc-done
and added a line to run the hosts hack at the end of the ifdhcpc-done
script.  The change should take effect the next time you reboot.  You
can tell it worked simply by doing an nslookup of the machine name.
Note that the machine name is set in the dhcpc scripts.  On RedHat
Linux, you can change it by using the network configurator tool.

The catches are that it doesn't aways work.  A machine may register
with WINS, but it will fall off within a couple of days, presumably
when the IP address gets renewed.  I probably need to make nmbd
restart whenever the address changes.  Also, sometimes it just doesn't
work at all.  I should have something clever to say about this, but I
don't, mostly because I really don't want to learn any more about

I know that's a pretty lame report of my hosts hack, but I though I'd
pass it on so anyone in the same situation can try it and suggest
improvements.  I hope this helps some people.  The script I wrote is
included below.

--------------cut here-------------

if [ -f /etc/hosts ]; then
    mv /etc/hosts /etc/hosts.prev

echo " localhost localhost.localdomain" > /etc/hosts

MYIP=`grep IPADDR /etc/dhcpc/hostinfo-*0` > /dev/null 2>&1
if [ ! $? ] ; then
    echo "Failed to get your IP address"
    exit 1

eval ${MYIP}
echo "${IPADDR} " `hostname` >> /etc/hosts

More information about the samba mailing list