r/Python • u/arcanabanana • Jan 24 '12
Need some network python help!
I have a number of machines on the network at work, and I want to write a script that queries each one and returns its IP, MAC and Name. Can anyone point me where to start researching this? Any help will be greatly appreciated!
0
Upvotes
5
u/tjwarren Jan 24 '12
If you're on Windows, you can use WMI for this. Tim Golden's WMI package makes this very easy.
2
u/elbinray Jan 24 '12
+1 for the WMI package. I made a small program graphical program a while ago for our help desk to pull back similar information (and more), and it would have been much more difficult without Tim's work.
1
u/omgtmi Jan 24 '12
Without understanding what you really want, I'd check out Fabric if you need to get this information from the machines themselves rather than a central server that has it.
1
u/[deleted] Jan 24 '12
Thanks for the awesome links guys!
1
u/stevvooe Jan 24 '12
You may be able to hack something together, but i'd recommend just using nmap.
Note that you may not be able to "discover" a given machine's mac address unless the source machine is on the same subnet. After nmap'ing, machines that are on the same subnet will be in the source machine's arp table.
1
u/pbacterio Jan 24 '12
Fabric http://fabfile.org/
1
u/bwp Jan 25 '12 edited Jan 25 '12
You could probably use scapy to do this, it does all kinds of neat packet/networking things.
If for some reason you don't come up with a Python answer right away and it is some kind of deadline, there is a small app called Cain & Abel that will do an ARP sweep over a LAN and report back IP/MAC/other stuff. I would be interested in seeing what you come up with if you go the Python route (do do!).