I have a list of IP addresses on a network, and most of them support multicast DNS. I'd like to be able to resolve the server name instead of just having the IP address.
ping computer.local
64 bytes from 192.168.0.52: icmp_seq=1 ttl=64 time=5.510 ms
64 bytes from 192.168.0.52: icmp_seq=2 ttl=64 time=5.396 ms
64 bytes from 192.168.0.52: icmp_seq=3 ttl=64 time=5.273 ms
Works, but I'd like to be able to determine that name from the IP. Also the devices don't necessarily broadcast any services, but definitely do support mDNS broadcast. So looking through services won't work.
Since you already know the IP addresses you can look up the reverse entry for each IP address to get the associated forward address:
For a more shell script friendly output, use '+short':
Depending on your intended use case there may be a more appropriate method of performing the query. Feel free to contact me if you should need any further information.
On Linux, you can use the getent command from the libc:
Or install avahi-utils, and run
This appears to work:
From Fun with multicast DNS
Well I did a fair bit more research on this one, and looking through mDNDS and the protocol, it looks like this isn't actually possible. There is a lookup request on the protocol for name retrieval, so when you ask for a name the appropriate client will respond, but there is not lookup request for an IP. There's no central store for addresses either.
Hope this help someone else, as I've spent way too much time tracking this down.
If anyone has any other ideas on this issues, I've love to hear em.