92

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.

billyduc
  • 1,637

6 Answers6

98

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:

nmblookup -A 10.10.10.10
mivk
  • 4,924
Phil Swiss
  • 1,457
69

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.

Izzy
  • 8,253
12

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

joeqwerty
  • 111,849
6

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

Sreedhar
  • 61
  • 1
  • 1
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.

balupton
  • 196
1

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

Arun
  • 11