Ping and ARP on both Win and Linux in Python

  • Thread starter Mauro \Baba\ Mascia
  • Start date
M

Mauro \Baba\ Mascia

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.
 
R

Rune Strand

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top