Persistent interface names

Network card

After upgrading to Debian Stretch from Jessie, I finally got to see the new interface naming scheme in action. This is a short document on how to revert to the old naming scheme and also, how to play along and predict the interface names of your newly upgraded system.

You might think, who cares, or why would I need to care? Well, it depends on your system and how you manage it. When you have some/a lot of scripts depending on the network interface name, it might be easier to rename the interface to the previous naming scheme (ethx).

The new (well, new to Debian users upgrading from stable) naming scheme might produce interface names such as enp0s3 or enp0s3. Quite different from the ethx form.

In case you want to revert to the old scheme, you will need to set-up a custom udev rule.

1. Custom udev rule

Create a file in /etc/udev/rules.d, for instance 010_interface.rules:

vi /etc/udev/rules.d/010_interface.rules

Put the interface mac in there, with the name you want the interface to have:

SUBSYSTEM=="net", DRIVERS=="?*", ATTR{address}=="00:11:22:33:44:55", NAME="eth0"

Reboot the system to load the new name(s).

Check with ip a or ifconfig.

2. Using the new scheme

2.1. Determine the interface names

If you don't want to go back to the old naming scheme, you can get udev to predict the new names for you, after you have updated your system to use a newer udev:

udevadm test /sys/class/net/eth0 2>/dev/null | grep ID_NET_NAME

Do this for all interfaces. If the previous line gives you have multiple possibilities, what devicename will udev choose? It will pick one of the following, with the first lines having a higher priority then the lower lines:


During the time of writing this article, on my test server the name given was the ID_NET_NAME_SLOT name.

2.2. udev

On my systems the /etc/udev/rules.d/70-persistent-net.rules didn't exist. If it exists, it might change the name of the interfaces to another name. If you prefer that you could change or create this file to rename the interfaces.

Move the file to use the new behaviour.

2.3. Change scripts

Change all relevant script to match the new names. For instance, to find the files using eth0 in /etc:

grep -r eth0 /etc

Those files could be:

  • firewall script if any
  • saved firewall rules (for instance /etc/iptables.up.rules)
  • interface file (vi /etc/network/interfaces)
  • find relevant files to change: grep -r eth0 /etc

2.4. systemd

Next move the file in /etc/systemd overriding the default policy:

mv /etc/systemd/network/ /root
update-initramfs -u

After reboot, and if you use iptables-save, you might want to save the iptables rules again:

iptables-save > /etc/iptables.up.rules

3. Using the old scheme

You can disable these stable names and go back to the kernel-provided ones.

3.1. net.ifnames=0

Change the kernel line in the grub default file:

vi /etc/default/grub