Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am in the process of upgrading a legacy system from RHEL 5.4 to 5.8. There are three NICs installed, each with defined IP addresses and attached wiring.

After the upgrade, the cards are on the same PCI addresses but the OS has shuffled the NIC designations:

network old  new
net A   eth0 eth1
net B   eth1 eth2
net C   eth2 eth0

The PCI addresses in use are 05.03.0 for Net C and the other two are on 03.03.0 and 03.03.1.

There is no /etc/udev/rules.d/70-persistent-net.rules file.

Is there a way to specify which PCI addresses are used for each interface?


I have found /etc/sysconfig/hwconf and /etc/sysconfig/network-scripts/ifcfg-eth? files that contain the IP and MAC address values. hwconf also specifies the PCI address, but seems to get re-written on boot.

I would prefer to be able to specify the NICs by PCI position as this is effectively what is used to determine the behaviour rather than MAC address which would be changed if a different card was used.

share|improve this question
i've added info about persistent naming by PCI address. see "3." in my answer. – cas Sep 1 '12 at 1:30
up vote 4 down vote accepted

This is generally done by MAC address, not PCI address.

  1. If RHEL 5.8 supports the /etc/udev/rules.d/70-persistent-net.rules file, you could create one.

    Just copy one from another machine and edit it so that the correct device name is assigned based on MAC address.

    All you really need in that file is 3 lines like this one: (ignore any line-wrapping, this is all one line)

    SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:23:cd:b0:23:b9", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

    Change the ATTR{addresss} and NAME="eth[012]" to suit your NICs and your requirements.

    I'm not sure if RHEL 5.4 or 5.8 has it, but it might be worthwhile checking to see if you have a script called /lib/udev/write_net_rules - if you have, just run it, it will generate the 70-persistent-net.rules file, so just edit the NAME for each NIC.

    You can get the MAC addresses with ifconfig | grep 'eth.*HWaddr', then just copy-paste them into the 70-persistent-net.rules file.

    When that's done, you can either reboot, or down all your interfaces, unload their kernel driver modules, reload the modules (the interfaces will now have their assigned device names), and then bring your interfaces back up.

  2. Before udev and the 70-persistent-net.rules file, I used to use a program called ifrename from the wireless-tools package (it works on any NIC, not just wireless). It uses an /etc/iftab file to rename network interfaces by MAC address. It mostly worked, but was less reliable than the udev method.

    I have no idea if it's packaged for RHEL or not but you can find it at http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html

  3. I haven't used this method for a NIC myself, but it is also possible to use udev to persistently name devices based on PCI address. First, delete the /etc/udev/rules/70-persistent-net.rules if it exists. Then create a new file in /etc/udev/rules - perhaps call it 70-persistent-net-by-pci.rules

    Add lines like the following:

    ACTION=="add", SUBSYSTEM=="net", BUS=="pci", KERNELS=="0000:03:03.0",    NAME="eth0"
    ACTION=="add", SUBSYSTEM=="net", BUS=="pci", KERNELS=="0000:03:03.1",    NAME="eth1"
    ACTION=="add", SUBSYSTEM=="net", BUS=="pci", KERNELS=="0000:05:03.0",    NAME="eth2"

    On some newer Linuxes (e.g. Ubuntu 13.04 or later) you need to remove the BUS qualifier, so the rule(s) should look like:

    ACTION=="add", SUBSYSTEM=="net", KERNELS=="0000:03:03.0",    NAME="eth0"

    Then either reboot or unload & reload the driver modules as described above.

    You can find more details at http://linux-tips.org/article/73/persistent-device-naming-with-udev - but the page is fairly old and refers to the obsolete udevinfo command. Use udevadm info instead

share|improve this answer
3 does the trick. thanks – DanS Sep 6 '12 at 7:58
Using the udev/rules.d I also need to remember to remove the HWADDR line from /etc/sysconfig/network-scripts/ifcfg-eth* files. – DanS Sep 6 '12 at 15:45

On RedHat 5 the MAC and interface-name should be enough. I never fiddled with udev or PCI-designators there.

Set HWADDR to the MAC and DEVICE to the target device name.

As for the name in /etc/sysconfig/network* you can use a meaningful alias for the configuration-names ifcfg-ALIAS.

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.