Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

We are using OpManager to montior interface devices on remote linux boxes. These boxes have VLANs that we use to collect information about the networks that are being trunked to the boxes. For example we have eth0.2, eth0.3, eth0.12, eth0.13, eth0.22, eth0.23 (corrisponding to vlans 2,3,12,13,22,23 respectively).

We are using SNMP on a management IP address to check and make sure the interfaces are up. However, we run into an issue with the interface indexes changing if we have to restart the networking service. We will get error messages like:

Interface 'eth0.23 - eth0.23' is shutdown. Interface description is 'eth0.23' and index is 11. Circuit ID not configured.

Even though the interface is up and running.

How can we change the index values to be persistent through reboots. We have seen this if we change an interface from static IP to dynamic as well.

share|improve this question

2 Answers 2

up vote 5 down vote accepted

Short answer, the SNMP RFCs do not require ifIndex persistence between network manager reinitialization. net-snmp does not provide any special facility to provide this functionality.

From RFC 2863:

The requirement for constancy (between re-initializations) of an interface's ifIndex value is met by requiring that after an interface is dynamically removed, its ifIndex value is not re-used by a different dynamically added interface until after the following re-initialization of the network management system.

The takeaway is that ifIndex entries are explicitly allowed to be used for any interface when the system is re-initialized (i.e. rebooted).

From the Linux kernel (net/core/dev.c):

static int dev_new_index(struct net *net)
    static int ifindex;
    for (;;) {
        if (++ifindex <= 0)
            ifindex = 1;
        if (!__dev_get_by_index(net, ifindex))
            return ifindex;

The ifindex allocation within the kernel uses a simple incrementation algorithm. This is relevant because in net-snmp (agent/mibgroup/if-mib/data_access/interface_ioctl.c):

netsnmp_access_interface_ioctl_ifindex_get(int fd, const char *name)
    return 0;
    struct ifreq    ifrq;
    int rc = 0;

    DEBUGMSGTL(("access:interface:ioctl", "ifindex_get\n"));

    rc = _ioctl_get(fd, SIOCGIFINDEX, &ifrq, name);
    if (rc < 0) {
                   "ifindex_get error on inerface '%s'\n", name));
        return 0;

    return ifrq.ifr_ifindex;
#endif /* SIOCGIFINDEX */

This function ends up being called to populate the ifindex, and it simply uses the IOCTL interface to retreive the SIOCGIFINDEX value from the Linux kernel.

When I ran into a problem of this nature with an SNMP based monitoring system, I ended up using an alternative means to reference the network interfaces. In particular, I used the interface name instead of the interface index number (i.e. "eth0", "eth1", "vlan150", etc.).

share|improve this answer
Thanks for the explaination, that makes alot of sense. I will need to look at an alternative method as well. – jinanwow Aug 6 '10 at 4:27

You can think of using if_indextoname(index_val, index_name). Where index_val is of unsigned int type and index_name is of char * type.

Pass the index_val and linux kernel will map it to correct index_name which you can use in your code as index_name is same across reboots.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.