4

It is well-known that systemd changes the network interface names from e.g. eth0 to enp0s25, and this is called "Predictable Network Interface Names".

On my system, eth0 is called "enp0s31f6".

And I'm sorry to say this, but I too agree with this user that says "I see little irony in word "predictable"" https://askubuntu.com/questions/704361/why-is-my-network-interface-named-enp0s25-instead-of-eth0

Back on topic:

On my system (Debian 9.8 with one physical PCI Ethernet adapter), I suddenly discovered that DHCP doesn't work any longer.

I need to manually run dhclient to get an IP.

Then, I look into /etc/network/interfaces and see:

auto eth0
iface eth0 inet dhcp

Shouldn't this be enp0s31f6?

However, how am I supposed to know what to put there, what if it changes again, e.g. if I move the Ethernet PCI card to a different slot?

Am I really supposed to edit this file manually, and change eth0 to whatever systemd decides to call my interface?

Surely I must be missing some crucial piece of information here regarding how either systemd works, how Debian works, or how Predictable Network Interfaces work. Perhaps a combination of those.

Am I supposed to refer to an abstract network interface in /etc/network/interfaces? Some abstract string that always means "the first network interface card" (isn't this just eth0?)? Or by some UID? By its PCI domain:bus:device?

This is very confusing, and a lot of documentation refers to what I would consider a mess of legacy scripts, modern systemd, and many distros seem to use a combination of old style scripts and systemd functionality which is hard to grasp.

Questions:

  • Why did it stop working?

  • What did I do wrong?

  • Why was it ever eth0 in my /etc/network/interfaces, when Debian uses systemd and Predictable Network Interfaces?

  • What is the correct way to fix this?

  • 1
    The problem Predictable Network Interface Names is trying to solve is that there is no "first network interface card" (unless it is also the last). Before the predictable names, ethernet cards could be enumerated in random order, which meant eth0 would show up as eth1, and vice versa. A machine could be rebooted ten times without a problem, and then suddenly on the eleventh boot eth0and eth1would be swapped even if no configuration changes had been done to the machine. This is a bigger problem than a card getting renamed when you move a PCI card to a different slot. – Johan Myréen Apr 1 at 11:47
  • systemd doesn't rename the interfaces, the kernel does. The predictability is that it will get that name on every boot. Before it was possible that eth0 and eth1 got switched around sometimes; although udev tried to work around that by setting persistent device names, which then gave unexpected results if a NIC needed to be replaced (eth0 was now eth2, for example). – wurtel Apr 1 at 11:49
  • I don't think this is a problem if you only have one Ethernet adapter, then it will always be called eth0 without using Predictable Network Interface Names. However, this doesn't help me regarding what I should do in Debian 9.8. Am I supposed to manually check what my interface is called, and then manually update the file? – AlphaCentauri Apr 1 at 14:16
  • I think /etc/network/interfaces is no more in use ( but perhaps if you boot from lan).You can try to rename it and saw there is no change. – ctac_ Apr 1 at 16:26
2

Why did it stop working? What did I do wrong?

It's hard to tell what happened "suddenly". Review your /var/log/syslog or /var/log/messages for DHCP logs around the time it stopped working and you may find out. Also check the modification time in stat /etc/network/interfaces.

Why was it ever eth0 in my /etc/network/interfaces, when Debian uses systemd and Predictable Network Interfaces?

This is the new default since Debian stretch. If you installed your system earlier and your /etc/network/interfaces originates from jessie (or wheezy...) then it was created by the installer (netcfg) using the old naming scheme.

What is the correct way to fix this?

Whatever suits you best.

  • If you expect to ever have multiple Ethernet interfaces in this machine, then think about how you'd like to tell them apart. Remember that their ethX order would not be stable/predictable. PredictableNetworkInterfaceNames gives you several options, choose according to your use case.

  • If this machine will only ever have a single Ethernet interface, then you can either

    • fall back to using the kernel name, which will always be eth0 (the above page gives you several options, my favorite is ln -s /dev/null /etc/systemd/network/99-default.link, just don't forget to regenerate your initramfs afterwards with update-initramfs -u);
    • or don't care about the name of your interface, ditch /etc/network/interfaces entirely and switch to systemd-networkd with a match-all config like
[Network]
DHCP=ipv4

in /etc/systemd/network/dhcp.network (choose an arbitrary file name). Sorry, I can't get the indentation right...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.