14

How can you determine the hostname associated with an IP on the network? (without configuring a reverse DNS)

This was something that I thought was impossible. However I've been using Fing on my mobile. It is capable of finding every device on my network (presumably using an arp-scan) and listing them with a hostname.

For example, this app is capable of finding freshly installed Debian Linux devices plugged into a home router, with no apparent reverse DNS.

As far as I know neither ping, nor Neighbor Discovery, nor arp include a hostname. So how can fing be getting this for a freshly installed Linux PC? What other protocol on a Linux machine would give out the machine's configured hostname?

0

2 Answers 2

18

The zeroconf protocol suite (Wikipedia) could provide this information.

The best known implementations are AllJoyn (Windows and others), Bonjour (Apple), Avahi (UNIX/Linux).

Example showing a list of everything on a LAN (in this case not very much):

avahi-browse --all --terminate
+  ens18 IPv6 Canon MG6650                                  _privet._tcp         local
+  ens18 IPv4 Canon MG6650                                  _privet._tcp         local
+  ens18 IPv6 Canon MG6650                                  Internet Printer     local
+  ens18 IPv4 Canon MG6650                                  Internet Printer     local
+  ens18 IPv6 Canon MG6650                                  UNIX Printer         local
+  ens18 IPv4 Canon MG6650                                  UNIX Printer         local
+  ens18 IPv6 Canon MG6650                                  _scanner._tcp        local
+  ens18 IPv4 Canon MG6650                                  _scanner._tcp        local
+  ens18 IPv6 Canon MG6650                                  _canon-bjnp1._tcp    local
+  ens18 IPv4 Canon MG6650                                  _canon-bjnp1._tcp    local
+  ens18 IPv6 Canon MG6650                                  Web Site             local
+  ens18 IPv4 Canon MG6650                                  Web Site             local
+  ens18 IPv6 SERVER                                        _device-info._tcp    local
+  ens18 IPv4 SERVER                                        _device-info._tcp    local
+  ens18 IPv6 SERVER                                        Microsoft Windows Network local
+  ens18 IPv4 SERVER                                        Microsoft Windows Network local

More specifically, you can use avahi-resolve-address to resolve an address to a name.

Example

avahi-resolve-address 192.168.1.254
192.168.1.254 router.roaima...
0
1

In Linux you may use dig or host. Example:

dig -x 192.0.2.1

host 192.0.2.1

In windows you may use ping -a like so:

ping -a 192.0.2.1
1
  • 1
    as far as I know dig and host are reverse DNS. This requires special DNS setup to work. That is it couldn't just find the hostname for a new device plugged onto the network. Commented Nov 20, 2019 at 13:37

You must log in to answer this question.

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