keeping eth0 as ETH0.
July 7th, 2012 by Andrea Matesi 156 ViewsIntro.
Sometimes the easiness to add/remove hardware components with virtualization brings plenty of confusion with Linux ethX interfaces.
Someday, I removed a network interface from a VM, then I added another I/F and what happened was that my new I/F got the "eth1" name tag (instead of the expected eth0).
The Easy solution.
To prevent this from happening again, the easiest thing to do, before shutting down the VM, is:
rm -f /etc/udev/rules.d/70-persistent-net.rules
Then you can shutdown your VM and remove your virtualized eth I/Fs safely.
Once you add a new eth I/F and boot your Linux system, this new I/F will automatically get the "eth0" name.
The Radical solution.
What if you wish to "fix the elections?" (ie. make sure your actual eth0 stays always ETH0, no-matter-what).
The first thing would be to find what driver is used by your eth interface with ethtool:

ethtool -i eth0
In this case the result you'd be interested would be the driver (ie. "hv_netvsc" or "e1000").
Next you'll have to find your I/F's MAC Address, which is usually just a matter of running ifconfig eth0:

ifconfig eth0
Take note of your driver and MAC Address.
Now you'll need to edit some files.
The first one is the persistent network rules from udev.
On CentOS 5.x the file was /etc/udev/rules.d/60-net.rules, on CentOS 6.x it is /etc/udev/rules.d/70-persistent-net.rules
Open it up with your favourite editor, then make sure it is similar to the following:
# eth0 = intel e1000
KERNEL=="eth*", SYSFS{address}=="00:0d:60:aa:bb:cc", NAME="eth0"
(from one of my SRC -- check below):"…Note that in the MAC address, the hexadecimal digits should be in lowercase, otherwise udev fails to match them properly with the network interface."
Then edit /etc/modprobe.conf and specify an alias which relates your driver to eth0 like so:
# intel e1000 alias (specify driver name)
alias eth0 e1000
Edit also the following:
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/sysconfig/networking/devices/ifcfg-eth0
/etc/sysconfig/networking/profiles/default/ifcfg-eth0
And make sure the "HWADDR=00:0D:60:84:6A:DF" statement contains your I/F's MAC Address. This way, if the devices are swapped, you'll receive an error.
That would be all.
SRC:
http://www.debianadmin.com/rename-network-interface-using-udev-in-linux.html
http://www.cyberciti.biz/faq/rhel-fedora-centos-howto-swap-ethernet-aliases/
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/86437/comments/3
http://www.centos.org/modules/newbb/viewtopic.php?topic_id=16094&forum=40&post_id=58600
http://wiltonsoftware.com/posts/view/find-your-ethernet-driver-under-debian
Posted in LINUX, System Administration | No Comments »