avahi-daemon and “.local” domain issues

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 sayYour 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!

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

I had the same problem. I have a home network with Macs, and they want avahi/bonjour and a .local domain to share properly. My ISP provides a DSL router that provides private IP addresses (192.168.1.*) and gives a local domain (attlocal.net). However it also responds as an authority for a .local unicast domain – even though it doesn’t really have one. That is a no-no, but they do it anyway. I was left with a network where Macs could discover and attach to other Macs, and Linux could see avahi services, but failed to connect to them.

The symptoms: If your linux system is showing services but won’t connect through nautilus. If DLNS services won’t connect. If ping hostname.local fails to resolve. Finally if dig local gives an authority section result for your router/ISP.

What works for me:
create a file /etc/mdns.allow with the following two lines

    .local
    .local.

Then edit /etc/nsswitch.conf and in the line that starts with hosts: replace the item mdns4_minimal with mdns4. The result for me looked like this:
hosts:     files mdns4 [NOTFOUND=return] dns

Finally reboot or sudo systemctl restart network. This has worked for me on Ubuntu 18 to 21 as well as Debian Stretch and Buster including on Raspberry Pi. As a result I can see and attach to samba shares, AFP shares, and even SSH ports when browsing Other Locations in Files (nautilus) on Ubuntu.

Why was it broken to begin with?
mdns_minimal did not work, yet mdns4 did. That is not an expected outcome, and I got as far as trying to report a bug against mdns_minimal but then I found a clear answer why this is so at their GitHub site: https://github.com/lathiat/nss-mdns . mdns_minimal will not resolve unless both domain is .local and also IPv4 is from the 169.254 self-config range. It also will not look at an /etc/mdns.allow file. So if you need to resolve .local and don’t have self-config addresses you may need to replace it in nsswitch.conf as described above.

Method 2

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

Method 3

So I tried to change the “host-name” parameter in “avahi-daemon.conf” to something that’s not the machines hostname, and I’ve been running 2 weeks without any issues.
Maybe this had to do with the machine also running samba and Windows using the “.local” domain for it’s own purposes?


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments