🎁 New User? Get 20% off your first purchase with code NEWUSER20 Register Now →
Menu

Categories

nmcli Command

Intermediate Networking man(1)

NetworkManager command-line client

📅 Updated: Mar 16, 2026
SYNTAX
nmcli [OPTIONS] OBJECT {COMMAND | help}

What Does nmcli Do?

The nmcli command is the primary command-line tool for controlling NetworkManager — the default network management daemon on most modern Linux distributions including Ubuntu, Fedora, RHEL, AlmaLinux, and CentOS Stream.

nmcli allows you to create, display, edit, delete, activate, and deactivate network connections, as well as control and display network device status. It replaces older tools like ifconfig and route for network configuration on systems running NetworkManager.

Unlike manual /etc/network/interfaces editing, nmcli provides a structured, persistent, and distribution-agnostic way to manage all types of network connections: Ethernet, WiFi, VPN (including WireGuard and OpenVPN), bridges, VLANs, bonds, and teams. Changes made with nmcli persist across reboots automatically.

nmcli is essential for server administration, especially when configuring static IPs, DNS servers, bonded interfaces for redundancy, VLAN tagging, or WiFi connections from the command line on headless systems.

Options & Flags

OptionDescriptionExample
general status Show overall NetworkManager status nmcli general status
device status List all network devices and their state nmcli device status
connection show List all connections (active and inactive) nmcli connection show
connection show --active List only active connections nmcli connection show --active
connection up NAME Activate a connection by name nmcli connection up "Wired 1"
connection down NAME Deactivate a connection nmcli connection down "Wired 1"
connection add Create a new connection profile nmcli connection add type ethernet con-name eth0-static ifname eth0
connection modify Modify an existing connection nmcli connection modify eth0-static ipv4.addresses 10.0.0.5/24
connection delete Delete a connection profile nmcli connection delete "Wired 1"
-t Terse output for scripting (colon-separated) nmcli -t -f NAME,STATE connection show

Practical Examples

#1 Show all connections

Lists all configured connections with name, UUID, type, and device.
$ nmcli connection show
Output: NAME UUID TYPE DEVICE\nWired 1 a1b2c3d4-e5f6-7890-abcd-ef1234567890 ethernet eth0

#2 Set static IP address

Configure static IP, gateway, and DNS on an existing connection. Apply with: nmcli connection up "Wired 1"
$ nmcli connection modify "Wired 1" ipv4.addresses 192.168.1.100/24 ipv4.gateway 192.168.1.1 ipv4.dns "1.1.1.1,8.8.8.8" ipv4.method manual

#3 Switch to DHCP

Reset connection to automatic (DHCP) configuration.
$ nmcli connection modify "Wired 1" ipv4.method auto ipv4.addresses "" ipv4.gateway "" ipv4.dns ""

#4 Connect to WiFi

Connect to a WiFi network. The connection profile is created and activated automatically.
$ nmcli device wifi connect "MyNetwork" password "MyPassword"

#5 List available WiFi networks

Scan and display nearby WiFi access points with signal strength, security, and channel.
$ nmcli device wifi list

#6 Create a network bridge

Create a bridge interface and add eth0 as a bridge port. Useful for KVM/QEMU VMs.
$ nmcli connection add type bridge con-name br0 ifname br0 ipv4.addresses 10.0.0.1/24 ipv4.method manual && nmcli connection add type bridge-slave con-name br0-port1 ifname eth0 master br0

#7 Add a VLAN interface

Create VLAN 100 on interface eth0 with a static IP.
$ nmcli connection add type vlan con-name vlan100 ifname eth0.100 dev eth0 id 100 ipv4.addresses 10.100.0.5/24 ipv4.method manual

#8 Monitor connection changes

Watch for real-time NetworkManager events — connection changes, device state changes, etc.
$ nmcli monitor

Tips & Best Practices

Apply changes after modify: nmcli connection modify only saves the profile. You must run nmcli connection up "name" to apply the changes to the active connection.
Tab completion: nmcli supports tab completion in bash/zsh. Type nmcli con<TAB> to auto-complete. Install bash-completion package if not working.
Connection name vs device name: Connection names and device names are different. A device (eth0) can have multiple connection profiles. Use nmcli connection show to see which profile is active on which device.
Use -f for specific fields: Filter output fields: nmcli -f NAME,TYPE,DEVICE connection show — cleaner output for scripts and monitoring.
Config files location: nmcli stores connection profiles in /etc/NetworkManager/system-connections/ as .nmconnection files (keyfile format). You can edit these directly too.

Frequently Asked Questions

How do I set a static IP in Linux?
Use: nmcli connection modify "Wired 1" ipv4.addresses 192.168.1.100/24 ipv4.gateway 192.168.1.1 ipv4.dns "1.1.1.1" ipv4.method manual && nmcli connection up "Wired 1"
What is the difference between nmcli and ifconfig?
ifconfig is deprecated and only shows/sets temporary network config. nmcli works with NetworkManager for persistent configuration that survives reboots. nmcli also manages WiFi, VPNs, VLANs, and bonds.
How do I restart networking with nmcli?
Restart a specific connection: nmcli connection down "name" && nmcli connection up "name". Or restart NetworkManager itself: sudo systemctl restart NetworkManager.
How do I see my current IP address with nmcli?
Use: nmcli device show eth0 | grep IP4 — or for all devices: nmcli -f DEVICE,IP4.ADDRESS device show
How do I delete a WiFi network from nmcli?
First find the connection name: nmcli connection show, then delete it: nmcli connection delete "WiFi-Name". This removes the saved password and profile.

Master Linux with Professional eBooks

Curated IT eBooks covering Linux, DevOps, Cloud, and more

Browse Books →