What is AlternativeNamesPolicy in Interface naming scheme?

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux 8.5 and above
  • Red Hat Enterprise Linux 9.0 and above
  • AlternativeNamesPolicy

Issue

  • What is AlternativeNamesPolicy?
  • What is "altname" in "ip a" command?

Resolution

The feature AlternativeNamesPolicy is added from RHEL 8.5 and above version where it allow the feature to create alternate names for existing interfaces. It is space-separated list of policies by which the interface's alternative names should be set. Each of the policies may fail, and all successful policies are used. The available policies are "database", "onboard", "slot", "path", and "mac". If the kernel does not support the alternative names, then this setting will be ignored.

      "database"
           The name is set based on entries in the udev's Hardware
           Database with the key "ID_NET_NAME_FROM_DATABASE".

      "onboard"
           The name is set based on information given by the firmware for
           on-board devices, as exported by the udev property
           "ID_NET_NAME_ONBOARD". See systemd.net-naming-scheme(7).

       "slot"
           The name is set based on information given by the firmware for
           hot-plug devices, as exported by the udev property
           "ID_NET_NAME_SLOT". See systemd.net-naming-scheme(7).

      "path"
           The name is set based on the device's physical location, as
           exported by the udev property "ID_NET_NAME_PATH". See
           systemd.net-naming-scheme(7).

       "mac"
           The name is set based on the device's persistent MAC address,
           as exported by the udev property "ID_NET_NAME_MAC". See
           systemd.net-naming-scheme(7).

The goal of introducing the alternate names are:

1. Overcome the IFNAMSIZE limitation.
2. To allow interfaces with multiple names at the same time (multiple udev patterns).
3. To allow use of alternative names as handle for commands.

Note: when you use net.ifnames=0 in kernel options, altname will appear by default in ip addr command.

# ip addr
:
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 52:54:00:33:f8:ae brd ff:ff:ff:ff:ff:ff
    altname enp1s0
    inet 192.168.122.9/24 brd 192.168.122.255 scope global dynamic noprefixroute eth0
       valid_lft 3591sec preferred_lft 3591sec
:

net.ifnames=0 is not recommended. Please see https://access.redhat.com/solutions/2435891

In which version of kernel and iproute can we use altname?

altname is supported in RHEL8.5(4.18.0-348.el8.x86_64). however ip command could not show altname because there was a bug in iproute of RHEL8.5 or less.
You can see altname in the following combination:

  kernel:  4.18.0-348.el8.x86_64 or later
  iproute: 5.9.0-4.el8 or later

How to set up your unique altname temporarily by ip command ?

Note: altname set by ip command will go off after the reboot

# ip link property add dev enp1s0 altname **your_altname**

How to set up your original altname permanently ?

Note: At the moment, the following setup works well in RHEL9 only. (You will be able to use altname in the case of using bond. )

Caution: Please note that the use of OriginalName= is not always recommended. This is because the name of the interface may differ from the name originally recognized by the kernel. Therefore, please test this in your environment before use.

  1. create /etc/systemd/network/00my.link

     [Match]
     OriginalName=enp1s0
    
     [Link]
     AlternativeNamesPolicy=
     AlternativeName=myaltname
    
  2. reboot

     # reboot
    
  3. Check the altname you set up

     # ip a
    

Limitations

1. ASCII characters except / and space
2. Maximum length 128 bytes

Root Cause

AlternativeNamesPolicy is defined in the "/usr/lib/systemd/network/99-default.link" file.

   The link file 99-default.link that is shipped with systemd defines the
   default naming policy for links.

    [Link]
    NamePolicy=kernel database onboard slot path
    AlternativeNamesPolicy=database onboard slot path 
    MACAddressPolicy=persistent

In RHEL9 alternative names can be seen using" ip a" command. But it could not be listed with 'ip a' command in RHEL8.5(kernel) and less than iproute05.9.0-4.el8. Now the bug was fixed.

   # ip a
    ens8: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 
               qdisc fq_codel master bond0 state UP group default qlen 1000
               link/ether 00:00:00:00:00:aa brd ff:ff:ff:ff:ff:ff permaddr 
              00:00:00:00:00:bb
               altname enp0s8 
  • Component
  • ipa

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments