nmcli, Start to Finish: Addresses, Gateways, and Re-applying a Connection

root@rhel9:~# nmcli con edit eth0
root@rhel9:~# nmcli con edit eth0 # the interactive editor — the part everyone skips

nmcli, Start to Finish
Addresses, Gateways, and Re-applying a Connection

NetworkManager owns the network on every modern RHEL, AlmaLinux, Oracle Linux, and Ubuntu box that uses it — and nmcli is the way to drive it from the shell. This is the full usage in one place: look at what is there, create a connection, add an address and a gateway, modify a profile without the editor, add a second address in the same subnet, and re-apply the profile without dropping the link. One convention: # means run as root, nmcli> means inside the interactive editor. The examples use a connection called eth0 — yours may be called Wired connection 1 or System eth0, and the first section shows how to find out.

# the short version — the most common job in eight lines
# nmcli con show   # connection names — the first column is the profile, the last is the interface
# nmcli con edit eth0   # open the interactive editor on that profile
nmcli> set ipv4.addresses 192.168.1.10/24, 192.168.1.11/24   # the whole list, comma-separated
nmcli> set ipv4.gateway 192.168.1.1   # the default route, in the same profile
nmcli> save   # write it to the profile
nmcli> quit   # leave the editor
# nmcli device reapply eth0   # apply it live, no link flap
# ip addr show eth0   # both addresses, .10 and .11
Every command here appears again below, with its explanation. The middle four lines run inside the editor, not at the shell — the prompt tells you where you are. One detail the short version hides: on a DHCP connection, set asks whether to switch the method to manual. Answer no and you keep DHCP plus the static secondaries; answer yes and the profile goes fully static.
# look before you touch — profiles, devices, and the live state
# nmcli con show   # every profile: NAME, UUID, TYPE, DEVICE
# nmcli device status   # every interface: DEVICE, TYPE, STATE, CONNECTION
# nmcli dev show eth0   # the live state of one interface: addresses, gateway, DNS, route metric
The distinction that runs through this whole post: a connection is a saved profile (a name, an address, a gateway), and a device is the physical or virtual interface it is applied to. nmcli con edit, con mod, and con up take the profile name; nmcli device reapply takes the interface name. nmcli con show prints both side by side, which is why it is always the first command. nmcli dev show is the live truth — what the interface actually has right now, as opposed to what the profile says it should have. When the two disagree, something was changed in the profile and never applied, which is the subject of the re-apply section below.
# create a connection — address, gateway, and DNS in one command
# nmcli con add type ethernet ifname eth0 con-name office-lan ipv4.method manual ipv4.addresses 192.168.1.10/24 ipv4.gateway 192.168.1.1 ipv4.dns "192.168.1.53,8.8.8.8"   # one command, the whole static profile
# ip addr show eth0   # 192.168.1.10/24, live already — con add activates immediately
# ip route   # default via 192.168.1.1, proto static
con add creates the profile and activates it in the same step — there is no separate apply for a new connection. The pieces: type ethernet and ifname eth0 say what it attaches to, con-name office-lan is the profile name you will use from here on, ipv4.method manual says no DHCP, and the addresses, gateway, and DNS are properties on the profile. DNS takes a quoted, comma-separated list. The gateway is what makes the default route appear — a profile with addresses and no gateway has no route out. For DHCP instead of static, the whole command shrinks to nmcli con add type ethernet ifname eth0 con-name office-lan ipv4.method auto, and the address, gateway, and DNS come from the lease.
# the interactive editor — set, save, quit, up
# nmcli con edit eth0   # the connection name from nmcli con show — quote it if it has spaces
nmcli> print ipv4.addresses   # what the profile holds right now
The editor is nmcli con edit followed by the connection name — the profile, not the device. print ipv4.addresses shows what is already there (on a DHCP box: nothing, the address comes from the lease). The editor’s own commands are short: set, print, describe, verify, save, activate, quit — type help inside it for the full list.

Set the list

