0

I want to permanently change the device name of a network interface using a portable script.

The interface gets the ugly name of enp02fghjkl1. I want to give a pretty name of netface1. I have tried using ip link and nmcli and so many other things to change the device name permanently, and I can change it, but I cannot get it to persist through a reboot.

Here is the command set that works to temporarily change it:

sudo ip link set enp02fghjkl1 down
sudo ip link set enp02fghjkl1 name netface1
sudo nmcli connection modify Wired\ connection\ 1 con-name netface1
sudo nmcli device connect netface1
sudo nmcli con up netface1
sudo nmcli con reload

However, after a reboot, the command nmcli c shows netface1 but the command nmcli d shows enp02fghjkl1

Note: I have also created a network-script called ifcfg-netface1 and placed the uuid in it, but it just gets ignored after a reboot.

1 Answer 1

0
  • Step 1. The robust solution that worked for me: These four lines that must exist in the network-script file:
    /etc/sysconfig/network-scripts/ifcfg-somename1
NAME=somename1
DEVICE=somename1
HWADDR=FE:FF:GG:11:00:10
UUID=b623cbaa-ffe2-3456-7890-1a23b465cd67

Caveat: The file cannot have HWADDR and MACADDR at the same time, it can only have one or the other. You can get the UUID from the command nmcli c.

  • Step 2. add net.ifnames=0 somewhere after nomodeset and before rhgb in this file:
    /etc/default/grub

then run the command sudo grub2-mkconfig -o /boot/grub2/grub.cfg

  • Step 3. Match the MAC address to the nic name in this file:
    /etc/systemd/network/70-custom-ifnames.link
[Match]
MACAddress=FE:FF:GG:11:00:10

[Link]
Name=somename1
  • Step 4. Add these lines to the custom rules file:
    /etc/udev/rules.d/70-custom-ifnames.rules
SUBSYSTEM=="net",ACTION=="add",ATTR{address}=="FE:FF:GG:11:00:10",ATTR{type}=="1",NAME="somename1"

More details here:
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/configuring_and_managing_networking/consistent-network-interface-device-naming_configuring-and-managing-networking

You must log in to answer this question.

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