Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question
    
Reverse lookups of local IP-addresses return the appropriate *.local hostname here. What tools are you using to do reverse lookups? –  JanC Feb 2 '11 at 3:31
    
Thanks, JanC. You were right! I have learned that how you check this can make all the difference. –  user8979 Feb 13 '11 at 10:07

2 Answers 2

up vote 4 down vote accepted

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.)

share|improve this answer

dig also could perform reverse DNS lookup using avahi:

dig -x 192.168.0.1 @224.0.0.251 -p 5353

share|improve this answer
    
That's fantastic, vagran. I didn't realise dig could perform multicast DNS queries. I investigated and found that you can also do this using nslookup: nslookup -port=5353 -querytype=PTR 192.168.0.1 224.0.0.251. However, I also found that if ufw (which allows multicast by default) is running, only getent hosts 192.168.0.1 works. Aargh! If I figure this out, I'll update my answer. –  user8979 Feb 20 '11 at 22:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.