Switches, Hubs, and Modems
1753435 Members
4576 Online
108794 Solutions
New Discussion юеВ

Perlscript to connect hp switch and read the mac-address

 
Christian Czech
New Member

Perlscript to connect hp switch and read the mac-address

Hi,
I need a perlscript to connect my hp procurve switch and read the mac-address from the connected hosts.
Can someone help me with an example?
Thanks Christian
6 REPLIES 6
cenk sasmaztin
Honored Contributor

Re: Perlscript to connect hp switch and read the mac-address

what you say ??
if I true understand you
you want look pc mac address each port on switch
is this true ?
cenk

Igoris_1
Frequent Advisor

Re: Perlscript to connect hp switch and read the mac-address

how do you want to connect, I believe SNMP is the easiest way to retrieve MAC addresses.
Christian Czech
New Member

Re: Perlscript to connect hp switch and read the mac-address

Hi,
with snmp there is no way to find out a matching witch mac-address connect on which port on the switch. (like the command show mac-address vlan 1)

;-)) I know my english is not good.
Matt Hobbs
Honored Contributor

Re: Perlscript to connect hp switch and read the mac-address

There are scripts out there.... I haven't tried it but I found this - http://linux.softpedia.com/get/Programming/Libraries/SNMP-BridgeQuery-26173.shtml
Christian Czech
New Member

Re: Perlscript to connect hp switch and read the mac-address

Hi,
sorry the script do not work.


#!/usr/bin/perl

my $address = "x.x.x.x";
my $community = "public";
use SNMP::BridgeQuery;
use SNMP::BridgeQuery qw(querymacs queryports queryat);

my $fdb = queryfdb(host => $address,
comm => $community);
unless (exists $fdb->{error}) {
($fdb->{$mac} = "n/a") unless (exists $fdb->{$mac});
print "This MAC address was found on port: ".$fdb->{$mac}."\n";
}
~

Output:

/test.pl
This MAC address was found on port: n/a

But I do not why. The mac addresses are in the snmp parameter (with a snmpwalk).
It is very mysteries.
Andr├й Beck
Honored Contributor

Re: Perlscript to connect hp switch and read the mac-address

Hi Christian,

given that NeDi (www.nedi.ch) can do exactly that (correlate host MAC addresses to switch ports on ProCurve boxes), the information has to be there in the SNMP MIBs. The discovery module is even a perl script, so you might have a look into it for how it's done.

HTH,
Andre.