AlmaLinux 10: managing NetworkManager profiles as code
Test scope
Section titled “Test scope”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 showNAME TYPE DEVICElab-static ethernet ens18lo loopback loens18 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.
Create profiles from the command line
Section titled “Create profiles from the command line”nmcli connection add type dummy ifname dummy0 con-name lab-a \ ipv4.method manual ipv4.addresses 10.99.0.1/24 connection.autoconnect yesnmcli 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 yeslab-b dummy0 noconnection.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.
Exclusivity on one device
Section titled “Exclusivity on one device”$ nmcli connection up lab-a$ ip -4 -br addr show dummy0dummy0 UNKNOWN 10.99.0.1/24$ nmcli connection up lab-b$ ip -4 -br addr show dummy0dummy0 UNKNOWN 10.99.0.2/24Activating lab-b deactivates lab-a: a device is an exclusive resource, profiles do not stack.
Extract values with -g
Section titled “Extract values with -g”$ nmcli -g ipv4.method connection show lab-bmanual$ nmcli -g GENERAL.DEVICE connection show lab-bdummy0-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.
When autoconnect should be off
Section titled “When autoconnect should be off”| Scenario | autoconnect | Why |
|---|---|---|
| Primary production link | yes | comes up at boot |
| Test or migration profile | no | must not steal the device |
| Several profiles on one device | only one yes | otherwise boot behaviour is ambiguous |
Common traps
Section titled “Common traps”- 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
ens18over SSH: easy way to lock yourself out; use dummy devices first.
Practice: a safe experiment with dummy
Section titled “Practice: a safe experiment with dummy”sudo nmcli connection add type dummy ifname dummy9 con-name drill ipv4.method manual ipv4.addresses 10.96.0.1/24sudo nmcli connection up drillip -4 -br addr show dummy9sudo nmcli -g ipv4.addresses connection show drillsudo nmcli connection delete drillChecks:
dummy9exists with 10.96.0.1/24;- The
-gvalue matchesip addr; - The device disappears after
connection delete; - 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.
Next steps
Section titled “Next steps”- Troubleshooting: /en/network-troubleshoot/
- Network basics: /en/network-basics/
- Troubleshooting: /en/network-troubleshoot/