CCIE Pursuit Blog

December 26, 2008

Lab Tip: Finding The ifIndex of an Interface

Often times you’ll run across a task where you know how to do the configuration, but you have no idea how to find a piece of necessary information.  I hit a task like that recently:

The RESTRICTED view should include the branch “ifEntry.*.n”, where n is the ifIndex of R6’s serial interface.

This was part of a larger SNMP task.  I had no problem completing the task except that I had no idea how to find the ifIndex of an interface.

Luckily, a quick trip to the Interwebs provided an answer:

The CLI command show snmp mib ifmib ifindex allows you to view the SNMP Interface Index Identification numbers assigned to interfaces and subinterfaces. An NMS is not required.

Once snmp-server enable traps (or informs) is configured, this command will work to list all ifindex values, or to show the value for a particular interface.

Darrell A. Escola
B.Sc. Information Technology
MCSE, MCDBA, MCSD

You can find the documentation here.

As stated, if snmp-server traps (or informs) are not enabled, then this command will not provide output:

r6#show snmp mib ifmib ifindex
%SNMP agent not enabled

You can enable traps with this command:

r6(config)#snmp-server enable ?
informs Enable SNMP Informs
traps Enable SNMP Traps

But this will fill your configuration with a ton of snmp-server traps statements:

r6(config)#do sh run | i snmp|trap
snmp-server enable traps snmp authentication linkdown linkup coldstart warmstart
snmp-server enable traps vrrp
snmp-server enable traps ds1
snmp-server enable traps tty
snmp-server enable traps eigrp
snmp-server enable traps casa
snmp-server enable traps xgcp
snmp-server enable traps bulkstat collection transfer
snmp-server enable traps isdn call-information
snmp-server enable traps isdn layer2
snmp-server enable traps isdn chan-not-avail
snmp-server enable traps isdn ietf
snmp-server enable traps icsudsu
—output truncated—

Simply disabling the traps removes them from the configuration, but also leaves the SNMP agent enabled (you can also achieve this by configuring and then removing an SMTP community string):

r6(config)#no snmp-server enable traps
% This command also disables previously enabled shamlink config error traps.
r6(config)#do sh run | i snmp|trap
r6(config)#do show snmp mib ifmib ifindex
Null0: Ifindex = 7
Serial0/0: Ifindex = 1
FastEthernet1/0: Ifindex = 5
FastEthernet2/0: Ifindex = 6
Serial0/1: Ifindex = 2
Serial0/2: Ifindex = 3
Serial0/3: Ifindex = 4

Now we that know what the Ifindex value is we can finish our configuration.

5 Comments »

  1. That is a handy tip.

    Comment by Paul Stewart — December 26, 2008 @ 3:37 pm | Reply

  2. Good tip!
    I’ve had to find the ifindex while in the process of creating traffic graphs under HP Openview (used HP for this).

    Cheers 🙂

    Comment by Roy — December 26, 2008 @ 6:07 pm | Reply

  3. Will come in handy

    Comment by sebastiaannoppe — December 28, 2008 @ 8:12 am | Reply

  4. One other thing to remember is the ifindex can change on a reboot. This can be avoided with this command ‘snmp-server ifindex persist’

    Comment by nklhd — December 30, 2008 @ 9:07 am | Reply


RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.