30

I want to get the hostname of a remote server using the IP address using my Ubuntu.

In Windows we can get using NBTSTAT but this doesn't work in Linux.

Does anyone know how to do that?

3 Answers 3

43

NetBIOS

Windows (and Linux devices with Samba) use NetBIOS to 'publish' their addresses. This is what NBTSTAT uses to look up the IP address.

To find a hostname in your local network by IP address you can use:

nmblookup -A <ip>

Or you can install nbtscan by running:

sudo apt-get install nbtscan

And use:

nbtscan <ip>

Multicast DNS

If systems publish their address via Multicast DNS (OS X, Windows 10 and Linux devices with a running avahi-daemon do this), do a lookup using avahi-resolve (requires installing avahi-utils):

avahi-resolve -a <ip>

Reverse DNS

If the host has a public IP-address and a working reverse DNS entry, use the dig (requires installing dnsutils) or host (requires installing bind9-host) programs:

dig -x <ip>
host <ip>
9
  • 2
    it said no reply from xxx.xx.xx.xxx but ping is able to communicate with server
    – OmiPenguin
    Oct 23, 2012 at 9:27
  • 2
    In that case, try host.
    – Silke
    Oct 23, 2012 at 9:28
  • 2
    ok now i used host ipaddress, It replied Host xxx.xx.xx.xxx.in-addr.arpa. not found: 3(NXDOMAIN)
    – OmiPenguin
    Oct 23, 2012 at 9:35
  • 1
    Is the server in your local network or is it a public IP address?
    – Silke
    Oct 23, 2012 at 9:37
  • 2
    Yes this is in our local Network.
    – OmiPenguin
    Oct 23, 2012 at 9:54
10

Simply type the following command into the Linux/Ubuntu terminal:

host <ip>
2

Just another minor addition to others contribution, in case you don't know the IP.

If you don't know your then type:

sudo ifconfig -all

You may find the there. Then, all you need to do is use the:

 host <ip> 

command as mentioned before.

Although this is a already answered question, I may found useful add this simple hint to ubuntu-linux newcomers.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .