The default names given to network interfaces on a Linux machine are not all that useful. Often they’ll be called something like eth0 or p4p1, but what if you are setting up a router and want to call them something more sensible like lan and wan. Luckily with udev and a bit of kernel tweaking that is possible. There are a few guides around online but none of them seem to pull all the steps together so I’m doing that here.

Add the udev rules

Edit the file at /etc/udev/rules.d/70-persistent-net.rules adding a line for each interface that you want set the name for that looks like this

SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="xx:xx:xx:xx:xx:xx", NAME="newname0"

replace the address towards the end with the MAC address of the interface. The name can be whatever you choose.

Allow the names to be set

Edit /etc/default/grub adding the kernel parameters net.ifnames=1 and biosdevnames=0 to allow the new names to be applied. My file looks like this

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

Don’t forget to apply the changes with update-grub.

Update network config

Don’t forget to edit /etc/network/interfaces or /etc/netplan/whatever replacing the old interface names with the new ones.

Reboot

Reboot the machine and with a bit of luck the new names will show up in ifconfig.