Interface will not rename under systemd

Asked by Jan

I'm trying to rename a network interface on an Ubuntu 16.04 VPS, but am unable to do so. Systemd names my primary network interface enp0s3. I want to rename this interface to eth0.

According to the systemd.link documentation (https://www.freedesktop.org/software/systemd/man/systemd.link.html) I created a file called /etc/systemd/network/10-eth0.link with the following content:

[Match]
MACAddress=08:00:27:f7:57:e5

[Link]
Name=eth0

The MAC address matches the one given in the `ip a` output for the interface. I also renamed the enp0s3 entries to eth0 in the /etc/network/interfaces file. Although, when I reboot the machine, the interface is still named enp0s3.

The following entries in the dmesg output are interesting to me:

> e1000 0000:00:03.0 eth0: (PCI:33MHz:32-bit) 08:00:27:f7:57:e5
> e1000 0000:00:03.0 eth0: Intel(R) PRO/1000 Network Connection
> e1000 0000:00:03.0 enp0s3: renamed from eth0

So apparently, it starts out as eth0, but is then renamed back to enp0s3 again. I am not sure why?

When I try to debug the link file, I get the following output:

$ sudo udevadm test-builtin net_setup_link /etc/systemd/network/10-eth0.link
calling: test-builtin
=== trie on-disk ===
tool version: 229
file size: 6841778 bytes
header size 80 bytes
strings 1755242 bytes
nodes 5086456 bytes
Load module index
timestamp of 'etc/systemd/network' changed
Parsed configuration file /lib/systemd/network/99-default.link
Parsed configuration file /etc/systemd/network/10-eth0.link
Created link configuration context.
unable to open device '/sys/etc/systemd/network/10-eth0.link'

Unload module index
Unloaded link configuration context.

The line about it being unable to open the device seems odd. I'm not sure why it's trying that, there is no etc directory under /sys at all, should I create it?

I also tried disabling the /lib/systemd/network/99-default.link file and set the NamePolicy option to mac, but to no avail.
Any insights into why my interface name doesn't stick is very welcome.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
actionparsnip
Solved:
Last query:
Last reply:
Revision history for this message
Best actionparsnip (andrew-woodhead666) said :
#1
Revision history for this message
daniel CURTIS (anoda) said :
#2

Hwllo. Additionally You can try something like this: add a custom rule to the '70-my-net-names.rules' file (create if does not exist) in /etc/udev/rules.d folder. It could looks this way:

SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="08:00:27:3b:f3:cd", NAME="eth0"

Also, You should read <https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/> and especially "I don't like this, how do I disable this?" chapter. Check this: <https://bbs.archlinux.org/viewtopic.php?id=163533>

Best regards.

Revision history for this message
daniel CURTIS (anoda) said :
#3

Sorry for a double posts; of course "ATTR{address}==" should contain yours MAC address.

Revision history for this message
Jeremy (wa113y3s) said :
#4

In terminal

sudo ln -s /dev/null /etc/systemd/network/99-default.link

sudo -H gedit /etc/default/grub

Scroll down to the line that starts with GRUB_CMDLINE_LINUX_DEFAULT=

add

net.ifnames=0

inside of the quotes, mine is

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash net.ifnames=0"

Save file and exit gedit, then in terminal

sudo update-grub

Reboot

Revision history for this message
daniel CURTIS (anoda) said :
#5

Geez, andrew-woodhead666, has similar solution. I'm sorry once again :- (

Revision history for this message
Jan (jdorsman) said :
#6

Thanks for your answers. Adding the additional udev rules file did the trick!

Revision history for this message
Jan (jdorsman) said :
#7

Thanks actionparsnip, that solved my question.