Changing interface back to eth0 from eth1 in Linux (CentOS/RHEL)

Want to help support this blog? Try out Oh Dear, the best all-in-one monitoring tool for your entire website, co-founded by me (the guy that wrote this blogpost). Start with a 10-day trial, no strings attached.

We offer uptime monitoring, SSL checks, broken links checking, performance & cronjob monitoring, branded status pages & so much more. Try us out today!

Profile image of Mattias Geniar

Mattias Geniar, February 21, 2012

Follow me on Twitter as @mattiasgeniar

If you run a VMware stack and you clone a virtual machine, or you remove a network adapter and add a new one, you will often find that your eth0 device is no longer present but replaced with an eth1 device (or a higher number). That’s because the MAC address of that adapter will have changed, which is what causes the Linux Kernel to assign it a new device ID. If you want, you can change that back.

For CentOS or RHEL systems, find the following file: /etc/udev/rules.d/70-persistent-net.rules. If you have this issue, it should look like this now.

~# cat /etc/udev/rules.d/70-persistent-net.rules 
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x15ad:0x07b0 (vmxnet3) (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:8b:00:1e", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x8086:0x100f (e1000) (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:8b:00:34", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

That file defines two interfaces, with a unique MAC address each. If that eth1 line (the last) contains your active current uplink, you can simply copy the MAC address from there to the first line which defines your eth0. Then delete your eth1 line. The end could look like this. Notice how now eth0 has the MAC address which previously belonged to eth1.

~# cat /etc/udev/rules.d/70-persistent-net.rules 
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x15ad:0x07b0 (vmxnet3) (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:8b:00:34", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

After you’ve made the change, also change the MAC address in your interface configuration at /etc/sysconfig/network-scripts/ifcfg-eth0. Restart your your server so the new device names will be known in your system.



Want to subscribe to the cron.weekly newsletter?

I write a weekly-ish newsletter on Linux, open source & webdevelopment called cron.weekly.

It features the latest news, guides & tutorials and new open source projects. You can sign up via email below.

No spam. Just some good, practical Linux & open source content.