How to determine the hostname from an IP address in a Windows network?

749,540

Solution 1

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,

NBTSTAT -A 10.10.10.10

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

Solution 2

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.

Solution 3

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

Solution 4

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

Solution 5

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.

Share:
749,540

Related videos on Youtube

hxuanhung
Author by

hxuanhung

Updated on September 17, 2022

Comments

  • hxuanhung
    hxuanhung over 1 year

    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.

  • aeroshock
    aeroshock over 14 years
    PING can result in inaccurate results, especially if you're actively working on DNS issues.
  • aeroshock
    aeroshock over 14 years
    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.
  • joeqwerty
    joeqwerty over 14 years
    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
    joeqwerty over 14 years
    i didn't say ping was the best way, i said it was a way. using nslookup assumes that he has an internal dns infrastructure in place. i didn't make that assumption as he mentioned workgroup in his post.
  • aeroshock
    aeroshock over 14 years
    You refer to NSLOOKUP like it's some internal resolution tool... Either way, NSLOOKUP is the technically superior option.
  • Maximus Minimus
    Maximus Minimus over 14 years
    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
    Maximus Minimus over 14 years
    DNS is actually required for Active Directory. We simply don't have enough info to say anything definitive regarding that.
  • GAThrawn
    GAThrawn over 14 years
    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.
  • joeqwerty
    joeqwerty over 14 years
    @mh: yes it is, but again... not enough info from the op.
  • joeqwerty
    joeqwerty over 14 years
    @mh& @izzy: i'm not debating that nslookup is not the proper tool to use. nslookup is the tool i would use in my environment where i know i have dns set up. i would use it for testing external dns resolution also, but as the op didn't give us enough detail, my answer was based on what was likely to give him some kind of result. maybe he'll post back with more info.
  • hxuanhung
    hxuanhung over 14 years
    Thanks you Decca, the nbtstat is rock btw ... I failed on Linux box nmblookup 192.168.1.92 querying 192.168.1.92 on 192.168.1.255 name_query failed to find name 192.168.1.92
  • hxuanhung
    hxuanhung over 14 years
    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.
  • hxuanhung
    hxuanhung over 14 years
    The command nmblookup -A 192.168.1.92 is working sucessfully
  • Jeff Moden
    Jeff Moden almost 12 years
    @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
  • HopelessN00b
    HopelessN00b over 11 years
    No, that's wrong. Netbios is (sadly) not deprecated, and actually required for a number of vital Active Directory functions.
  • styfle
    styfle over 10 years
    @joeqwerty Nice gravitar. Seriously.
  • joeqwerty
    joeqwerty over 10 years
    LOL. Homestar Runner.
  • Mikhail
    Mikhail over 10 years
    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?
  • Pacerier
    Pacerier over 9 years
    @Izzy, What do you mean by "PING can result in inaccurate results, especially if you're actively working on DNS issues"?
  • Trevor Boyd Smith
    Trevor Boyd Smith about 7 years
    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).
  • Massimo
    Massimo over 5 years