For When You Can't Have The Real Thing
[ start | index | login ]
start > snmp > Switching Tables

Switching Tables

Created by dave. Last edited by dave, 12 years and 254 days ago. Viewed 22,116 times. #11
[diff] [history] [edit] [rdf]

Querying a switch's Switching Table through SNMP

(aka the Forwarding Table from the MIB-II Bridge, formal name dot1dBridge.dot1dTpFdbTable)

$ snmpwalk -v 1 -c public . | grep
SNMPv2-SMI::mib- = Hex-STRING: 00 16 36 6D B4 5B
SNMPv2-SMI::mib- = INTEGER: 8
SNMPv2-SMI::mib- = INTEGER: 3

In this case we see that 00 16 36 6D B4 5B (which in decimal is is reachable through port 8.

The oid . ( is the mib-2 table detailing which interface to use to reach a particular MAC address.

The entries:

  • entry 1 is the MAC address in hex
  • entry 2 is the port to use
  • entry 3 is the type of entry (3 == "learn", which is what most of the entries will be)

If you have more than one VLAN

...beware that modern switches maintain a separate instance of the bridge MIB for each VLAN that the switch is a member of. If you don't specify one in your query (see below), then by default the switch answers with the contents of the table instance which belongs to the VLAN servicing the management interface you are querying.

If you query the switching table and you get back something that look suspiciously short, this is probably what's going on.

For a cisco, you specify the VID in the community name as so:

$  snmpwalk -v 1 -c "COMMUNITY@VID" IP .
$  snmpwalk -v 1 -c "public@135" .

>>HP Forum about Ciscos

>>Dell Forum Thread on Power Edge switches

The Dell Forum suggests querying the >>Q-Bridge-MIB instead, which is$entry.$VID.$MAC (formal name: dot1qTpFdbTable), where

  • the value for $entry=1 doesn't appear to be defined
  • the value for $entry=2 is the switch port through which the target is reachable
  • I presume the value for $entry=3 is the same as above (ie 3 = learned)
  • $VID is the VLAN ID number that the target is reachable
  • $MAC is the MAC address in decimal separated by dots
# snmpwalk -v 1 -On -c $COMMUNITY $SWITCH | grep .
. = INTEGER: 10
. = INTEGER: 3
This tells me that the MAC address 00:07:E9:D7:EC:FA is reachable through port 10 on VLAN 1942 and it is a learned entry.

The Q-BRIDGE-MIB is also available on HP ProCurve 5412zl switches.


If you are doing this with perl it may be worth knowing how to automatically convert Hex MAC to decimal OID values.

Interface names and descriptions:

  • ifDescr:$PORT
Ciscos anyways can use other tables. You look up the ifIndex from the $PORT value you have, then use the ifIndex in the other OIDs

Object NameOID 
ifAlias1.$ifIndexThis is the "Port Label"
no comments | post comment
This is a collection of techical information, much of it learned the hard way. Consider it a lab book or a /info directory. I doubt much of it will be of use to anyone else.

Useful: | Copyright 2000-2002 Matthias L. Jugel and Stephan J. Schmidt