xref: /illumos-gate/usr/src/man/man8/dns-sd.8 (revision dd72704bd9e794056c558153663c739e2012d721)
1.\" -*- tab-width: 4 -*-
2.\"
3.\" Copyright (c) 2004 Apple Computer, Inc. All Rights Reserved.
4.\"
5.\" Licensed under the Apache License, Version 2.0 (the "License");
6.\" you may not use this file except in compliance with the License.
7.\" You may obtain a copy of the License at
8.\"
9.\"     http://www.apache.org/licenses/LICENSE-2.0
10.\"
11.\" Unless required by applicable law or agreed to in writing, software
12.\" distributed under the License is distributed on an "AS IS" BASIS,
13.\" WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14.\" See the License for the specific language governing permissions and
15.\" limitations under the License.
16.\"
17.\" Copyright 2016 Toomas Soome <tsoome@me.com>
18.\"
19.Dd Jan 28, 2016            \" Date
20.Dt DNS-SD 8               \" Document Title
21.Os illumos                 \" Operating System
22.\"
23.Sh NAME
24.Nm dns-sd
25.Nd Multicast DNS (mDNS) & DNS Service Discovery (DNS-SD) Test Tool \" For whatis
26.\"
27.Sh SYNOPSIS
28.Nm
29.Op Fl E
30.Pp
31.Nm
32.Op Fl F
33.Pp
34.Nm
35.Op Fl R Ar name type domain port Op Ar key=value ...
36.Pp
37.Nm
38.Op Fl B Ar      type domain
39.Pp
40.Nm
41.Op Fl L Ar name type domain
42.Pp
43.Nm
44.Op Fl P Ar name type domain port host IP Op Ar key=value ...
45.Pp
46.Nm
47.Op Fl q Ar name rrtype rrclass
48.Pp
49.Nm
50.Op Fl Z Ar      type domain
51.Pp
52.Nm
53.Op Fl G Ns \ v4/v6/v4v6 Ar      name
54.Pp
55.Nm
56.Op Fl V
57.\"
58.Sh DESCRIPTION
59The
60.Nm
61command is a network diagnostic tool, much like
62.Xr ping 8
63or
64.Xr traceroute 8 .
65However, unlike those tools, most of its functionality is not implemented in the
66.Nm
67executable itself, but in library code that is available to any application.
68The library API that
69.Nm
70uses is documented in
71.Pa /usr/include/dns_sd.h .
72The
73.Nm
74command replaces the older
75mDNS
76command.
77.Pp
78The
79.Nm
80command is primarily intended for interactive use.
81Because its command-line arguments and output format are subject to change,
82invoking it from a shell script will generally be fragile.
83Additionally, the asynchronous nature of DNS Service Discovery does
84not lend itself easily to script-oriented programming.
85For example, calls like "browse" never complete; the action of performing a
86"browse" sets in motion machinery to notify the client whenever instances of
87that service type appear or disappear from the network.
88These notifications continue to be delivered indefinitely, for minutes,
89hours, or even days, as services come and go, until the client
90explicitly terminates the call.
91This style of asynchronous interaction works best with applications that are
92either multi-threaded, or use a main event-handling loop to receive keystrokes,
93network data, and other asynchronous event notifications as they happen.
94.br
95If you wish to perform DNS Service Discovery operations from a
96scripting language, then the best way to do this is not to execute the
97.Nm
98command and then attempt to decipher the textual output, but instead to
99directly call the DNS-SD APIs using a binding for your chosen language.
100.br
101For example, if you are programming in Ruby, then you can
102directly call DNS-SD APIs using the dnssd package documented at
103.Pa <http://rubyforge.org/projects/dnssd/> .
104.br
105Similar bindings for other languages are also in development.
106.Bl -tag -width E
107.It Nm Fl E
108return a list of domains recommended for registering(advertising) services.
109.It Nm Fl F
110return a list of domains recommended for browsing services.
111.Pp
112Normally, on your home network, the only domain you are likely to see is
113"local".
114However if your network administrator has created Domain Enumeration records,
115then you may also see other recommended domains for registering and browsing.
116.It Nm Fl R Ar name type domain port Op Ar key=value ...
117register (advertise) a service in the specified
118.Ar domain
119with the given
120.Ar name
121and
122.Ar type
123as listening (on the current machine) on
124.Ar port.
125.Pp
126.Ar name
127can be arbitrary unicode text, containing any legal unicode characters
128(including dots, spaces, slashes, colons, etc. without restriction),
129up to 63 UTF-8 bytes long.
130.Ar type
131must be of the form "_app-proto._tcp" or "_app-proto._udp", where
132"app-proto" is an application protocol name registered at
133.Pa http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xml .
134.Pp
135.Ar domain
136is the domain in which to register the service.
137In current implementations, only the local multicast domain "local" is
138supported.
139In the future, registering will be supported in any arbitrary domain that has a
140working DNS Update server [RFC 2136].
141The
142.Ar domain
143"." is a synonym for "pick a sensible default" which today
144means "local".
145.Pp
146.Ar port
147is a number from 0 to 65535, and is the TCP or UDP port number upon
148which the service is listening.
149.Pp
150Additional attributes of the service may optionally be described by
151key/value pairs, which are stored in the advertised service's DNS TXT
152record.
153Allowable keys and values are listed with the service registration at
154.Pa http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xml .
155.It Nm Fl B Ar type domain
156browse for instances of service
157.Ar type
158in
159.Ar domain .
160.Pp
161For valid
162.Ar type Ns s
163see
164.Pa http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xml .
165as described above.
166Omitting the
167.Ar domain
168or using "." means "pick a sensible default."
169.It Nm Fl L Ar name type domain
170look up and display the information necessary to contact and use the
171named service: the hostname of the machine where that service is
172available, the port number on which the service is listening, and (if
173present) TXT record attributes describing properties of the service.
174.Pp
175Note that in a typical application, browsing may only happen rarely, while
176lookup (or "resolving") happens every time the service is used.
177For example, a user browses the network to pick a default printer fairly rarely,
178but once a default printer has been picked, that named service is resolved to
179its current IP address and port number every time the user presses Cmd-P to
180print.
181.It Nm Fl P Ar name type domain port host IP Op Ar key=value ...
182create a proxy advertisement for a service running on(offered by) some other
183machine.
184The two new options are Host, a name for the device and IP, the address of it.
185.Pp
186The service for which you create a proxy advertisement does not necessarily have
187to be on your local network.
188You can set up a local proxy for a website on the Internet.
189.It Nm Fl q Ar name rrtype rrclass
190look up any DNS name, resource record type, and resource record class,
191not necessarily DNS-SD names and record types.
192If rrtype is not specified, it queries for the IPv4 address of the name,
193if rrclass is not specified, IN class is assumed.
194If the name is not a fully qualified domain name, then search domains may be
195appended.
196.It Nm Fl Z Ar type domain
197browse for service instances and display output in zone file format.
198.It Nm Fl G Ns \ v4/v6/v4v6 Ar name
199look up the IP address information of the name.
200If v4 is specified, the IPv4 address of the name is looked up,
201if v6 is specified the IPv6 address is looked up.
202If v4v6 is specified both the IPv4 and IPv6 address is looked up.
203If the name is not a fully qualified domain name, then search domains may be
204appended.
205.It Nm Fl V
206return the version of the currently running daemon/system service.
207.El
208.Sh FILES
209.Pa /usr/bin/dns-sd \" Pathname
210.\"
211.Sh EXAMPLES
212To advertise the existence of LPR printing service on port 515 on this
213machine, such that it will be discovered by the Mac OS X printing software
214and other DNS-SD compatible printing clients, use:
215.Pp
216.Dl Nm Fl R Ns \ \&"My Test\&" _printer._tcp. \&. 515 pdl=application/postscript
217.Pp
218For this registration to be useful, you need to actually have LPR service
219available on port 515.
220Advertising a service that does not exist is not very useful, and will be
221confusing and annoying to other people on the network.
222.Pp
223Similarly, to advertise a web page being served by an HTTP
224server on port 80 on this machine, such that it will show up in the
225Bonjour list in Safari and other DNS-SD compatible Web clients, use:
226.Pp
227.Dl Nm Fl R Ns \ \&"My Test\&" _http._tcp \&. 80 path=/path-to-page.html
228.Pp
229To find the advertised web pages on the local network (the same list that
230Safari shows), use:
231.Pp
232.Dl Nm Fl B Ns \ _http._tcp
233.Pp
234While that command is running, in another window, try the
235.Nm Fl R
236example given above to advertise a web page, and you should see the
237"Add" event reported to the
238.Nm Fl B
239window.
240Now press Ctrl-C in the
241.Nm Fl R
242window and you should see the "Remove" event reported to the
243.Nm Fl B
244window.
245.Pp
246In the example below, the www.apple.com web page is advertised as a service
247called "apple",
248running on a target host called apple.local, which resolves to 17.149.160.49.
249.Pp
250.Dl Nm Fl P Ns \ apple _http._tcp \&"\&"\& 80 apple.local 17.149.160.49
251.Pp
252The Bonjour menu in the Safari web browser will now show "apple".
253The same IP address can be reached by entering apple.local in the web browser.
254In either case, the request will be resolved to the IP address and browser will
255show contents associated with www.apple.com.
256.Pp
257If a client wants to be notified of changes in server state, it can
258initiate a query for the service's particular record and leave it running.
259For example, to monitor the status of an iChat user you can use:
260.Pp
261.Dl Nm Fl q Ns \ someone@ex1._presence._tcp.local txt
262.Pp
263Everytime status of that user(someone) changes, you will see a new TXT record
264result reported.
265.Pp
266You can also query for a unicast name like www.apple.com and monitor its status.
267.Pp
268.Dl Nm Fl q Ns \ www.apple.com
269.Sh INTERFACE STABILITY
270.Sy Volatile .
271.Sh SEE ALSO
272.Xr resolv.conf 5 ,
273.Xr mdnsd 8 ,
274.Xr ping 8 ,
275.Xr traceroute 8
276