Controlling NetworkManager - nmcli

Controlling NetworkManager

nmcli connection show

1
2
3
$ nmcli connection show
NAME UUID TYPE DEVICE
DONGSHENG-CMMC 58dba110-b6e9-4793-98cf-6f893f22de28 wifi wlx6c5ab5a4f8a7

nmcli device show

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
$ nmcli device show wlx6c5ab5a4f8a7
GENERAL.DEVICE: wlx6c5ab5a4f8a7
GENERAL.TYPE: wifi
GENERAL.HWADDR: 6C:5A:B5:A4:F8:A7
GENERAL.MTU: 1500
GENERAL.STATE: 100 (connected)
GENERAL.CONNECTION: DONGSHENG-CMMC
GENERAL.CON-PATH: /org/freedesktop/NetworkManager/ActiveConnection/1
IP4.ADDRESS[1]: 192.168.1.11/24
IP4.GATEWAY: 192.168.1.1
IP4.ROUTE[1]: dst = 192.168.1.0/24, nh = 0.0.0.0, mt = 600
IP4.ROUTE[2]: dst = 0.0.0.0/0, nh = 192.168.1.1, mt = 600
IP4.DNS[1]: 192.168.1.1
IP4.DNS[2]: 114.114.114.114
IP4.DNS[3]: 8.8.8.8
IP4.DNS[4]: 8.8.4.4
IP6.ADDRESS[1]: 2409:8a55:8b8:4560:1755:efdd:ae0e:b950/64
IP6.ADDRESS[2]: fe80::223f:a26d:9121:859d/64
IP6.GATEWAY: fe80::1
IP6.ROUTE[1]: dst = fe80::/64, nh = ::, mt = 600
IP6.ROUTE[2]: dst = 2409:8a55:8b8:4560::/64, nh = ::, mt = 600
IP6.ROUTE[3]: dst = ::/0, nh = fe80::1, mt = 600
IP6.ROUTE[4]: dst = ff00::/8, nh = ::, mt = 256, table=255
IP6.DNS[1]: fe80::1

nmcli connection modify

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
nmcli connection | tail -n+2 | grep --color '[0-9a-z]\{8\}-.\{28\}' -o | \
while read UUID; do
echo $UUID;
nmcli connection show $UUID | grep -i dns;
nmcli connection modify $UUID ipv4.ignore-auto-dns yes
nmcli connection modify $UUID ipv6.ignore-auto-dns yes
echo -e '\n\n';
done

# nmcli connection modify 58dba110-b6e9-4793-98cf-6f893f22de28 ipv4.dns "192.168.1.1,114.114.114.114,8.8.8.8,8.8.4.4"

$ nmcli connection show 58dba110-b6e9-4793-98cf-6f893f22de28 | grep "dns"
connection.mdns: -1 (default)
ipv4.dns: 192.168.1.1,114.114.114.114,8.8.8.8,8.8.4.4
ipv4.dns-search: --
ipv4.dns-options: ""
ipv4.dns-priority: 0
ipv4.ignore-auto-dns: yes
ipv6.dns: --
ipv6.dns-search: --
ipv6.dns-options: ""
ipv6.dns-priority: 0
ipv6.ignore-auto-dns: no