Virtual Machine Ethernet Interface Keeps Incrementing eth0 eth1 eth2 etc

Written by James McDonald

July 24, 2011

How to set your Ethernet card back to eth0

I have a Ubuntu 9.04 JEOS (Just Enough OS) Virtual Machine running under Virtualbox. I have upgraded my host machine several times, converted the VM from VMWare to Virtualbox, moved the VM from one disk to another, created a new Virtualbox machine and added the U9.04JEOS VM’s harddisk file (*.vdi) without also using the original VM configuration file. So it’s understandable that the VM might become confused as to which Ethernet NIC it’s currently using.

Each time you boot a VM and the MAC address of the Virtual Ethernet Card (NIC) changes udev writes a new rule into /etc/udev/rules.d/70-persistent-net.rules and increments your network card number. I got up to eth5 before I got sick of editing /etc/network/interfaces to change the card name each time. I would prefer that the NIC stays at eth0

So to get it all back to the default of eth0 I did the following.

From inside your running VM firstly do an ifconfig to find out the current ethernet cards MAC Address.

jimmy@mybox:~$ ifconfig -a | grep HWaddr
eth5      Link encap:Ethernet  HWaddr 08:00:27:68:99:26  

Open /etc/udev/rules.d/70-persistent-net.rules and identify the line that matches the MAC Address for your currently installed Virtual Ethernet Card. Edit this line to make it eth0. Comment all other lines out using the # symbol as below.

# 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 0x1022:0x2000 (pcnet32)
#SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:9b:44:5a", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x1022:0x2000 (pcnet32)
#SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:85:99:8a", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

# PCI device 0x1022:0x2000 (pcnet32)
#SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:c7:56:74", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"

# PCI device 0x1022:0x2000 (pcnet32)
#SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:4f:fd:97", ATTR{type}=="1", KERNEL=="eth*", NAME="eth3"

# PCI device 0x8086:0x100e (e1000)
#SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:40:2e:ab", ATTR{type}=="1", KERNEL=="eth*", NAME="eth4"

# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:68:99:26", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

If you have a statically assigned IP address edit /etc/network/interfaces to make it eth0 again.

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface

#auto eth4
#iface eth4 inet dhcp

auto eth0
#iface eth2 inet dhcp
iface eth0 inet static

Then reboot.


Submit a Comment

Your email address will not be published. Required fields are marked *

You May Also Like…

How to Research a CPU Upgrade

How to Research a CPU Upgrade

Upgrade Time! Doing a lot of VMWare Workstation virtualization to create labs for self-study and training. Finding...