Persistently rename a Linux network interface without Udev / Reboot
Solution 1:
Thanks to netplan (default in ubuntu 18.04) this is now particularly easy. You can set the interface name based on macaddress or driver:
Edit an existing .yaml configuration file in /etc/netplan/ or create a new one:
sudo nano /etc/netplan/config.yaml
Here is an example with MAC address matching. Names are set with 'set-name' and matched by the MAC address of the interface:
network:
ethernets:
wan:
match:
macaddress: 00:ab:cd:ef:12:34
addresses:
- 10.5.1.2/16
dhcp4: true
optional: true
set-name: wan0
lan:
match:
macaddress: 00:ab:cd:ef:12:45
addresses:
- 10.6.1.1/16
optional: true
set-name: eth0
version: 2
Save the .yaml file and apply the configuration with:
sudo netplan apply
A reboot may be required to apply the name change.
Solution 2:
Knowing the ip
command is nice, but there are persistent ways to configure using existing scripts, and yes, udev.
One thing you can dois map a NIC of a specific MAC address to a name. Append something like this to /etc/udev/rules.d/70-persistent-net.rules
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="xx:xx:xx:xx:xx:xx", NAME="eth0"
- Changing Network Interfaces name Ubuntu 16.04
- Linux Rename Eth0 Network Interface Card Name [ Udev ]