In this post, I will explain how to change the network interface name in Ubuntu based distro. In my case, I used release 17.10 (artful).
Since Ubuntu 16.04 (maybe even before), the classic name of network interfaces like eth0 or wlan0 has been replaced by really nasty names and often impossible to memorize. In fact, a renaming process occurs during the boot of the OS.
I do not know why exactly but I can prove it
Update 05.01.18 : Thank to @Eduardo for information in its comment. The reasons why this renaming is performed is explained in detail here :
- the proposal : https://lists.ubuntu.com/archives/ubuntu-devel/2015-May/038761.html
It is possible to show this renaming process by looking in the kernel log after the boot. Once you are logged into Ubuntu, open a terminal and display kernel log and filter output with egrep for example.
fl0at0xff@bl00b:~/Desktop$ dmesg | egrep "renamed" [1.692529] tg3 0000:04:00.0 enp4s0f0: renamed from eth0 [1.693602] tg3 0000:04:00.0 enx68cf2: renamed from wlan0
As you can see, during the boot, 2 network devices are detected, eth0 and wlan0, and for an unknown reason, they are renamed. It is possible to add a special command in the Grub configuration to avoid this renaming process. To do this, edit the file /etc/default/grub.
Search for the variable GRUB_CMDLINE_LINUX and set it to the following value : net.ifnames=0 biosdevname=0. In my case, I commented the default line, created a new one with the value. Once modified, you must have this entry in the file.
fl0at0xff@bl00b:~/Desktop$ cat /etc/default/grub | egrep GRUB_CMDLINE_LINUX= #GRUB_CMDLINE_LINUX="" GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"
After that, it is necesary to reload this change. You can do it simply using this command:
fl0at0xff@bl00b:~/Desktop$ sudo update-grub Generating grub configuration file ... Warning: Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported. Found linux image: /boot/vmlinuz-4.13.0-21-generic Found initrd image: /boot/initrd.img-4.13.0-21-generic Found linux image: /boot/vmlinuz-4.13.0-19-generic Found initrd image: /boot/initrd.img-4.13.0-19-generic Found linux image: /boot/vmlinuz-4.13.0-17-generic Found initrd image: /boot/initrd.img-4.13.0-17-generic Found linux image: /boot/vmlinuz-4.13.0-16-generic Found initrd image: /boot/initrd.img-4.13.0-16-generic done
Just reboot your system and the name of the NICs on your system should not be changed !
ps: If someone knows why Ubuntu performs this renaming, please let me a comment !