How can I get a list of the IP addresses or host names from a local network easily in Python?
It would be best if it was multi-platform, but it needs to work on Mac OS X first, then others follow.
Edit: By local I mean all active addresses within a local network, such as 192.168.xxx.xxx
.
So, if the IP address of my computer (within the local network) is 192.168.1.1
, and I have three other connected computers, I would want it to return the IP addresses 192.168.1.2
, 192.168.1.3
, 192.168.1.4
, and possibly their hostnames.
If by "local" you mean on the same network segment, then you have to perform the following steps:
Or you can just let Python execute nmap externally and pipe the results back into your program.
Update: The script is now located on github.
I wrote a small python script, that leverages scapy's arping()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With