> For the complete documentation index, see [llms.txt](https://handbook.bsdcn.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://handbook.bsdcn.org/di-33-zhang-wang-luo-fu-wu-qi/33.8.-ling-pei-zhi-wang-luo.md).

# 33.8.零配置网络（mDNS/DNS-SD）

零配置网络（[Zero-configuration networking](https://en.wikipedia.org/wiki/Zero-configuration_networking)，有时被称为 *Zeroconf*）是一组简化网络配置的技术。Zeroconf 的主要部分包括：

* 链路本地寻址（Link-Local Addressing），提供数值型网络地址的自动分配。
* 多播 DNS（*mDNS*），提供主机名的自动分发与解析。
* 基于 DNS 的服务发现（*DNS-SD*），提供服务实例的自动发现。

## 33.8.1. 配置和启动 Avahi

zeroconf 的一个流行实现是 [Avahi](https://avahi.org/)。可以使用以下命令安装和配置 Avahi：

```sh
# pkg install avahi-app nss_mdns
# grep -q '^hosts:.*\<mdns\>' /etc/nsswitch.conf || sed -i "" 's/^hosts: .*/& mdns/' /etc/nsswitch.conf
# service dbus enable
# service avahi-daemon enable
# service dbus start
# service avahi-daemon start
```
