Resolve host name from IP address

Solution 1:

The command you are looking for is called nslookup, works fine for reverse lookups IFF someone has configured a reverse zone file, which they don't always do.

Solution 2:

if all the above fails, and you are specifically looking for a Windows machine, you can use

nbtstat -a 192.168.1.50

The data returned will be all the NetBIOS records the machine has. The one with a <20h> record type will usually be the machine's name.


Solution 3:

For many IP addresses you could just use ping -a, for example

ping -a 209.85.229.106

will return

Pinging ww-in-f106.google.com [209.85.229.106] with 32 bytes of data:

Reply from 209.85.229.106...........

Solution 4:

If you use nslookup command with the IP address as its first argument will return the PTR record (the reverse entry) if it exists. For example:

nslookup 192.168.1.50

Solution 5:

Use dig. A Windows port is available from the ISC here (look in the immediate download box for the link to the zip file). Here's their man page reference for dig.

Ward's point about the reverse lookup records often not getting created is very much true. Reverse lookups often do fail because many admins don't bother creating the ptr records.