Should nm-initrd-generator be generating new interface profiles at boot?

I’ve been doing some research on how Network Manager uses profiles located in /etc/NetworkManager/system-connections. When RHEL/Rocky is first installed, there is a new profile created for whatever interfaces are present, which is great. But I’ve found that if an interface is added later, even if the system is rebooted, no new profile is getting created for these new devices.

I’ve tested this on a running system adding a USB network interface, also a VM running Rocky 9, and adding another network interface to the VM.

I’m not entirely clear on where exactly nm-initrd-generator is called from at boot, so I’m not sure what arguments it is getting passed. It would seem that it ‘should’ create new profiles for newly added interfaces automatically, so I’m not sure if this is a bug or not. If this is expected behavior, is there a way to manually run this to create new profiles like the ones at first boot?

While I’m still trying to figure out if this is a feature or not, I bashed out the following bit of code to help create new profiles for devices that do not yet have one defined. This will use the nm-initrd-generator tool to create a properly formatted connection profile matching what the default would have been if the interface had existed at first boot.

It looks like RHEL is only creating these at first boot, I’m finding posts for other OS versions that seem to imply that this is running at each boot.

#!/bin/bash

if [ "$EUID" -ne 0 ]
  then echo -e "\nScript requires elevated permissions.  Please run as root.\n"
  exit
fi

# Define the path that NetworkManager uses for system connections
conPath='/etc/NetworkManager/system-connections/'

# Check nmcli for all devices of type ethernet
devs=$(nmcli dev | grep 'ethernet' | awk '{print $1}')
for str in $devs; do
        echo $str
        if test -f "$conPath$str".nmconnection; then
                echo -e "Connection exists for $conPath$str.nmconnection.\n"
        else
                echo -e "No connection exists for $conPath$str.nmconnection.  Creating!\n"
                /usr/libexec/nm-initrd-generator -c /etc/NetworkManager/system-connections "ip=$str:dhcp"
        fi
done

According to RHEL documentation NetworkManager does create a connection for each device,
unless you install package NetworkManager-config-server, that:

adds a NetworkManager configuration file to make it behave more like the old “network” service. In particular, it stops NetworkManager from automatically running DHCP on unconfigured ethernet devices, and allows connections with static IP addresses to be brought up even on ethernet devices with no carrier.

The “create a connection” in “automatically running DHCP on unconfigured ethernet devices” means runtime config, not one saved into files. If you do modify such runtime config, then the result is saved into file and on next boot that ethernet devices is “configured”.

You do mention /etc/NetworkManager/system-connections/. Up to EL8 most connections were still saved in the legacy “initscript format” in /etc/sysconfig/network-scripts/. Only EL9 does focus on the new format and location. (It is possible that the runtime config that I did mention above behaves differently in EL9.)

Sorry about that, I should have specifically mentioned in the first post that this is all under EL9.