This article provides describes the process of how a SNMP ifIndex is assigned to a interface and why the same interface may have a different ifIndex in two Junos devices.
How a SNMP ifIndex is assigned to a interface and why the same interface may have a different ifIndex in two Junos devices.
The SNMP ifIndex information stored in a text format file – dcd.snmp_ix, which is located in the /var/db folder.
When a new interface gets created in the system, mib2d checks for an entry of the interface in the file /var/db/dcd.snmp_ix. If the entry for this index is present, the system then picks the SNMP interface index value from this file, or else it assigns a new interface index value and writes it to this file.
Since the file is maintained across reboots, the next time somebody deletes and re-creates the same interface, the SNMP ifIndex does not change.
The assignment of the interface index primarily depends on the order in which it is created and if any old value of SNMP exists in the index of /var/db/dcd.snmp_ix.
So, there is no guarantee of the snmpindex values being the same on two different machines.
The /var/db/dcd.snmp_ix file stores SNMP indexes for the interfaces, using the following syntax:
<snmpindex> <i/f name> <subunit> <logical(1/0)> <xx-xx>
For example, the SNMP ifIndex of ge-0/0/8 can be checked either in the /var/db/dcd.snmp_ix file or through the CLI command – show interface ge-0/0/8.
{master:0} root@s10-test> file show /var/db/dcd.snmp_ix | match ge-0/0/8 513 "ge-0/0/8" 0 0 1; 552 "ge-0/0/8" 0 1 1; {master:0} root@s10-test> show interfaces ge-0/0/8 Physical interface: ge-0/0/8, Enabled, Physical link is Down Interface index: 140, SNMP ifIndex: 513 Link-level type: Ethernet, MTU: 1514, Speed: Auto, Duplex: Auto, BPDU Error: None, MAC-REWRITE Error: None, Loopback: Disabled, Source filtering: Disabled, Flow control: Enabled, Auto-negotiation: Enabled, Remote fault: Online Device flags : Present Running Down Interface flags: Hardware-Down SNMP-Traps Internal: 0x0 Link flags : None CoS queues : 8 supported, 8 maximum usable queues Current address: 00:19:e2:51:3f:48, Hardware address: 00:19:e2:51:3f:48 Last flapped : 2011-11-14 06:56:52 UTC (3d 21:35 ago) Input rate : 0 bps (0 pps) Output rate : 0 bps (0 pps) Active alarms : LINK Active defects : LINK Interface transmit statistics: Disabled Logical interface ge-0/0/8.0 (Index 89) (SNMP ifIndex 552) Flags: Device-Down SNMP-Traps Encapsulation: ENET2 Input packets : 76333 Output packets: 1960364 Protocol eth-switch Flags: None