9

Ubuntu uses 'avahi' to perform host name lookups on the local network, which allows me to find other computers just by adding '.local' to the name, e.g. laptop.local or desktop.local.

However, avahi does not seem to perform reverse lookups for the IP addresses of computers on the local network. So when applications look up IP addresses for local computers, a request goes out to an Internet DNS server on the Internet which returns NXDOMAIN (name does not exist).

Is it possible for avahi to perform reverse lookups for IP addresses? If it is, how do I do it?

3 Answers3

7

Yes, avahi supports reverse IP address lookups for the .local names that are registered on the local network. However, most of the commands for performing test queries contact DNS servers directly without using avahi. In order to confirm that this is working at the command line, you have to use the getent hosts command instead of nslookup, dig, or host.

For example, you can look up an IP address using the following commands:

$ nslookup 192.168.0.1
$ dig -x 192.168.0.1
$ host 192.168.0.1
$ getent hosts 192.168.0.1

Only the getent hosts command will return the corresponding name because it is the only command that uses avahi to perform the reverse lookup.

(Actually, this also applies to looking up names, but it is usually simpler to just type ping hostname.local which performs a name lookup using DNS or avahi and checks connectivity at the same time.)

5

dig also could perform reverse DNS lookup using avahi:

dig -x 192.168.0.1 @224.0.0.251 -p 5353

3

There is an avahi command for it: avahi-resolve-address. E.g.:

avahi-resolve-address 192.168.0.1

Or, an equivalent variant:

avahi-resolve --address 192.168.0.1