[olug] network devices spontaneously swapping in Fedora and probably a few other distros

Lou Duchez lou at paprikash.com
Fri Jul 12 14:34:05 UTC 2013

My trusty Linux router started acting up after a power outage last 
night, where it started spontaneously swapping network devices -- eth0 
started getting assigned to eth1 and eth1 started getting assigned to 
eth0.  That shouldn't be happening, I thought ... except, it turns out, 
it should.

Here's the deal.  System names get assigned semi-randomly, according to 
which devices are discovered first.  udev allows for "locking" device 
names on your computer, and in particular you can lock network adapter 
names in the file /etc/udev/rules.d/70-persistent-net.rules .  So if you 
set up your /etc/udev/rules.d/70-persistent-net.rules it might look 
something like this:

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", 
ATTR{address}=="00:18:8b:28:da:b4", ATTR{type}=="1", NAME="eth0"

Basically it's saying: if you find a device with an address of 
"00:18:8b:28:da:b4", make sure to assign it the name "eth0".

SYSTEM NAMES.  Linux will smile and nod when it reads that line I put 
into 70-persistent.net.rules, but it won't act on it, because Linux has 
its own ideas about eth0.  In other words, you should assume you have 
zero control over eth0, eth1, and so on.  Here is a semi-official 


So, what can a person do?  Well, the most reliable recourse is to use 
udev to assign your own custom names, and then use those custom names in 
the rest of your configuration.  So change "eth0" to "myeth0" (or 
whatever) in 70-persistent-net.rules:

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", 
ATTR{address}=="00:18:8b:28:da:b4", ATTR{type}=="1", NAME="myeth0"

Then further steps:

-    In /etc/sysconfig/network-scripts, rename ifcfg-eth0 to ifcfg-myeth0.

-    Edit ifcfg-myeth0 so it contains this line:


-    Do your iptables or other firewall rules make explicit mention of 
eth0 or eth1?  Fix 'em.

-    How about your DHCP -- is it tied to eth0 or eth1?  You know what 
to do.

And by the way, this is also an issue with hard drives -- just having a 
USB drive plugged in at boot time could be enough for your system to 
misdiscover your drives.  This was discussed a long time ago right here 
on OLUG (the very issue that caused me to discover OLUG in fact).  To 
nail down your drive AND its partitions, do something like this:

KERNEL=="sd[a-z]",      SUBSYSTEM=="block", 
ENV{ID_SERIAL}=="3600508e000000000ebf986dc63d2910f", SYMLINK+="bootdrive"
KERNEL=="sd[a-z][1-9]", SUBSYSTEM=="block", 
ENV{ID_SERIAL}=="3600508e000000000ebf986dc63d2910f", SYMLINK+="bootdrive%n"

And to figure out what the ID_SERIAL is, run this:

udevadm info --query=env --name=sda | grep ID_SERIAL=

More information about the OLUG mailing list