[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Ping and ARP on both Win and Linux in Python

Mauro \"Baba\" Mascia

3/13/2008 8:15:00 PM

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.

1 Answer

runes

3/14/2008 9:22:00 PM

0

On Mar 13, 9:14 pm, "Mauro \"Baba\" Mascia" <baba_...@yahoo.it> wrote:
> 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.

There are several Ping /ICMP implentations in Python. I did something
similar using a python ping module and parsing the arp cache. A
different approach may be to use SNMP. I believe there are Python
tools around.