139

A lot of my scripts stopped working after installing Ubuntu 15.10 and I have trouble remembering this new name as I was used to ethx and wlanx for years. Is there a reason for this change? Do I have to get used to this or can I just rename it and go back to good old eth0?

$ ifconfig

enp0s25   Link encap:Ethernet  HWaddr 77:5a:5e:a6:86:d5  
      inet addr:192.168.31.239  Bcast:192.168.31.255  Mask:255.255.255.0
      inet6 addr: fe80::725a:b6ff:fea6:86d7/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:4833 errors:1332 dropped:0 overruns:0 frame:666
      TX packets:5589 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000 
      RX bytes:3266446 (3.2 MB)  TX bytes:1046654 (1.0 MB)
      Interrupt:20 Memory:d3500000-d3520000
muru
  • 197,895
  • 55
  • 485
  • 740
Mike
  • 5,691
  • 2
    see this which also has a further link to more details. – Doug Smythies Nov 30 '15 at 19:19
  • 5
    Ooooooooooooooor fix your scripts once and for all and remove the reference (and change it for a command to determine the device name) ;-) (here are some pointers: http://askubuntu.com/questions/396837/detecting-the-name-of-a-network-device-in-bash ) – Rinzwind Dec 01 '15 at 09:56
  • @Rinzwind That is great idea. – Mike Dec 01 '15 at 10:41
  • @Mike my boss (= lead coder) always agrees with me on that too but then he always uses hard coded paths and devices... and I scold him again and again ;) – Rinzwind Dec 01 '15 at 10:46
  • 1
    Dupe of this: https://unix.stackexchange.com/questions/134483/why-is-my-ethernet-interface-called-enp0s10-instead-of-eth0 – rugk Oct 11 '18 at 20:23

3 Answers3

140

This is known as Predictable Network Interface naming and is part of systemd, to which Ubuntu has been transitioning as of version 15.04.

Basic idea is that unlike previous *nix naming scheme where probing for hardware occurs in no particular order and may change between reboots, here interface name depends on physical location of hardware and can be predicted/guessed by looking at lspci or lshw output. Conversely we can guess information about it's physical position in the pci system. In your case that would be pci bus 0, slot 2. According to the freedesktop.org article, there actually are 3 ways how interface name is assigned: based on BIOS/Firmware for onboard cards, based on PCI information, and based on MAC address of the interface. Refer here for other examples.

According to the freedesktop.org page one of the reasons for switching to predictable naming is that classic naming convention can lead to software security risks in multi-interface systems when devices are added and removed at boot. Also, according to the comment by Sam Hanes, "On a big server with many Ethernet ports it's invaluable: you can immediately tell which interface goes to which port and adding or removing hardware doesn't change the names of other ports."

See How to rename network interface in 15.10 in case you decide to revert back to the other version of naming.

