
avahi-daemon
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.
Avahi是mDNS / DNS守护程序,该服务实现了Apple的Zeroconf机制。 Zeroconf也称为Rendezvous或Bonjour。 Zeroconf有其主要任务要处理。
- Automatic assignment of numeric network addresses 自动分配数字网络地址
- Automatic distribution and resolution of hostnames,自动分配和解析主机名,
- Automatic location of network services such as printing devices. 网络服务(例如打印设备)的自动位置。
安装Avahi (Installing Avahi)
Avahi-daemon can be installed with yum and apt like below.
Avahi-daemon可以与yum和apt一起安装,如下所示。
$ 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.
在我们知道安装avahi之后,avahi通常可以用作守护程序。 我们将启动avahi守护程序。 使用初始化脚本,可以发出以下命令。 请记住,avahi需要root特权,正如我们从下面的屏幕快照中看到的那样,它要求输入root密码。
$ /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
启动avahi-daemon的另一种方法是使用如下所示的systemctl
命令。 使用avahi服务名称avahi-daemon。 avahi服务的当前状态也可以看到
$ 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.
可以使用以下命令在初始化系统中停止avahi。 停止avahi服务也需要root特权。
$ /etc/init.d/avahi-daemon stop

OR
要么
$ sudo systemctl stop avahi-daemon
启用Avahi守护程序 (Enable Avahi Daemon)
Avahi daemon can be enabled to start automatically in the system start with the systemctl command like below.
可以使用以下systemctl命令在系统启动时启用Avahi守护程序自动启动。
$ sudo systemctl enable avahi-daemon

禁用Avahi守护程序(Disable Avahi Daemon)
Avahi daemon can be disabled to start automatically in the system start with the following command.
可以禁用Avahi守护程序以在系统中使用以下命令自动启动。
$ 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.
Avahi配置文件位于/etc/avahi
。 Avahi守护程序配置文件名为avahi-daemon.conf
。 此文件有不同类型的配置功能。 Avahi服务器的主机名和IP地址存储在hosts
文件中。 服务以XML文件的形式存储在services
目录中。

添加主机(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.
将主机添加到avahi的DNS服务就像添加主机Linux主机文件一样。 如屏幕截图所示,将以下行添加到host
文件中,然后重新启动avahi守护程序。
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配置文件,该文件将放入/etc/avahi/services/
。 以下服务配置文件定义了从tcp 21端口提供的FTP文件。
<?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>

翻译自: https://www.poftut.com/linux-avahi-daemon-tutorial-examples/
avahi-daemon