Linux network interfaces are named emX and enX instead of ethX

Written by - 0 comments

Published on - last updated on April 17th 2024 - Listed in Linux Network Systemd


Today I manually installed a new Ubuntu 14.04 LTS server on a HP Proliant DL 380 Gen8 server. To my big surprise the network interfaces were detected as "emX" rather than "ethX" during the setup process:

Ubuntu naming interfaces em

Use BIOS dev name as interface name

The reason for this is a changed naming convention in the naming of network interfaces. It seems that Ubuntu has decided to go the same way as Fedora for the interface naming.

In one way it makes sense to call the onboard nics "em" (for embedded) to separate onboard and additional nics. But this can also lead to unexpected errors as there are many scripts to configure nics which use static naming, for example "ifconfig eth2".

The change of the interface names is coming from the biosdevname naming convention. As the Red Hat documentation describes it:

 Device  Old Name
 New Name
 Embedded network interface
eth[012345...] em[123456...]
 PCI network card
eth[012345...] p<slot>p<port>
 Virtual
eth[012345...] p<slot>p<port>_<virtual interface>

The obvious advantage: The interface order is better detected and remains stable across reboots - while (theoretical) the older ethX naming could change for each interface after a reboot (mostly did not though).

Different interface naming styles across Linux distributions

In the meantime other naming styles have appeared.

  • On my physical workstation I can see the onboard NIC being named enp3s0.
  • On virtual machines using newer Ubuntu distributions the interfaces are often named eno160 or eno192.
  • On some CentOS VM's I even spotted interfaces with names such as eno16777984.

I agree, this can be quite confusing.

How to revert back to the ethX naming convention

To revert back to the previous naming style (using eth0, eth1, etc) you can add the biosdevname Kernel option to your boot command line (usually in /etc/default/grub) and set it to 0 (default is 1 for enabled).

ck@mint ~ $ cat /etc/default/grub | grep CMDLINE
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash biosdevname=0"
GRUB_CMDLINE_LINUX=""

Followed by a Grub update:

ck@mint ~ $ sudo update-grub
[sudo] password for ck:       
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/50_linuxmint.cfg'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.15.0-75-generic
Found initrd image: /boot/initrd.img-5.15.0-75-generic
Found linux image: /boot/vmlinuz-5.15.0-73-generic
Found initrd image: /boot/initrd.img-5.15.0-73-generic
Found linux image: /boot/vmlinuz-5.4.0-152-generic
Found initrd image: /boot/initrd.img-5.4.0-152-generic
Found linux image: /boot/vmlinuz-5.0.0-32-generic
Found initrd image: /boot/initrd.img-5.0.0-32-generic
done

ck@mint ~ $ sudo grub-install /dev/sda
Installing for i386-pc platform.
Installation finished. No error reported.

Depending on your physical hardware, setting biosdevname=0 might not be enough. Some information hints that biosdevname is only applicable on DELL hardware.

Another Kernel parameter is net.ifnames. Setting net.ifnames=0 should generally disable the "predictable names" for the network interfaces. From the Systemd documentation:

net.ifnames=
           Network interfaces are renamed to give them predictable names when possible. It is enabled by default; specifying 0 disables it.
           Added in version 199.

Therefore:

ck@mint ~ $ cat /etc/default/grub | grep CMDLINE
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash net.ifnames=0"
GRUB_CMDLINE_LINUX=""

ck@mint ~ $ sudo update-grub


Add a comment

Show form to leave a comment

Comments (newest first)

No comments yet.

RSS feed

Blog Tags:

  AWS   Android   Ansible   Apache   Apple   Atlassian   BSD   Backup   Bash   Bluecoat   CMS   Chef   Cloud   Coding   Consul   Containers   CouchDB   DB   DNS   Database   Databases   Docker   ELK   Elasticsearch   Filebeat   FreeBSD   Galera   Git   GlusterFS   Grafana   Graphics   HAProxy   HTML   Hacks   Hardware   Icinga   Influx   Internet   Java   KVM   Kibana   Kodi   Kubernetes   LVM   LXC   Linux   Logstash   Mac   Macintosh   Mail   MariaDB   Minio   MongoDB   Monitoring   Multimedia   MySQL   NFS   Nagios   Network   Nginx   OSSEC   OTRS   Office   PGSQL   PHP   Perl   Personal   PostgreSQL   Postgres   PowerDNS   Proxmox   Proxy   Python   Rancher   Rant   Redis   Roundcube   SSL   Samba   Seafile   Security   Shell   SmartOS   Solaris   Surveillance   Systemd   TLS   Tomcat   Ubuntu   Unix   VMWare   VMware   Varnish   Virtualization   Windows   Wireless   Wordpress   Wyse   ZFS   Zoneminder