When working with Ubuntu 16.04 VPS instances, many administrators prefer the traditional ethX naming scheme over systemd's predictable network interface names. The automatic renaming back to enp0s3 after configuration changes is particularly frustrating. Here's what's happening under the hood:
# dmesg shows the rename operation:
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
To achieve permanent renaming, we need a multi-layered approach:
- Create proper .link file configuration
- Disable predictable naming in GRUB
- Update network configuration files
- Handle udev rules properly
1. Create the link configuration file:
# /etc/systemd/network/10-eth0.link
[Match]
MACAddress=08:00:27:f7:57:e5
[Link]
Name=eth0
NamePolicy=
Notice the crucial NamePolicy=
line which prevents systemd from applying its default naming policy.
2. Modify GRUB configuration:
# Edit /etc/default/grub
GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"
# Update GRUB
sudo update-grub
3. Update network interfaces file:
# /etc/network/interfaces
auto eth0
iface eth0 inet dhcp
To verify your configuration before reboot:
# Test udev rules
sudo udevadm test /sys/class/net/enp0s3 2>&1 | grep -i "renamed"
# Check link file processing
sudo udevadm test-builtin net_setup_link /sys/class/net/enp0s3
If you still see issues, check for conflicting configurations:
# Check for conflicting .link files
ls -l /usr/lib/systemd/network/*.link /etc/systemd/network/*.link
# Verify systemd-networkd is not interfering
systemctl status systemd-networkd
For systems where .link files don't work, try classic udev rules:
# /etc/udev/rules.d/70-persistent-net.rules
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*",
ATTR{address}=="08:00:27:f7:57:e5", NAME="eth0"
Remember to reload udev rules:
sudo udevadm control --reload-rules
sudo udevadm trigger
After implementing these changes, verify with:
ip link show
journalctl -b | grep -i "renamed"
The system should now consistently use eth0 instead of reverting to enp0s3.
When working with Ubuntu 16.04 VPS instances, many administrators encounter stubborn network interface naming issues where traditional renaming methods fail under systemd. The system persistently reverts to predictable names (like enp0s3) despite proper configuration attempts.
The dmesg output reveals a critical sequence:
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
This indicates the interface initially loads as eth0, but something in the systemd stack forcibly renames it later in the boot process.
The problematic udevadm test output shows:
$ sudo udevadm test-builtin net_setup_link /etc/systemd/network/10-eth0.link ... unable to open device '/sys/etc/systemd/network/10-eth0.link'
This error suggests systemd-networkd isn't properly processing our .link file due to incorrect path resolution.
Try this multi-pronged solution:
# 1. Create proper .link file sudo tee /etc/systemd/network/10-eth0.link <After reboot, verify with:
$ ip -o link show | awk '{print $2,$(NF-2)}'Should show "eth0" instead of "enp0s3". Monitor boot logs with:
$ journalctl -b -u systemd-networkdFor older systems or hybrid environments, consider creating a udev rule:
# /etc/udev/rules.d/70-persistent-net.rules SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:f7:57:e5", NAME="eth0"Then reload udev rules:
sudo udevadm control --reload-rules sudo udevadm trigger