User Tools

Site Tools


Renaming network interfaces

With Debian 10 Buster

According some sources, there is at least two methods to rename a network interface e.g. from enx00e04c885302 to something more human like lan0 or the plain old eth0.

The simplest method should be to add a line into /etc/network/interfaces (or to create a new file /etc/network/interfaces.d/local) with the following:

rename enx00e04c885302=lan0

Another methos should be to create a file /etc/systemd/network/ (one file for each interface to be renamed) with something like this:


The systemd method has a problem if you need to create a VLAN. When the system creates e.g. the lan.602, its MAC address matches the systemd snippet, so systemd tries to assign to it the name lan but the name already exists, so the interface remains with a temporary name e.g. rename5.

A workaround can be the following: tell the kernel to use the old eth0 schema (passing the net.ifnames=0 option), then instruct systemd to act only on eth* network interfaces:


NetworkManager interfering with rename

Both methods seen above seem to work, unfortunately on my XFCE environment, the NetworkManager stepped into the play, reverting back the name:

NetworkManager[581]: <info>  [1620916630.3558] device (eth0):
   interface index 10 renamed iface from 'eth0' to 'enx00e04c885302'

If you want to manage the interface using NetworkManager from the user session, be sure that the interface is not referred by /etc/network/interfaces or any snippet file into /etc/network/interfaces.d/. If the interface is configured by /etc/network/interfaces, NetworkManger will ignore it, labelling as unmanaged.

Use the old naming schema (eth0, ...)

If you want to use the old naming schema (eth0, eth1, …) enable the kernel override option in /etc/default/grub:

GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"

Followed by update-grub and reboot.

Beware that by using that schema the card's assigned name depends upon the time when the kernel discover the interfaces, in some cases you may find the names swapped after a reboot, even if the Ethernet cards are fixed built-in.

How it worked in the old days of Debian 4 Etch

In a modern Linux system, network interface drivers are compiled as modules. Generally there is a subsytem that provides loading kernel modules automatically. Debian GNU/Linux Etch uses udev for that.

Interface names (eth0, eth1, …) are assigned as they are discovered and kernel modules are loaded, unfortunately the order of discovering can sligtly vary across reboots. So you can find that after a reboot your system has swapped eth0 and eth1, with all the nasty consequences you can imagine.

I suggest two ways to assign interface names in a consisten way.


In a Debian Etch box, check the /etc/udev/rules.d/z25_persistent-net.rules. This file is updated at bootstrap when new network interfaces are found. It contains a persistent mapping of MAC addresses to interface names.

In general, add a custom configuration file /etc/udev/rules.d/010_netinterfaces.rules with lines like this:

KERNEL=="eth*", SYSFS{address}=="00:12:34:fe:dc:ba", NAME="eth0"

In the above example we used the SYSFS{address} as a match for the rule, use this command to print all sysfs properties of the specified device that can be used in udev rules to match the specified device:

udevinfo -a -p /sys/class/net/eth0


You configure this userspace program writing the configuration file/etc/iftab:

# Example /etc/iftab file
eth2           mac 08:00:09:DE:82:0E
eth3           driver wavelan interrupt 15 baseaddress 0x390
eth4           driver pcnet32 businfo 0000:02:05.0
# wildcard name: pick the lowest available name of air0, air1, air2, etc.
air*           mac 00:07:0E:* arp 1

The good thing of this program is that you can select intefaces by the name of the kernel module, by MAC address, by bus position and other methods. But beware that the standard Debian startup of ifrename runs the program once, when all the interfaces are already discovered and named. In this case it is not possible to swap two interface names, because when you try to rename the first interface, an error occurr: Error: cannot change name of eth1 to eth0: File exists.

Debian 8 Jessie

The udev cache file is named now /etc/udev/rules.d/70-persistent-net.rules, sometimes only one Ethernet card is automatically added to this file, some other times the cache file is not created at all.

To force the creation of that file just execute the command:

udevadm trigger --action=add

Debian 9 predictable network interface names

Esempio: enp3s0f1

  • en Ethernet network card
  • p3 PCI bus #3
  • s0 Slot #0
  • f1 Function #1 (eg. a dual porta LAN has two functions).

Per disabilitare questa funzione, chiamata Predictable Network Interface Names è possibile aggiungere l'opzione kernel net.ifnames=0 ad esempio in /etc/default/grub, opzione GRUB_CMDLINE_LINUX.

Se è installato la helper utility di udev chiamata biosdevname, è opportuno passare al kernel anche il parametro biosdevname=0.

Avendo attivato l'opzione net.ifnames=0 può essere comunque desiderabile una persistenza nell'assegnare il nome all'interfaccia , considerato che il kernel assegna i nomi legacy eth0, eth1, etc. in base all'ordine di rilevamento hardware, che è non deterministrico. È possibile quindi creare un file /etc/udev/rules.d/70-network.rules con l'assegnamento statico in base al MAC address, ad esempio

SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="00:30:67:9a:75:0b", NAME="eth0"
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="00:18:e7:22:0b:f7", NAME="eth1"

Debian 9 Network Interface Naming

doc/appunti/linux/sa/if_rename.txt · Last modified: 2021/12/13 09:38 by niccolo