Skip to content
Search AlmaLinux

    Browse this documentation

    AlmaLinux 10: managing NetworkManager profiles as code

    An AlmaLinux 10.2 Server VM with NetworkManager 1.56.0-1.el10.

    The experiments use dummy interfaces: no real hardware needed and no way to cut the SSH path. Screenshot: public/evidence/nmcli/alma-profiles.png.

    A profile is an object, not “the NIC config”

    Section titled “A profile is an object, not “the NIC config””
    $ nmcli -f NAME,TYPE,DEVICE connection show
    NAME TYPE DEVICE
    lab-static ethernet ens18
    lo loopback lo
    ens18 ethernet --

    One device can have several profiles (here lab-static and ens18), but only one is activated at a time. A -- in the DEVICE column means nothing is active for that profile.

    Terminal window
    nmcli connection add type dummy ifname dummy0 con-name lab-a \
    ipv4.method manual ipv4.addresses 10.99.0.1/24 connection.autoconnect yes
    nmcli connection add type dummy ifname dummy0 con-name lab-b \
    ipv4.method manual ipv4.addresses 10.99.0.2/24 connection.autoconnect no
    $ nmcli -f NAME,DEVICE,AUTOCONNECT connection show | grep lab-
    lab-a dummy0 yes
    lab-b dummy0 no

    connection.autoconnect no means the profile only comes up when explicitly activated — right for “temporarily switch to the test network” profiles that must not grab the device at boot.

    $ nmcli connection up lab-a
    $ ip -4 -br addr show dummy0
    dummy0 UNKNOWN 10.99.0.1/24
    $ nmcli connection up lab-b
    $ ip -4 -br addr show dummy0
    dummy0 UNKNOWN 10.99.0.2/24

    Activating lab-b deactivates lab-a: a device is an exclusive resource, profiles do not stack.

    $ nmcli -g ipv4.method connection show lab-b
    manual
    $ nmcli -g GENERAL.DEVICE connection show lab-b
    dummy0

    -g (--get-values) prints values only, which makes it safe for $(...) and conditionals. Without it the output carries headers and alignment and is unfit for parsing.

    ScenarioautoconnectWhy
    Primary production linkyescomes up at boot
    Test or migration profilenomust not steal the device
    Several profiles on one deviceonly one yesotherwise boot behaviour is ambiguous
    • Changing a profile and expecting it live: values are pushed on activation (covered in the reapply page);
    • Reading the DEVICE column as “the NIC”: it is the currently activated device;
    • Deleting by name without checking: the UUID is the identifier, names can repeat;
    • Experimenting on ens18 over SSH: easy way to lock yourself out; use dummy devices first.
    Terminal window
    sudo nmcli connection add type dummy ifname dummy9 con-name drill ipv4.method manual ipv4.addresses 10.96.0.1/24
    sudo nmcli connection up drill
    ip -4 -br addr show dummy9
    sudo nmcli -g ipv4.addresses connection show drill
    sudo nmcli connection delete drill

    Checks:

    1. dummy9 exists with 10.96.0.1/24;
    2. The -g value matches ip addr;
    3. The device disappears after connection delete;
    4. SSH was never interrupted.

    常见问题

    Where are profiles stored?

    As keyfiles under /etc/NetworkManager/system-connections/ with mode 600 — they can be version controlled directly.

    Can I import several profiles at once?

    Yes: copy the keyfiles in and run nmcli connection reload.

    Are dummy interfaces useful outside labs?

    They carry extra addresses and are handy for testing, but they produce no real traffic.