4

It seems that this is the best way to get the Bonjour name from an IP address:

$ dig -x 192.168.214.108 @224.0.0.251 -p 5353

; <<>> DiG 9.8.3-P1 <<>> -x 192.168.214.108 @224.0.0.251 -p 5353
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 15357
;; flags: qr aa; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;108.214.168.192.in-addr.arpa.  IN  PTR

;; ANSWER SECTION:
108.214.168.192.in-addr.arpa. 10 IN PTR David-iPhone.local.

;; Query time: 40 msec
;; SERVER: 192.168.214.108#5353(224.0.0.251)
;; WHEN: Sat Sep  5 12:10:08 2015
;; MSG SIZE  rcvd: 78

This works as expected on my Macbook Pro. However, running dig on another device (Raspberry Pi), there are no results:

$ dig -x 192.168.214.108 @224.0.0.251 -p 5353

; <<>> DiG 9.8.4-rpz2+rl005.12-P1 <<>> -x 192.168.214.108 @224.0.0.251 -p 5353
;; global options: +cmd
;; connection timed out; no servers could be reached

Why is that? How can I get the same results when calling dig from the Raspberry Pi? The host can be pinged just fine from the Raspberry Pi.

I'm looking to gather as much information as possible from network devices, happy to consider other approaches. (the name ("Joe's iPhone") of iOS/mobile devices is especially valuable)

  • 1
    Packet traces would be helpful. When say you want to "get the same results from the Pi", are you saying you're running the dig command on the Pi, or are you saying you're trying to discover the Pi's .local name? Is the Pi running Avahi or some other ZeroConf/mDNS implementation? I wonder if you're running dig but not Avahi on the Pi, and the responses are coming back multicast, but the Pi isn't running an mDNS-savvy DNS resolver, so it isn't listening for the responses at 224.0.0.251:5353. – Spiff Sep 05 '15 at 19:55
  • Ah. I mean running the same dig command on the Pi. Edited my question to make that clearer. – David Chouinard Sep 05 '15 at 20:05
  • The Pi is accessible at `raspberrypi.local` and I see `avahi-daemon` running under `ps`. I haven't fiddled with that, that's the default setup. That could interfere with mDNS resolving? – David Chouinard Sep 05 '15 at 20:08
  • How can I provide packet traces? – David Chouinard Sep 05 '15 at 20:11

1 Answers1

3

It may be that dig on Raspbian might be using a non-mDNS-aware DNS resolver library, which doesn't know to listen for mDNS answers on 224.0.0.251:5353.

See if your Raspbian Avahi install includes the avahi-resolve --address or avahi-resolve-address commands, and use those instead of dig.

Spiff
  • 101,729
  • 17
  • 175
  • 229