Skip to main content

SNMP port-to-interface

(Note to Googlers: I'm more than a little surprised to get so many hits on this page so soon. To add context to this, this is an example, emailed to me by the JTAC while I was trying to troubleshoot my SNMP query sequence with EX2200 switches. I stuck it here so I could refer to it. I'm trying to write a script that automates this, but it is nowhere near ready enough to even mention even in a forum like this, let alone publish.)

*         To see Mac addresses on vlans other than default.
o   root@JUNIPER> show snmp mib walk 1.3.6.1.2.1.17.7.1.2.2

regress@EX4200-2> show ethernet-switching table
Ethernet-switching table: 9 entries, 3 learned
  VLAN              MAC address       Type         Age Interfaces
  default           *                 Flood          - All-members
  default           00:23:9c:0a:4b:2e Learn          0 ge-0/0/23.0
  LC-vlan-45        *                 Flood          - All-members
  customer1-vlan10  *                 Flood          - All-members
  customer1-vlan10  00:1f:12:32:b7:80 Static         - Router
  customer1-vlan10  00:1f:12:32:b7:90 Learn          0 ge-0/0/11.0
  customer2-vlan20  *                 Flood          - All-members
  customer2-vlan20  00:1f:12:32:b7:80 Static         - Router
  customer2-vlan20  00:1f:12:32:b7:91 Learn          0 ge-0/0/12.0

regress@EX4200-2> show snmp mib walk dot1qVlanStaticTable
dot1qVlanStaticName.2 = SL2-vlan-31
dot1qVlanStaticName.3 = SL3-vlan-31
dot1qVlanStaticName.4 = SL4-vlan-31
dot1qVlanStaticName.8 = default
dot1qVlanStaticName.9 = LC-vlan-45
dot1qVlanStaticName.10 = customer1-vlan10===============FDB ID of this vlan is 10(not 
vlan id)
dot1qVlanStaticName.11 = customer2-vlan20

show Ethernet-switching table is shown below

regress@EX4200-2> show snmp mib walk dot1qTpFdbTable
dot1qTpFdbPort.8.0.35.156.10.75.46 = 536
dot1qTpFdbPort.9.0.0.0.0.0.0 = 0
dot1qTpFdbPort.10.0.0.0.0.0.0 = 0
dot1qTpFdbPort.10.0.31.18.50.183.128 = 0
dot1qTpFdbPort.10.0.31.18.50.183.144 = 524===================MAC learnt on VLAN ID 10 
and MAC is 0.31.18.50.183.144 (in decimal). Convert to HEX it will be 00:1f:12:32:b7:90 
on Port number 524(bridge port)
dot1qTpFdbPort.11.0.0.0.0.0.0 = 0
dot1qTpFdbPort.11.0.31.18.50.183.128 = 0
dot1qTpFdbPort.11.0.31.18.50.183.145 = 525
dot1qTpFdbStatus.8.0.35.156.10.75.46 = 3
dot1qTpFdbStatus.9.0.0.0.0.0.0 = 5
dot1qTpFdbStatus.10.0.0.0.0.0.0 = 5
dot1qTpFdbStatus.10.0.31.18.50.183.128 = 4
dot1qTpFdbStatus.10.0.31.18.50.183.144 = 3
dot1qTpFdbStatus.11.0.0.0.0.0.0 = 5
dot1qTpFdbStatus.11.0.31.18.50.183.128 = 4
dot1qTpFdbStatus.11.0.31.18.50.183.145 = 3

Now check which is port 524 from dot1dBase Table

regress@EX4200-2> show snmp mib walk dot1dBase
dot1dBaseBridgeAddress.0 = 00 1f 12 32  b7 80
dot1dBaseNumPorts.0 = 17
dot1dBaseType.0 = 2
dot1dBasePort.513 = 513
dot1dBasePort.515 = 515
dot1dBasePort.524 = 524=================Port 524
dot1dBasePort.525 = 525
dot1dBasePort.529 = 529
dot1dBasePort.530 = 530
dot1dBasePort.536 = 536
dot1dBasePortIfIndex.513 = 193
dot1dBasePortIfIndex.515 = 195
dot1dBasePortIfIndex.524 = 204================= IfIndex of port 524 is 204
dot1dBasePortIfIndex.525 = 205
dot1dBasePortIfIndex.529 = 208
dot1dBasePortIfIndex.530 = 209
dot1dBasePortIfIndex.536 = 215

regress@EX4200-2> show snmp mib get ifName.204
ifName.204    = ge-0/0/11.0===============================

So port ge-0/0/11.0 is the 
interface on which  00:1f:12:32:b7:90 is learnt for VLAN customer1-vlan10