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.
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: Withdrawing address record for 192.168.1.200 on enp3s0.
Mar 17 18:33:27 15 avahi-daemon: Leaving mDNS multicast group on interface enp3s0.IPv4 with address 192.168.1.200.
Mar 17 18:33:27 15 avahi-daemon: 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.
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"
hosts: files dns mdns4
2.) Modify /etc/avahi/avahi-daemon.conf
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.
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!