dns-sd

dns-sd is a commandline tool to manipulate Bonjour (Zeroconf) services. You can find the Manpage online here - developer.apple.com

Registering a local service

To register a local service you can use the -R flag. Therefore to advertise a web page being served by an HTTP server on port 80 on the local machine use:

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

To find the advertised web pages on the local network (the same list that Safari shows), use:

dns-sd -B _http._tcp

While that command is running, in another window, try the dns-sd -R example given above to advertise a web page, and you should see the "Add" event reported to the dns-sd -B window. Now press Ctrl-C in the dns-sd -R window and you should see the "Remove" event reported to the dns-sd -B window.

Serving a local Fedwiki Farm on OSX involves teh following steps:

Registering remote services

To manually register a remote service using the -P parameter - stackoverflow

dns-sd -P <Name> <Type> <Domain> <Port> <Host> <IP> [<TXT>...]

In the example below, the www.apple.com web page is advertised as a service called "apple", running on a target host called apple.local, which resolves to 17.149.160.49.

dns-sd -P apple _http._tcp "" 80 apple.local 17.149.160.49

The Bonjour menu in the Safari web browser will now show "apple". The same IP address can be reached by entering apple.local in the web browser. In either case, the request will be resolved to the IP address and browser will show contents associated with www.apple.com.

If the service you're proxy registering already has a unicast DNS hostname something like this will work:

dns-sd -P Google _http._tcp local 80 google.com google.com path=/ Registering Service Google._http._tcp.local host google.com port 80 TXT path=/ 4:23:00.928 Got a reply for service Google._http._tcp.local.: Name now registered and active ^C

If it doesn't have a hostname a unique name should be used for the host:

$ dns-sd -P Google _http._tcp local 80 google.local 74.125.237.144 path=/ Registering Service Google._http._tcp.local host google.local port 80 TXT path=/ 4:16:48.208 Got a reply for record google.local: Name now registered and active 4:16:48.208 Got a reply for service Google._http._tcp.local.: Name now registered and active ^C

Finding ssh shares

To view all of the ssh shares on Bonjour-enabled computers, try this in the Terminal:

dns-sd -B _ssh._tcp .

You should receive a list of workstations that are broadcasting ssh services via Bonjour. Don't forget that you need to replace the spaces with hyphens and add a .local prefix when trying to connect. For example, to ssh to Macintosh HD found this way, you need to use ssh Macintosh-HD.local - hints.macworld.com