EMZETT.
Login

mDNS and Bonjour: Finding devices on the local network

In short: Methods with which devices on the same network find each other by names such as “printer.local” without a central DNS server.

In more detail: In a home network there is often no DNS server of its own that resolves names such as “living-room-tv”. Multicast DNS (mDNS) solves this: a device asks all devices on the network by multicast (“Who is printer.local?”), and the one sought answers with its IP address. Apple calls the technology Bonjour, on Linux the implementation is called Avahi, on Windows it has been built in since Windows 10.

In Depth

How it works

mDNS uses the multicast address 224.0.0.251 (IPv6: ff02::fb) and UDP port 5353. The domain .local is reserved for it. Devices announce their name at startup and answer queries. There is no server and no setup.

Finding services (DNS-SD)

Together with DNS-SD (service discovery), services can also be found: a printer announces _ipp._tcp, a media server _airplay._tcp, SSH servers _ssh._tcp. Programs such as AirPrint, AirPlay, Chromecast detection and smart-home devices use this so that users do not have to enter anything.

In practice

ping printer.local
avahi-browse -a        # Linux: show all services
dns-sd -B _http._tcp  # macOS: web servers on the network

Multicast stays in the local network. Across subnets, VLANs or VPN it does not work without an mDNS repeater/reflector (available on routers such as OPNsense or with UniFi). That explains why a printer in the guest Wi-Fi is not found.

Security

mDNS has no authentication: a device on the same network can send false answers, and services often reveal device names and models. On untrusted networks (hotel, café) one should switch sharing off, and in company networks mDNS is often filtered.

See also: DNS, IP addresses, VLAN, localhost