Changing network device names

The latest versions of the kernel now rely on the BIOS enumeration of device names which means that the name of the network interface can change depending on your bus configuration (specifically where your network interface is connected).

The new naming convention may appear very odd but it is logical once you understand how it works. Wired network interfaces will start with en and wireless interfaces will start with wl, but then it gets a bit strange. Depending on your system’s hardware configuration this can be followed by a p followed by a number indicating which PCI bus it is on; and/or an s followed by a number which indicates which slot the device is in; or an o followed by a number if it is an on-board device. There may also be an f followed by a number if there are multiple interfaces on the same card.

What can make it confusing is that just because your machine has two interfaces on the motherboard it does NOT mean that they are going to be on-board devices, as the device names will depend on how the motherboard is designed. In practice they may not even be on the same PCI bus!

If you don’t like your machines having device names that depend on the hardware you can continue to use the old network device names by passing a couple of parameters to the kernel when your system boots.

To do this you need and edit /etc/default/grub as a superuser using your favourite editor (or what ever you have installed – I’ve chosen vi as it is almost always available), and add net.ifnames=0 biosdevname=0 to the kernel parameters.

# vi /etc/default/grub

Generally I prefer to comment out the original line before making any changes, as I’ve done here.

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

Then you need to update grub. If you are using a Debian or a related distribution like Ubuntu then you need to use update-grub to do this.

# update-grub
Generating grub configuration file …
Found linux image: /boot/vmlinuz-4.9.0-3-amd64
Found initrd image: /boot/initrd.img-4.9.0-3-amd64

Alternatively if you are using a RedHat or a related distribution like CentOS then you need to use grub2-mkconfig.

# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file …
Found linux image: /boot/vmlinuz-4.9.0-3-amd64
Found initrd image: /boot/initrd.img-4.9.0-3-amd64

You will also need to update the network device names. If you are using a Debian based system you will need to edit /etc/network.interfaces.

# vi /etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
# allow-hotplug ens33
allow-hotplug eth0
# iface ens33 inet dhcp
iface eth0 inet dhcp 

If you are using RedHat or CentOS you will need to rename and edit the interface specific files in /etc/sysconfig/network-scripts.

# mv /etc/sysconfig/network-scripts/ifup-ens33 \
> /etc/sysconfig/network-scripts/ifup-eth0
# vi /etc/sysconfig/network-scripts/ifup-eth0

# DEVICE=ens33

Then you will need to reboot for these changes to take effect.

# reboot


This entry was posted in CentOS, Debian, Linux, Networking, RedHat, Ubuntu and tagged , . Bookmark the permalink.