What is AlternativeNamesPolicy in interface naming scheme?

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux 8.5 and later
  • Red Hat Enterprise Linux 9.0 and later

Issue

  • What is AlternativeNamesPolicy?
  • What is altname in the output of the ip a command?

Resolution

The feature AlternativeNamesPolicy is available in RHEL 8.5 and later versions where alternate names for existing interfaces can be created. There 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 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 using net.ifnames=0 in kernel options, altname will appear by default in the ip addr command. However, setting net.ifnames=0 is not recommended. Please see https://access.redhat.com/solutions/2435891.

# 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
...

In which OS and kernel versions is AlternativeNamesPolicy available?

AlternativeNamesPolicy is supported in RHEL 8.5 and kernel 4.18.0-348.el8.x86_64 and later.

How to set up a unique altname temporarily with the ip command

For example, to add then alternate name fast-nic to the interface enp1s0, run:

# ip link property add dev enp1s0 altname fast-nic

Note: An alternate name set by the ip command will be reset after a reboot

How to set up your original altname permanently?

Note: At the moment, the following setup works well in RHEL 9 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 because the name of the interface may differ from the name originally recognized by the kernel.

  1. Create /etc/systemd/network/00my.link:

     [Match]
     OriginalName=enp1s0
    
     [Link]
     AlternativeNamesPolicy=
     AlternativeName=fast-nic
    
  2. Reboot the node:

     # reboot
    
  3. Check the altname

     # 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

   # 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