renaming network interface in Ubuntu 16.04 with systemd fails

Solution 1:

This may or may not help .. I would check /etc/udev/rules.d and see if you have 70-persistent-net.rules. You should be able to rename them using that file

Mine looks like this:

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="e0:cb:ee:d7:ff:9a", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

If you have the entries for your cards in this file you can change the name to what ever you want by changing the "NAME=TheNameYouWant"

Solution 2:

An option that doesn't require udev rules (an alternative to systemd-networkd .link files) that works with Ubuntu 16.04 as well as many other Linux versions is

Example:

ifconfig peth0 down  
ip link set peth0 name eth0  
ifconfig eth0 up 

In the example above peth0 is the original interface name and eth0 is the desired name. Plug in the name you currently have where peth0 is and the name you want where eth0 is. No reboot is required or suggested. Repeat the process for the second interface card

Tested on Ubuntu 16.04 with kernel 4.4.0-36-generic #55-Ubuntu

Edit: If you are looking for a persistent solution that survives reboot see Changing Network Interfaces name Ubuntu 16.04

Sources: https://www.freedesktop.org/software/systemd/man/systemd.link.html

http://kernelpanik.net/rename-a-linux-network-interface-without-udev/

Testing.

Note: since @antti-haapala method worked before and suddenly stopped you might be interested to know that "As a special case, an empty file (file size 0) or symlink with the same name pointing to /dev/null disables the configuration file entirely (it is "masked")". <-Source