0

I am scanning my local network, and trying to resolve IP addresses to hostnames where possible. For those on the DNS server, that is easy, just reverse lookup / PTR record.

For those hosts not on DNS, it seems that avahi/bonjour/zeroconf (as far as I can tell, those all use mDNS and are the same underlying thing) can provide answers in some instances. AFAIK, this is using multicast to send a query to the local network, and getting replies directly from the servers involved.

avahi-resolve -v --address <list of IP addresses> works, but I want to do this explicitly in Python, not kicking out to an external process (portability, dependencies, etc). That seems to be supported by the python zeroconf library.

I am finding the documentation for Python zeroconf impenetrable: the low level details are documented, but nothing explains the concepts and structure. There's a few examples (with little or no explanation), but a wide API.

I think something like this is needed:

browser = ServiceBrowser(zeroconf, "_services._dns-sd._udp.local.", listener)

However ZeroconfServiceTypes.find() doesn't even list dns (though avahi command does work, so it must be there), and calling with that name throws an error. Are you meant to just union all the available services, or is ServiceBrowser the wrong API here?

If anyone can show a minimal example of how to do that lookup (bulk lookup or individual IP), or explain the architecture better, I would much appreciate it.

0

Browse other questions tagged or ask your own question.