NetworkManager is a dynamic network control and configuration system that attempts to keep network connectivity active when available. It manages Ethernet, WiFi, mobile broadband (WWAN), and PPPoE devices while providing VPN integration.
nmcli - Command-line interfacenmtui - Text-based user interfacenm-connection-editor - GUI editornmcli [OPTIONS] OBJECT { COMMAND | help }
Objects:
general NetworkManager's general status and operations
networking Overall networking control
radio NetworkManager radio switches
connection NetworkManager's connections
device Devices managed by NetworkManager
agent NetworkManager secret agent or polkit agent
monitor Monitor NetworkManager changes
| Option | Description |
|---|---|
-t, --terse |
Output for scripting (no headers, colon-separated) |
-p, --pretty |
Human-readable output |
-m, --mode |
Output mode: tabular, multiline |
-c, --colors |
Use colors in output (yes/no/auto) |
-f, --fields |
Specify fields to output |
-w, --wait |
Wait for operation to complete |
# Show NetworkManager status
nmcli general status
# Show all devices
nmcli device status
# Show all connections
nmcli connection show
# Show active connections only
nmcli connection show --active
# Show device details
nmcli device show eth0
# Show connection details
nmcli connection show "Wired connection 1"
# List all devices
nmcli device
# Show detailed device information
nmcli device show
# Show specific device
nmcli device show eth0
# Monitor device changes
nmcli device monitor
# Monitor specific device
nmcli device monitor eth0
# Connect a device
nmcli device connect eth0
# Disconnect a device
nmcli device disconnect eth0
# Reapply connection on device
nmcli device reapply eth0
# Delete software device
nmcli device delete bond0
# List available WiFi networks
nmcli device wifi list
# Rescan for WiFi networks
nmcli device wifi rescan
# Connect to WiFi network
nmcli device wifi connect "SSID" password "password"
# Connect to hidden WiFi
nmcli device wifi connect "SSID" password "password" hidden yes
# Show WiFi radio status
nmcli radio wifi
# Turn WiFi on/off
nmcli radio wifi on
nmcli radio wifi off
# List all connections
nmcli connection show
# Show connection details
nmcli connection show "Wired connection 1"
# Show active connections
nmcli connection show --active
# Show connection in machine-readable format
nmcli -t connection show "Wired connection 1"
nmcli connection add \
type ethernet \
con-name "My-Ethernet" \
ifname eth0 \
ipv4.method auto \
ipv6.method auto
nmcli connection add \
type ethernet \
con-name "Static-Ethernet" \
ifname eth0 \
ipv4.method manual \
ipv4.addresses "192.168.1.100/24" \
ipv4.gateway "192.168.1.1" \
ipv4.dns "8.8.8.8,8.8.4.4"
nmcli connection add \
type wifi \
con-name "Home-WiFi" \
ifname wlan0 \
ssid "MyNetwork" \
wifi-sec.key-mgmt wpa-psk \
wifi-sec.psk "password"
# Change to static IP
nmcli connection modify "Wired connection 1" \
ipv4.method manual \
ipv4.addresses "192.168.1.100/24" \
ipv4.gateway "192.168.1.1" \
ipv4.dns "8.8.8.8,8.8.4.4"
# Change to DHCP
nmcli connection modify "Wired connection 1" \
ipv4.method auto
# Add additional DNS server
nmcli connection modify "Wired connection 1" \
+ipv4.dns "1.1.1.1"
# Remove DNS server
nmcli connection modify "Wired connection 1" \
-ipv4.dns "8.8.8.8"
# Change connection autoconnect priority
nmcli connection modify "Wired connection 1" \
connection.autoconnect-priority 10
# Bring connection up
nmcli connection up "Wired connection 1"
# Bring connection down
nmcli connection down "Wired connection 1"
# Reload connection from disk
nmcli connection reload
# Reload specific connection
nmcli connection reload "Wired connection 1"
# Delete a connection
nmcli connection delete "Wired connection 1"
# Delete by UUID
nmcli connection delete uuid 12345678-1234-1234-1234-123456789abc
# Edit connection interactively
nmcli connection edit "Wired connection 1"
# Commands within interactive mode:
# print - Print current values
# set - Set property value
# remove - Remove property
# describe - Describe property
# save - Save changes
# activate - Activate connection
# back - Go to upper level
# quit - Quit without saving
# Launch nmtui
nmtui
# Options:
nmtui edit # Edit a connection
nmtui connect # Activate a connection
nmtui hostname # Set system hostname
Connection profiles are stored as keyfiles in:
/etc/NetworkManager/system-connections/
[connection]
id=MyEthernet
uuid=12345678-1234-1234-1234-123456789abc
type=ethernet
autoconnect=true
interface-name=eth0
[ethernet]
[ipv4]
method=manual
address1=192.168.1.100/24,192.168.1.1
dns=8.8.8.8;8.8.4.4;
[ipv6]
method=auto
[proxy]
# Edit profile with your favorite editor
sudo vi /etc/NetworkManager/system-connections/MyEthernet.nmconnection
# Set correct permissions
sudo chmod 600 /etc/NetworkManager/system-connections/MyEthernet.nmconnection
# Reload the connection
sudo nmcli connection reload MyEthernet
# Bring it up
sudo nmcli connection up MyEthernet
# Complete static IP configuration
nmcli connection modify "Wired connection 1" \
ipv4.method manual \
ipv4.addresses "192.168.1.100/24" \
ipv4.gateway "192.168.1.1" \
ipv4.dns "8.8.8.8,8.8.4.4" \
ipv4.dns-search "example.com"
# Apply changes
nmcli connection up "Wired connection 1"
# Add primary and secondary IP
nmcli connection modify "Wired connection 1" \
ipv4.addresses "192.168.1.100/24,192.168.1.101/24"
# Or add additional IP to existing
nmcli connection modify "Wired connection 1" \
+ipv4.addresses "192.168.1.102/24"
# Set DNS servers
nmcli connection modify "Wired connection 1" \
ipv4.dns "8.8.8.8,8.8.4.4"
# Add additional DNS server
nmcli connection modify "Wired connection 1" \
+ipv4.dns "1.1.1.1"
# Ignore automatic DNS from DHCP
nmcli connection modify "Wired connection 1" \
ipv4.ignore-auto-dns yes
# Set MTU for connection
nmcli connection modify "Wired connection 1" \
802-3-ethernet.mtu 1500
This covers the basics of NetworkManager and nmcli. Continue to: