Changing Network Interfaces name Ubuntu 16.04
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.
Related videos on Youtube
Geancarlo Abich
Updated on September 18, 2022Comments
-
Geancarlo Abich over 1 year
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:
-
flickerfly over 7 yearsBingo! 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"
-
soufrk over 7 yearsHow can I set the name to
enp0s1
fromenp0s17
? Is it the same process ? Also, what should I do for virtual network-interfaces likeenp0s1:1
orenp0s2
etc. ? -
kbuilds over 7 yearsYou 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"
-
vimal prakash over 7 yearsnot working for me, after update of these steps. ifcofig show only "lo" card , it not showing eth and ens :(
-
chitti over 7 yearsThis 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.
-
John Doe about 7 years@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.
-
musbach about 7 yearsStep two is not necessary.
-
musbach about 7 yearsBetter is
GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"
-
menixator about 7 yearsYep. Can confirm what @musbach said on 16.04
-
Paulo almost 7 yearsIt worked for me.
-
vNottbeck almost 7 yearswhat do the commands "net.ifnames=0" && "biosdevname=0" do??? The post here is pure gold anyways .... worked on 16.04 xubuntu
-
Simon Warta about 6 yearsWorked on Ubuntu 18.04 as well
-
7heViking about 6 yearsThis only works for the desktop version of Ubuntu - not the server version. If applied to the server version only the lo interface remains.
-
AnythingIsFine almost 6 yearsI confirm this naming solution works on Armbian Xenial which is based on Ubuntu 16.04 and does not use grub.
-
Clinton Lam over 5 yearsThis worked on Ubuntu16. I have changed the motherboard and this network problem showed up. This solved the problem.
-
user4551 over 5 yearsImportant: 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.
-
Phil795 over 4 yearsThis solution is bad! With more than 1 NIC it can happen that the cards are initialized in the wrong order and the IP configuration is moved between the cards. Better is the udev solution where the name is directly bound to the MAC address.
-
pierrely about 3 years20.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 about 3 yearsalso 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.