how can I read the STP port status of each interface (in my software/program)? There is a MIB called BRIDGE-MIB with OID "dot1dStpPortState=" that returns the FORWARDING OR BLOCKING state. BUT my problem is that i can not associate the returned value with the port/interface. It seems the index of the OID is the "nbr" that is shown in the output of the "show spanning-tree" command, yet again I dont know how this relates to the interface number (it seems there is a fix offset added to the interface number, but how is that calculated?) the output for a typical show spanning-tree cmd is shown:

Switch2#show spanning-tree
Spanning tree enabled protocol ieee
 Root ID    Priority    32769
         Address     0006.d6ab.a040
         Cost        19
         Port        11 (FastEthernet0/11)
         Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
  Bridge ID  Priority    32769  (priority 32768 sys-id-ext 1)
         Address     0006.d6ac.46c0
         Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
         Aging Time 15
Interface        Role Sts Cost      Prio.**Nbr** Type
---------------- ---- --- --------- --------        -------------------------------
Fa0/2            Desg FWD 19        128.4    P2p
Fa0/11           Root FWD 19        128.13   P2p
Fa0/12           Altn BLK 19        128.14   P2p

the last three rows show that status of each interface/port and the relating priority.Nbr (Does anyone know how nbr for each interface is calculated?)

Is there any OID that would simply show the STP status of each port?

Thanks for the help in advance.

1 Answer 1


What you're getting at the OID you mentioned is a table:

BRIDGE-MIB::dot1dStpPortState.1025 = INTEGER: blocking(2)
BRIDGE-MIB::dot1dStpPortState.1026 = INTEGER: blocking(2)
BRIDGE-MIB::dot1dStpPortState.1027 = INTEGER: blocking(2)
BRIDGE-MIB::dot1dStpPortState.1028 = INTEGER: forwarding(5)
BRIDGE-MIB::dot1dStpPortState.1029 = INTEGER: blocking(2)
BRIDGE-MIB::dot1dStpPortState.1030 = INTEGER: blocking(2)
BRIDGE-MIB::dot1dStpPortState.1031 = INTEGER: forwarding(5)
BRIDGE-MIB::dot1dStpPortState.1032 = INTEGER: blocking(2)
BRIDGE-MIB::dot1dStpPortState.1033 = INTEGER: blocking(2)
BRIDGE-MIB::dot1dStpPortState.1034 = INTEGER: blocking(2)
BRIDGE-MIB::dot1dStpPortState.1035 = INTEGER: blocking(2)
BRIDGE-MIB::dot1dStpPortState.1036 = INTEGER: blocking(2)

Then match the bridge port to the interface index by querying .

BRIDGE-MIB::dot1dBasePortIfIndex.1033 = INTEGER: 62009

Then look it up in the interface table

IF-MIB::ifName.62009 = STRING: ge.6.9
  • thanks for the quick reply, i will check it out and then give the feedback
    – ae41
    Dec 13, 2015 at 15:25
  • @ae41, it may also be worth mentioning the snmp-server ifindex persist and snmp ifmib ifindex persist IOS commands.
    – Ron Maupin
    Dec 13, 2015 at 19:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.