mdnsd is a small Multicast DNS and DNS-SD (service discovery) responder and library for advertising hosts and services on the local link. It descends from Jeremie Miller’s original mDNS/mDNS-SD daemon and is a lightweight alternative to avahi, small enough to embed in firmware.

Features

  • Multicast DNS responder with RFC 6763 DNS-SD service discovery
  • Dual-stack: answers over IPv4 (224.0.0.251) and IPv6 (ff02::fb), with A and AAAA records for the host and its services
  • Service PTR records point at the instance, so they show up in avahi-browse, mdns-scan, and friends. Replies bundle the matching SRV, TXT, and address records in the additional section, so clients skip the follow-up queries; key-only TXT flags work too
  • Multiple addresses per interface, with all of a host’s services under one host name
  • Tracks interface and address changes in real time over netlink, no poll cycle – start it before the interface even exists
  • Ships as three parts: an embeddable C library (libmdnsd), the mdnsd daemon, and the mquery scan/debug tool
  • Runs on GNU/Linux and the BSDs, needs no special privileges, and can drop to an unprivileged user

Advertising Services

By default mdnsd reads service definitions from /etc/mdns.d/*. The file format is free-form; type and port are required, the rest is optional. See mdnsd.service(5) for the details. An HTTP service, for example:

# /etc/mdns.d/http.service
name Troglobit HTTP Server
type _http._tcp
port 80
txt  server=merecat
txt  version=2.31
cname home.local

You need at least one service record for mdnsd to answer browse queries from tools like mdns-scan.

Browsing with mquery

The bundled mquery tool discovers and resolves services on the local link, a bit like avahi-browse. Give it a service type or a host name, the .local. domain is implied:

mquery                 # browse all service types on the link
mquery _http._tcp      # list instances of a service type
mquery -t 33 NAME      # resolve an instance's host and port (SRV)
mquery -D              # scan and resolve into a device table

See mquery(1) for the full list of record types and options.

Resolving .local Names

mdnsd answers queries for the names it advertises; it does not make the system resolver mDNS-aware. To let programs on the host resolve .local names (ping foo.local, getaddrinfo()), install libnss-mdns and add it to /etc/nsswitch.conf:

hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4

The two halves are complementary: mdnsd answers for the names it advertises, while libnss-mdns resolves everyone else’s.

Note: run either mdnsd or avahi-daemon, not both. Two responders on the same link would answer over each other.

Get It

Latest release available on GitHub

Users who clone from GitHub must run ./autogen.sh first; released tarballs already ship a configure script. mdnsd is licensed under the 3-clause BSD license.

Origin & References

This mDNS-SD implementation was developed by Jeremie Miller in 2003, originally announced on the rendezvous-dev mailing list under the name mhttp. It has many forks and has been used by a host of other applications over the years.

The GitHub project is an effort by Joachim Wiberg to clean up the original code base, develop it further, and maintain it for the long haul under the name mdnsd.