How to change network interface names permanently in Linux

Question: I want to change a network interface name (e.g., "eth0") to something else on my Linux. What is a proper way to rename network interfaces on Linux?

In Linux, device name management is handled by udev system. When Linux kernel discovers a new device (e.g., a network interface card) added to the system, it notifies udev daemon of the device event. The udev daemon will then match various device attributes against a set of rules to identify the device, name it, and store its information in udev database.

In case of network devices, udev relies on MAC addresses to assign persistent names to the devices. The MAC address based naming rules are stored in /etc/udev/rules.d/70-persistent-net.rules.

In order to change a network device name, you can thus edit /etc/udev/rules.d/70-persistent-net.rules. If there is no such file, you can create one yourself.

In /etc/udev/rules.d/70-persistent-net.rules, you can assign an arbitrary device name to a particular MAC address. Thus, first find out the MAC address of your network interface, and then define the interface name to that MAC address in the following format.

$ sudo vi /etc/udev/rules.d/70-persistent-net.rules
# interface with MAC address "00:0c:29:43:28:11" will be assigned "eth0"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:43:28:11", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# interface with MAC address "00:0c:29:43:28:1b" will be assigned "eth1"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:43:28:1b", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

After editing /etc/udev/rules.d/70-persistent-net.rules, reboot your machine to activate the interface name change.

Subscribe to Ask Xmodulo

Do you want to receive Linux related questions & answers published at Ask Xmodulo? Enter your email address below, and we will deliver our Linux Q&A straight to your email box, for free. Delivery powered by Google Feedburner.

2 thoughts on “How to change network interface names permanently in Linux

  1. Well, actually changing interface names is bad, the old convention is absurd.. The best way (and it is implemented right now in modern Linux distros) is assignment of interface names based on physical location on the bus. So even if you change your NIC, you can retain the same configuration as long as your slot is the same. As a network administrator I found this pretty cool and useful.

    Also there are IP utils and they are awesome. ifconfig, vconfig, etc are just plain old and stupid. Also sometimes you don't have vconfig installed, but IP stack utils are always there.

    P.S. Ubuntu is not a modern distro and will never be.

    • "P.S. Ubuntu is not a modern distro and will never be."
      Could you maybe try to sound like more of an elitist c unt here?

      You sound like a pompus ass with a serious god complex, your rate of turn overs pretty high for underlings I bet.

Leave a comment

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