Quick Command:nmcli Purpose: Command-line tool for controlling NetworkManager and reporting network status Best For: Scripting, automation, remote administration, and quick operations
1. Introduction to nmcli
1.1 What is nmcli?
nmcli is a command-line client for NetworkManager. It allows users to control NetworkManager and report network status without requiring a graphical interface. It's designed for both interactive use and scripting.
1.2 Key Features
Complete NetworkManager control from command line
Script-friendly output formats
Interactive connection editor mode
Support for all connection types
Real-time monitoring capabilities
Tab completion support
Works over SSH and in headless environments
1.3 Why Use nmcli?
Scenario
Why nmcli
Automation
Scriptable, consistent output, exit codes
Remote Administration
Works over SSH, no GUI required
Server Management
Lightweight, headless-friendly
Quick Status Checks
Fast, one-line commands
CI/CD Pipelines
Integrates with build systems
Mass Deployment
Batch operations across systems
2. Basic Syntax and Structure
2.1 Command Structure
nmcli [OPTIONS] OBJECT { COMMAND | help }
2.2 Common Options
Option
Description
Example
-t, --terse
Machine-readable output (colon-separated)
nmcli -t device status
-p, --pretty
Human-readable formatted output
nmcli -p connection show
-m, --mode
Output mode: tabular or multiline
nmcli -m multiline
-c, --colors
Use colors: yes, no, auto
nmcli -c no
-f, --fields
Specify which fields to display
nmcli -f NAME,TYPE connection show
-g, --get-values
Get specific values (script-friendly)
nmcli -g IP4.ADDRESS device show
-w, --wait
Timeout for operations (seconds)
nmcli -w 30 connection up eth0
-a, --ask
Prompt for missing parameters
nmcli -a connection add
-s, --show-secrets
Display passwords/secrets
nmcli -s connection show
-h, --help
Show help
nmcli --help
-v, --version
Show version
nmcli --version
2.3 Objects
Object
Abbreviation
Purpose
general
g
NetworkManager status and operations
networking
n
Overall networking control
radio
r
Radio switches (WiFi, WWAN)
connection
c, con
Connection profiles
device
d, dev
Network devices
agent
-
Secret agent operations
monitor
m
Monitor NetworkManager changes
2.4 Command Abbreviations
Pro Tip: nmcli supports abbreviations for faster typing. As long as the abbreviation is unambiguous, it will work:
# These are all equivalent:
nmcli connection show
nmcli con show
nmcli c s
# These are equivalent:
nmcli device status
nmcli dev status
nmcli d s
3. General Operations
3.1 General Status and Information
# Show NetworkManager status
nmcli general status
# Show NetworkManager version
nmcli --version
# Show overall connectivity
nmcli general
# Get system hostname
nmcli general hostname
# Set system hostname
nmcli general hostname new-hostname
3.2 General Status Output
Example Output:
$ nmcli general status
STATE CONNECTIVITY WIFI-HW WIFI WWAN-HW WWAN
connected full enabled enabled enabled enabled
# Check if networking is enabled
nmcli networking
# Enable networking
nmcli networking on
# Disable networking (disconnects all)
nmcli networking off
# Check connectivity
nmcli networking connectivity
# Returns: none, portal, limited, full, unknown
# Force connectivity check
nmcli networking connectivity check
3.4 Radio Management
# Show all radio states
nmcli radio all
# Enable/disable WiFi
nmcli radio wifi on
nmcli radio wifi off
# Enable/disable mobile broadband
nmcli radio wwan on
nmcli radio wwan off
# Enable/disable all radios
nmcli radio all on
nmcli radio all off
4. Device Management
4.1 Device Status
# List all devices
nmcli device status
# or
nmcli device
# or
nmcli d
# Show detailed information about all devices
nmcli device show
# Show specific device details
nmcli device show eth0
# Show in script-friendly format
nmcli -t device status
# Show only specific fields
nmcli -f DEVICE,STATE,CONNECTION device status
4.2 Device Status Output
Example Output:
$ nmcli device status
DEVICE TYPE STATE CONNECTION
eth0 ethernet connected Wired connection 1
wlan0 wifi disconnected --
lo loopback unmanaged --
State
Meaning
connected
Device is connected with active connection
disconnected
Device is available but not connected
unavailable
Device is not available (carrier off, firmware missing)
unmanaged
Device is not managed by NetworkManager
connecting
Connection in progress
deactivating
Connection being torn down
4.3 Device Operations
# Connect a device (activates connection)
nmcli device connect eth0
# Disconnect a device
nmcli device disconnect eth0
# Reapply connection settings
nmcli device reapply eth0
# Set device to managed
nmcli device set eth0 managed yes
# Set device to unmanaged
nmcli device set eth0 managed no
# Delete software device (bond, bridge, etc.)
nmcli device delete bond0
4.4 WiFi Operations
# List available WiFi networks
nmcli device wifi list
# Rescan for WiFi networks
nmcli device wifi rescan
# Rescan specific device
nmcli device wifi rescan ifname wlan0
# Connect to WiFi network
nmcli device wifi connect "SSID" password "password"
# Connect to WiFi with specific interface
nmcli device wifi connect "SSID" password "password" ifname wlan0
# Connect to hidden WiFi
nmcli device wifi connect "SSID" password "password" hidden yes
# Show WiFi passwords for saved networks
nmcli -s device wifi show-password
# Show QR code for current WiFi (if supported)
nmcli device wifi show-password
4.5 WiFi List Output
Example Output:
$ nmcli device wifi list
IN-USE BSSID SSID MODE CHAN RATE SIGNAL BARS SECURITY
* 00:11:22:33:44:55 MyHomeNetwork Infra 6 130 Mbit/s 85 ▂▄▆█ WPA2
00:AA:BB:CC:DD:EE OfficeWiFi Infra 11 65 Mbit/s 65 ▂▄▆_ WPA2
00:99:88:77:66:55 GuestNetwork Infra 1 54 Mbit/s 45 ▂▄__ WPA2
# Show all connection profiles
nmcli connection show
# or
nmcli con show
# or
nmcli c s
# Show only active connections
nmcli connection show --active
# Show specific connection details
nmcli connection show "Wired connection 1"
# Show with all settings including secrets
nmcli -s connection show "Wired connection 1"
# Script-friendly output
nmcli -t connection show
# Show only specific fields
nmcli -f NAME,UUID,TYPE connection show
# Activate (bring up) a connection
nmcli connection up "My-Connection"
# Activate by UUID
nmcli connection up uuid 12345678-1234-1234-1234-123456789abc
# Activate connection on specific device
nmcli connection up "My-Connection" ifname eth0
# Deactivate (bring down) a connection
nmcli connection down "My-Connection"
# Deactivate by UUID
nmcli connection down uuid 12345678-1234-1234-1234-123456789abc
# Reload a connection from disk
nmcli connection reload
# Reload specific connection
nmcli connection reload "My-Connection"
# Load connection from file
nmcli connection load /etc/NetworkManager/system-connections/My-Connection.nmconnection
Warning: Deleting a connection is permanent. The connection profile file is removed from /etc/NetworkManager/system-connections/. Consider exporting the connection first.
# Edit existing connection interactively
nmcli connection edit "My-Connection"
# Edit by type (creates new if doesn't exist)
nmcli connection edit type ethernet
# Edit by UUID
nmcli connection edit uuid 12345678-1234-1234-1234-123456789abc
6.2 Interactive Editor Commands
Command
Description
print
Print all settings or specific property
describe
Describe a property
set
Set property value
remove
Remove property value
add
Add new value to property
change
Change property value
goto
Go to setting or submenu
back
Go up one level
save
Save connection (persistent or temporary)
activate
Activate the connection
verify
Verify connection settings
help
Show help
quit
Exit editor
6.3 Interactive Editor Example Session
Example Interactive Session:
$ nmcli connection edit type ethernet
===| nmcli interactive connection editor |===
Adding a new '802-3-ethernet' connection
Type 'help' or '?' for available commands.
Type 'describe [<setting>.<prop>]' for detailed property description.
You may edit the following settings: connection, 802-3-ethernet (ethernet),
802-1x, dcb, ipv4, ipv6, tc, proxy
nmcli> set connection.id My-Static-Connection
nmcli> set connection.interface-name eth0
nmcli> set ipv4.method manual
nmcli> set ipv4.addresses 192.168.1.100/24
nmcli> set ipv4.gateway 192.168.1.1
nmcli> set ipv4.dns 8.8.8.8 8.8.4.4
nmcli> print
...
nmcli> save
Connection 'My-Static-Connection' successfully saved.
nmcli> activate
Connection successfully activated
nmcli> quit
7. Advanced Connection Types
7.1 Bond Configuration
# Create bond interface
nmcli connection add \
type bond \
con-name bond0 \
ifname bond0 \
bond.options "mode=active-backup,miimon=100"
# Add slave interface 1
nmcli connection add \
type ethernet \
con-name bond0-slave1 \
ifname eth0 \
master bond0
# Add slave interface 2
nmcli connection add \
type ethernet \
con-name bond0-slave2 \
ifname eth1 \
master bond0
# Configure IP on bond
nmcli connection modify bond0 \
ipv4.method manual \
ipv4.addresses "192.168.1.100/24" \
ipv4.gateway "192.168.1.1"
# Bring up bond
nmcli connection up bond0
nmcli connection up bond0-slave1
nmcli connection up bond0-slave2
Bond Modes
Mode
Value
Description
balance-rr
0
Round-robin load balancing
active-backup
1
One active, others standby
balance-xor
2
XOR load balancing
broadcast
3
Broadcast on all
802.3ad
4
Dynamic link aggregation (LACP)
balance-tlb
5
Transmit load balancing
balance-alb
6
Adaptive load balancing
7.2 Bridge Configuration
# Create bridge interface
nmcli connection add \
type bridge \
con-name br0 \
ifname br0
# Add interface to bridge
nmcli connection add \
type ethernet \
con-name br0-slave \
ifname eth0 \
master br0
# Configure IP on bridge
nmcli connection modify br0 \
ipv4.method manual \
ipv4.addresses "192.168.1.100/24" \
ipv4.gateway "192.168.1.1"
# Bring up bridge
nmcli connection up br0
nmcli connection up br0-slave
# Advanced bridge options
nmcli connection modify br0 \
bridge.stp no \
bridge.forward-delay 0
7.3 VLAN Configuration
# Create VLAN interface
nmcli connection add \
type vlan \
con-name vlan100 \
ifname eth0.100 \
dev eth0 \
id 100
# Configure IP on VLAN
nmcli connection modify vlan100 \
ipv4.method manual \
ipv4.addresses "192.168.100.10/24"
# Bring up VLAN
nmcli connection up vlan100
# Multiple VLANs on same interface
nmcli connection add type vlan con-name vlan200 ifname eth0.200 dev eth0 id 200
nmcli connection add type vlan con-name vlan300 ifname eth0.300 dev eth0 id 300
7.4 Team Configuration (Alternative to Bonding)
# Create team interface
nmcli connection add \
type team \
con-name team0 \
ifname team0 \
config '{"runner": {"name": "activebackup"}}'
# Add team slaves
nmcli connection add \
type ethernet \
con-name team0-slave1 \
ifname eth0 \
master team0
nmcli connection add \
type ethernet \
con-name team0-slave2 \
ifname eth1 \
master team0
# Configure IP
nmcli connection modify team0 \
ipv4.method manual \
ipv4.addresses "192.168.1.100/24"
8. Scripting and Automation
8.1 Script-Friendly Output
# Terse mode (colon-separated values)
nmcli -t device status
# Output: eth0:ethernet:connected:Wired connection 1
# Get specific values
nmcli -g IP4.ADDRESS device show eth0
# Output: 192.168.1.100/24
# Multiple fields
nmcli -g NAME,UUID connection show
# Output: Wired connection 1:uuid-here
# Fields option with terse mode
nmcli -t -f NAME,TYPE,DEVICE connection show
# Mode for machine parsing
nmcli -m tabular connection show
8.2 Exit Codes
Exit Code
Meaning
0
Success
1
Unknown or unspecified error
2
Invalid user input, wrong nmcli invocation
3
Timeout expired
4
Connection activation failed
5
Connection deactivation failed
6
Disconnecting device failed
7
Connection deletion failed
8
NetworkManager is not running
10
Connection, device, or access point does not exist
8.3 Example Scripts
Network Status Check Script
#!/bin/bash
# network-check.sh - Check network connectivity
# Check if NetworkManager is running
if ! systemctl is-active --quiet NetworkManager; then
echo "ERROR: NetworkManager is not running"
exit 1
fi
# Get connectivity status
CONNECTIVITY=$(nmcli -t -f CONNECTIVITY general)
echo "Connectivity: $CONNECTIVITY"
case "$CONNECTIVITY" in
full)
echo "✓ Full internet connectivity"
exit 0
;;
limited|portal)
echo "⚠ Limited connectivity (captive portal?)"
exit 1
;;
none)
echo "✗ No connectivity"
exit 2
;;
*)
echo "? Unknown connectivity status"
exit 3
;;
esac
Connection Setup Script
#!/bin/bash
# setup-network.sh - Configure network connection
CONNECTION_NAME="Production-Eth"
INTERFACE="eth0"
IP_ADDRESS="192.168.1.100/24"
GATEWAY="192.168.1.1"
DNS="8.8.8.8,8.8.4.4"
# Check if connection exists
if nmcli connection show "$CONNECTION_NAME" &>/dev/null; then
echo "Connection exists, modifying..."
nmcli connection modify "$CONNECTION_NAME" \
ipv4.method manual \
ipv4.addresses "$IP_ADDRESS" \
ipv4.gateway "$GATEWAY" \
ipv4.dns "$DNS"
else
echo "Creating new connection..."
nmcli connection add \
type ethernet \
con-name "$CONNECTION_NAME" \
ifname "$INTERFACE" \
ipv4.method manual \
ipv4.addresses "$IP_ADDRESS" \
ipv4.gateway "$GATEWAY" \
ipv4.dns "$DNS"
fi
# Activate connection
if nmcli connection up "$CONNECTION_NAME"; then
echo "✓ Connection activated successfully"
# Verify IP assignment
IP=$(nmcli -g IP4.ADDRESS device show "$INTERFACE")
echo "Current IP: $IP"
# Test gateway
if ping -c 3 -W 2 "$GATEWAY" &>/dev/null; then
echo "✓ Gateway reachable"
else
echo "⚠ Cannot reach gateway"
fi
else
echo "✗ Failed to activate connection"
exit 1
fi
WiFi Auto-Connect Script
#!/bin/bash
# wifi-connect.sh - Connect to preferred WiFi network
PREFERRED_NETWORKS=("HomeWiFi" "OfficeWiFi" "MobileHotspot")
# Rescan for networks
nmcli device wifi rescan
# Try each preferred network
for network in "${PREFERRED_NETWORKS[@]}"; do
# Check if network is available
if nmcli -t -f SSID device wifi list | grep -q "^${network}$"; then
echo "Found network: $network"
# Check if connection profile exists
if nmcli -t -f NAME connection show | grep -q "^${network}$"; then
echo "Connecting to $network..."
if nmcli connection up "$network"; then
echo "✓ Connected to $network"
exit 0
fi
else
echo "Connection profile not found for $network"
fi
fi
done
echo "✗ No preferred networks found"
exit 1
Connection Monitor Script
#!/bin/bash
# monitor-connection.sh - Monitor and log connection changes
LOG_FILE="/var/log/network-changes.log"
log_message() {
echo "$(date '+%Y-%m-%d %H:%M:%S') - $1" >> "$LOG_FILE"
}
# Get initial state
PREV_STATE=$(nmcli -t -f STATE general)
log_message "Monitoring started. Initial state: $PREV_STATE"
while true; do
sleep 5
CURR_STATE=$(nmcli -t -f STATE general)
if [ "$CURR_STATE" != "$PREV_STATE" ]; then
log_message "State changed: $PREV_STATE -> $CURR_STATE"
# Log active connections
ACTIVE=$(nmcli -t -f NAME connection show --active)
log_message "Active connections: $ACTIVE"
PREV_STATE="$CURR_STATE"
fi
done
8.4 Error Handling in Scripts
#!/bin/bash
# Example with proper error handling
# Enable error handling
set -e # Exit on error
set -u # Exit on undefined variable
# Function to handle errors
error_exit() {
echo "ERROR: $1" >&2
exit 1
}
# Check if running as root (if needed)
[[ $EUID -eq 0 ]] || error_exit "This script must be run as root"
# Check if NetworkManager is running
systemctl is-active --quiet NetworkManager || \
error_exit "NetworkManager is not running"
# Try to bring up connection with timeout
if ! nmcli -w 30 connection up "My-Connection"; then
error_exit "Failed to activate connection"
fi
# Verify connectivity
if ! ping -c 3 8.8.8.8 &>/dev/null; then
echo "WARNING: No internet connectivity" >&2
fi
echo "SUCCESS: Network configured"
exit 0
9. Advanced Features
9.1 Connection Import and Export
# Export connection to file
# (Note: Use nm-connection-editor GUI for graphical export)
# Via command line, manually copy the file:
sudo cp /etc/NetworkManager/system-connections/My-Connection.nmconnection \
~/backup/
# Import VPN connection
nmcli connection import type openvpn file /path/to/config.ovpn
# Import generic connection
nmcli connection load /path/to/connection.nmconnection
# Bulk export
for conn in /etc/NetworkManager/system-connections/*.nmconnection; do
cp "$conn" ~/network-backup/
done
9.2 Secrets Management
# Show connection with passwords visible
nmcli -s connection show "My-Connection"
# Modify password
nmcli connection modify "WiFi" \
wifi-sec.psk "newpassword"
# Remove saved password (will prompt when connecting)
nmcli connection modify "WiFi" \
wifi-sec.psk ""
# Store password in keyring vs connection file
nmcli connection modify "My-Connection" \
connection.permissions ""
9.3 Dispatcher Scripts
NetworkManager Dispatcher: Scripts in /etc/NetworkManager/dispatcher.d/ run when network state changes.
# Example dispatcher script
# File: /etc/NetworkManager/dispatcher.d/10-my-script
#!/bin/bash
# Arguments: $1 = interface, $2 = action
INTERFACE=$1
ACTION=$2
case "$ACTION" in
up)
echo "Interface $INTERFACE is up" | logger
# Run custom commands
;;
down)
echo "Interface $INTERFACE is down" | logger
# Run cleanup commands
;;
vpn-up)
echo "VPN connection established" | logger
# VPN-specific actions
;;
vpn-down)
echo "VPN connection closed" | logger
;;
esac
exit 0
# Make executable:
# sudo chmod +x /etc/NetworkManager/dispatcher.d/10-my-script
# Make connection available to specific user
nmcli connection modify "My-Connection" \
connection.permissions "user:john:;"
# Make available to multiple users
nmcli connection modify "My-Connection" \
connection.permissions "user:john:;user:jane:;"
# Remove user restrictions (system-wide)
nmcli connection modify "My-Connection" \
connection.permissions ""
10. Troubleshooting with nmcli
10.1 Diagnostic Commands
# Check overall status
nmcli general status
# Check device status
nmcli device status
# Check active connections
nmcli connection show --active
# Get detailed device info
nmcli device show eth0
# Check logs
journalctl -u NetworkManager -n 50
# Monitor real-time changes
nmcli monitor
# Test connectivity
nmcli networking connectivity check
10.2 Common Issues and Solutions
Issue: Connection Won't Activate
# Check connection details
nmcli connection show "My-Connection"
# Check device state
nmcli device status
# Try bringing device up first
nmcli device connect eth0
# Check for conflicts
nmcli connection show --active
# Deactivate conflicting connection
nmcli connection down "Other-Connection"
# Try with longer timeout
nmcli -w 60 connection up "My-Connection"
# Check logs for errors
journalctl -u NetworkManager -n 100 | grep -i error
Issue: No IP Address Assigned
# Check IP method
nmcli -f ipv4.method connection show "My-Connection"
# Verify DHCP is working (if using auto)
nmcli connection modify "My-Connection" ipv4.method auto
nmcli connection up "My-Connection"
# Check if address is assigned
nmcli -f IP4.ADDRESS device show eth0
# Try manual DHCP request
nmcli device reapply eth0
# Check DHCP logs
journalctl -u NetworkManager | grep -i dhcp
Issue: DNS Not Working
# Check DNS settings
nmcli -f ipv4.dns device show eth0
# Check resolv.conf
cat /etc/resolv.conf
# Set DNS manually
nmcli connection modify "My-Connection" \
ipv4.dns "8.8.8.8,8.8.4.4"
# Ensure not ignoring auto DNS
nmcli connection modify "My-Connection" \
ipv4.ignore-auto-dns no
# Restart connection
nmcli connection down "My-Connection"
nmcli connection up "My-Connection"
# Test DNS
nslookup google.com
dig google.com
Issue: Changes Not Persisting
# Ensure connection is saved
nmcli connection modify "My-Connection" connection.id "My-Connection"
# Check connection files exist
ls -l /etc/NetworkManager/system-connections/
# Reload connections from disk
nmcli connection reload
# Check permissions
ls -l /etc/NetworkManager/system-connections/My-Connection.nmconnection
# Should be: -rw------- root root
# Fix permissions if needed
sudo chmod 600 /etc/NetworkManager/system-connections/*.nmconnection
sudo chown root:root /etc/NetworkManager/system-connections/*.nmconnection
10.3 Debug Mode
# Enable debug logging temporarily
sudo nmcli general logging level DEBUG domains ALL
# View debug logs
journalctl -u NetworkManager -f
# Restore normal logging
sudo nmcli general logging level INFO domains ALL
# Or edit config file for persistent debug
sudo vi /etc/NetworkManager/NetworkManager.conf
# Add:
[logging]
level=DEBUG
domains=ALL
# Restart NetworkManager
sudo systemctl restart NetworkManager
11. Best Practices
11.1 Naming Conventions
Connection Naming Best Practices:
Use descriptive names: Office-Static-192.168.1.100
Include purpose: WebServer-Primary
Include location: Datacenter-A-VLAN100
Avoid spaces in scripts: Office_Network vs "Office Network"
Use consistent naming across infrastructure
Include date for temporary configs: Test-2024-10-25
Use variables/secrets management for passwords in scripts
Set connection.permissions for user-specific connections
Use WPA2/WPA3 for WiFi, never WEP
Regularly rotate WiFi passwords
Use VPN for untrusted networks
Disable autoconnect for public WiFi
Review active connections regularly
12. Quick Reference
12.1 Most Common Commands
Task
Command
Show status
nmcli
List devices
nmcli device
List connections
nmcli connection
Show connection details
nmcli connection show "Name"
Activate connection
nmcli connection up "Name"
Deactivate connection
nmcli connection down "Name"
List WiFi networks
nmcli device wifi list
Connect to WiFi
nmcli device wifi connect "SSID" password "pass"
Add static IP
nmcli con add type ethernet ifname eth0 ipv4.method manual ipv4.addresses 192.168.1.100/24
Modify connection
nmcli connection modify "Name" ipv4.dns "8.8.8.8"
Delete connection
nmcli connection delete "Name"
Reload connections
nmcli connection reload
12.2 Command Cheat Sheet
# === GENERAL ===
nmcli general status # Overall status
nmcli general hostname # Show hostname
nmcli general hostname new-name # Set hostname
# === NETWORKING ===
nmcli networking on # Enable networking
nmcli networking off # Disable networking
nmcli networking connectivity # Check connectivity
# === RADIO ===
nmcli radio wifi # WiFi status
nmcli radio wifi on/off # WiFi control
nmcli radio all on/off # All radios control
# === DEVICES ===
nmcli device # List devices
nmcli device show # Show device details
nmcli device show eth0 # Specific device
nmcli device connect eth0 # Connect device
nmcli device disconnect eth0 # Disconnect device
nmcli device wifi list # List WiFi networks
nmcli device wifi rescan # Rescan WiFi
nmcli device monitor # Monitor changes
# === CONNECTIONS ===
nmcli connection # List connections
nmcli connection show # List all
nmcli connection show --active # Active only
nmcli connection show "Name" # Details
nmcli connection up "Name" # Activate
nmcli connection down "Name" # Deactivate
nmcli connection reload # Reload all
nmcli connection delete "Name" # Delete
nmcli connection clone "Old" "New" # Clone
# === MODIFY ===
nmcli con mod "Name" ipv4.method auto # DHCP
nmcli con mod "Name" ipv4.method manual # Static
nmcli con mod "Name" ipv4.addresses "192.168.1.100/24" # Set IP
nmcli con mod "Name" ipv4.gateway "192.168.1.1" # Set gateway
nmcli con mod "Name" ipv4.dns "8.8.8.8,8.8.4.4" # Set DNS
nmcli con mod "Name" +ipv4.dns "1.1.1.1" # Add DNS
nmcli con mod "Name" -ipv4.dns "8.8.8.8" # Remove DNS
nmcli con mod "Name" connection.autoconnect yes # Autoconnect
# === CREATE ===
# DHCP Ethernet
nmcli con add type ethernet con-name "Name" ifname eth0
# Static Ethernet
nmcli con add type ethernet con-name "Name" ifname eth0 \
ipv4.method manual ipv4.addresses "192.168.1.100/24" \
ipv4.gateway "192.168.1.1" ipv4.dns "8.8.8.8"
# WiFi
nmcli con add type wifi con-name "Name" ifname wlan0 ssid "SSID" \
wifi-sec.key-mgmt wpa-psk wifi-sec.psk "password"
# === SCRIPTING ===
nmcli -t device status # Terse output
nmcli -g IP4.ADDRESS device show eth0 # Get specific value
nmcli -f NAME,TYPE connection show # Specific fields
12.3 Connection Property Reference
Property
Example Value
Description
connection.id
My-Connection
Connection name
connection.interface-name
eth0
Network interface
connection.autoconnect
yes/no
Auto-activate
connection.autoconnect-priority
0-999
Priority (lower=higher)
ipv4.method
auto, manual, disabled
IP configuration method
ipv4.addresses
192.168.1.100/24
IP address(es)
ipv4.gateway
192.168.1.1
Default gateway
ipv4.dns
8.8.8.8,8.8.4.4
DNS servers
ipv4.dns-search
company.local
DNS search domains
ipv4.routes
10.0.0.0/8 192.168.1.254
Static routes
802-3-ethernet.mtu
1500, 9000
MTU size
802-11-wireless.ssid
MyNetwork
WiFi SSID
wifi-sec.key-mgmt
wpa-psk
WiFi security type
wifi-sec.psk
password
WiFi password
13. Summary
nmcli Quick Start
Check status:nmcli
List devices:nmcli device
List connections:nmcli connection
Create connection:nmcli connection add type ethernet ...