nmcli> set ipv4.addresses 192.168.1.10/24, 192.168.1.11/24   # the whole list, comma-separated — this replaces whatever was there
On a DHCP connection, setting addresses asks a question first:
nmcli> set ipv4.addresses 192.168.1.10/24, 192.168.1.11/24
Do you also want to set 'ipv4.method' to 'manual'? [yes]: no
Two facts from the property’s own description (describe ipv4.addresses in the editor): the addresses are listed in decreasing priority, so the first one is the primary — the one the kernel uses as the source address by default — and a missing prefix is read as /32, so always write the prefix. The method question is the part people trip over: answer no and the profile stays on DHCP with your static addresses riding along as secondaries; answer yes and the profile goes fully static, in which case set a gateway too (set ipv4.gateway 192.168.1.1) or the box has no default route. And that is the nugget that started this post: one interface, two addresses in the same subnet, both in the profile, both surviving a reboot — the thing ip addr add can never give you.

Save it, apply it, check it

nmcli> save   # write the profile
nmcli> quit   # leave the editor
# nmcli con up eth0   # apply the profile — this is the step that makes the addresses live
# ip addr show eth0   # both addresses, .10 and .11
Saving writes the profile; it does not touch the running interface. nmcli con up is what applies it — and on a remote box, that is the moment the link flaps, so do it from a console or a second path if the address you are changing is the one you are connected through. verify inside the editor checks the profile for errors before you save, which is worth doing when the list is long. The next section is the way to apply without the flap.
# modify without the editor — the + and – prefixes are the whole trick
# nmcli con mod eth0 +ipv4.addresses 192.168.1.11/24   # append one address — the + matters
# nmcli con mod eth0 -ipv4.addresses 192.168.1.11/24   # remove that one address again
# nmcli con mod eth0 ipv4.gateway 192.168.1.2   # move the default route
# nmcli con mod eth0 ipv4.dns "1.1.1.1"   # replace the DNS list
# nmcli con mod eth0 +ipv4.dns 9.9.9.9   # append a DNS server instead
# nmcli con mod eth0 connection.autoconnect no   # stop it coming up on its own
con mod edits the saved profile and nothing else — the running interface does not change until you apply it, which is the next section. The + and - prefixes control list properties: +ipv4.addresses appends to the list, -ipv4.addresses removes one entry, and a bare ipv4.addresses with no prefix replaces the entire list — the commonest way to lose an address is a con mod without the +. The same prefixes work on ipv4.dns and ipv4.routes. Single-value properties take no prefix: ipv4.gateway, ipv4.method, connection.autoconnect, ethernet.mtu. There is a second footgun next door: nmcli device modify changes the running device only and is never written to the profile, so it is gone at the next activation — the same trap as ip addr add, in fancier clothes.
# re-applying — the no-flap path, and the flap path
# nmcli device reapply eth0   # apply the profile to the running interface, without reactivating it
# ip addr show eth0   # the new address is live, the link never went down
# ip route   # the new gateway is live too
This is the command the post is really about. device reapply takes the interface name and pushes the current profile onto the running device without deactivating it. Tested on AlmaLinux 10.3 with NetworkManager 1.58: an appended address, a changed gateway, and a changed DNS list all went live on reapply, with the link up the whole time. The man page says attempt to update the device — not every change can be reapplied, and when one cannot, the command says so and you fall back to the flap path:
# nmcli con down eth0   # the link goes down; the addresses leave with it
# nmcli con up eth0   # the link comes back, with the whole profile applied
con up on its own reactivates the profile, which is the same flap in one command — it is the right call when the change is the method itself (DHCP to static, or back), or when reapply refuses. con down followed by con up is the full cycle: down takes the addresses off the interface entirely, up brings the profile back. Either way, do it from a console or a second path when the address you are changing is the one you are connected through — the flap is the price of reactivating, and reapply exists precisely so you do not have to pay it.
# editing the file on disk — keyfiles, and the reload that picks them up
# ls /etc/NetworkManager/system-connections/   # the profiles, one keyfile each, root-only
# nmcli con reload   # re-read every profile from disk — NetworkManager does not watch the files
# nmcli con show eth0   # the hand edit is visible now
Profiles live as keyfiles in /etc/NetworkManager/system-connections/, one file per connection, readable only by root. Editing one by hand is legitimate — it is how automation and image builds set addresses — but NetworkManager does not watch the directory, so a hand edit is invisible until nmcli con reload re-reads the files. Tested: changing dns= in the keyfile left con show reporting the old value until the reload, and the new value immediately after. Do not confuse it with plain nmcli reload, which reloads NetworkManager’s own configuration and not the connections — that one takes flags, including dns-rc, which rewrites /etc/resolv.conf from the current DNS settings.
# if the profile file is lost — the ifcfg trick, and the keyfile rescue

