67

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:

4 Answers 4

81

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).

6
  • 2
    Bingo! I now have enusb01 for my USB Docking Station's NIC. Thanks! # USB Display Link Docking Station SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="8c:ae:4c:fa:92:bf", ATTR{dev_id}=="0x0", ATTR{type}=="1", NAME="enusb1"
    – flickerfly
    Aug 9, 2016 at 22:18
  • How can I set the name to enp0s1 from enp0s17 ? Is it the same process ? Also, what should I do for virtual network-interfaces like enp0s1:1 or enp0s2 etc. ?
    – soufrk
    Oct 5, 2016 at 15:12
  • 2
    You don't really need to specify all of that in 16.04. I was able to get away with SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="xx:xx:xx:xx:xx:xx", NAME="eth0"
    – kbuilds
    Oct 18, 2016 at 22:13
  • 6
    @kbuilds, per Linux From Scratch: DRIVERS=="?*" - This exists so that Udev will ignore VLAN or bridge sub-interfaces (because these sub-interfaces do not have drivers). These sub-interfaces are skipped because the name that would be assigned would collide with their parent devices.
    – nichtNox
    Feb 11, 2017 at 19:00
  • 1
    Important: you need to edit /etc/network/interfaces to make sure the renamed interface gets automatically started. Otherwise, if you're on SSH - you will lose access to that machine, not to mention waste time trying to figure out why it doesn't work.
    – user4551
    Jan 29, 2019 at 23:10
77

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)
8
  • 1
    not working for me, after update of these steps. ifcofig show only "lo" card , it not showing eth and ens :( Nov 26, 2016 at 7:10
  • 2
    This worked for me. @vimalprakash I also had only 'lo' showing up in ifconfig output after this change. However, that's because other interfaces were down (do ifconfig -a to see all interfaces) since configs in my /etc/network/interfaces were in the older names.
    – chitti
    Jan 3, 2017 at 0:00
  • It worked for me.
    – Paulo
    Jun 2, 2017 at 10:30
  • what do the commands "net.ifnames=0" && "biosdevname=0" do??? The post here is pure gold anyways .... worked on 16.04 xubuntu
    – user115639
    Jul 4, 2017 at 17:51
  • 2
    Worked on Ubuntu 18.04 as well Mar 28, 2018 at 22:32
12

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
2
10

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.

4
  • 5
    Step two is not necessary.
    – musbach
    Feb 12, 2017 at 13:15
  • 1
    Yep. Can confirm what @musbach said on 16.04
    – menixator
    Feb 20, 2017 at 17:33
  • 20.10 worked for me except as it says "and change only the value of the NAME= key." and I only put in the preferred name (it did not work when I did put in mac addresses). note I now have eth0 even though I put in eth9 as my name in persistent rules (which I had to create)... also I deleted gnome gui connections and allowed this to come up. it comes up as eth0 even when chaning usb ethernet devices and shows their changing mac addresses under the same name... so far so good.
    – pierrely
    Feb 20, 2021 at 1:46
  • also I had set 01-network-manager-all.yaml to the defaults. it could be any of these changes. persistent rules did not work for me yesterday prior to the grub change today.
    – pierrely
    Feb 20, 2021 at 4:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .