My LAN has 50 Windows hosts. At the Windows command line I try ping to get the IP address of a running Windows machine.

The question is how to get hostname of a specific IP address in the same Windows workgroup?

Another question is how to know the hostname of Windows machine from a Linux box if I have an IP address? Which command do you use? I have one host running Kubuntu 9.04.


If you want to determine the name of a Windows machine without DNS, you should try Nbtstat. But that will only work on Windows:

For example,


On Linux, you should try nmblookup that does nearly the same.

| improve this answer | |
  • 3
    NBTSTAT does rely on having NetBIOS loaded and running, which is often switched off in larger organisations with their own AD & DNS infrastructure. Probably a safe assumption here though with a 50 machine workgroup. – GAThrawn Nov 25 '09 at 11:58
  • Thanks you Decca, the nbtstat is rock btw ... I failed on Linux box nmblookup querying on name_query failed to find name – billyduc Nov 30 '09 at 1:26
  • 8
    The command nmblookup -A is working sucessfully – billyduc Nov 30 '09 at 1:40
  • 1
    nmblookup is part of my distro's Samba package. Not sure why nmblookup that does ip to hostname is part of Samba (networked file system code and print services code). – Trevor Boyd Smith Feb 28 '17 at 18:12

The technically preferable method is to type nslookup <ip address>

NSLOOKUP actually asks the DNS server for the IP address of the hostname. Ping will use the local DNS Resolver Cache, which may be incorrect until you flush.

| improve this answer | |
  • that's assuming he has an internal dns server for name resolution. also, the op stated that he wanted to resolve a host name from the ip, so i'm assuming he doesn't know the host name to begin with. also, as far as i'm concerned there's no correct or incorrect way of doing it. there are multiple methods, each of which are valid, and each of which may produce different results. – joeqwerty Nov 25 '09 at 4:58
  • 3
    Nope. Using PING is not the best way of doing it. You can do an nslookup <ip address> and it will resolve the reverse lookup. – Izzy Nov 25 '09 at 5:00
  • 1
    You refer to NSLOOKUP like it's some internal resolution tool... Either way, NSLOOKUP is the technically superior option. – Izzy Nov 25 '09 at 5:07
  • 1
    But he is correct. nslookup is only of use in this scenario if there is a DNS server (whether that be internal or external) which has reverse lookup zone entries for the OP's hosts, and the OP's machines are configured to use that DNS server. – Maximus Minimus Nov 25 '09 at 9:52
  • 3
    @Izzy I registered as a new member just to say thanks for the tip for NSLOOKUP, Izzy. Out of all the stuff above, it's the only one that worked for me. Thanks a million. --Jeff Moden – Jeff Moden Jul 18 '12 at 3:09

On Windows you can use ping -a x.x.x.x to attempt to resolve the hostname from the IP address.

| improve this answer | |
  • 1
    PING can result in inaccurate results, especially if you're actively working on DNS issues. – Izzy Nov 25 '09 at 4:56
  • the op didn't state he was working on dns issues, he he implied that he was working on name resolution issues. dns is not the only name resolution mechanism in windows and is not a required name resolution mechanism. he also stated he's working in a workgroup setting so i didn't make any assumption regarding his having a dns infrastructure in place. – joeqwerty Nov 25 '09 at 5:01
  • DNS is actually required for Active Directory. We simply don't have enough info to say anything definitive regarding that. – Maximus Minimus Nov 25 '09 at 11:10
  • @mh: yes it is, but again... not enough info from the op. – joeqwerty Nov 25 '09 at 12:26
  • thank you all ! I don't have Active Directory service, I have one DNS server resolve for dhcp, mail, web server in my company, most of the employee host are running windows XP and using the same WORKGROUP. – billyduc Nov 30 '09 at 1:33

There are a couple of ways of doing it on both Windows and Linux. For example,

  1. nslookup: the classic way to find the IP address from a hostname or vice-versa.
  2. ipconfig or ifconfig based on whether you are running on Windows or Unix
  3. hostname -i on Linux

Ref: Multiple ways to get IP address from hostname in Linux and Windows

| improve this answer | |

For mac users smbutil -v status -ae x.x.x.x works. You can also use arp -a to get mac addresses for everything on your network.

| improve this answer | |

nmblookup might not work well for Linux hosts, because the NetBIOS name is deprecated. And on Windows, it is limited to the local network.

| improve this answer | |
  • 2
    No, that's wrong. Netbios is (sadly) not deprecated, and actually required for a number of vital Active Directory functions. – HopelessN00b Nov 22 '12 at 6:20
  • Can somebody point out how in which cases AD DS still relies on Netbios? There have been talks that Netbios bound to be depricate since Windows Server 2003 times. Does it still somehow required now with Windows Server 2012 AD DS networks? – Mikhail Dec 4 '13 at 14:47
  • Sadly, yes: serverfault.com/questions/676867/… – Massimo Feb 13 '19 at 22:55

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