NetworkManager and nmcli Explained: Wired, Wi-Fi, Static IPs, and VPNs
NetworkManager handles networking on almost every Linux desktop and on Fedora, RHEL, and many server installs. Most people only meet it through the network icon in the corner of the screen, but its command-line tool, nmcli, can do everything the GUI can, and is often faster. Ubuntu servers usually use Netplan with systemd-networkd instead.
Devices and connections
Two concepts matter:
- A device is a network interface:
enp1s0,wlp2s0,wg0 - A connection (profile) is a saved configuration: addresses, DNS, Wi-Fi password, VPN settings
nmcli device status
nmcli connection show
DEVICE TYPE STATE CONNECTION
enp1s0 ethernet connected Wired connection 1
wlp2s0 wifi connected HomeWiFi
A laptop might have profiles for home Wi-Fi, office Wi-Fi, and a wired dock; NetworkManager picks the right one automatically. Most nmcli words can be abbreviated: nmcli con and nmcli dev work fine.
Wi-Fi
nmcli device wifi list
nmcli device wifi connect "HomeWiFi" --ask
nmcli radio wifi off # and on
--ask prompts for the password instead of putting it in your shell history. For lower-level Wi-Fi details, see our Wi-Fi on Linux guide.
Static IP address
Modify the existing profile rather than creating a new one:
nmcli con mod "Wired connection 1" \
ipv4.method manual \
ipv4.addresses 192.168.1.50/24 \
ipv4.gateway 192.168.1.1 \
ipv4.dns "1.1.1.1 9.9.9.9"
nmcli con up "Wired connection 1"
Switch back to DHCP:
nmcli con mod "Wired connection 1" ipv4.method auto ipv4.addresses "" ipv4.gateway ""
nmcli con up "Wired connection 1"
Addresses use CIDR notation; our subnetting guide explains it. Over SSH, be careful: a wrong address cuts you off. Test with a console available, or run the change and a fallback in a tmux session.
DNS only
Keep DHCP addresses but use your own DNS servers:
nmcli con mod "HomeWiFi" ipv4.ignore-auto-dns yes ipv4.dns "9.9.9.9 1.1.1.1"
nmcli con up "HomeWiFi"
resolvectl status
On systems using systemd-resolved, resolvectl shows what each interface actually uses; see our systemd-resolved guide.
Bridges
A bridge for virtual machines, with the physical NIC as a member:
nmcli con add type bridge ifname br0 con-name br0 ipv4.method auto
nmcli con add type bridge-slave ifname enp1s0 master br0
nmcli con up br0
Then point VMs at br0 in virt-manager. Our VLANs and bridges guide covers when you need one.
VPNs
Import a WireGuard configuration file directly:
nmcli con import type wireguard file /etc/wireguard/wg0.conf
nmcli con up wg0
OpenVPN works the same way with type openvpn once the NetworkManager-openvpn plugin is installed. Our WireGuard guide and WireGuard config generator help with the config file itself.
Where profiles live
Profiles are keyfiles in /etc/NetworkManager/system-connections/, one per connection, owned by root with mode 600 because they may contain passwords. You can edit them and run nmcli con reload, but nmcli con mod is safer. The older ifcfg format on Red Hat systems is deprecated.
nmtui
Prefer a menu? nmtui gives a text interface for editing and activating connections and setting the hostname. It is ideal over SSH.
Troubleshooting
nmcli general status
nmcli -f GENERAL,IP4,IP6 device show enp1s0
journalctl -u NetworkManager -b --no-pager | tail -50
Common issues:
- “Device is strictly unmanaged”: another tool, such as Netplan with networkd or an old
/etc/network/interfacesentry, owns that interface - Two default routes: wired and Wi-Fi both active; NetworkManager picks by route metric, adjustable with
ipv4.route-metric - DNS not changing: check
ipv4.ignore-auto-dnsand whether systemd-resolved is in use
Our network troubleshooting commands guide covers the next steps.
Frequently Asked Questions
What is NetworkManager?
A daemon that manages network connections on Linux: wired, Wi-Fi, mobile broadband, VPNs, bridges, and more. It is the default on Fedora, RHEL, Ubuntu Desktop, Debian with a desktop, and most other desktop distributions, and is controlled with GUI settings, nmcli, or nmtui.
What is the difference between a device and a connection?
A device is a network interface such as enp1s0 or wlan0. A connection, or profile, is a saved set of settings such as addresses, DNS, and Wi-Fi password. A device can have several profiles, and NetworkManager activates one at a time on it.
How do I set a static IP with nmcli?
Modify the connection: nmcli con mod “name” ipv4.method manual ipv4.addresses 192.168.1.50/24 ipv4.gateway 192.168.1.1 ipv4.dns “1.1.1.1 9.9.9.9”, then nmcli con up “name” to apply it.
Where does NetworkManager store connections?
As keyfiles in /etc/NetworkManager/system-connections/, one file per connection, readable only by root because they can contain passwords. Older Red Hat systems used ifcfg files, which are deprecated. On Ubuntu, connections may also be written as Netplan files.
Is there a text menu instead of commands?
Yes. nmtui gives a simple menu in the terminal for editing and activating connections and setting the hostname. It is handy on servers and over SSH when you do not want to remember nmcli syntax.
How do I see why a connection failed?
Run journalctl -u NetworkManager -b and look around the time of the failure. nmcli device status shows each interface’s state, and nmcli -f GENERAL,IP4 device show interface shows its current addresses and gateway.