Adventures of the Retired Guy

Adventures of the Retired Guy

Stuff and nonsense from a retired guy

11 Nov 2019

Learning to live with Linux: avahi and systemctl

First of maybe a short series on the nits of supporting Ubuntu for home use...

This all started with a frequently recurring notification from avahi-daemon, "mumble, mumble .local domain". This would briefly display on my desktop a few minutes after boot up, or shortly after a network change like opening or closing a VPN connection.

avahi's prejudice against windows networks using '.local' domain is well documented. All I can say is Windows started using it first...

I'm not sure I'm not depending on it, or would like to depend on it, so I decided to switch avahi's domain. And, not only did I learn something useful about Avahi, I learned a more general thing about systemctl as well.

Fix for Avahi .local domain

Caveat: although this change made all errors go away, I have no test to prove avahi is, er, working. YMMV. What I think it does is have avahi browse domain .attlocal.net, which my AT&T home router establishes for me. I think it's preferable than having it create a whole parallel domain called alocal, which seems like it's getting around some hard-coded string comparison. I think keeping the daemon running is preferable to shutting it down, which I have also seen suggested.

root@bob-desktop:/etc/avahi# diff avahi-daemon.conf{,.old}
23,24c23,24
< domain-name=attlocal.net
< browse-domains=attlocal.net,ncsd.local
---
> #domain-name=local
> #browse-domains=0pointer.de, zeroconf.org

We will see whether my change, to map zeroconf to an existing local domain, works more smoothly.

Troubleshooting systemctl startup errors – systemctl status ...

This is a well documented subcommand, but it was news to me. And it worked so smoothly that I thought I'd blog about it just to cement the concept in my head.

In the above change, you'll notice the domain names do not have a leading dot. Avahi-daemon.conf(5) man page clearly says domain-name should have a leading dot, though it does not say anything about browse-domains. Typical unix laxness? or am I missing something fundamental about avahi?

domain-name= Set the default domain name avahi-daemon tries to register its host name and services on the LAN in. If omitted defaults to ".local".

When I tried .attlocal.net based on this, I got startup errors. Removing it generated what seems like clean startup. And systemctl was nice enough to tell me how to debug it!

$ sudo systemctl restart avahi-daemon.service                                                                                                                               
Job for avahi-daemon.service failed because the control process exited with error code.
See "systemctl status avahi-daemon.service" and "journalctl -xe" for details.
~~~~~~~~~~~~ bob@bob-desktop /etc/avahi  ~~~~~~~~~~~~                                                                                                                       
$ sudo systemctl status avahi-daemon.service                                                                                                                                
 avahi-daemon.service - Avahi mDNS/DNS-SD Stack
   Loaded: loaded (/lib/systemd/system/avahi-daemon.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sun 2019-11-10 16:19:40 EST; 23s ago
  Process: 6286 ExecStart=/usr/sbin/avahi-daemon -s (code=exited, status=255/EXCEPTION)
 Main PID: 6286 (code=exited, status=255/EXCEPTION)

Nov 10 16:19:40 bob-desktop systemd[1]: Starting Avahi mDNS/DNS-SD Stack...
Nov 10 16:19:40 bob-desktop avahi-daemon[6286]: Process 2618 died: No such process; trying to remove PID file. (/run/avahi-daemon//pid)
Nov 10 16:19:40 bob-desktop avahi-daemon[6286]: Invalid domain name ".attlocal.net" for key "browse-domains" in group "server"
Nov 10 16:19:40 bob-desktop systemd[1]: avahi-daemon.service: Main process exited, code=exited, status=255/EXCEPTION
Nov 10 16:19:40 bob-desktop systemd[1]: avahi-daemon.service: Failed with result 'exit-code'.
Nov 10 16:19:40 bob-desktop systemd[1]: Failed to start Avahi mDNS/DNS-SD Stack

When I edited the .conf file to remove the leading dots, everything looks fine. my PC is running with a reasonable-looking domain name. Only time will tell whether this holds up.

sudo systemctl status avahi-daemon.service                                                                                                                                
● avahi-daemon.service - Avahi mDNS/DNS-SD Stack
   Loaded: loaded (/lib/systemd/system/avahi-daemon.service; enabled; vendor preset: enabled)
   Active: active (running) since Sun 2019-11-10 16:22:54 EST; 52s ago
 Main PID: 7257 (avahi-daemon)
   Status: "avahi-daemon 0.7 starting up."
    Tasks: 2 (limit: 4915)
   Memory: 1.4M
   CGroup: /system.slice/avahi-daemon.service
           ├─7257 avahi-daemon: running [bob-desktop.alocal]
           └─7263 avahi-daemon: chroot helper

Nov 10 16:22:54 bob-desktop avahi-daemon[7257]: Joining mDNS multicast group on interface lo.IPv4 with address 127.0.0.1.
Nov 10 16:22:54 bob-desktop avahi-daemon[7257]: New relevant interface lo.IPv4 for mDNS.
Nov 10 16:22:54 bob-desktop avahi-daemon[7257]: Network interface enumeration completed.
Nov 10 16:22:54 bob-desktop avahi-daemon[7257]: Registering new address record for 2600:1700:2d61:ca0:2cd9:4d7d:156:6347 on enp30s0.*.
Nov 10 16:22:54 bob-desktop avahi-daemon[7257]: Registering new address record for 2600:1700:2d61:ca0:f584:2343:1020:7348 on enp30s0.*.
Nov 10 16:22:54 bob-desktop avahi-daemon[7257]: Registering new address record for 2600:1700:2d61:ca0::40 on enp30s0.*.
Nov 10 16:22:54 bob-desktop avahi-daemon[7257]: Registering new address record for 192.168.1.247 on enp30s0.IPv4.
Nov 10 16:22:54 bob-desktop avahi-daemon[7257]: Registering new address record for ::1 on lo.*.
Nov 10 16:22:54 bob-desktop avahi-daemon[7257]: Registering new address record for 127.0.0.1 on lo.IPv4.
Nov 10 16:22:55 bob-desktop avahi-daemon[7257]: Server startup complete. Host name is bob-desktop.alocal. Local service cookie is 586061434.