显示当前网络连接
nmcli connection show

修改当前网络连接对应的DNS服务器,这里的网络连接可以用名称或者UUID来标识,二个NDS根据需求修改,一般添加这二个就可以。
nmcli con mod ens33 ipv4.dns “114.114.114.114 8.8.8.8”

将dns配置生效
nmcli con up ens33

[root@localhost ~]# nmcli connection show
NAME   UUID                                  TYPE      DEVICE 
ens33  582c683b-a2fd-4a81-9138-c499254c75c2  ethernet  ens33  
[root@localhost ~]# nmcli con mod ens33 ipv4.dns "114.114.114.114 8.8.8.8"
[root@localhost ~]# nmcli con up ens33
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/3)
[root@localhost ~]# nmcli connection show
NAME   UUID                                  TYPE      DEVICE 
ens33  582c683b-a2fd-4a81-9138-c499254c75c2  ethernet  ens33  
[root@localhost ~]# ping www.baidu.com
PING www.a.shifen.com (220.181.38.150) 56(84) bytes of data.
64 bytes from 220.181.38.150 (220.181.38.150): icmp_seq=1 ttl=128 time=5.81 ms
64 bytes from 220.181.38.150 (220.181.38.150): icmp_seq=2 ttl=128 time=4.31 ms
64 bytes from 220.181.38.150 (220.181.38.150): icmp_seq=3 ttl=128 time=6.57 ms
64 bytes from 220.181.38.150 (220.181.38.150): icmp_seq=4 ttl=128 time=4.56 ms
^C
--- www.a.shifen.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 4034ms
rtt min/avg/max/mdev = 4.310/5.313/6.571/0.926 ms