Thursday, 14 September 2017

Goodbye, eth0 - Hello enp4s0?!

Today, I got a small shock whilst installing a few services on a new Ubuntu Server 16 LTS (16.04.3)  instance on an old HP Proliant server we had lying about not doing very much in order to do something more useful with it.

Whilst installing and configuring shorewall (my go-to iptables firewall management tool on Ubuntu), each time I started it, it just stopped all external connectivity, despite having it "correctly configured".

After a few moments, I thought to just check that I did indeed have an eth0 and ran ifconfig - lo and behold, the cryptically name enp4s0 was my Ethernet interface.
/etc/network/interfaces also had an entry for this cryptic new device and lo - but nothing else.
Wait. What happened to eth0?

Changing my eth0 interface definitions in shorewall to enp4s0 quickly got my firewall running as expected.

This is, apparently, is a side-effect of the introduction of systemd (I've never, up until now, understood why everyone seems to hate systemd). This (initially somewhat counter-intuitively, perhaps) is called "predictable network interface names".

In a way it is predictable - such a name will never change as you add and remove (other) NICs - ethn could occasionally change places (chaos ensues!) as you reconfigured NICs in a Linux server. But for those that are used to the single NIC in a system being called eth0, well, it's not at all predictable! What this interface will be called depends on your system, so get used to figuring out what NICs are called before you configure them.

So, if you wonder why your networking is not behaving as expected in more modern Ubuntu server editions (15.x onwards, I believe), check to see what your interfaces are actually called! Knowing where to find out what NIC is what within an OS is useful, no matter what OS it is (Windows servers with multiple NICs can also be a bit of a 'mare).


  1. if edit /etc/default/grub
    find the GRUB_CMDLINE_LINUX and change it to :-

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

    then run

    grub-mkconfig -o /boot/grub/grub.cfg

    your eth0 will be returned to its former glory

    ps/ I do exactly the same job as you ;)

    1. Thank you for this helpful comment :)

      We did recently do something similar on a machine that runs the local electronic textbooks service - it also wasn't using eth0 - in this case, their sysadmin just edited it in the networking file, and Ubuntu seemed to handle it OK - but I prefer your solution!