Linux Avahi Daemon Tutorial With Examples


Avahi is an mDNS/DNS daemon, service which implements Apples’s Zeroconf mechanism. Zeroconf is also known as Rendezvous or Bonjour. Zeroconf have their main task to process.

  1. Automatic assignment of numeric network addresses
  2. Automatic distribution and resolution of hostnames,
  3. Automatic location of network services such as printing devices.

Installing Avahi

Avahi-daemon can be installed with yum and apt like below.

$ sudo apt install avahi-daemon
Installing Avahi
Installing Avahi

Starting Avahi

After installing avahi as we know avahi works as daemon generally. We will start the avahi daemon. Using init scripts following command can be issued. Keep in mind that avahi requires root privileges as we can see from the following screenshot it asks for the root password.

$ /etc/init.d/avahi-daemon start
Starting Avahi
Starting Avahi

OR

Another way to start avahi-daemon is by using systemctl command like below. with the avahi service name avahi-daemon. The avahi service current status can be seen too

$ sudo systemctl start avahi-daemon
Starting Avahi
Starting Avahi

Stopping Avahi

Stopping avahi in the init system can be done with the following command. Stopping avahi service requires root privileges too.

$ /etc/init.d/avahi-daemon stop
Stopping Avahi
Stopping Avahi

OR

$ sudo systemctl stop avahi-daemon

Enable Avahi Daemon

Avahi daemon can be enabled to start automatically in the system start with the systemctl command like below.

$ sudo systemctl enable avahi-daemon
Enable Avahi Daemon
Enable Avahi Daemon

Disable Avahi Daemon

Avahi daemon can be disabled to start automatically in the system start with the following command.

$ sudo systemctl disable avahi-daemon
Disable Avahi Daemon
Disable Avahi Daemon

Configuration Files

Avahi configuration files reside in /etc/avahi . Avahi daemon configuration file is named avahi-daemon.conf . There is a different type of configuration abilities with this file.
Avahi server hostnames and IP addresses are stored in hosts file. Services are stored in services directory as XML file.

LEARN MORE  How To Discover Network Hosts With Nmap?
Configuration Files
Configuration Files

Add Host

Adding host to the DNS service of avahi is like adding host Linux hosts file. Add the following line into the host file like in the screenshot and then restart avahi daemon.

192.168.122.45  ubu2
Add Host
Add Host

Add Service

Adding services is harder than adding hosts. There is an XML configuration file used to describe services and this file will be put into /etc/avahi/services/ . The following service configuration file defines FTP file which is  served from tcp 21 port.

<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
  <name>FTP file sharing</name>
  <service>
    <type>_ftp._tcp</type>
    <port>21</port>
  </service>
</service-group>
Add Service
Add Service

Leave a Comment