
Learn through the super-clean Baeldung Pro experience:
>> Membership and Baeldung Pro.
No ads, dark-mode and 6 months free of IntelliJ Idea Ultimate to start with.
Last updated: June 1, 2024
avahi-daemon is a network service discovery daemon that operates on Linux systems, enabling automatic discovery of services and devices on a local network through the implementation of the mDNS/DNS-SD protocol suite. While avahi-daemon can be useful in certain environments, there are circumstances where users might want to disable it.
In this tutorial, we’ll explore methods to properly disable avahi-daemon on various Linux systems.
Before disabling avahi-daemon, it’s important to understand its purpose and possible implications. avahi-daemon is the main component of the Avahi package that listens for mDNS queries and announces services such as printers, file sharing, and other network resources to other devices on the local network.
mDNS queries resolve hostnames to IP addresses within a network that do not include a local DNS server, particularly useful in the home or small office networks.
When a device needs to resolve a hostname, it sends a multicast query to all devices on the local network. Devices that recognize the hostname respond with their IP address, allowing the querying device to establish a connection. This process simplifies networking by eliminating the need for manual IP address assignments or the presence of a dedicated DNS server.
Since avahi-daemon makes it easier for devices to connect and communicate within a local network, some users may prefer to keep avahi-daemon enabled for several reasons:
While avahi-daemon provides convenient service discovery capabilities, there are several reasons why we might want to disable it:
systemd-based systems are modern Linux distributions that use systemd as their init system, offering efficient service management and system initialization. Most modern Linux distributions use systemd as the init system, including Ubuntu, Debian, Fedora, and CentOS.
Before disabling avahi-daemon, let’s check its status using systemctl:
$ sudo systemctl status avahi-daemon
● avahi-daemon.service - Avahi mDNS/DNS-SD Stack
Loaded: loaded (/usr/lib/systemd/system/avahi-daemon.service; enabled; preset: disabled)
Active: active (running) since Wed 2024-04-03 13:04:06 +0545; 12s ago
TriggeredBy: ● avahi-daemon.socket
Main PID: 7517 (avahi-daemon)
Status: "avahi-daemon 0.8 starting up."
Tasks: 2 (limit: 9186)
Memory: 1.2M ()
CPU: 28ms
CGroup: /system.slice/avahi-daemon.service
├─7517 "avahi-daemon: running [kali.local]"
└─7518 "avahi-daemon: chroot helper"
The command output shows that the avahi-daemon service is currently active and running. It also shows details such as when it started, its main process ID, status, CPU usage, and related tasks.
Disabling avahi-daemon on systemd-based systems is relatively straightforward. If we want to stop the service temporarily, we can halt it using systemctl along with the stop option:
$ sudo systemctl stop avahi-daemon
Similarly, to prevent avahi-daemon from starting automatically on system boot, we need to disable the service permanently using systemctl:
$ sudo systemctl disable avahi-daemon
SysVinit was the traditional init system used by many Linux distributions before systemd became widely adopted. To disable avahi-daemon on SysVinit systems, first, let’s stop the avahi-daemon using the service command:
$ sudo service avahi-daemon stop
The above command disables the service temporarily. To permanently disable and prevent avahi-daemon from starting on system boot, we can use update-rc.d which modifies the initialization script in the /etc/rc*.d directories for SysVinit systems:
$ sudo update-rc.d avahi-daemon disable
Once we disable avahi-daemon, it’s necessary to restart the system or reboot the avahi-daemon service for the changes to take effect.
Further, we can verify avahi-daemon‘s status to ensure it’s no longer running on the system. Let’s check the status using the service command:
$ sudo service avahi-daemon status
In this article, we explored methods to disable avahi-daemon in Linux. Whether temporarily disabling the avahi-daemon, or permanently preventing it from starting on system boot in systemd-based systems or SysVinit systems, these methods will allow avahi-daemon to be safely disabled. Disabling avahi-daemon can be necessary for various reasons, but it’s essential to understand the implications and follow the proper steps to avoid unintended consequences.