Interface will not rename under systemd

Solution 1:

According to https://www.freedesktop.org/software/systemd/man/systemd.link.html, the default naming policy is:

#  /usr/lib/systemd/network/99-default.link
[Link]
NamePolicy=kernel database onboard slot path
MACAddressPolicy=persistent

So I suspect you might want to add the following line to your eth0.link:

NamePolicy=mac

I haven't tested this, so I am not certain, but I suspect the issue is that you Match on MAC, but there is no naming policy to make that stick.

Each of the policies may fail, and the first successful one is used. The name is not set directly, but is exported to udev as the property "ID_NET_NAME", which is, by default, used by a udev rule to set "NAME". If the name has already been set by userspace, no renaming is performed

It is just a guess though.

You should also be able to just disable the default.link, at least per https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/

On some openSUSE systems I run, I had a similar issue, which (in addition to having had to use the 99-default.link 'trick') was resolved by creating two files under /etc/udev/rules.d (see https://unix.stackexchange.com/questions/118272/80-net-setup-link-no-longer-functions-when-i-downgraded-systemd, https://wiki.archlinux.org/index.php/Network_configuration#Device_names and https://wiki.gentoo.org/wiki/Udev/Upgrade_Guide):

sudo touch /etc/udev/rules.d/80-net-setup-link.rules (or just make sure an empty file of that name is in that location)

AND

I created /etc/udev/rules.d/10-persistent-network.rules:

ACTION=="add", SUBSYSTEM=="net", KERNEL=="eth*", ATTR{tx_queue_len}="1000"

In your case, you could actually use that file to set the name you want:

ACTION=="add", SUBSYSTEM=="net",ATTR{address}=="08:00:27:f7:57:e5",NAME="eth0"

Solution 2:

I've tried all of the above. Nothing works. I have been researching constantly for 2 weeks.

I did find an answer AND IT WORKS. Here:

https://superuser.com/questions/914646/renaming-network-interface-with-systemd

The post contains a link to Lennart's notes, which help not at all. read the post and you should win.

Here is how I got it to work:

Step 1: sudo nano /etc/udev/rules.d/70-local-net-names.rules

SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="74:da:38:68:55:c1", NAME="wlan1"

This file needs to be ordered before /usr/lib/udev/rules.d/80-net-setup-link.rules

This works on Debian Stretch. It should work on Ubuntu as well.


Solution 3:

Acording to systemd docs, this is due to the new Predictable Network Interface Names

Docs say you have three options to disable that behaviuor, and probably the third one is the easiest one:

  1. You disable the assignment of fixed names, so that the unpredictable kernel names are used again. For this, simply mask udev's .link file for the default policy: ln -s /dev/null /etc/systemd/network/99-default.link

  2. You create your own manual naming scheme, for example by naming your interfaces "internet0", "dmz0" or "lan0". For that create your own .link files in /etc/systemd/network/, that choose an explicit name or a better naming scheme for one, some, or all of your interfaces. See systemd.link(5) for more information.

  3. You pass the net.ifnames=0 on the kernel command line