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.
- Automatic assignment of numeric network addresses
- Automatic distribution and resolution of hostnames,
- 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

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

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

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

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

Disable Avahi Daemon
Avahi daemon can be disabled to start automatically in the system start with the following command.
$ sudo systemctl 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.

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 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>
