nmcli - NetworkManager command line tool

# list all connections
nmcli con
nmcli con show --active | grep -i vpn
# show connection details
nmcli con show 'MY_CONNECTION_1'
# start vpn from command line (ubuntu)
nmcli con up id VPN_NAME
nmcli device wifi list
# create wifi configuration
SSID="FRITZ!Box 5960"
nmcli con add con-name "${SSID}" ifname wlan0 type wifi ssid "${SSID}"
nmcli con modify "c}" wifi-sec.key-mgmt wpa-psk
nmcli con modify "${SSID}" wifi-sec.psk "${PASS}"
# set DNS
nmcli con mod wg0 ipv4.dns ""
nmcli con up "${SSID}"
# get connection UUID
nmcli -g connection.uuid connection show <CONNCTION_NAME>
nmcli -t -f UUID con
# test: bounding
nmcli con add type bond con-name bond1 ifname bond1 mode 802.3ad ipv4
nmcli con mod id bond1 bond.options mode=802.3ad,miimon=100,lacp_rate=fast,xmit_hash_policy=layer2+3
nmcli con mod id bond1 802-3-ethernet.mtu 9000
nmcli con add type bond-slave ifname p5p1 con-name p5p1 master bond1
nmcli con add type bond-slave ifname p5p1 con-name p5p2 master bond1
# disable autoconnect
nmcli connection modify wg0 autoconnect no
# configure secondaries hack (static DNS required)
nmcli connection modify my-wireguard connection.secondaries my-anyconnect

Autostart delayed VPN connection

# /home/foo/.config/autostart/vpn.desktop 
[Desktop Entry]
Exec=nmcli con up VPN1
Name=Auto connect to VPN1

NetworkManager event scripts


Network manager GUI


Configure IP

nmcli connection modify enp1s0 ipv4.addresses
# set gateway
nmcli connection modify enp1s0 ipv4.gateway
# set DNS
# for multiple DNS, specify with space separated ⇒ ipv4.dns ""
mcli connection modify enp1s0 ipv4.dns
# set DNS search base (your domain name -for multiple one, specify with space separated)
nmcli connection modify enp1s0 ipv4.dns-search srv.world
# set [manual] for static setting (it's [auto] for DHCP)
nmcli connection modify enp1s0 ipv4.method manual
# restart the interface to reload settings
nmcli connection down enp1s0; nmcli connection up enp1s0