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"
PASS=00011090700208423311
 
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 "8.8.8.8 8.8.4.4."
 
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 179.254.0.2/16
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

Autostart delayed VPN connection

# /home/foo/.config/autostart/vpn.desktop 
[Desktop Entry]
Type=Application
Exec=nmcli con up VPN1
Hidden=false
NoDisplay=false
X-GNOME-Autostart-Delay=3
X-GNOME-Autostart-enabled=true
Name=Auto connect to VPN1

NetworkManager event scripts

/etc/NetworkManager/dispatcher.d/

Network manager GUI

nm-connection-editor

Configure IP

nmcli connection modify enp1s0 ipv4.addresses 10.0.0.30/24
# set gateway
nmcli connection modify enp1s0 ipv4.gateway 10.0.0.1
# set DNS
# for multiple DNS, specify with space separated ⇒ ipv4.dns "10.0.0.10 10.0.0.11 10.0.0.12"
mcli connection modify enp1s0 ipv4.dns 10.0.0.10
# 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

Links
https://developer.gnome.org/NetworkManager/stable/nmcli-examples.html
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Networking_Guide/sec-Using_the_NetworkManager_Command_Line_Tool_nmcli.html
https://www.mankier.com/7/nmcli-examples