For mDNS to work you need:
224.0.0.251 (mDNS group) reaches all ports in the VLAN..local to be reliable.Rules: lowercase, no spaces, 1–63 chars, no leading/trailing hyphen, unique on the LAN. Example set:
| Role | Hostname | Static IP |
|---|---|---|
| Workstation A | box-a | 192.168.178.10 |
| Workstation B | box-b | 192.168.178.11 |
| NAS | nas | 192.168.178.20 |
| Server / build | build | 192.168.178.30 |
# pick one name, e.g. box-a sudo hostnamectl set-hostname box-a # verify hostname
(On distros without hostnamectl: edit /etc/hostname and reboot.)
# Debian / Ubuntu sudo apt update sudo apt install -y avahi-daemon avahi-discover avahi-utils nss-mdns # Fedora / RHEL sudo dnf install -y avahi avahi-tools # Arch sudo pacman -S avahi
nss-mdns is the part that makes getent hosts box-a.local, ping box-a.local, ssh box-a.local, curl http://box-a.local all „just work“ without any DNS configuration.
sudo systemctl enable --now avahi-daemon # On systemd distros also make sure systemd-resolved is running (it is by default): systemctl status systemd-resolved sudo systemctl enable --now systemd-resolved
/etc/nsswitch.conf — the hosts: line must contain mdns4_minimal [NOTFOUND=return] before dns. On most distros the default already looks like this:
hosts: files mdns4_minimal [NOTFOUND=return] dns
If your file is missing mdns4_minimal, add it (order matters — keep it before dns).
On Debian/Ubuntu, /etc/resolv.conf is usually a symlink to systemd-resolved's stub at 127.0.0.53 — that's fine, leave it.
# UFW sudo ufw allow in on eth0 to any port 5353 udp sudo ufw allow in on eth0 to any port 5353 tcp # for DNS-SD browsing, optional # firewalld sudo firewall-cmd --permanent --add-service={mdns,avahi} sudo firewall-cmd --reload
This gives you a fallback if mDNS is ever down:
echo "192.168.178.10 box-a.box-a box-a" | sudo tee -a /etc/hosts
(Not strictly necessary — mDNS + nss-mdns already cover it — but it's cheap insurance.)
# 1) Is Avahi running and advertising our name? systemctl status avahi-daemon avahi-browse -a -r # should list your own name plus neighbours # 2) Can we resolve by name? getent hosts box-a.local # should return 192.168.178.10 ping -c 2 box-a.local # should work # 3) Can we reach a service by name? curl -I http://box-a.local:80 ssh box-a.local
Do the same from every other machine on the LAN — if ping box-a.local works from each of them, you're done.
sudo hostnamectl set-hostname <name> sudo apt install -y avahi-daemon avahi-discover avahi-utils nss-mdns # dnf/pacman equivalent sudo systemctl enable --now avahi-daemon grep -q 'mdns4_minimal' /etc/nsswitch.conf || sudo sed -i 's/^hosts:.*/hosts:\tfiles mdns4_minimal [NOTFOUND=return] dns/' /etc/nsswitch.conf avahi-browse -a -r
avahi-browse shows nothing, check journalctl -u avahi-daemon./etc/resolv.conf on reconnect. On systemd systems use systemd-resolved (default) rather than NetworkManager's own resolver; mDNS still works through nss-mdns regardless.box-a.local. If you need remote access to .local names, use a VPN that forwards DNS (e.g., WireGuard + a dnsmasq at the gateway) — that's the „alternative“ approach I mentioned.disallow-local-interfaces=yes (rare, mostly in containers). Check /etc/avahi/avahi-daemon.conf if nothing gets advertised.
That's it — after doing steps 3a–3f on every machine, every Linux box on 192.168.178.0/24 will resolve name.local for every other box, no central DNS server needed.