Networking

NetworkManager WiFi Configuration on Linux

Maximilian B. 2 min read 1,236 views

NetworkManager: The Modern Connection Manager

NetworkManager is the standard network configuration daemon on most Linux distributions. It manages network interfaces, connections, and provides both CLI (nmcli) and GUI tools for network management.

nmcli Basics

# Check NetworkManager status
nmcli general status

# List all connections
nmcli connection show

# List active connections
nmcli connection show --active

# Show available WiFi networks
nmcli device wifi list

# Rescan for WiFi networks
nmcli device wifi rescan

# Show device status
nmcli device status

Connecting to WiFi

# Connect to a visible network (interactive password prompt)
nmcli device wifi connect "MyNetwork" password "MySecurePass"

# Connect to a specific BSSID (when multiple APs share the same SSID)
nmcli device wifi connect "MyNetwork" bssid AA:BB:CC:DD:EE:FF password "MySecurePass"

# Connect to a hidden network
nmcli device wifi connect "HiddenSSID" password "MySecurePass" hidden yes

# Connect using a specific interface
nmcli device wifi connect "MyNetwork" password "MySecurePass" ifname wlan0

Managing Connection Profiles

# Create a new WiFi connection profile
nmcli connection add \
    type wifi \
    con-name "Office-WiFi" \
    ifname wlan0 \
    ssid "CorpNetwork" \
    wifi-sec.key-mgmt wpa-psk \
    wifi-sec.psk "SecurePassword"

# Modify an existing connection
nmcli connection modify "Office-WiFi" \
    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

# Set connection to auto-connect
nmcli connection modify "Office-WiFi" connection.autoconnect yes

# Set connection priority (higher = preferred)
nmcli connection modify "Office-WiFi" connection.autoconnect-priority 100

# Activate a connection
nmcli connection up "Office-WiFi"

# Deactivate a connection
nmcli connection down "Office-WiFi"

# Delete a connection profile
nmcli connection delete "Office-WiFi"

WPA2-Enterprise (802.1X)

# PEAP/MSCHAPv2 (common in corporate environments)
nmcli connection add \
    type wifi \
    con-name "Enterprise-WiFi" \
    ssid "CorpSecure" \
    wifi-sec.key-mgmt wpa-eap \
    802-1x.eap peap \
    802-1x.phase2-auth mschapv2 \
    802-1x.identity "user@corp.com" \
    802-1x.password "CorpPassword"

# EAP-TLS (certificate-based)
nmcli connection add \
    type wifi \
    con-name "Cert-WiFi" \
    ssid "SecureNet" \
    wifi-sec.key-mgmt wpa-eap \
    802-1x.eap tls \
    802-1x.identity "user@corp.com" \
    802-1x.ca-cert /etc/certs/ca.pem \
    802-1x.client-cert /etc/certs/client.pem \
    802-1x.private-key /etc/certs/client-key.pem

Troubleshooting

# Check WiFi hardware status
nmcli radio wifi

# Enable/disable WiFi
nmcli radio wifi on
nmcli radio wifi off

# View connection details
nmcli -p connection show "MyNetwork"

# Check logs
journalctl -u NetworkManager --since "1 hour ago"
journalctl -u NetworkManager -f   # Follow live

# Restart NetworkManager
sudo systemctl restart NetworkManager

NetworkManager's nmcli provides complete control over your network connections from the terminal. Whether you're configuring a simple home WiFi or a complex enterprise 802.1X setup, these commands have you covered.

Share this article
X / Twitter LinkedIn Reddit