Interface naming rules in RockyLinux 9

I just upgrade my OS from CentOS 7.9 to rockylinux 9.0.

According to Chapter 11. Consistent Network Device Naming, I guess the name of all my network interface will stay the same before.

But fact is the interface name before is “enp101s0f0”, now become “ens6f0” with an altname “enp101s0f0”.
And maybe my driver/userspace program is just a little stupied that they did not recognize the alname “enp101s0f0”, making my hard coded scripts not able to work anymore.

So my question is is here any document describing how or why interface’s name changed from “enp101s0f0” to “ens6f0”. Or how can I change the naming rules to make it stay the same way as CentOS 7.9?

Okay, maybe I find the reason, ensX means device supports hotplug. But how can I configure(disable) it?

Your link is to RHEL 7 documentation. Corresponding RHEL 9 doc Chapter 1. Consistent network interface device naming Red Hat Enterprise Linux 9 | Red Hat Customer Portal describes “udev rules” and “systemd link files”.

Yes, changing the name is a good choice: udev rules or systemd link files can both achieve that.

But I’m still curious about is here any option, like a switch. Just by turning it on or off, an old style naming rule will just be applied: It is finished automatically. Thus I don’t have to write any rules, making live easier.

For example, If it is because device become an hot-pluggable device in rockylinux 9 so that device gets a new name. Maybe turn off hotplug support can be an cheaper option compared with writting namening rules. Maybe from kernel option, maybe from a pcie config file, or maybe editing BIOS setting.

But, I don’t know how to turn it(hotplug) off.

True. Then again, creating config for one interface is relatively trivial.
Given file play.yml:

hosts: all
tasks:
- name: systemd subdir for customizations
  ansible.builtin.file:
    path:  /etc/systemd/network
    state: directory
    owner: root
    group: root
    mode:  0755
- name: Rename interface
  ansible.builtin.copy:
    content: |
      [Match]
      MACAddress="{{ mac_addr }}"
      [Link]
      Name="{{ if_name }}"
    dest:  /etc/systemd/network/70-custom-ifnames.link
    owner: root
    group: root
    mode:  0644

and file myhosts:

foo.mydomain mac_addr=b4:96:91:14:ae:58 if_name=enp101s0f0

command:

ansible-playbook -i myhosts play.yml --become

should:

  1. connect to foo.mydomain with ssh
  2. use sudo to become priviledged user
  3. create directory
  4. create file

For the ansible command you do need to install package ansible-core

The bonus is that then you have a logical copy of that part of config, a backup that you can redeploy whenever you need to.

But perhaps per-interface renaming is not necessary, if the NamePolicy can guide udev?

See description of NamePolicy in man systemd.link and man systemd.net-naming-scheme.
Perhaps the second task in the play could be something like:

- name: Interface NamePolicy
  ansible.builtin.copy:
    content: |
      [Link]
      NamePolicy=slot path keep
    dest:  /etc/systemd/network/70-custom-ifnames.link
    owner: root
    group: root
    mode:  0644
2 Likes

Really good! Thank you for your patient response! The second method is really the thing I want:
Don’t need to get every MAC from every mis-named machine.
I will try it soon!