查看网络设备的状态:
# nmcli dev status DEVICE TYPE STATE ens32 802-3-ethernet connected eth1 802-3-ethernet disconnected lo loopback unmanaged --
断开网络设备:
# nmcli dev disconnect ens32 #ens32是device名,不是connection名
连接网络设备:
# nmcli dev connect ens32 #ens32是device名,不是connection名
列出所有的connections:
# 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状态的connections:
[root@rhce7 ~]# nmcli con show --active NAME UUID TYPE DEVICE ens32 10d3aba6-f468-4b6e-b5a7-789c85811c09 802-3-ethernet ens32
断开connection:
# nmcli con down eth1
激活connection:
# nmcli con up eth1 #这里的eth1是connection名,不是device名
修改connection的配置:
# nmcli con mod ens32 ipv4.addresses "10.10.12.192/24 10.10.12.254"
添加属性:
# nmcli con mod ens32 +ipv4.dns 192.0.2.1 #关键符号"+" 如果手动修改了ifcfg-*配置文件,需要使用nmcli con reload 来同时NetworkMananger
添加一个网络连接:
# nmcli con add con-name eth1 type ethernet ifname eth1 Connection 'eth1' (085c71ca-aac2-4851-a8a5-8e4f239e5e65) successfully added. # 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.
删除网络连接:
# nmcli con del eth2
查看当前网络配置:
# ip add show 1: lo: <LOOPBACK,UP,LOWER_UP> 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: <BROADCAST,MULTICAST,UP,LOWER_UP> 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: <BROADCAST,MULTICAST,UP,LOWER_UP> 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 # ip addr show eth2 3: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> 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 #