Friday, October 25, 2013

Using dig to do MDNS lookup

I love MDNS (or Bonjour as Apple calls it). Multicast DNS is a local area domain naming service that makes it easy to discover endpoints on your local area network. For example, I can always connect to my netbook with ssh pnetbook.local. If you have avahi-daemon installed on Linux, it will do a DNS query to 224.0.0.251:5353 and the avahi-daemon on the network that it responsible for that domain name will respond. In the past, I could only use this if I have avahi-daemon (or Apple Bonjour for Windows) installed on both machine. But it just truck me that I can use "dig" to emulate a DNS query to that same multicast IP and port without have avahi-daemon installed on both machines. As long as there are MDNS responders on the network, they will see the request and reply accordingly. Anyways, here is the command (so beautiful)

dig @224.0.0.251 -p 5353 pnetbook.local

Well I hope this helps some of you.

2 comments:

  1. Thanks for this, I used this dig command for bonjour gateway trouble shooting

    ReplyDelete
  2. The problem is, dig tells the server to use a multicast return instead of unicast, and then it never sees the response until the device also sends an additional unicast out of the goodness of it's heart.

    ReplyDelete