实验要求:在当前主机添加两块网卡,将两块网卡绑定实现网卡冗余操作。
一、添加网卡
1、打开虚拟机设置,添加网络适配器
2、通过查看ip a命令查看网卡是否添加成功
二、激活网卡
1、查看本地网卡情况
[root@localhost ~]# nmcli device
DEVICE TYPE STATE CONNECTION
ens160 ethernet connected ens160
ens224 ethernet connected Wired connection 2
ens256 ethernet connected Wired connection 1
virbr0 bridge connected (externally) virbr0
lo loopback unmanaged --
2、激活网卡
[root@localhost ~]# nmcli device connect ens224
Device 'ens224' successfully activated with '86d51163-1571-3b91-974e-c2c8654e7b64'.
[root@localhost ~]# nmcli device connect ens256
Device 'ens256' successfully activated with '3fecf83b-5e95-3aea-98f0-6657af5c80ae'.
三、添加虚拟网卡team0
[root@localhost ~]# nmcli connection add type team con-name team0 ifname team0 config '{"runner": {"name": "activebackup"} }'
Connection 'team0' (b1c03e35-604a-4df9-8641-de1e75461910) successfully added.
四、虚拟绑定真实网卡
[root@localhost ~]# nmcli connection add type team-slave con-name team0-port1 ifname ens224 master team0
Connection 'team0-port1' (101ade9e-7721-4dfe-842e-4b53bc6a6d62) successfully added.
[root@localhost ~]# nmcli connection add type team-slave con-name team0-port2 ifname ens256 master team0
Connection 'team0-port2' (6d5d0e0f-e9cd-480a-9150-db3541d8fb22) successfully added.
五、激活设备
规则:先从后主
1、激活从设备
[root@localhost ~]# nmcli connection up team0-port1
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/14)
[root@localhost ~]# nmcli connection up team0-port2
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/15)
2、激活主设备
[root@localhost ~]# nmcli connection up team0
Connection successfully activated (master waiting for slaves) (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/16)
3、查看是否激活
六、查看启动后的虚拟网卡team0的状态
七、当停止其中一个设备后的状态
[root@localhost ~]# nmcli connection down team0-port1
Connection 'team0-port1' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/17)
[root@localhost ~]# nmcli device disconnect ens224
Error: Device 'ens224' (/org/freedesktop/NetworkManager/Devices/4) disconnecting failed: This device is not active
Error: not all devices disconnected.