mDNS 配置
This guide explains how to install and configure mDNS (Multicast DNS) using Avahi on various Linux distributions. This allows you to access devices using .local hostnames (e.g., myserver.local).
1. Alpine Linux
Section titled “1. Alpine Linux”sudo apk add avahi dbussudo rc-update add avahi-daemonsudo service avahi-daemon start2. CentOS / RHEL
Section titled “2. CentOS / RHEL”-
Install Packages:
Terminal window sudo yum install avahi avahi-tools nss-mdns -
Enable Service:
Terminal window sudo systemctl start avahi-daemonsudo systemctl enable avahi-daemon -
Configure Name Resolution:
Edit
/etc/nsswitch.confand find thehosts:line. Change it from:hosts: files dnsto:
hosts: files mdns_minimal [NOTFOUND=return] dns -
Configure Firewall:
Allow mDNS traffic through the firewall:
Terminal window sudo firewall-cmd --permanent --add-service=mdnssudo firewall-cmd --reload
3. Ubuntu / Debian
Section titled “3. Ubuntu / Debian”Ubuntu usually comes with Avahi installed. If not:
sudo apt updatesudo apt install avahi-daemon4. Arch Linux / Manjaro
Section titled “4. Arch Linux / Manjaro”-
Install Package:
Terminal window sudo pacman -S avahi -
Enable Service:
Terminal window sudo systemctl enable --now avahi-daemon.service