How can I find the IP of a Windows host from OS X?
Is there an easy way from the OS X (Lion) command line or Finder to determine the IP address of a Windows machine on the same subnet (in a home network)? Assume the machine itself is not easily accessible.
I know of the following ways:
- Refer to the router(dhcp server)'s web admin page.
- Use
arp -a
to get a list of recently accessed IPs and guess from there.
The machine does show up in Finder, so I know it's network computer name (which I'm guessing is a WINS name?), but not what workgroup it is. We are not on a domain.
I'm not entirely sure how OS X "maps" an SMB/WINS name, since doing something like pinging "mywindowsbox" fails, as does pinging "mywindowsbox.local".
Use smbutil lookup HOSTNAME
(Source).
This will give you the IP address of a given NetBIOS name.
I presume it’s the same as what the Finder does when connecting to an smb://
URL, so it’s probably subject to the same limitations (I don’t actually know what these are but I’ve noticed that the Finder is not always able to look up windows machines in the local network when other windows clients seemingly have no problem doing so).
Do you not have access to the Windows machine?
Can you ping the IP of the Windows machine? If not, perhaps the Windows machine has its software firewall on preventing pings.
Also, if you have access to the router, it might list the hostname of the Windows machine.
update: Well, the name that shows up in the Finder should be the PCs hostname.
If you have nmblookup installed, try:
nmblookup hostname
Hostname would be the WINS name. This might return the IP address. Also look at the nmblookup man pages for other options that might get this working.
The information might be in a local nameserver; you can try:
nslookup HOSTNAME
or
nslookup HOSTNAME.yourdomain.com