Thursday, September 2, 2010

Multicast DNS (mDNS) Avahi Zeroconfig not resolving .local hosts on Linux

There’s a little tweak that you need to know to get Avahi multicast DNS (mDNS) Service Discovery (DNS-SD) ( aka: Zeroconfig) to resolve .local hostnames for applications running on Linux hosts. This problem vexed me for several days so I thought I'd document it so others could save a bit of time digging into the inner workings of the Linux advanced networking features. The Avahi mdns responder responds to dns requests both external (from remote hosts) and internal from applications on the local host. However, for some reason the default nslookup file on some Linux distributions (Angstrom embedded!) has mdns lookups disabled in the host name lookup process - - meaning your applications will return "bad address" for commands like (.local is the local mdns domain in an ad-hoc network)

Example of the error:

qsense1_user@overo:~$ ping -6 qsense2.local
ping: unknown host qsense2.local


You must add the word ‘mdns’ to the line ‘hosts:’ in the nsswitch.conf file to remedy the situation so host name lookup will use mDNS. Here’s the file with the problem:

qsense1_user@overo:~$ more /etc/nsswitch.conf
# /etc/nsswitch.conf
# Example configuration of GNU name service
hosts: files dns


Now for the fix:

qsense1_user@overo:~$ sudo vi /etc/nsswitch.conf
# /etc/nsswitch.conf
# Example configuration of GNU name service
hosts: files dns mdns //add mdns to this line above or the host lookup never uses mdns!

Test the fix:

qsense1_user@overo:~$ ping -6 qsense2.local
PING qsense2.local (fe80::219:88Fff::fe20:fae9) 56 bytes of data.
64 bytes from fe80::219:88Fff::fe20:fae9: icmp_seq=1 ttl=127 time=0.305 ms
--- hostqsense1.local ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms


Success! Now use IPv6, mDNS, DNS-SD, and advance web services to conquer the world with your ad-hoc, serverless network... Can you think of anywhere where you might want to run a network with minimal/no IT support, where you would like user to be able to automatically find objects, sensors, controllers, peers and interact with them? The consumer home, ad-hoc military networks, transportation environments perhaps...

No comments:

Post a Comment