3

How do you configure Avahi on Ubuntu to automatically broadcast and discover the DNS info for each Linux server on a local network?

I've ran this on my localhost (hostname mylocalhost) and a test server (hostname mytestserver), but all hostname lookups still fail:

$ sudo apt-get install avahi-daemon
$ sudo nano /etc/avahi/avahi-daemon.conf
    -#host-name=foo
    +host-name=<hostname>
    -#publish-addresses=yes
    +publish-addresses=yes
$ sudo service avahi-daemon restart
$ sudo update-rc.d avahi-daemon defaults
$ avahi-daemon --check
$ host mytestserver
Host mytestserver not found: 3(NXDOMAIN)
$ host mytestserver.local
Host mytestserver.local not found: 3(NXDOMAIN)
$ ping mytestserver
ping: unknown host mytestserver
$ ping mytestserver.local
ping: unknown host mytestserver.local

I've confirmed my firewall is disabled, so that shouldn't be blocking it. I've also read through Ubuntu's wiki page on Zeroconf and mDNS, but it didn't help.

What am I doing wrong?

Cerin
  • 3,497
  • 17
  • 57
  • 72
  • In my experience Avahi is not very reliable, and it's worth the hour or so it takes to set up a real domain (e.g. with FreeIPA). – Michael Hampton Nov 30 '14 at 01:41

1 Answers1

0
$ host mytestserver
Host mytestserver not found: 3(NXDOMAIN)
$ ping mytestserver
ping: unknown host mytestserver

Hostname mytestserver is not in /etc/hosts nor local/lan dns setup. This has nothing to do with avahi.


$ host mytestserver.local
Host mytestserver.local not found: 3(NXDOMAIN)
$ ping mytestserver.local
ping: unknown host mytestserver.local

This is related to avahi, check below.


In /etc/nsswitch.conf, the hosts line should be as follow:

hosts: files mdns4_minimal [NOTFOUND=return] dns

files means check /etc/hosts, then mdns4_minimal means check avahi.


There are a few things to check in /etc/avahi/avahi-daemon.conf.

In server section, allow-interfaces should be unset/commented, or have the interface you intended to use avahi:

#allow-interfaces=

Use netstat to check if avahi is listening on all interfaces:

# netstat -npl|grep avahi
udp  0 0 0.0.0.0:5353 0.0.0.0:* 696/avahi-daemon: r 
udp6 0 0 :::5353      :::*      696/avahi-daemon: r 

I encountered a few cases that line was uncommented and with the wrong interface in it, blocking avahi on the intended network.

In publish section, set publish-workstation to yes (the default is no):

publish-workstation=yes

In general, publish-addresses=yes, which is the default, should be enough. However, with no share service(vnc/samba/etc) running, sometimes(base on past experience) avahi don't seems to publish/announce machine. So we enable publish-workstation=yes to force it.


One last note, sometimes it takes 2 to 5min for avahi to pickup others boxes.

John Siu
  • 3,577
  • 2
  • 15
  • 23