In this post I will show you how to rename a Network Interface in Ubuntu 18.04.
Note your MAC Address.
ip addr
Create 70-persistent-net.rules.
nano /etc/udev/rules.d/70-persistent-net.rules
Add the following rule to 70-persistent-net.rules and replace the red text with your MAC Address and Interface name.
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="xx:yy:xx:yy:xx:yy", NAME="INTERFACENAME"
Rename your network interface name in /etc/netplan/filename.yaml
ethernets:
INTERFACENAME:
Open the GRUB configuration file.
nano /etc/default/grub
From:
GRUB_CMDLINE_LINUX=""
To:
GRUB_CMDLINE_LINUX="net.ifnames=1 biosdevname=0"
Update the bootloader
update-grub
(Optional) update-initram:
update-initramfs -u
Reboot and done!
Thank you, this worked. However, as a consequence, netplan appears to have to be re-written since the original NIC names disappear.
Hello Leroy,
Thanks for your reply.
‘Rename your network interface name in /etc/netplan/filename.yaml’ is indeed important.
Tom
Great article. very informative and useful post.
You can also do this in netplan only:
network:
ethernets:
myNewIfName:
match:
macaddress: 00:ab:cd:ef:12:34
set-name: myNewIfName
After a reboot ifconfig shows this.
Good Information. Works well.
Hey @Jan Florkowski
Thanks for the help. I thought I might put the proper format here:
network:
version: 2
renderer: networkd
ethernets:
enp0s3:
match:
macaddress: 00:a0:98:72:13:f7
set-name: eth0
dhcp4: true
dhcp6: false
Change enp0s3, the macaddress and your eth0 to your desired variables. The example is using dhcp4 for dynamic IP address given by router. If you need static address you need to change this