How can I force an Ethernet port device name to always be Eth0?

I am looking for a solution to the problem one encounters on motherboards with dual Ethernet ports or computers with identical Ethernet interface cards. How can one force a particular adapter port to always be the same device name, e.g. Eth0. In practice, the same port is not assigned the same device name by the kernel on power up, making power failures and remote management problematic.

This is similar to the problem that exists with hard disks. Now one can use the UUID to force that drive to keep the same device name. I'm looking for a similar solution to the Ethernet problem.


With udev you can create a mapping from mac addresses to device names. On my Ubuntu Jaunty system I have a file /etc/udev/rules.d/70-persistent-net.rules that contains lines like this:

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="11:22:33:44:55:66", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

This file was created by my distro, I did not need to change it manually.


create the NIC and open the config file for it, some like /etc/sysconfig/network/ifcfg-eth1 or 2 or 3. in the file will be something like hardware="00:11:22:33:44:55" this is the MAC address of the card. rename the file to ifcfg-eth0 and make sure that it contains this line, this will make sure that this NIC is always eth0. if ifcfg-eth0 already exists then you will need to rename this too to something like ifcfg-eth1.