nmcli

Goal: Allow to connect to a wireless network using Linux CLI

To use nmcli the Network manager needs to be started

Starting and stoping the Network Manager

service NetworkManager start
service NetworkManager stop

List all available connections

nmcli con show

Connect to a Wi-Fi network

nmcli dev wifi connect <SSID> password <PASSWORD>

Delete a connection

nmcli con del <connection_name>

Edit connection profile

To change configuration for automatic connection

nmcli con modify "SSID" connection.autoconnect <yes/no> 

Connect to WPA/WPA2-PSK

nmcli dev wifi connect "<SSID>" password "<PASSWORD>" ifname <interface_name>

Example: Connecting to the wireless network MonPrecieux with the password Lord123$ with the interface wlan1
nmcli dev wifi connect "MonPrecieux" password "Lord123$" ifname <wlan1>

Check if you have an ip address to connect to the Internet. Otherwise, do

dhclient -v -i <interface>

To disconnect from a wireless network

nmcli con down "<SSID>"

Connect to WPA Enterprise

nmcli con add type wifi ifname <interface> con-name <any-connection-name> ssid <SSID>
nmcli con edit id <connection_name_choosed>

nmcli> set ipv4.method auto
nmcli> set 802-1x.eap peap
nmcli> set 802-1x.phase2-auth mschapv2
nmcli> set 802-1x.identity <USERNAME>
nmcli> set 802-1x.password <PASSWORD>
nmcli> set wifi-sec.key-mgmt wpa-eap
nmcli> save
nmcli> activate

Disconnect from an activated connection

nmcli con down id <connection_name_choosed>

Last updated