How do I keep my network interface indexes constant?

Asked by Christian Reis on 2007-09-21

My SNMP interfaces keep getting reordered. How do I get them to stop moving around? It causes me a lot of mrtg pain.

kiko@anthem:~$ snmpget -v 1 -c public anthem ifDescr.2
IF-MIB::ifDescr.2 = STRING: eth1
kiko@anthem:~$ snmpget -v 1 -c public anthem ifDescr.3
IF-MIB::ifDescr.3 = STRING: eth0
kiko@anthem:~$ snmpget -v 1 -c public anthem ifDescr.4
IF-MIB::ifDescr.4 = STRING: eth2

Question information

English Edit question
Ubuntu net-snmp Edit question
No assignee Edit question
Solved by:
Christian Reis
Last query:
Last reply:

This question was reopened

Launchpad Janitor (janitor) said : #1

This question was expired because it remained in the 'Open' state without activity for the last 15 days.

Christian Reis (kiko) said : #2

So, I dug up a solution to this today...

Christian Reis (kiko) said : #3

There are a couple of problems at play here:

  - Interface numbers (eth0, 1, 2) used to get reshuffled in kernel updates; this was poorly fixed by ifrename, and now properly by udev's persistent numbering.
  - snmpd just reads the interfaces in whatever order they appear in /proc/net/dev
  - that order is kernel-specified but not modifiable

Luckily, my original problem was fixable: the reason I was annoyed with snmpd was mrtg, since I used the absolute indexes to the network devices. Turns out you can specify network interfaces in other ways:

I changed my entries that said:


to now say:


And guess what?

Christian Reis (kiko) said : #4

BTW, this is what my /proc/net/dev looks like:

Inter-| Receive | Transmit
 face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
    lo:1626546420 4596708 0 0 0 0 0 0 1626546420 4596708 0 0 0 0 0 0
  eth2:1959129502 1979899 0 0 0 0 0 0 268085627 1666122 0 0 0 0 0 0
  eth1:890039027 54678358 0 0 0 0 0 934 2656517748 61679003 0 0 0 0 0 0
  eth0:449812459 1841278 0 0 0 0 0 0 1348959754 2035242 0 0 0 0 0 0

So as you can see, trusting that order is madness. eth2 is a 3com; eth1 is an e1000; eth0 is an e100.

Paulo Estrela (paulojbe) said : #5

I'm having the same issue, but I'm not using MRTG. I think this should remain static across reboots.

Christian Reis (kiko) said : #6

On Tue, Mar 25, 2008 at 07:08:43PM -0000, Paulo Estrela wrote:
> I'm having the same issue, but I'm not using MRTG. I think this should
> remain static across reboots.

Are you talking about static in the SNMP order, or something else?

Paulo Estrela (paulojbe) said : #7

Yes. I have a proxy box that has 3 interfaces. eth0 (onboard interface) is connected local network, eth1 is connected to adsl router 1, eth2 connected to adsl router 2. Using snmpwalk, ifDescr.2 is eth2, should be eth1 and vice-versa. My /proc/net/dev looks like yours.

Paulo Estrela (paulojbe) said : #8

I would like to know why /proc/net/dev is not ordered by interfaces name.