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:

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:

  1. 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.
  2. 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.
  3. 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:

Why Bonjour Relies on UDP

Bonjour relies on UDP because of several key architectural advantages:

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.