Ping and ARP on both Win and Linux in Python

Mauro "Baba" Mascia baba_mmx at yahoo.it
Thu Mar 13 16:14:52 EDT 2008


Hi, this is my question:

I want to know if several switch (about 50) in a big lan are up and then 
know their MAC addresses to do a list that contains host name, ip and mac.
I know only the range of their IP addresses (the host name it's simply 
to know using socket.gethostn.

The first idea it's to ping all ip, parse the response and then execute 
the command "arp -a" and parse the response.
However this way depends on the operating system and the ping response 
depends too from the language.

Another way it's to open the main page of the switch and parse the HTML 
code where i can find the MAC address.
However this way depends on the particular brand's switch.

I know (or better i think) that there is a third way: make ping and arp 
building the packets with socket and so on (but i dont have understand 
in what way do this).

Any suggestion?

(i've already search in google, found many sources but a lot of them 
don't works or don't do what im trying to do...)

Regards,
    Mauretto.




More information about the Python-list mailing list