nmcli 使用案例
設定檔寫入的路徑
/etc/NetworkManager/system-connections
1
| [root@Linux-lab ~]# nmcli device
|
1
| [root@Linux-lab ~]# nmcli device show
|
1
| [root@Linux-lab ~]# nmcli device show ethX
|
1
| [root@Linux-lab ~]# nmcli device
|
1
| [root@Linux-lab ~]# nmcli device disconnect ethX
|
1
| [root@Linux-lab ~]# nmcli con show
|
增加DHCP:
1
| [root@Linux-lab ~]# nmcli connection add type ethernet con-name dynamic ifname ens192
|
啟動裝置:
1
| [root@Linux-lab ~]# nmcli connection up dynamic
|
增加Static:
1
| [root@Linux-lab ~]# nmcli connection add type ethernet con-name static ifname ens224
|
設置Static:
1
| [root@Linux-lab ~]# nmcli connection modify static ipv4.method manual ipv4.addresses 192.168.133.199/24 ipv4.gateway 192.168.133.2 ipv4.dns 192.168.133.2 autoconnect yes
|
註1: 如要停用ipv6 ,可在後方接 ipv6.method disable
註2. 如要增減IP,- +ipv4.addresses 或 ipv4.dns
刪除網路設定檔:
1 2
| 1. 先查看設定檔 [root@Linux-lab ~]# nmcli con show
|
1 2
| 2. 刪除裝置Name > Static [root@Linux-lab ~]# nmcli connection delete static
|
如何查看使用者設定網路的權限:
1
| [sam@Linux-lab ~]$ nmcli general permissions
|
#Linux回顧