Changing Network Interfaces name Ubuntu 16.04

I tried to change network interfaces name on this new Ubuntu 16.04 LTS version but doesn't have the /etc/udev/rules.d/70-persistent-net.rules.

So, I tried to use /lib/udev/write_net_rules but it not exist.

Why do I need this modification? Because I'm using a tool to Simulate virtual platforms that use flex licensing and the authentication need to be in eth0 interface name.

Any suggestion?

The command ip link returns:

user@laptop:~$ ip link 
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp6s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT group default qlen 1000
link/ether b8:2a:xx:yy:xx:yy brd ff:ff:ff:ff:ff:ff
3: wlp7s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DORMANT group default qlen 1000
link/ether 5c:e0:xx:yy:xx:yy brd ff:ff:ff:ff:ff:ff

user@laptop:~$ ifconfig 
enp6s0    Link encap:Ethernet  HWaddr b8:2a:xx:yy:xx:yy  
lo        Link encap:Local Loopback  
wlp7s0    Link encap:Ethernet  HWaddr 5c:e0:xx:yy:xx:yy  

(Some information were ignored and suppressed)

I already tried some links:

  • Network interface name changes after update to 15.10 - udev changes
  • How to rename an Ethernet interface?

Solution 1:

There is a lot of misleading information about how to change network names in recent versions of Ubuntu. Some information points to systemd.link, which is just wrong because Ubuntu (as of 16.04) does not use this part of systemd.

Actually, changing interface name works nearly like it used to, with two small differences: First, the file /etc/udev/rules.d/70-persistent-net.rules now has to be created manually. This has the advantage that you do not have to worry about any script overwriting this file and can simply add the lines that you need (you do not need any comments either). Second - and this is the change that cost me a lot of time to figure it out - the format changed slightly compared to Ubuntu 14.04 LTS:

The line for fixing the interface name of the NIC with MAC address "02:01:02:03:04:05" to "eth0" is now:

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="02:01:02:03:04:05", ATTR{dev_id}=="0x0", ATTR{type}=="1", NAME="eth0"

This line looks nearly the same as in Ubuntu 14.04 LTS with one slight difference: In Ubuntu 14.04, there was the additional condition KERNEL=="eth*". For some reason, this does not work in Ubuntu 16.04 LTS. If this additional condition is present, the whole line is ignored and you are back to the default behavior (as specified in 80-net-setup-link.rules).

Solution 2:

On Ubuntu 16.04.1 LTS, Linux plaptop 4.4.0-31-genericx86_64 MATE. step one of @Geancarlo Abich answer and it worked. Ubuntu created a new names directly after reboot:

Edit your /etc/default/grub changing the line from

GRUB_CMDLINE_LINUX=""

to

GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"

and, finally:

$ sudo update-grub

and reboot your system:

$ sudo reboot
msa@plaptop:~$ ifconfig 
eth0      Link encap:Ethernet  HWaddr 70:5a:0f:d7:03:38  
          inet addr:10.67.10.43  Bcast:10.67.10.255  Mask:255.255.255.0
          inet6 addr: fe80::8c03:edb5:a3d1:ba21/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:63129 errors:0 dropped:0 overruns:0 frame:0
          TX packets:37788 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:51115719 (51.1 MB)  TX bytes:5006758 (5.0 MB)
          Interrupt:16 Memory:f1200000-f1220000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:255 errors:0 dropped:0 overruns:0 frame:0
          TX packets:255 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1 
          RX bytes:21076 (21.0 KB)  TX bytes:21076 (21.0 KB)

wlan0     Link encap:Ethernet  HWaddr 44:85:00:62:c6:e5  
          inet addr:10.67.14.106  Bcast:10.67.14.255  Mask:255.255.255.0
          inet6 addr: fe80::5844:f9dd:32ff:9b45/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:25 errors:0 dropped:0 overruns:0 frame:0
          TX packets:86 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:5320 (5.3 KB)  TX bytes:14611 (14.6 KB)

Solution 3:

Ubuntu-16.04-server-amd64

In /etc/default/grub, change

GRUB_CMDLINE_LINUX=""

to

GRUB_CMDLINE_LINUX="net.ifnames=0"

Then, type in:

sudo update-grub

and reboot your system

sudo reboot

Solution 4:

I tried to mix some suggestions and I had found the solution!

Step 1: Disable the default Firmware inherited names.

Edit your /etc/default/grub changing the line from

GRUB_CMDLINE_LINUX=""

to

GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"

and, finally run as root:

$ sudo update-grub

and reboot your system.

$ sudo reboot

Step 2: Create the persistent file /etc/udev/rules.d/70-persistent-net.rules as root and fill them.

$ sudo gedit /etc/udev/rules.d/70-persistent-net.rules

Example:

# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device lan Device
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="XX:yy:XX:yy:XX:yy", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="ethX"

# PCI device Wlan Device
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="XX:yy:XX:yy:XX:yy", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="wlanX"

(Use the interfaces MAC Address to refer to the interface that you want to rename, and change the 'X' interface name values as you want)

Save changes and reboot.

$ sudo reboot

This works for me.