System Administration Guide: Naming and Directory Services (DNS, NIS, and LDAP)

mDNS and dns-sd Tool

Use the dns-sd command as a network diagnosis tool, to browse and discover services, similar to how you would use ping (1M) or traceroute (1M).

The dns-sd command is intended primarily for interactive use, mainly because its command line arguments and its output format can change over time, which makes invoking it from a shell script unpredictable and risky. Additionally, the asynchronous nature of DNS Service Discovery does not easily lend itself to script-oriented programming.

For complete dns-sd information, see the man page for dns-sd (1M) and to incorporate DNS service in applications, see the libdns_sd (3DNS_SD) man page.

EXAMPLES of the dns-sd command

Advertising a printing service

The following command advertises the existence of LPR printing service on port 515 on “My Test” machine, so that it will be available to DNS-SD compatible printing clients:


dns-sd -R "My Test" _printer._tcp. . 515 pdl=application/postscript

For this registration to be useful, the LPR service should be available on port 515.

Advertising a web page

The following command advertises a web page being served by an HTTP server on port 80 on My Test machine. The web page will appear on the Bonjour list in Safari and other DNS-SD compatible Web clients:


dns-sd -R "My Test" _http._tcp . 80 path=/path-to-page.html