Alex Rivera | Logout

How to get MAC or IP Addresses of devices connected to a switch using SNMP?

Asked 2012-08-31T14:44:28.783
8

Using SNMP, how do I get the MAC address of the device connected to each port on the switch? We're using HP ProCurve Switches.

I tried using the OID dot1dTpFdbPort but that seems to be giving me the MAC address of every device that's in communication with the switch, not just connected to it.

I'm trying to find the OID that will give me ports 1-48 in a list, and for each port, the MAC (or IP address) of the device connected to that port.

Thanks!

Edit
Report

1 Answer

6

Thank you so much raz3r for your answer. It works like a charm !

From your linux server :

$ snmpwalk -v 1 -c public xxx.xxx.xxx.xxx 1.3.6.1.2.1.17.4.3.1.2 | grep "INTEGER: 11"

(port number 11)

Will return :

SNMPv2-SMI::mib-2.17.4.3.1.2.44.118.138.64.143.95 = INTEGER: 11
SNMPv2-SMI::mib-2.17.4.3.1.2.56.170.60.108.174.57 = INTEGER: 11
SNMPv2-SMI::mib-2.17.4.3.1.2.104.181.153.172.54.237 = INTEGER: 11
SNMPv2-SMI::mib-2.17.4.3.1.2.120.172.192.143.226.236 = INTEGER: 11
SNMPv2-SMI::mib-2.17.4.3.1.2.124.195.161.20.109.76 = INTEGER: 11
SNMPv2-SMI::mib-2.17.4.3.1.2.152.75.225.59.127.180 = INTEGER: 11

Then you can do this to find which Mac Address is connected :

$ snmpwalk -v 1 -c public xxx.xxx.xxx.xxx 1.3.6.1.2.1.17.4.3.1.1 | grep "152.75.225.59.127.180"

Return mac address :

SNMPv2-SMI::mib-2.17.4.3.1.1.152.75.225.59.127.180 = Hex-STRING: 98 4B E1 3B 7F B4

You can make a script.sh to do this...

answered 2013-04-24T15:45:48.080

Your Answer