Multicast DNS (mDNS) is a computer networking protocol that resolves hostnames to IP addresses within small networks that do not include a local name server. It is a zero-configuration service, using essentially the same programming interfaces, packet formats and operating semantics as unicast Domain Name System (DNS). It was designed to work as either a stand-alone protocol or compatible with standard DNS servers. mDNS uses IP multicast and User Datagram Protocol (UDP) packets and is implemented by Apple Bonjour, Windows 10 and later and open-source Avahi software packages included in most Linux distributions. Although the Windows 10 implementation in earlier releases (Version 1703) was limited to discovering networked printers, screen mirroring devices, wireless speakers etc, subsequent releases (Windows 10 1903 and later) resolved hostnames as well. mDNS can work in conjunction with DNS Service Discovery (DNS-SD), a companion zero-configuration networking technique specified separately in .
History
Multicast DNS was first proposed by Bill Woodcock and Bill Manning in the IETF in 2000, and was eventually published as standards-track by Stuart Cheshire and Marc Krochmal thirteen years later.
Protocol overview
When an mDNS client needs to resolve a hostname, it sends an IP multicast query message that asks the host having that name to identify itself. That target machine then multicasts a message that includes its IP address. All machines in that subnet can then use that information to update their mDNS caches. Any host can relinquish its claim to a name by sending a response packet with a time to live (TTL) equal to zero.
By default, mDNS exclusively resolves hostnames ending with the <code>.local</code> top-level domain. This can cause problems if <code>.local</code> includes hosts that do not implement mDNS but that can be found via a conventional unicast DNS server. Resolving such conflicts requires network-configuration changes that mDNS was designed to avoid.
Packet structure
An mDNS message is a multicast UDP packet sent using the following addressing:
- IPv4 address or IPv6 address
- UDP port 5353
- When using Ethernet frames, the standard IP multicast MAC address (for IPv4) or (for IPv6)
The payload structure is based on the unicast DNS packet format, consisting of two parts—the header and the data.
The header is identical to that found in unicast DNS, as are the sub-sections in the data part: queries, answers, authoritative-nameservers, and additional records. The number of records in each sub-section matches the value of the corresponding *COUNT field in the header.
Queries
The wire format for records in the query section is slightly modified from that in unicast DNS, adding the single-bit UNICAST-RESPONSE field.
