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?
Best Answer
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 instat /etc/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.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
ln -s /dev/null /etc/systemd/network/99-default.link
, just don't forget to regenerate your initramfs afterwards withupdate-initramfs -u
);/etc/network/interfaces
entirely and switch to systemd-networkd with a match-all config likein
/etc/systemd/network/dhcp.network
(choose an arbitrary file name). Sorry, I can't get the indentation right...