Fix avahi-daemon and .local Domain Issues in Linux

avahidnslinux

I have a Ubuntu 16.04 based HTPC/Media Server that's running 24/7. As far as I can remember using an official Ubuntu distro, I've always had issues with the avahi-daemon. The issue is pretty often discussed online. Some people decide to just delete daemon, however, I actually need it as I'm running a CUPS server and use Kodi as my AirPlay reciever.

The issue

mDNS/DNS-SD is inherently incompatible with unicast DNS zones .local. We strongly recommend not to use Avahi or ​nss-mdns in such a network setup. N.B.: nss-mdns is not typically bundled with Avahi and requires a separate download and install.
(avahi.org)

The symptoms are simple – after around 2-4 days of uptime the network connection will go down and this will be logged

Mar 17 18:33:27 15 avahi-daemon[1014]: Withdrawing address record for 192.168.1.200 on enp3s0.
Mar 17 18:33:27 15 avahi-daemon[1014]: Leaving mDNS multicast group on interface enp3s0.IPv4 with address 192.168.1.200.
Mar 17 18:33:27 15 avahi-daemon[1014]: Interface enp3s0.IPv4 no longer relevant for mDNS.

The network will go back up without issues if you physically reconnect the Ethernet plug, or if you reconnect software-side.

Possible solutions

There are three solutions listed on the official wiki, which has been non-functional since what appears to be June 2016, so I'm providing a non-direct archive.org link

1.) Edit /etc/nsswitch.conf from

"hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4"

to

hosts: files dns mdns4

2.) Modify /etc/avahi/avahi-daemon.conf

from

domain-name=.local

to

domain-name=alocal

3.) "Ask the administrator to move the .local zone" (as said on the wiki)

What I did

The first solution did not appear to work for me – the daemon still works, however, the network will go down the same way as before (to be fair, on the wiki it does say "Your Mileage May Vary")

The second solution causes the daemon to seemingly function properly (nothing wrong if you look at the logs) but the iOS devices fail to "see" the machine as a printer or an AirPlay reciever (as well as iTunes on my Windows machine)

The third solution is tricky, because I'm not well versed in the "ins and outs" of how a network is functioning; and I'm not sure I actually tried it. Here's what I mean: on my Asus Router running Asuswrt-Merlin I went into a settings subcategory /LAN/DHCP Server/Basic Config. There I set "RT-AC68U's Domain Name" as "lan" (a domain name I saw advised on the web, because it doesn't conflict with anything, unlike "local"). As far as I can understand, that's what "moving the .local zone" means. If this is in fact correct, than this solution does not work for me as well.

Conclusion

So, what should I do? I've been battling with this problem for over 4 months now, and every answer online comes down to the those I've already tried; frankly, I'm completely lost.
Thanks in advance!

Best Answer

I think the third solution is the way to go when you have access to the router configuration. I would try setting the "RT-AC68U's Domain Name" to blank.

The next thing that I would do is run something like wireshark, and watch the packets sent and received by avahai-daemon, as well as any packets sent from and to any domain name ending in .local ... if something other than avahai is setting LAN domain names to .local you'll find it there.

It's also possible that the issue is something else entirely, and wireshark might tell you that as well.

If you're using Avahai entirely for the purpose of assigning domain names to machines on your network, you might consider using dnsmasq instead. You can run it off your RT-AC88U router, or from your Ubuntu box (In fact, it's probably already running on your ubuntu box, and you'll just need to tweak the config file).

Documentation for setting up dnsmasq under Asus-Merlin

Related Question