KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
My target is to discover the IP address of a Linux computer "server" in the local network from a Windows computer. From another Linux computer "client" I can do: ping -c1 server.local and get a reply. Both "server" and "client" run Avahi, so this is easy. However, I would like to discover the IP address of "server" from a Python application of mine, which runs on both MS Windows and Linux computers. Note: on MS Windows computers that do not run mDNS software, there is no hostname resolution (and obviously ping does not work on said Windows systems). I know of the existence of pyzeroconf , and this is the module I tried to use; however, the documentation is scarce and not very helpful to me. Using tools like avahi-discover , I figured that computers publish records of the service type _workstation._tcp.local. (with the obviously dummy port 9, the discard service) of mDNS type PTR that might be the equivalent of a DNS A record. Or I might have misunderstood completely the mDNS mechanism. How can I discover the IP address of a computer (or get a list of IP addresses of computers) through mDNS from Python? CLARIFICATION (based on a comment) The obvious socket.gethostbyname works on a computer running and configured to use mDNS software (like Avahi): Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import socket >>> socket.gethostbyname('server.local') '192.168.42.42' However, on Windows computers not running mDNS software (the default), I get: Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 b
Tags (comma-separated)
Save Edits
Cancel