Multicast DNS

In computer networking, the multicast DNS (mDNS) protocol 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 the unicast Domain Name System (DNS). Although Stuart Cheshire designed mDNS as a stand-alone protocol, it can work in concert with standard DNS servers.[1]

The mDNS protocol is published as RFC 6762, uses IP multicast User Datagram Protocol (UDP) packets, and is implemented by the Apple Bonjour and open source Avahi software packages, included in most Linux distributions. mDNS has also been implemented in Windows 10, initially limited to discovering networked printers[2], later becoming capable of resolving hostnames as well.

mDNS can work in conjunction with DNS Service Discovery (DNS-SD), a companion zero-configuration technique specified separately in RFC 6763.[3]

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 .local top-level domain (TLD). This can cause problems if that domain includes hosts which do not implement mDNS but which can be found via a conventional unicast DNS server. Resolving such conflicts requires network-configuration changes that violate the zero-configuration goal.

Packet structure

An mDNS message is a multicast UDP packet sent using the following addressing:

The payload structure is based on the unicast DNS packet format, consisting of two parts—the header and the data.[4]

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.[1]

mDNS Query section fields
FieldDescriptionLength bits
QNAMEName of the node to which the query pertainsVariable
QTYPEThe type of the query, i.e. the type of RR which should be returned in responses.16
UNICAST-RESPONSEBoolean flag indicating whether a unicast-response is desired1
QCLASSClass code, 1 a.k.a. "IN" for the Internet and IP networks15

As in unicast DNS, the QNAME field consists of a series of length/value sub-fields called "labels". Each label represents one of the dot-separated substrings in a fully qualified domain name (FQDN). The list is terminated by a single null-byte, representing the "root" of the DNS.

The UNICAST-RESPONSE field is used to minimize unnecessary broadcasts on the network: if the bit is set, responders SHOULD send a directed-unicast response directly to the inquiring node rather than broadcasting the response to the entire network.

The QCLASS field is identical to that found in unicast DNS.

Resource Records

All records in the answers, authoritative-nameservers, and additional records sections have the same format and are collectively known as Resource Records (RR).

Resource Records in mDNS also have a slightly modified general format compared to unicast DNS:

mDNS Resource Record fields
FieldDescriptionLength bits
RRNAMEName of the node to which the record pertainsVariable
RRTYPEThe type of the Resource Record16
CACHE-FLUSHBoolean flag indicating whether outdated cached records should be purged1
RRCLASSClass code, 1 a.k.a. "IN" for the Internet and IP networks15
TTLTime interval (in seconds) that the RR should be cached32
RDLENGTHInteger representing the length (in octets) of the RDATA field16
RDATAResource data; internal structure varies by RRTYPEVariable

The CACHE-FLUSH bit is used to instruct neighbor nodes that the record should overwrite, rather than be appended onto, any existing cached entries for this RRNAME and RRTYPE.

The formats of the RDATA fields are the same as those found in unicast DNS. However, DNS Service Discovery (DNS-SD), the most common use-case for mDNS, specifies slight modifications to some of their formats (notably TXT records).

See also

References

  1. Multicast DNS. Internet Engineering Task Force (IETF). doi:10.17487/RFC6762. RFC 6762..
  2. mDNS and DNS‐SD slowly making their way into Windows 10, Ctrl blog, retrieved 2017-08-30
  3. DNS Service Discovery. Internet Engineering Task Force (IETF). doi:10.17487/RFC6763. RFC 6763.
  4. P. Mockapetris (November 1987). DOMAIN NAMES - IMPLEMENTATION AND SPECIFICATION. Network Working Group, IETF. doi:10.17487/RFC1035. RFC 1035..
This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.