RHEL 7: restart NetworkManager and it builds a default

# systemctl restart NetworkManager   # NM finds a managed Ethernet device with no profile and builds a default one
# nmcli con show   # "Wired connection 1", DHCP — and a fresh ifcfg file on disk
This is the regeneration you remember from RHEL 7. The ifcfg file is gone, but NetworkManager creates a temporary default wired connection for any managed Ethernet device that has no profile, and the ifcfg plugin writes it out as a new ifcfg file. Two catches: it comes back as DHCP, not your old static settings — those died with the file, so re-enter them with con mod or con add — and if the device is listed in /var/lib/NetworkManager/no-auto-default.state, NM will not recreate the default at all. That file records devices whose default was already deleted or saved once; clear the entry, or just con add the profile yourself. The deterministic route on any version is the same: nmcli con add recreates the profile and writes the file — an ifcfg file on RHEL 7, a keyfile on RHEL 9 and 10.

RHEL 9 and 10: rescue it before you reload

# nmcli con mod eth0 connection.autoconnect yes   # any trivial change: NM rewrites the file on the spot
# ls /etc/NetworkManager/system-connections/   # the keyfile is back
On the keyfile versions the rescue works differently, and the order matters. The keyfile is gone but NetworkManager still holds the connection in memory — it is still listed in nmcli con show — and the file is gone, so the first nmcli con reload or daemon restart drops the connection for good, address and all. Tested on AlmaLinux 10.3: a trivial con mod after deleting the keyfile rewrote it immediately, while deleting the file and reloading first left nothing behind to recover. So if the file is lost: do not reload, do not restart — change anything in the profile and let NetworkManager write it back. And if you restored a file from backup instead, nmcli con load /etc/sysconfig/network-scripts/ifcfg-eth0 loads that one file without reloading everything.
# clone and delete — the cheap way to a second profile
# nmcli con clone eth0 office-lan-test   # a copy with a new UUID, same addresses — change the address before you activate it
# nmcli con mod office-lan-test ipv4.addresses 192.168.1.20/24   # the clone gets its own address
# nmcli con del office-lan-test   # remove a profile you no longer need
Cloning is the fast way to a variant profile — a test copy of a working connection, or the starting point for the second address in the cutover story that opened this post. The clone is a full copy with a fresh UUID, so give it its own address before you activate it, or two profiles will claim the same one. Deleting a profile removes the keyfile; if it was the active profile, the device deactivates, and NetworkManager may activate another fitting profile in its place.
# the temporary way, for contrast — know what you are replacing
# ip addr add 192.168.1.11/24 dev eth0   # immediate, and gone at the next reboot
# ip addr show eth0                     # both addresses listed, .10 and .11
ip addr add is the command everyone reaches for, and it is the right tool for a test that lasts an afternoon. It is not in any profile, so it does not survive a reboot — and a nmcli con up reapplies the profile, which replaces the runtime addresses with the profile’s. If the address has to be there next week, it has to be in the profile. That is the whole post, really; everything above is the fastest way to put it there and keep it there.
# quick reference — the whole post as a table
I need to… Command
List profiles and interfaces nmcli con show and nmcli device status
See the live state of an interface nmcli dev show eth0
Create a static connection nmcli con add type ethernet ifname eth0 con-name office-lan ipv4.method manual ipv4.addresses 192.168.1.10/24 ipv4.gateway 192.168.1.1 ipv4.dns "192.168.1.53,8.8.8.8"
Create a DHCP connection nmcli con add type ethernet ifname eth0 con-name office-lan ipv4.method auto
Open the interactive editor nmcli con edit eth0
See the addresses in the profile print ipv4.addresses (inside the editor)
Set the whole address list set ipv4.addresses 192.168.1.10/24, 192.168.1.11/24 (inside the editor)
Set the gateway in the editor set ipv4.gateway 192.168.1.1 (inside the editor)
Save the profile and leave save, then quit (inside the editor)
Append one address, no editor nmcli con mod eth0 +ipv4.addresses 192.168.1.11/24
Remove one address, no editor nmcli con mod eth0 -ipv4.addresses 192.168.1.11/24
Change the gateway / DNS nmcli con mod eth0 ipv4.gateway 192.168.1.2 / nmcli con mod eth0 ipv4.dns "1.1.1.1"
Apply without dropping the link nmcli device reapply eth0
Apply with a reactivation nmcli con up eth0 (or con down then con up)
Re-read hand-edited keyfiles nmcli con reload
Regenerate a lost ifcfg file (RHEL 7) systemctl restart NetworkManager — NM builds a default DHCP connection and writes a fresh ifcfg file
Rescue a deleted keyfile (RHEL 9/10) nmcli con mod eth0 connection.autoconnect yes — any trivial change rewrites the file; never reload first
Load one restored profile file nmcli con load /etc/sysconfig/network-scripts/ifcfg-eth0
Clone / delete a profile nmcli con clone eth0 office-lan-test / nmcli con del office-lan-test
See the live addresses / routes ip addr show eth0 / ip route
Go back to pure DHCP nmcli con mod eth0 ipv4.method auto ipv4.addresses "" ipv4.gateway ""
The model: a connection is a saved profile, a device is the interface it runs on — con commands take the profile name, device reapply takes the interface name.
The durable way: addresses live in the profile, not on the command line — ip addr add is gone at the next reboot.
The editor: nmcli con edit, set with a comma-separated list, save, quit — and on DHCP, answer no to keep DHCP plus static secondaries.
The prefixes: + appends, - removes, no prefix replaces the whole list.
The apply: device reapply pushes addresses, gateway, and DNS live without a flap; con up reactivates when reapply cannot.
The lost file: RHEL 7 rebuilds a default DHCP ifcfg on a NetworkManager restart; on keyfile systems, a trivial con mod rewrites the file — but only before a reload.
The trap: flipping to DHCP leaves old addresses behind unless you clear them in the same command.

