Clean up legacy network interface naming

Written in the mid-afternoon in English • Tags: , , ,

Predictable network interface names are all the rage in Linux distros these days. My systems are of various vintage so most have carried on with eth0 and eth1 through upgrades by having old udev rules kept around.

To get with the times a few steps are needed:

udevadm test-builtin net_id /sys/class/net/eth0

vi /etc/network/interfaces
vi /etc/dhcp/dhclient.conf

vi /etc/default/isc-dhcp-server

vi /etc/vnstat.conf
service vnstat stop
mv /var/lib/vnstat/{eth0,enp2s0}

There might be other files that need editing as well, so it might be a good idea to check carefully before rebooting:

grep -r eth0 /etc

Remove udev rules and update initrd as interface renaming happens early:

rm /etc/udev/rules.d/70-persistent-net.rules
update-initramfs -u

Check that you are not using the net.ifnames=0 kernel argument:

vi /etc/default/grub
update-grub
reboot

Some services may need further care once network interfaces are up with their new names:

service vnstat stop
vnstat -u
service vnstat start

It’s a good idea to look around (e.g. /var/log/syslog) to see if anything is amiss.

Add a comment