Network OID/MIB Changes on reboot

We are fairly new to LXC, moving from OpenVZ.

We monitor network traffic to the containers using SNMP. What we are finding though is on every reboot, the OID for the network device changes. Once this happens, the monitoring breaks becuase it is checking the wrong OID. Example, pre-reboot:

root@witness:~# snmpwalk localhost -v 1 -c rogot .
iso. = STRING: “lo”
iso. = STRING: “eth0”

And then after a reboot

root@witness:~# snmpwalk localhost -v 1 -c rogot .
iso. = STRING: “lo”
iso. = STRING: “eth0”

You can see that the last number for the identifier changes from 17 to 19. And after each reboot, it increments by 2.

Is there some way I can stop this behavior?

I don’t think so. You’ll notice that the number comes from the VETH pair created to manage network connectivity (you can see it by running ip addr on the host before and after restarting a container) and the ifindex is set by the kernel without any possibility of user configuration.
This is the age-old problem of ifindex persistence.
If you use a standard monitoring tool like Icinga I think it’s possible to monitor with the interface name instead of the index.

Well, this is unfortunate to hear. We can’t change monitoring systems.

what monitoring system are you using?

PRTG by Paessler

How about this ?

snmpwalk le -v 1 -c public .
IF-MIB::ifIndex.1 = INTEGER: 1
IF-MIB::ifIndex.35 = INTEGER: 35
IF-MIB::ifDescr.1 = STRING: lo
IF-MIB::ifDescr.35 = STRING: eth0

in the previous quote ‘le’ is an Ubuntu 18.04 LTS container, so the ifDescr field is available for your monitoring system.

FYI the Paessler KB is also as an issue reporting tool, so you can ask if you don’t find what you want in the query engine.