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.Dd April 2004 \" Date 18.Dt dns-sd 1 \" Document Title 19.Os NetBSD \" Operating System 20.\" 21.Sh NAME 22.Nm dns-sd 23.Nd Multicast DNS (mDNS) & DNS Service Discovery (DNS-SD) Test Tool \" For whatis 24.\" 25.Sh SYNOPSIS 26.Nm Fl R Ar name type domain port Op Ar key=value ... 27.Pp 28.Nm Fl B Ar type domain 29.Pp 30.Nm Fl L Ar name type domain 31.\" 32.Sh DESCRIPTION 33The 34.Nm 35command is a network diagnostic tool, much like 36.Xr ping 8 37or 38.Xr traceroute 8 . 39However, unlike those tools, most of its functionality is not implemented in the 40.Nm 41executable itself, but in library code that is available to any application. 42The library API that 43.Nm 44uses is documented in 45.Pa /usr/include/dns_sd.h . 46.Pp 47The 48.Nm 49command is primarily intended for interactive use. 50Because its command-line arguments and output format are subject to change, 51invoking it from a shell script will generally be fragile. Additionally, 52the asynchronous nature of DNS Service Discovery does 53not lend itself easily to script-oriented programming. For example, 54calls like "browse" never complete; the action of performing a "browse" 55sets in motion machinery to notify the client whenever instances of 56that service type appear or disappear from the network. These 57notifications continue to be delivered indefinitely, for minutes, 58hours, or even days, as services come and go, until the client 59explicitly terminates the call. This style of asynchronous interaction 60works best with applications that are either multi-threaded, or use a 61main event-handling loop to receive keystrokes, network data, and other 62asynchronous event notifications as they happen. 63.br 64If you wish to perform DNS Service Discovery operations from a 65scripting language, then the best way to do this is not to execute the 66.Nm 67command and then attempt to decipher the textual output, but instead to 68directly call the DNS-SD APIs using a binding for your chosen language. 69.br 70For example, if you are programming in Ruby, then you can 71directly call DNS-SD APIs using the dnssd package documented at 72.Pa <http://rubyforge.org/projects/dnssd/> . 73.br 74Similar bindings for other languages are also in development. 75.Pp 76.Bl -tag -width R 77.It Nm Fl R Ar name type domain port Op Ar key=value ... 78register (advertise) a service in the specified 79.Ar domain 80with the given 81.Ar name 82and 83.Ar type 84as listening (on the current machine) on 85.Ar port. 86.Pp 87.Ar name 88can be arbitrary unicode text, containing any legal unicode characters 89(including dots, spaces, slashes, colons, etc. without restriction), 90up to 63 UTF-8 bytes long. 91.Ar type 92must be of the form "_app-proto._tcp" or "_app-proto._udp", where 93"app-proto" is an application protocol name registered at 94.Pa http://www.dns-sd.org/ServiceTypes.html . 95.Pp 96.Ar domain 97is the domain in which to register the service. 98In current implementations, only the local multicast domain "local" is 99supported. In the future, registering will be supported in any arbitrary 100domain that has a working DNS Update server [RFC 2136]. The 101.Ar domain 102"." is a synonym for "pick a sensible default" which today 103means "local". 104.Pp 105.Ar port 106is a number from 0 to 65535, and is the TCP or UDP port number upon 107which the service is listening. 108.Pp 109Additional attributes of the service may optionally be described by 110key/value pairs, which are stored in the advertised service's DNS TXT 111record. Allowable keys and values are listed with the service 112registration at 113.Pa http://www.dns-sd.org/ServiceTypes.html . 114.It Nm Fl B Ar type domain 115browse for instances of service 116.Ar type 117in 118.Ar domain . 119.Pp 120For valid 121.Ar type Ns s 122see 123.Pa http://www.dns-sd.org/ServiceTypes.html 124as described above. Omitting the 125.Ar domain 126or using "." means "pick a sensible default." 127.It Nm Fl L Ar name type domain 128look up and display the information necessary to contact and use the 129named service: the hostname of the machine where that service is 130available, the port number on which the service is listening, and (if 131present) TXT record attributes describing properties of the service. 132.Pp 133Note that in a typical application, browsing happens rarely, while lookup 134(or "resolving") happens every time the service is used. For example, a 135user browses the network to pick a default printer fairly rarely, but once 136a default printer has been picked, that named service is resolved to its 137current IP address and port number every time the user presses Cmd-P to 138print. 139.El 140.Sh EXAMPLES 141.Pp 142To advertise the existence of LPR printing service on port 515 on this 143machine, such that it will be discovered by the Mac OS X printing software 144and other DNS-SD compatible printing clients, use: 145.Pp 146.Dl Nm Fl R Ns \ \&"My Test\&" _printer._tcp. \&. 515 pdl=application/postscript 147.Pp 148For this registration to be useful, you need to actually have LPR service 149available on port 515. Advertising a service that does not exist is not 150very useful, and will be confusing and annoying to other people on the 151network. 152.Pp 153Similarly, to advertise a web page being served by an HTTP 154server on port 80 on this machine, such that it will show up in the 155Bonjour list in Safari and other DNS-SD compatible Web clients, use: 156.Pp 157.Dl Nm Fl R Ns \ \&"My Test\&" _http._tcp \&. 80 path=/path-to-page.html 158.Pp 159To find the advertised web pages on the local network (the same list that 160Safari shows), use: 161.Pp 162.Dl Nm Fl B Ns \ _http._tcp 163.Pp 164While that command is running, in another window, try the 165.Nm Fl R 166example given above to advertise a web page, and you should see the 167"Add" event reported to the 168.Nm Fl B 169window. Now press Ctrl-C in the 170.Nm Fl R 171window and you should see the "Remove" event reported to the 172.Nm Fl B 173window. 174.Pp 175.Sh FILES 176.Pa /usr/bin/dns-sd \" Pathname 177.\" 178.Sh SEE ALSO 179.Xr mdnsd 8 180.\" 181.Sh HISTORY 182The 183.Nm 184command first appeared in 185.Nx 6.0 , 186having originated in Mac OS X 10.4 (Tiger). 187