I am looking for a way to make reverse mDNS query on OSX over IPv6 only. I am not interested by solution using IPv4.
The following works on Linux with dig
9.16.1:
dig +short @ff02::fb -p 5353 -x 2001:db8::1
I've installed dig
9.16.7 with homebrew on OSX, that command with the exact same arguments produces a timeout. And there is no sign of the outgoing query on Wireshark.
The following works well on both Linux and OSX:
dig +short @224.0.0.251 -p 5353 -x 192.168.1.23
The binary avahi-resolve-address
is not available on OSX and I didn't find a way to make a reverse DNS works with dns-sd
.
Here is the operating system version used:
- OSX version: Catalina 10.15.7
- Linux: Ubuntu 20.04
I found a couple of ways to do this, but they're both a bit ugly. First, you can use
dns-sd -q
and specify theptr
record type... but you need to convert the address you want to look up into nibble-by-nibble reverse format by yourself. For example, to look upfe80::4e6:97e7:d892:d977
you'd use:Unfortunately, this only seems to work for link-local addresses, not public addresses. I have no idea why. Also, note that
dns-sd
doesn't exit automatically after doing the lookup, but keeps monitoring for changes. You need to kill it after a bit.You can also use
dig
, somewhat like your original command, but you need to tell it which interface to send the query out over, and in a rather weird format. The "standard" thing to do would be to add a zone index for the interface, e.g. to send it toff02::fb
overen1
you'd use@ff02::fb%en1
. Butdig
doesn't like that format, so you have to be sneakier. BSD-based unixes, including macOS, allow you to put a numeric zone index in the second 16-bit word of some kinds of addresses, and that does work here. Here's a (anonymized) example where I usenetstat -rn -f inet6
to find out that2001:db8:1234:5678::/64
is on interfaceen1
, that interface's link number is5
, and then use that to do a lookup (I added ^^^s to emphasize the relevant parts):