nmcli-examples

Example 1. Listing available Wi-Fi APs
$ nmcli device wifi list

Example 2. Showing general information and properties for a Wi-Fi interface
$ nmcli -p -f general,wifi-properties device show wlan0

Example 3. Listing NetworkManager polkit permissions
$ nmcli general permissions

Example 4. Listing NetworkManager log level and domains
$ nmcli general logging

Example 5. Changing NetworkManager logging
$ nmcli g log level DEBUG domains CORE,ETHER,IP
$ nmcli g log level INFO domains DEFAULT

Example 6. Adding a bonding master and two slave connection profiles
$ nmcli con add type bond ifname mybond0 mode active-backup
$ nmcli con add type ethernet ifname eth1 master mybond0
$ nmcli con add type ethernet ifname eth2 master mybond0

Example 7. Adding a team master and two slave connection profiles
$ nmcli con add type team con-name Team1 ifname Team1 config team1-master-json.conf
$ nmcli con add type ethernet con-name Team1-slave1 ifname em1 master Team1
$ nmcli con add type ethernet con-name Team1-slave2 ifname em2 master Team1

Example 8. Adding a bridge and two slave profiles
$ nmcli con add type bridge con-name TowerBridge ifname TowerBridge
$ nmcli con add type ethernet con-name br-slave-1 ifname ens3 master TowerBridge
$ nmcli con add type ethernet con-name br-slave-2 ifname ens4 master TowerBridge
$ nmcli con modify TowerBridge bridge.stp no

Example 9. Adding an ethernet connection profile with manual IP configuration
$ nmcli con add con-name my-con-em1 ifname em1 type ethernet \
ip4 192.168.100.100/24 gw4 192.168.100.1 ip4 1.2.3.4 ip6 abbe::cafe
$ nmcli con mod my-con-em1 ipv4.dns “8.8.8.8 8.8.4.4”
$ nmcli con mod my-con-em1 +ipv4.dns 1.2.3.4
$ nmcli con mod my-con-em1 ipv6.dns “2001:4860:4860::8888 2001:4860:4860::8844”
$ nmcli -p con show my-con-em1

Example 10. Convenient field values retrieval for scripting
$ nmcli -g ip4.address connection show my-con-eth0
192.168.1.12/24
$ nmcli -g ip4.address,ip4.dns connection show my-con-eth0
192.168.1.12/24
192.168.1.1
$ nmcli -g ip4 connection show my-con-eth0
IP4:192.168.1.12/24:192.168.1.1::192.168.1.1::

Example 11. Adding an Ethernet connection and configuring SR-IOV VFs
$ nmcli con add type ethernet con-name EthernetPF ifname em1
$ nmcli con modify EthernetPF sriov.total-vfs 3 sriov.autoprobe-drivers false
$ nmcli con modify EthernetPF sriov.vfs ‘0 mac=00:11:22:33:44:55 vlans=10, 1 trust=true spoof-check=false’
$ nmcli con modify EthernetPF +sriov.vfs ‘2 max-tx-rate=20’

Example 12. Escaping colon characters in tabular mode
$ nmcli -t -f general -e yes -m tab dev show eth0

Example 14. Adding an ethernet connection profile in interactive editor (a)
$ nmcli connection edit type ethernet