nmcli是网络管理命令行工具,该命令可以完成网卡上所有的配置工作,并且可以写入配置文件,永久生效
一、直接回车
[root@Ceph-247 ~]# nmcli
eth3: connected to System eth3
"Intel 82576"
ethernet (igb), 00:1B:21:DA:3F:4B, hw, mtu 1500
ip4 default
inet4 10.229.37.247/24
route4 10.229.37.0/24
route4 0.0.0.0/0
inet6 fe80::21b:21ff:feda:3f4b/64
route6 ff00::/8
route6 fe80::/64
ens2f0: connected to ens2f0
"Mellanox MT27710"
ethernet (mlx5_core), 84:13:9F:32:2D:6E, hw, mtu 1500
inet4 192.168.180.247/24
route4 192.168.180.0/24
inet6 fe80::5ea5:d4ee:6001:fc74/64
route6 fe80::/64
route6 ff00::/8
二、nmcli connection
- nmcli c show (nmcli connection show)查看连接信息
[root@Ceph-247 ~]# nmcli c show
NAME UUID TYPE DEVICE
System eth3 c5ca8081-6db2-4602-4b46-d771f4330a6d ethernet eth3
ens2f0 ed1882d4-49bb-f7aa-26b6-8d587ab08855 ethernet ens2f0
ens2f1 22c030ed-9cf6-8eb4-c21a-cd9ff42909d8 ethernet ens2f1
interface-br_comm_port bbd5bdfb-9550-4dff-a280-e704c69e9766 ovs-interface br_comm_port
interface-eth0 4351e6b2-31da-4db7-baed-a55974499ccf ovs-interface eth0
interface-test 091ba1f9-0d4a-4380-ada0-a09af5b3cceb ovs-interface test
bridge-br_comm 084c09d3-0984-4551-b2ce-da3f7dcb3660 ovs-bridge br_comm
bridge-DVS01_dp de204b0a-c29f-49c7-9fff-c08c1f52f9ff ovs-bridge DVS01_dp
interface-br_comm fc7ca762-1b26-4cdb-909c-2e9feb2aa53e ovs-interface br_comm
interface-DVS01_dp a4ebed8f-3b66-4f43-9db8-28826bc41920 ovs-interface DVS01_dp
port-br_comm 4c384c28-4ae0-46f6-9901-20ea0645082a ovs-port br_comm
port-br_comm_port 8598f75b-1921-49e8-b45b-627e78652d52 ovs-port br_comm_port
port-DVS01_dp c0032289-6117-4d09-872e-08f1cacebffa ovs-port DVS01_dp
port-ens8f3 5dbcc0e8-1c94-40ae-a88d-f2560e496ae0 ovs-port ens8f3
port-eth0 02272675-fe85-44eb-89d5-56f8de367bee ovs-port eth0
port-test 1ade442b-2831-44a2-9530-ac5d2cc8fa4a ovs-port test
ens8f0 e3112efd-8246-4475-8ce1-3df323e3df2b ethernet --
ens8f1 be7a30ef-a877-44d2-9c83-82588a50f46e ethernet --
ens8f2 90e637df-e4a7-488a-a638-a9bec7c318f3 ethernet --
interface-ens8f3 6eb05d2b-df80-4fbf-9578-3be43f612d36 ethernet --
System ens8f3 1af65176-3348-5da3-2312-af43e7225375 ethernet --
Wired connection 1 03466844-894c-3a1b-8c2c-f4821a90f0df ethernet --
Wired connection 2 dd32d6f8-0813-31b4-8e09-b54ac8e4ed5a ethernet --
三、nmcli device 查看和管理网络接口信息
- nmcli device status 查看网络接口信息
[root@Ceph-247 ~]# nmcli device status
DEVICE TYPE STATE CONNECTION
eth3 ethernet connected System eth3
ens2f0 ethernet connected ens2f0
ens2f1 ethernet connected ens2f1
br_comm_port ovs-interface connected interface-br_comm_port
eth0 ovs-interface connected interface-eth0
test ovs-interface connected interface-test
DVS01_dp ovs-bridge connected bridge-DVS01_dp
br_comm ovs-bridge connected bridge-br_comm
DVS01_dp ovs-interface connected interface-DVS01_dp
br_comm ovs-interface connected interface-br_comm
DVS01_dp ovs-port connected port-DVS01_dp
br_comm ovs-port connected port-br_comm
br_comm_port ovs-port connected port-br_comm_port
ens8f3 ovs-port connected port-ens8f3
eth0 ovs-port connected port-eth0
test ovs-port connected port-test
ens8f0 ethernet unavailable --
ens8f1 ethernet unavailable --
eth2 ethernet unavailable --
lo loopback unmanaged --
- nmcli device show ens2f1 查看网卡地址信息
[root@Ceph-251 rules.d]# nmcli device show ens2f1
GENERAL.DEVICE: ens2f1
GENERAL.TYPE: ethernet
GENERAL.HWADDR: 84:13:9F:32:2D:93
GENERAL.MTU: 1500
GENERAL.STATE: 100 (connected)
GENERAL.CONNECTION: ens2f1
GENERAL.CON-PATH: /org/freedesktop/NetworkManager/ActiveConnection/4
WIRED-PROPERTIES.CARRIER: on
IP4.ADDRESS[1]: 192.168.181.251/24
IP4.GATEWAY: --
IP4.ROUTE[1]: dst = 192.168.181.0/24, nh = 0.0.0.0, mt = 101
IP6.ADDRESS[1]: fe80::b7dc:64f7:64e0:3b65/64
IP6.GATEWAY: --
IP6.ROUTE[1]: dst = fe80::/64, nh = ::, mt = 101
IP6.ROUTE[2]: dst = ff00::/8, nh = ::, mt = 256, table=255
[root@Ceph-251 rules.d]# nmcli device show ens2f1 | grep -i hwaddr
GENERAL.HWADDR: 84:13:9F:32:2D:93
四、nmcli networking 管理网络状态
- nmcli networking
[root@Ceph-251 rules.d]# nmcli networking
enabled