Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm looking for a command line tool which gets an IP address and returns the host name, for Windows.

share|improve this question

5 Answers 5

up vote 6 down vote accepted

It's called nslookup, works fine for reverse lookups IFF someone has configured a reverse zone file, which they don't always do.

share|improve this answer

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
share|improve this answer

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.

share|improve this answer

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.

share|improve this answer

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...........
share|improve this answer
    
This is what I always use first as it is universally available on pretty much every machine. –  Goyuix Oct 13 '09 at 14:54
3  
ping is sooo often used to do simple DNS lookups... sigh don't do that. –  PEra Oct 13 '09 at 16:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.