cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
34663
Views
5
Helpful
5
Replies

How do I get Mac Address table - VIA SNMP

russ
Level 1
Level 1

Hardware: Cisco SG500-52 52-Port Gigabit Stackable Managed Switch

Is it possible to retrieve the Mac Address table using SNMP? I simply need the Mac address and associated Port values.

If possible, please tell me how I can get this data using a Windows Computer using any SNMP browsing software.
1. What browsing software can I use to see the data (Windows Computer).
2. What login or Community String do I use.
3. What object ID do I use.

I can get the Mac Address table using IOS command line:

MySwitch#show mac address-table

  Vlan        Mac Address         Port       Type   
-------- --------------------- ---------- ----------
   1       00:03:ff:98:dd:12    gi1/1/31   dynamic  
   1       00:0c:29:59:27:98    gi1/1/48   dynamic  
   1       00:0c:29:62:65:70    gi1/1/10   dynamic  
   ...

MySwitch#show version

     Unit             SW version         Boot version         HW version     
------------------- ------------------- ------------------- -------------------
         1               1.2.0.97            1.2.0.12               V01        
-Russ (Las Vegas NV)

 

5 Replies 5

Rolf Fischer
Level 9
Level 9

Russ,

I don't have such a platform but on Catalyst switches you need to walk the BRIDGE-MIB objects dot1dTpFdbPort and dot1dBasePortIfIndex with a community string with the following format: <community>@<VLAN-ID>

Unfortunately you'll need some scripting to make the result readable. An example:

.1.3.6.1.2.1.17.4.3.1.2.0.0.12.7.172.11 = 50

.1.3.6.1.2.1.17.4.3.1.2 = dot1dTpFdbPort OID

0.0.12.7.172.11 = The MAC address (decimal!)

50 = Port number (=> dot1dBasePortIfIndex)

 

I remember a tool called "netdisco" I saw years ago but I myself have never used it.

 

HTH

Rolf

Thanks for your reply. I am now getting data. However I'm using an snmptable instead:

//BRIDGE-MIB::dot1dTpFdbTable = (1.3.6.1.2.1.17.4.3)

snmpwalk -O0sUX -v2c -Cc -c public 172.16.16.160 BRIDGE-MIB::dot1dTpFdbPort
dot1dTpFdbPort[STRING: 00:03:ff:98:dd:12] = INTEGER: 79
dot1dTpFdbPort[STRING: 00:0c:29:59:27:98] = INTEGER: 96
dot1dTpFdbPort[STRING: 00:0c:29:88:dd:f4] = INTEGER: 96
dot1dTpFdbPort[STRING: 00:0f:66:90:75:28] = INTEGER: 88

However, when doing this query against Cisco SG500-52 switch, the INTEGER values are off by 48. So if I subtract 48. I get the right port number. So in the first row the INTEGER is 79 - 48 = 31. Port 31 matches the values I get using the cisco IOS show mac address-table.

When doing this same query against an HP ProCurve 1810G switch (24 ports), the INTEGER values (port numbers) are correct. I imagine this is because implementation is different for HP???

Is there a better way to do this for Cisco?

-Russ

 

It depends on the vendor and the platform. Most smaller Catalyst switches also have a fixed scheme like yours and you can simply calcultate the ports, others assign numbers unpredictably during the boot process (e.g. c6500).

Here the dot1dBasePortIfIndex object comes into play:

"The value of the instance of the ifIndex object,
defined in MIB-II, for the interface corresponding
to this port."

This additional "translation" is necessary for the assignment to Interface-MIB objects like ifName. As I mentioned above, it can be somewhat cumbersome to use this BRIDGE-MIB objects.

Useful Link: Using SNMP to Find a Port Number from a MAC Address on a Catalyst Switch


 

Hi, 

I can understand the show mac address-table can be fetched using the mentioned dot1dTpFdbTable snmp table. But the command actually displays VLAN information too. As can be seen below in the command snapshot. But the dot1dTpFdbTable has got only MAC - portIndex mapping. There's not OID to co-relate the VLAN for which the MAC has been learned. 

Any help/suggestions is much appriciated.

Regards,

Murali V

#show mac address-table

Unicast Entries
vlan     mac address     type        protocols               port

chsnraju78
Level 1
Level 1

any snmp mib to get data same as show mac address-table

Review Cisco Networking for a $25 gift card