I build SNMP Inspector, an iPhone and iPad app that compares a switch before and after your work. You won't need it here: the lab runs in Docker, and you can repeat it in two minutes.

You walk ifTable before a maintenance window and again after it, then compare the two walks. Each row carries a number, ifIndex, so you pair the rows by that number.

I built an 8-port switch in a container and did one job on it. I added a VLAN interface and patched a cable into port 6. Then I rebooted the switch, and the diff keyed on ifIndex printed this:

ifIndex 10: new interface, down ifIndex 7 (swp6): link down -> up ifIndex 9 (swp8): link down -> up 

Guess first: how many of these three lines are true? Click for the answer.

One, and by luck. Port 6 did come up, but the diff compared it with swp5, which sits on ifIndex 7 after the reboot and was up all along. Port 8 has no cable, as before. ifIndex 10 belongs to port 8, so nothing new appeared there. The diff also missed the one interface that is new: vlan99 took ifIndex 2 from swp1, and since both were up, the diff saw no change.

In the animation, the left column is the walk before the work and the right column the walk after it:

Animated diagram of two SNMP walks of an 8-port lab switch. Before the work, swp1 to swp8 sit on ifIndex 2 to 9, and swp6 and swp8 are down. After a new vlan99 interface and a reboot, vlan99 takes ifIndex 2 and every port moves up by one. Pairing rows by ifIndex flags ifIndex 7, 9 and 10 and misses vlan99. Pairing by ifName flags swp6 going from down to up and vlan99 as new.

The lab

The switch is a Docker container with net-snmp 5.9.4 on Alpine 3.22 and eight dummy interfaces, swp1 to swp8. ip link set swpN carrier off stands in for a port with no cable: admin up, oper down. A reboot is a fresh container, and in the second one I created vlan99 before the ports.

On Linux, net-snmp reports the kernel's interface index as ifIndex, and the kernel hands out indexes in creation order. vlan99 got 2, and every port moved up one:

Interface ifIndex before ifIndex after Link before Link after
vlan99 2 up
swp1 2 3 up up
swp2 to swp5 3 to 6 4 to 7 up up
swp6 7 8 down up
swp7 8 9 up up
swp8 9 10 down down

Run the lab yourself: one script, three boots
# Build once: net-snmp with its MIBs and iproute2 on Alpine 3.22 docker build -q -t snmp-lab - <<'EOF' FROM alpine:3.22 RUN apk add --no-cache net-snmp net-snmp-tools iproute2 EOF # One boot of an 8-port switch. $1=vlan-first creates vlan99 before the ports, # $2 lists ports with no cable, $3=recreate deletes swp3 and creates it again. boot() { docker run --rm --network none --cap-add NET_ADMIN snmp-lab sh -c " [ '$1' = vlan-first ] && ip link add vlan99 type dummy && ip link set vlan99 up for i in 1 2 3 4 5 6 7 8; do ip link add swp\$i type dummy; ip link set swp\$i up; done for i in $2; do ip link set swp\$i carrier off; done sleep 2 printf 'agentaddress udp:127.0.0.1:161\nrocommunity public 127.0.0.1\n' > /tmp/snmpd.conf snmpd -C -c /tmp/snmpd.conf; sleep 2 if [ '$3' = recreate ]; then ip link del swp3; ip link add swp3 type dummy; ip link set swp3 up; sleep 10 fi snmpwalk -v2c -c public -Oqs 127.0.0.1 IF-MIB::ifName snmpwalk -v2c -c public -Oqs 127.0.0.1 IF-MIB::ifOperStatus" } boot plain "6 8" # before: swp6 and swp8 have no cable boot vlan-first "8" # after: vlan99 added, swp6 patched, new boot boot plain "6 8" recreate # no reboot: swp3 deleted and created again 

The containers run with --network none, so the lab stays off your network. The first boot prints the switch before the work, the second after it. The third deletes swp3 and creates it again without a reboot.

RFC 2863 allows new numbers after a restart

RFC 2863, section 3.1.5, asks the ifIndex of an interface to stay the same "at least from one re-initialization of the entity's network management system to the next re-initialization". A reboot restarts the agent, and after it the agent may number the interfaces in a new way. My lab shows the Linux case, where the number follows creation order. On a real switch the vendor and the platform decide, so check whether yours keeps ifIndex across reboots before your script relies on it.

Pair ports by ifName

The same two walks, paired by ifName:

ifName swp6: link down -> up ifName vlan99: new interface, up 

Both lines are true. RFC 2863 asks ifName to carry the name the device itself uses for the port, the one you would type at its console. I walk through finding a port's ifIndex by its name on a RouterOS box in a separate post.

The catch: two rows with one name

Without a reboot, I deleted swp3 and created it again. Ten seconds later the walk had two swp3 rows. I cut the lines for the other ports:

ifName.4 swp3 ifName.10 swp3 ifOperStatus.4 down ifOperStatus.10 up 

The old row on ifIndex 4 stayed down, its counter frozen at 162,880 octets, and it was there 60 seconds later. net-snmp keeps a removed interface's row for interface_fadeout seconds, 300 by default. With interface_replace_old yes in snmpd.conf, net-snmp drops the old row as soon as a new interface with the same name appears. My second run with that option showed one swp3, on ifIndex 10.

A diff keyed on ifIndex reads the default case as "port 4 went down, and a new port appeared on 10". A diff keyed on ifName has to notice that two rows share a name and refuse to guess:

ifName swp3: on ifIndex 4, 10, can't pair 

Counters start over on the new number

In the run with interface_replace_old, swp3 moved from ifIndex 4 to 10, and its out counter fell from 162,740 to 140 octets. sysUpTime kept counting from 8.20 s to 20.52 s, so a check for an agent restart found nothing. ifCounterDiscontinuityTime read 0 on the new row. ifLastChange on the new row read 12.03 s, the moment of the re-create.

Subtract the two readings and you get −162,600 octets. A poller that reads a smaller value as a 32-bit wrap adds 2^32 and gets 4,294,804,696 octets in 12.3 seconds: a 2.79 Gbit/s spike on a port that sent 140 bytes. I worked through the wrap arithmetic in ifInOctets vs ifHCInOctets. My rule: when a port's ifIndex changes, start its counters over and don't subtract across the two numbers.

What to pair ports on

Field What I saw in the lab Pair on it?
ifIndex every port moved up one after the reboot ❌ across reboots; fine for snmpget within one session
ifName kept its value across the reboot; two rows for up to 5 minutes after a re-create on default net-snmp ✅ first choice, check for duplicates
ifDescr same text as ifName on Linux ✅ fallback when ifName is empty
ifAlias empty: I set no alias on the lab ports ⚠️ holds what an operator typed, and nothing keeps it unique

How SNMP Inspector pairs ports

My app pairs ports in a before/after job by ifName, then by ifDescr. If a port moved, the verdict reads "The agent renumbered the port" with "ifIndex 7 → 8 · matched by ifName". A name on two rows gets Can't verify and "The port mapping is ambiguous." Inside one recording, the app doesn't subtract counters across two ifIndex values and marks a gap instead. More on the before and after report.

SNMP Inspector is a paid app for iPhone and iPad, one purchase with no subscription: snmpinspector.app.

Tell me in the comments whether a reboot or a firmware upgrade has renumbered ifIndex on your gear, and on which platform.