Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
up vote 27 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 all the above fails, and you are specifically looking for a Windows machine, you can use

nbtstat -a

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
Not working when connected through the open vpn – Flextra Apr 5 at 6:13
@Flextra - you will need SMB access to the machine. Your VPN may be blocking it. – Moose Apr 7 at 2:55

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

ping -a

will return

Pinging [] with 32 bytes of data:

Reply from
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
ping is sooo often used to do simple DNS lookups... sigh don't do that. – PEra Oct 13 '09 at 16:48

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:

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

Your Answer


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.