1.常用查看命令
[root@localhost ~]# nmcli device status [root@localhost ~]# nmcli connection show [root@localhost ~]# nmcli device connect ens32 [root@localhost ~]# nmcli device disconnect ens32 [root@localhost ~]# nmcli connection up ens32 [root@localhost ~]# nmcli connection down ens32
2.使用nmcli配置網絡
#創建名爲new1的新連接 [root@localhost ~]# nmcli connection add con-name new1 ifname ens32 type ethernet #配置new1的IP地址模式爲靜態及相應的IP [root@localhost ~]# nmcli connection modify new1 ipv4.method manual ipv4.addresses192.168.1.1/24 ipv4.gateway 192.168.1.254 #設置連接自動啓動 [root@localhost ~]# nmcli connection modify new1 connection.autoconnect yes #設置爲動態獲取IP地址 [root@localhost ~]# nmcli connection modify new1 ipv4.method auto #使配置文件生效(兩者都可以) [root@localhost ~]# systemctl restart network [root@localhost ~]# nmcli connection reload
3.刪除new1連接
[root@localhost ~]# nmcli connection delete new1