Sergiy Kolodyazhnyy
  • 105,154
  • 20
  • 279
  • 497
  • 50
    I see little irony in word "predictable" :), thank you for the pointers. – Mike Dec 01 '15 at 10:35
  • 13
    "predictable", yeah, sure. I have ethernet disconnections after upgrade to 15.10 (clean install, old /home). Why break APIs and conventions? Now I have to figured out what is failing. I'm very upset with this :( – gorlok Jan 24 '16 at 14:31
  • 17
    failing is predictable i guess ;) – Anwar Aug 20 '16 at 07:16
  • 6
    eh, tell that to the systemd developers, guys. – Sergiy Kolodyazhnyy Aug 20 '16 at 07:23
  • 28
    Predictable Naming isn't particularly useful on desktop systems with only one interface, and in that case it's kind of obnoxious. On a big server with many Ethernet ports it's invaluable: you can immediately tell which interface goes to which port and adding or removing hardware doesn't change the names of other ports. That's the case it's designed for. – Sam Hanes Nov 12 '16 at 07:33
  • @Anwar when you fail to predict, it's predictable you'll fail ;) – WinEunuuchs2Unix Nov 28 '16 at 21:55
  • 3
    I don't get any advantage from this change so far. – Sam Mar 07 '17 at 09:44
  • 3
    Wow, that really broke a lot of software. Nice move systemd. You make so many new friends! – aminorex Apr 19 '17 at 18:27
  • 2
    Actually predictable naming breaks every now and then on modern systems when you insert a new PCI/PCIE network adapter. On one of my mainboards (X58 Extreme IIRC) this resulted in all the NIC names changing. – Ruslan May 27 '17 at 10:25
  • switching from the ethx, wlanx naming scheme to the enpxsx and wlpxsx scheme is a bit difficult. specially in the first days and while returning back from using other distros that still use the old naming schemes, like kali. but after a while I got the hang of it and now I become frustrated with switching back to the old name in kali. The hardest challenge is restructuring my scripts to use the names I screen scraped from ifconfig instead of the hardcoded names like eth0 or wlan0 - much thanks to the creator of cut and regexe - the mathematicians, not the ones that coded'em. – endrias Jul 11 '17 at 18:23
  • 1
    can this wonderful new naming scheme be disabled and the old one be used? – lurscher Oct 27 '17 at 16:50
  • 2
    @lurscher see https://serverfault.com/a/741212/363611 – Sergiy Kolodyazhnyy Oct 27 '17 at 16:53
  • This has a downside with desktop systems with build-in ethernet adapters. I was an Ubuntu noob back then, I installed 16.04 and it ran fine. However, when I added a new USB PCIE card, I noticed I lost ethernet connectivity. The reason was that built-in ethernet adapter's PCIE index changed (and its enpsX0 name changed accordingly at boot), but its name in /etc/network/interfaces remained the same. So I went to the store to buy a new adapter and found out it never fixed the issue. – Jimmy Falcon Jul 30 '18 at 11:33
  • @JimmyFalcon Common users of desktop systems don't edit /etc/network/interfaces and swapping adapters don't affect them. If you edit the file manually, yoiu should know that when you change an adapter you need to do the change. – Pilot6 Jul 30 '18 at 11:37
  • 2
    Pilot6, swapping PCIE cards does affect users of desktop systems with built-in ethernet controllers. Whenever a PCIE card added or removed (USB controller, GPU, etc), the motherboard "moves" the built-in ethernet controller to another PCIE slot, enpsXX boot up name changes accordingly, whereas /etc/network/interfaces name does not. Thus, machine boots to non-working connectivity state. To fix it, user must edit the /etc/network/interfaces file manually to reflect the change. I can confirm the problem exists on AMD 970 chipset motherboards. – Jimmy Falcon Jul 31 '18 at 14:01
  • This wonderful new invention has grinded my computer into a standstill more than the equally wonderful nvidia dkms driver. why is this enabled by default on desktop systems ? – jsaddwater Aug 29 '18 at 08:36
  • Suddenly, my server refused to come online, and it turns out that the network interface previously predictably known as enp179f0s0 is now even more predictably known as enp180f0s0. No idea how that happened, both ethernets are soldered on the mainboard, so I'm pretty sure I haven't moved them about. – Ketil Malde Mar 10 '21 at 11:12
2

FWIW the freedesktop.org PredictableNetworkInterfaceNames file references a source file's comments as canonical but that file has been altered to remove the comments - see https://github.com/systemd/systemd/pull/12518.

pbhj
  • 3,231
1

Here is the quick fix I use on Debian and RHEL based systems

#Edit /etc/grub/default

Step 1. ) Add this to the line below "net.ifnames=0 biosdevname=0"

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

Step 2.) Update GRUB

This depends on your OS.

Debian based Ubuntu/Mint:

update-grub

Centos/RHEL

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

Source: http://realtechtalk.com/Linux_How_To_Change_NIC_Name_to_eth0_instead_of_enps33_or_enp0s25-2303-articles