SWN HackNight 2006/03/15: Unicast DNS Service Discovery
Yesterday I watched a very good presentation about multicast dns service discovery (aka bonjour aka rendezvous aka zeroconf) given by Stuart Cheshire who happens to be the person at apple that created it. One of the things mentioned that I had not previously heard of was the fact that bonjour supports unicast dns service discovery as well, so tonight at hacknight we decided to attempt to get that to work.
The goal was to get an entry specified on Rob’s DNS server to show up in the “Connect to server”dialog in the OSX Terminal application.
The first problem we ran into was figuring out how to specify which domains bonjour will query for services. I swore that OSX had some sort of Bonjour preferences pane somewhere but we absolutely could not find it and decided that it must use the search domains specified for standard DNS resolution. After messing with that for quite a while with absolutely no success, Ken discovered that there is a bonjour preferences pane that lets you set the domains to browse – you just have to download it separately!
With bonjour now configured to query the correct domain the next problem we ran into was getting the correct BIND entries written to announce the service. After much cursing and digging through packet dumps, we finally managed to get the server to show up in the terminal’s connect dialog.
b._dns-sd._udp IN PTR @ lb._dns-sd._udp IN PTR @ _services._dns-sd._udp IN PTR _ssh._tcp _ssh._tcp IN PTR mouse-shell-server._ssh._tcp mouse-shell-server._ssh._tcp IN SRV 0 0 22 mouse.nocat.net.
However there was a problem, the name showed up but clicking on it did not populate the textbox with any hostname. I configured avahi on my ubuntu linux laptop to browse the domain we were testing (browse-domains in /etc/avahi/avahi-daemon.conf) and ran avahi-discover. The SSH service did show up, but selecting it produced a “Timed Out” error while it attempted to resolve information about the service.
More cursing and packet capturing later we discovered that a TXT record, even if completely empty is required for this to work.
b._dns-sd._udp IN PTR @ lb._dns-sd._udp IN PTR @ _services._dns-sd._udp IN PTR _ssh._tcp _ssh._tcp IN PTR mouse-shell-server._ssh._tcp mouse-shell-server._ssh._tcp IN SRV 0 0 22 mouse.nocat.net. mouse-shell-server._ssh._tcp IN TXT ""
And finally, the terminal was able to discover the ssh server and connect to it.
So, here’s a basic breakdown of what happens when the client queries the server to look for services:
- Check for a b._dns-sd._udp PTR record to see if this domain is browsable
- If so, query for any _services._dns-sd._udp PTR records, which will contain PTRs to all the service types publised for this domain.
- Perform a PTR query for the name of each service type returned by the preveous query, this will return PTRs to SRV records.
- Do an SRV query and a TXT for every name returned by the preveous query.
According to the video mentioned above bonjour will also query the DNS domain name that is given to you by DHCP, in addition to anything you specify manually, so a practical use for unicast service discovery would be for say a hotel to publish a list of websites containing information about the area for tourists, for example. We weren’t able to come up with any reason that we would ever care to use this ourselves, but were happy to have finally gotten it working.
That said, multicast dns service discovery is absolutely wonderful, and if any of you don’t know have any idea what I am talking about, I highly suggest watching the video.
If you happen to be a Mono/C# developer, you can use Avahi# to add bonjour support to your linux applications, and Mono.ZeroConf to add bonjour support to your osx/windows applications.
This is all most likely explained in the DNS-Based Service Discovery RFC Draft… but who reads those? :)
Categorized as Other, Events, Open Source, Technology, SeattleWireless, Technology
2 Comments
Trackbacks & Pingbacks
-
Significant Digits
Bonjour with BIND
While browsing monologue (the blog aggregator of the Mono Project), I found a post by Eric Butler detailing a method of using BIND to publish Bonjour services. As I’m hoping to disable the AppleTalk protocol on our network, the ability to publish net…
That’s awesome.