RHEL7 -- CentOS7 nmcli的使用及常規(guī)命令
技術(shù)支持服務(wù)電話:15308000360 【7x24提供運維服務(wù),解決各類系統(tǒng)/軟硬件疑難技術(shù)問題】
查看網(wǎng)絡(luò)設(shè)備的狀態(tài):
[root@rhce7 ~]# nmcli dev status DEVICE TYPE STATE ens32 802-3-ethernet connected eth1 802-3-ethernet disconnected lo loopback unmanaged --斷開網(wǎng)絡(luò)設(shè)備:
[root@rhce7 ~]# nmcli dev disconnect ens32 #ens32是device名,不是connection名連接網(wǎng)絡(luò)設(shè)備:
[root@rhce7 ~]# nmcli dev connect ens32 #ens32是device名,不是connection名列出所有的connections:
[root@rhce7 ~]# nmcli con show NAME UUID TYPE DEVICE eth2 96238a53-4ffd-4358-aa73-15e7b7ae81c5 802-3-ethernet -- eth1 085c71ca-aac2-4851-a8a5-8e4f239e5e65 802-3-ethernet -- ens32 10d3aba6-f468-4b6e-b5a7-789c85811c09 802-3-ethernet ens32 eth3 1ae34078-53db-4453-bd93-ba7bc3adc1b6 802-3-ethernet --列出active狀態(tài)的connections:
[root@rhce7 ~]# nmcli con show --active NAME UUID TYPE DEVICE ens32 10d3aba6-f468-4b6e-b5a7-789c85811c09 802-3-ethernet ens32斷開connection:
[root@rhce7 ~]# nmcli con down eth1激活connection:
[root@rhce7 ~]# nmcli con up eth1 #這里的eth1是connection名,不是device名修改connection的配置:
[root@rhce7 ~]# nmcli con mod ens32 ipv4.addresses "10.10.12.192/24 10.10.12.254"添加屬性:
[root@rhce7 ~]# nmcli con mod ens32 +ipv4.dns 192.0.2.1 #關(guān)鍵符號"+"如果手動修改了ifcfg-*配置文件,需要使用nmcli con reload 來同時NetworkMananger 添加一個網(wǎng)絡(luò)連接:
[root@rhce7 ~]# nmcli con add con-name eth1 type ethernet ifname eth1 Connection 'eth1' (085c71ca-aac2-4851-a8a5-8e4f239e5e65) successfully added. [root@rhce7 ~]# nmcli con add con-name eth2 type ethernet ifname eth2 ip4 192.168.56.120/24 gw4 192.168.56.254 ipv4.method manual Connection 'eth2' (96238a53-4ffd-4358-aa73-15e7b7ae81c5) successfully added.刪除網(wǎng)絡(luò)連接:
[root@rhce7 ~]# nmcli con del eth2查看當(dāng)前網(wǎng)絡(luò)配置:
[root@rhce7 ~]# ip add show 1: lo:mtu 16436 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth1: mtu 1500 qdisc mq state UNKNOWN qlen 1000 link/ether 00:50:56:a0:72:9a brd ff:ff:ff:ff:ff:ff inet 10.10.12.190/24 brd 10.10.12.255 scope global eth1 inet6 fe80::250:56ff:fea0:729a/64 scope link valid_lft forever preferred_lft forever 3: eth2: mtu 1500 qdisc mq state UNKNOWN qlen 1000 link/ether 00:50:56:a0:51:2c brd ff:ff:ff:ff:ff:ff inet6 fe80::250:56ff:fea0:512c/64 scope link valid_lft forever preferred_lft forever [root@rhce7 ~]# ip addr show eth2 3: eth2: mtu 1500 qdisc mq state UNKNOWN qlen 1000 link/ether 00:50:56:a0:51:2c brd ff:ff:ff:ff:ff:ff inet6 fe80::250:56ff:fea0:512c/64 scope link valid_lft forever preferred_lft forever