How Apple Bonjour Uses UDP on Local Networks
Apple Bonjour is a zero-configuration networking technology that enables devices on a local area network to discover each other, broadcast services, and resolve hostnames without requiring manual IP entry or central DNS servers. Bonjour achieves this automatic, decentralized communication by utilizing the User Datagram Protocol (UDP) through two core protocols: Multicast DNS (mDNS) and DNS-Based Service Discovery (DNS-SD).
Multicast DNS (mDNS) over UDP Port 5353
Traditional DNS queries are sent directly to a specific server over unicast UDP port 53. Bonjour replaces this central server model with Multicast DNS, transmitting standard DNS-format messages via UDP port 5353 to dedicated multicast addresses:
- IPv4:
224.0.0.251 - IPv6:
FF02::FB
When a device connects to a local network, it joins this multicast group. Any packet sent to this multicast IP address is automatically delivered to all other Bonjour-enabled devices on the same subnet.
Device and Hostname Resolution
Bonjour uses UDP multicasting to resolve human-readable
.local domain names into local IP addresses:
- Name Probing: When a device boots or changes
networks, it sends a series of UDP multicast probe queries to ensure its
chosen name (e.g.,
printer.local) is not already in use. - Query and Response: When a client wants to reach
printer.local, it sends a UDP query to the multicast group asking for the IP address associated with that name. - Local Reply: The target device recognizes its own name, generates a DNS response packet containing its IP address, and multicasts the response back over UDP to the entire subnet so all listeners can update their local caches.
DNS-Based Service Discovery (DNS-SD)
Beyond simple name-to-IP resolution, Bonjour uses DNS Service Discovery to advertise available capabilities, such as AirPrint, AirPlay, file sharing, and media streaming.
These capabilities are broadcast using standard DNS resource records encapsulated inside UDP datagrams:
- PTR (Pointer) Records: Used to discover which
service types exist on the network (e.g.,
_ipp._tcp.localfor printing). - SRV (Service) Records: Provide the specific hostname and TCP/UDP port number where the service is running.
- TXT (Text) Records: Contain metadata and configuration details specific to the service (such as supported printer formats or model information).
Why Bonjour Relies on UDP
Bonjour relies on UDP because of several key architectural advantages:
- Multicast Support: TCP requires point-to-point connections, making it impossible to broadcast a single message to multiple unknown receivers simultaneously. UDP natively supports one-to-many broadcasting via multicasting.
- Low Overhead: UDP datagrams are lightweight and connectionless, minimizing network congestion during frequent service discovery queries and announcements.
- Speed: Without the requirement of a three-way TCP handshake, devices can query and discover resources instantly.
Network Boundaries and Link-Local Scope
Bonjour packets are configured with a Time-to-Live (TTL) value of 1. This restricts UDP multicast traffic to the immediate local link (subnet), preventing local discovery broadcasts from traversing standard network routers or flooding the wider internet.