Tuesday 17 April 2007

find out the IP of a Windows machine in a samba network

We all know that with DNS, we can easily find out the IP of a machine with an FQDN (i.e., fully qualified domain name). The commands like ping, nslookup (obsolete), dig, ... can be used for this purpose.

Additioanlly on Unix the file /etc/hosts can also be used to store information for machine names <-> IP addresses translations. The Windows equivelant file is usually C:\Windows\system32\drivers\etc\hosts.

But what about name resolution with WINS? Is there any simple comamnd to dig out the IP address of a Windows machine over network?

The answer is yes (of course). In a Windows network, there must exist at least one machine functions as a browser which keeps the information who is who.

On a *nix machine where samba is running, you can use the command smbtree to list all Windows shares over network, including Windows machine names. In particular, you can use command nmblook command to find out the IP of a windows machine, e.g.:

nmblook windozebox

to get the IP of the quoted windows box, just like nslookup for name resolution with DNS.

On a Windows 2K/XP machine, you can use the command net to dig out a lot of network information, for example, net view tells you avaliable Windows/Samba machines on the local network block. And you can use the ping command to find out a windows machine's IP even it has no dns record.