Networking HowTos
Networking HowTos

Changing network interface numbers on Ubuntu

April 15, 2012 Linux, Ubuntu

Have you ever replaced a network card on Ubuntu and found that it is now appearing as eth1, instead of eth0? Or simply wanted to swap the numbering of two network interfaces? This guide shows you how to do just that.
Ubuntu uses the udev dynamic device management system, and automatically keeps track of what net card is assigned to what interface name.
Udev allows for device name persistance using rule files, which are stored in “/etc/udev/rules.d/”.
“70-persistent-net.rules” is the file that contains the persistance rules for network devices.
Open this file in your editor of choice.

$ nano /etc/udev/rules.d/70-persistent-net.rules

It should look something like this:

# 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 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:31:44:9e", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:31:44:a8", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

This indicates that the network card with the MAC address of “00:0c:29:31:44:9e” will always be assigned to “eth0” and “00:0c:29:31:44:a8” will always be assigned “eth1”.
You can simply swap eth0 and eth1 around, if you have two network cards in use.
If you only have the one network card (due to replacing a old one for example), you can simply delete the lines referring to the old card, and rename the new card to the correct “eth#” number.
Save the file and exit the editor.
Reboot the computer for the changes to take effect.

You Might Also Like