9

It's pretty straightforward to query out the guts of a DNS-SD entry via dig by asking your nameserver directly; but for multicast DNS, I'm not sure where to look.

Edit: My motivation is to be able to see example DNS entries so that I can better configure static bonjour entries for my OS X machines.

Nevir
  • 7,951
  • 4
  • 41
  • 50

2 Answers2

12

Aha, the secret is the multicast address/port.

For example, to query available AFP servers:

dig @224.0.0.251 -p 5353 -t ptr _afpovertcp._tcp.local
Nevir
  • 7,951
  • 4
  • 41
  • 50
  • This works for services on the same machine, but does not show services from other devices in the network. On the other hand, Bonjour Browser does show all services. – Alexei Sholik Sep 26 '13 at 13:40
7

The main utility is dns-sd, e.g.:

% dns-sd -B _afpovertcp._tcp
Browsing for _afpovertcp._tcp
Timestamp     A/R Flags if Domain           Service Type              Instance Name
20:02:23.350  Add     2  4 local.           _afpovertcp._tcp.         myhost
Alnitak
  • 334,560
  • 70
  • 407
  • 495
  • Does that have any tricks for getting at the underlying entries (or verbose details?) - part of my motivation is to figure out what entries a given service registers. (for instance, the afp shares also have an associated _device-info._tcp) – Nevir May 14 '12 at 20:51
  • 1
    When I tried it the command hangs... man page: "The dns-sd command is primarily intended for interactive use. Because its command-line arguments and output format are subject to change, invoking it from a shell script will generally be fragile. Additionally, the asynchronous nature of DNS Service Discovery does not lend itself easily to script-oriented programming. For example, calls like "browse" never complete; the action of performing a "browse" sets in motion machinery to notify the client whenever instances of that service type appear or disappear from the network." – Kurt Harriger Feb 05 '14 at 05:40
  • @KurtHarriger it's not "hung", it sits there continuously waiting for further multicast transmissions from other hosts. – Alnitak Feb 05 '14 at 09:30
  • 1
    Yes, I get that. I was looking for something suitable to use from a shell script. While it answered the readers question, I thought it worth noting this limitation so that others users like myself are aware of it. – Kurt Harriger Feb 05 '14 at 15:03