Rename network device

I’m working remotely and I’m stuck.

I need to rename a network device on an AlmaLinux 9 server. It’s currently ens33. I want to change it to eth0.

I have made numerous attempts but all have failed and I keep disconnecting myself!

I have made progress because now I can connect to the server and I was able to rename the connection, but the device name remains the same. I have tried so many different things, that I now have the following:

[root@srv-al9 ~]# nmcli device status
DEVICE           TYPE       STATE                   CONNECTION
ens33            ethernet   connected               eth0
br-37edd30c4c2e  bridge     connected (externally)  br-37edd30c4c2e
lo               loopback   connected (externally)  lo
wt0              wireguard  connected (externally)  wt0
docker0          bridge     connected (externally)  docker0
vethfe8267b      ethernet   unmanaged               --
[root@srv-al9 ~]# ls /etc/NetworkManager/system-connections
eth0.nmconnection
[root@srv-al9 ~]# cat /etc/NetworkManager/system-connections
eth0.nmconnection
cat: /etc/NetworkManager/system-connections: Is a directory
-bash: eth0.nmconnection: command not found
[root@srv-al9 ~]# cat /etc/NetworkManager/system-connections/eth0.nmconnection
[connection]
id=eth0
uuid=8637251c-fd20-4a76-9b85-54c33d2d2f12
type=ethernet
autoconnect-priority=-999
timestamp=1793545534

[ethernet]
mac-address=00:50:56:BC:84:C8

[ipv4]
method=auto

[ipv6]
addr-gen-mode=default
method=auto

[proxy]

/etc/sysconfig/network-scripts/ does not contain any files. It didn’t before I started.

/etc/systemd/network/ does not contain any files. It didn’t before I started.

What are the proper, concise steps to take when renaming a network device name on AlmaLinux 8, 9 and 10?

I have done this in the past but I can’t seem to do it on this server for some reason. Must be forgetting a step :slight_smile:

Why? Where do you need to even care about the name?

I use some old script that fail if the device name is not eth0.

Take a look at net.ifnames and biosdevname kernel arguments. Still, it is worth considering whether you should update your own scripts.

Unless someone has a better suggestion, I’m guessing 'net.ifnames=0' is still necessary to stop auto device naming.

Example:

grubby --update-kernel ALL --args 'net.ifnames=0'
reboot

I didn’t have to set that on some other servers but those servers were not built by me so maybe the builder had already set 'net.ifnames=0'.

Thank you, Daca!

I agree, modifying the scripts is the best option but I’m not a Linux pro so re-writing the scripts is a no-go for me.

biosdevname is not installed. I understand how net.ifnames works but how does biosdevname differ? What if you don’t have access to the bios or the bios does not have the info biosdevname needs? Just trying to understand how it works.

https://unix.stackexchange.com/questions/637295/linux-kernel-parameters-what-is-the-difference-of-net-ifnames-0-and-biosdevname notes that:

net.ifnames=
Network interfaces are renamed to give them predictable names when possible.

That is, the main toggle to enable/disable renaming.

and:

Biosdevname is a udev helper utility developed by Dell …

biosdevname takes a kernel device name as an argument, and returns the BIOS-given name it “should” be.

The biosdevname is enabled by default on systems running RedHat based on Dell hardware.

so the biosdevname merely affects how net.ifnames does the rename … on Dell systems.


RH describes the rename schemas in https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/9/html/configuring_and_managing_networking/consistent-network-interface-device-naming_configuring-and-managing-networking


Logically, one could use udev rules to set a name.

An important question is then how many devices do you have?

  • If there is only one, then the initial “eth0” by kernel is fine
  • If there are more than one, then one of them gets name “eth0” and renaming an another with same name would be an issue. Most likely the udev rules must set unique name for each interface

On enterprise Linux installations hosting centralized engineering license daemons, renaming network interfaces or altering MAC binding orders can unexpectedly invalidate hostid licensing locks or interrupt concurrent checkout threads across client subnets. For dimensioning seat buffer pools during network maintenance, check our reference queue calculator at FLEXlm License Seat Queue & Denial Probability Calculator.

Hopefully this reference helps address the engineering or workflow considerations under discussion.