11

I am running Kali 2.0 64-bit, and I recently noticed that avahi-daemon is starting at boot time, listening on several udp ports.

How do I disable it completely, without purging the package itself?

I have tried sudo rcconf --off avahi-daemon

But there is a warning: Service 'avahi-daemon' is already off. Skipping...

I then tried sudo update-rc.d -f avahi-daemon remove

It doesn't produce any errors, nor warnings, but avahi-daemon still persists at boot time.

I then tried editing the /etc/default/avahi-daemon file by adding AVAHI_DAEMON_START = 0

But that doesn't work either.

I finally used the UPSTART manual override -->> echo manual | sudo tee /etc/init/avahi-daemon.override

And still no go.

Please help,

I am at my wits's end!

Thank you.

Cain
  • 113
  • 1
  • 1
  • 4

4 Answers4

16

sudo systemctl disable avahi-daemon to disable boot time startup.

A few other options are systemctl list-units for a list of all known units, systemctl enable to enable boot time startup, systemctl start to start the service from terminal, but not enable boot time loading and systemctl stop to stop a service which has been started. man systemctl and man systemd will provide complete set of options.

Most (not all though) modern Linux distributions have switched or are switching to systemd from the traditional SysV init scripts. Also, http://blog.jorgenschaefer.de/2014/07/why-systemd.html covers some of the basics of systemd.

Munir
  • 3,222
  • 13
  • 27
  • somehow, avahi-daemon wont stop even after systemctl stop avahi-daemon. The message is Warning: Stopping avahi-daemon.service, but it can still be activated by: avahi-daemon.socket. And when I see the status it restarts automatically. Ubuntu 16.04 – infoclogged Apr 11 '17 at 10:31
  • 5
    A systemd `.socket` unit is designed to auto-start a service whenever something else needs it. This need is detected by a connection to an IPC or network socket, which systemd then passes on to the service, similar to inetd. If you don't want this behavior, you should disable the socket unit too: `systemctl disable avahi-daemon.socket`. Alternatively, `systemctl mask avahi-daemon.service` explicitly blocks the service from starting for any reason. – telcoM Mar 22 '18 at 15:50
  • 2
    Unfortunately, after some experimentation, I've found the only way to get avahi-daemon to stop -- even momentarily -- is to disable it completely using [@Daniel's answer below](https://unix.stackexchange.com/a/432821/41735). The only thing I would add is the `--now` flag to the `disable` command, which both _stops and disables_ the unit, rather than just keeping it from starting on boot: `sudo systemctl disable --now avahi-daemon.socket && sudo systemctl disable --now avahi-daemon.service` – kael Jun 08 '18 at 21:36
8

My solution was to edit /etc/avahi/avahi-daemon.conf and make the following change: use-ipv4=no use-ipv6=no

Then do a root@magrf# service avahi-daemon restart

Verify that avahi daemon is stopped: root@magrf# ps -ef | grep avahi root 8311 8220 0 17:50 pts/0 00:00:00 grep avahi root@magrf#

As you can see, avahi processes are not running. If restart fails, try an explicit root@magrf# service avahi-daemon stop root@magrf# service avahi-deamon start

Restart is important so avahi could re-read configuration and shutdown service processes. Then it had performed a graceful exit.

Rui F Ribeiro
  • 55,929
  • 26
  • 146
  • 227
mt42
  • 133
  • 2
  • 6
  • 2
    This is genius! avahi has been a pita for me for years, I used to chmod -x the binary and this used to work.. but nowadays that makes other gnome features hang waiting for an answer from this pinnacle of despair. – axkibe Aug 30 '19 at 14:38
4

Use the following to stop the service, avoid restart on the next boot and prevent apps that tickle the socket from restarting it.

sudo systemctl mask avahi-daemon
sudo systemctl disable avahi-daemon
sudo systemctl stop avahi-daemon
seacoder
  • 211
  • 2
  • 2
  • This is the answer. Not only does it work, but it seems like intended operation instead of a hack. Afterwards, `systemctl status avahi-daemon.service` responds with "Loaded: masked (Reason: Unit avahi-daemon.service is masked.) Active: inactive (dead)" – bitsmack May 17 '22 at 04:46
3

You can disable it with:

systemctl disable avahi-daemon.socket

And

systemctl disable avahi-daemon.service
Daniel
  • 771
  • 3
  • 8
  • 21