Disabling Avahi service in PureOS 10

I recently installed OpenSnitch and discovered that the avahi-daemon is running on my system. I assume this is either included and enabled by default on PureOS, or perhaps it was enabled by the installation of an application.

Is it necessary to have Avahi running on PureOS? What things might break if I disable it?

2 Likes

I finally went ahead and disabled the avahi-daemon using sudo systemctl disable avahi-daemon on PureOS 11. That alone doesn’t stop it unless you reboot, so I stopped it with sudo systemctl stop avahi-daemon. That came with the following warning

Warning: Stopping avahi-daemon.service, but it can still be activated by:
  avahi-daemon.socket

Will update this thread with any observed negative side effects. Searched the web for info about the same and couldn’t find much.

2 Likes

No, it will affect device discovery on your local network:

avahi - mDNS/DNS-SD

1 Like

Even if you don’t disable the service, you can tame the configuration somewhat.

avahi will allow hosts to resolve local domain names without having a local DNS server. (As I have a local DNS server, and hosts don’t come and go like crazy so it is easy enough to keep the local DNS data source up to date, I have no need for this aspect.)

avahi will allow a measure of auto-configuration of your local network by allowing a host to discover services running on other hosts. Whether you need that is a balance between your expertise and how dynamic your network is. (Again, I have no need for this aspect.)

1 Like

I don’t have any need for autodiscovery on the home LAN.

I ‘discovered’ that disabling ahavi-daemon.service via systemctl doesn’t do the trick. It comes back from the dead on reboot.

Stronger medicine needed. Suggestions welcome.

1 Like

sudo systemctl disable avahi-daemon.socket

(disable and stop, both the service and socket)

?

1 Like

I ran that command but there was no output, completed silently. Usually when I disable systemd services I see output showing links being removed.

Will report if it’s still back from the dead after next reboot.

1 Like

When I disable the socket I get
Removed /etc/systemd/system/sockets.target.wants/avahi-daemon.socket.

When I stop it I get
Job for avahi-daemon.socket canceled.

When I disable the service I get
Synchronizing state of avahi-daemon.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install disable avahi-daemon
Removed /etc/systemd/system/multi-user.target.wants/avahi-daemon.service.
Removed /etc/systemd/system/dbus-org.freedesktop.Avahi.service.

Disclaimers: This is on Ubuntu 22.04 LTS and I haven’t rebooted to see whether the changes persist correctly.

1 Like
$ sudo systemctl status avahi-daemon.service 
● avahi-daemon.service
     Loaded: masked (Reason: Unit avahi-daemon.service is masked.)
     Active: inactive (dead)
$ sudo systemctl status avahi-daemon.socket 
● avahi-daemon.socket
     Loaded: masked (Reason: Unit avahi-daemon.socket is masked.)
     Active: inactive (dead)

On my PureOS machines, this service is forever killed off. My understanding is that sudo systemctl disable avahi-daemon.service is not enough like you said, but if you replace disable with mask then it kills it forever, or whatever.

NOTE: Even after disabling avahi, I was still able to ssh into my friend’s Raspberry Pi on the local network that published itself via avahi. So, if I understand correctly, avahi is extremely, extremely pointless. It basically allows other machines to SSH into you (or otherwise reference your network host) with a name instead of an IP, in cases when you don’t have a DNS server, as @irvinewade said.

Most of my Purism machines are configured with avahi and sshd and stuff locked down and off, and I use them to do outgoing connections instead of incoming connections. So, for example, it is more important and valuable to me that my Librem 14 does not spam the local network with Avahi messages saying "HI! I am a Librem 14 named XYZ!" than it is to be able to ssh my-librem-14. And apparently avahi services are not even necessary to be able to use outgoing mDNS!!

But maybe it makes sense for my friend to retain avahi on his raspberry pi, since he is less technical and benefits from being able to SSH into the device with a hostname. To be honest I have a habit of connecting with local machines by their IP anyway. Maybe just old habit.

2 Likes

For completeness, an alternative is just to populate /etc/hosts

For a small network or a very stable network, that choice may be practical. For a larger network it would be a pain having to edit that file on n hosts in order to add one new host.

The other consideration is that using the hosts file or using a DNS server with a static configuration only really work if every host has a fixed IP address … where a fixed IP address is achieved (on a per host basis) either by setting the host to have a static IP address or by adding the host’s MAC address to the DHCP server’s configuration so that the DHCP server always hands out the same IP address to that host.

If you want truly dynamic IP addresses then you would need integration between your DHCP server and your DNS server or that’s where avahi might actually be useful.

2 Likes

Thanks for the systemctl mask tip. Both Avahi and CUPS services came back from the dead after reboot, and it took the mask option to kill them off for good. I also had to disable cups-browsed.service.

2 Likes