Commands verified November 2026 on AlmaLinux 10.3 (nmcli 1.58): the interactive editor session and describe ipv4.addresses output, the +/- modify syntax in nmcli(1), device reapply (“attempt to update device with changes to the currently active connection”), and a live dummy-interface test — con add with address, gateway, and DNS activated immediately; a profile-only +ipv4.addresses left the live interface unchanged until device reapply brought the second address, the new gateway, and the new DNS live without a flap; con down dropped the addresses and con up restored both; con clone made a copy with a fresh UUID; and a hand-edited keyfile only showed up in con show after nmcli con reload. The lost-file section was verified the same day: the default-wired-connection behaviour in NetworkManager.conf(5) (a temporary default for a managed Ethernet device with no profile; /var/lib/NetworkManager/no-auto-default.state blocks recreation), the RHEL 7 Networking Guide on ifcfg files and con load, and a live dummy-interface test on AlmaLinux 10.3 — a deleted keyfile was rewritten by a trivial con mod while the connection was still listed, and gone with its address after a con reload. The DHCP method prompt was confirmed under a real terminal on the same build, and is also documented in the original 2017 write-up of this trick (szakmeister.net). The stale-address behaviour on switching to DHCP is documented in the ComputingForGeeks nmcli cheat sheet, tested on Rocky Linux 10.2 (NetworkManager 1.56), October 2026. The editor and the +/- syntax work the same way back to NetworkManager 1.x (RHEL 7+); on Ubuntu, nmcli only speaks for interfaces NetworkManager owns — netplan-managed interfaces answer to netplan instead.

Series: GuidesPublished: 18 Nov 2026

Scroll to Top