473,734 Members | 2,375 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Ping and ARP on both Win and Linux in Python

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.

Mar 13 '08 #1
1 2718
On Mar 13, 9:14 pm, "Mauro \"Baba\" Mascia" <baba_...@yahoo .itwrote:
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.
Mar 14 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
9570
by: WIWA | last post by:
Hi all, Anybody that could tell me how to execute some Linux commands using Python. The application is that I want to be able from a website to launch a Python script and that python script should be able to ping to the provided IP address, or should do a whois of that IP address. I want to use the existing Linux commands if possible. Anyone has an idea or tutorial?
14
42884
by: Egil Hansen | last post by:
Hi I'm wondering if its possible to write a javascript, that can ping a ip and return the average round trip time (like ping in dos/linux)? Regards, Egil.
17
18202
by: wana | last post by:
I was reading through original source code of ping for some insight and was confused by unusual code. Entire listing available at: http://www.ping127001.com/pingpage/ping.html #include #include #include #include #include #include #include #include #include #include #include #include
8
18392
by: Nico Grubert | last post by:
Hi there, I could not find any "ping" Class or Handler in python (2.3.5) to ping a machine. I just need to "ping" a machine to see if its answering. What's the best way to do it? Kind regards, Nico
21
30527
by: Neel | last post by:
I am trying to "ping" a remote host in my C++/Redhat Linux code to check whether that host is connected or not. if (0 == system("ping -w 2 192.168.0.2)) But, in both cases (connected/disconnected), system call returns 0. Can someone please show what I am doing wrong? How to check the actual result of the ping status using C++ on Redhat linux ? Thanks in advance.
3
1837
by: amaccormack | last post by:
I wrote a quick script to check the "up-ness" of a list of machines, and timeout after 1 second. However, with a lot of timeouts, the script takes a logn time, so I thought to parallelise it. However, as soon as I do, the pings that do not get a response never return, so their threads block forever and the program hangs. Environment is: Python 2.3.3 (#1, Jan 5 2005, 15:24:27) on linux2 (running on SLES9) pinglist=
7
6541
by: Linus Cohen | last post by:
Hi all, I'm a newbie to python and programming in general, so I wanted a simple project to start off. What I'm trying to do here is write a python command-line ping program, much like the Unix and Windows ping programs. I've got this much worked out already: class ping def PING(IP, pings, size): and that's where I stop, because I realize I have no idea how to make
12
7376
by: Matt F | last post by:
I'm creating simple ping script that prompts a user for various parameters. However, I would like each line of the ping displayed as it is received. Currently, the result isn't displayed until the ping is finished. <?php $ping_ip_addr = $_GET;
1
1825
by: Karl Kobata | last post by:
Hi Fredrik, This is exactly what I need. Thank you. I would like to do one additional function. I am not using the tokenizer to parse python code. It happens to work very well for my application. However, I would like either or both of the following variance: 1) I would like to add 2 other characters as comment designation 2) write a module that can readline, modify the line as required, and finally, this module can be used as the...
0
8776
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9449
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9310
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9182
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3261
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2724
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.