麒麟系统/Centos实现多网卡链路聚合 1723次阅读 Centos • 学习归纳 2023-01-24 前情提示: Linux的链路聚合有bond、team两种模式 Bond最多支持绑定两块网卡、Team最多支持绑定八块网卡 ## Team模式配置 #### 环境配置 本次实验使用六块虚拟网卡。  其中ens33为外网网卡,配置静态IP以供远程连接。 其余五张网卡均为空闲网卡,配置为主备链路聚合功能。  最小化安装的麒麟系统/Centos 7不能tab补全命令,我们为主机安装一个bash的插件包 [root@server-1 ~]# yum install bash-completion -y  退出终端,重新连接终端即可 #### 开始配置基于team的链路聚合 创建名为team0的链路聚合虚拟网卡,使用主备模式(active-backup) ```shell [root@server-1 ~]# nmcli connection add type team con-name team0 ifname team0 autoconnect yes config '{"runner":{"name":"activebackup"}}' ```  修改team0网卡的IP地址为192.168.30.206 ```shell [root@server-1 ~]# nmcli connection modify team0 ipv4.method manual ipv4.addresses 192.168.30.206/24 ```  分别将ens37~ens41等五张网卡绑定至team0 ```shell [root@server-1 ~]# nmcli connection add type team-slave con-name team0-1 ifname ens37 master team0 [root@server-1 ~]# nmcli connection add type team-slave con-name team0-2 ifname ens38 master team0 [root@server-1 ~]# nmcli connection add type team-slave con-name team0-3 ifname ens39 master team0 [root@server-1 ~]# nmcli connection add type team-slave con-name team0-4 ifname ens40 master team0 [root@server-1 ~]# nmcli connection add type team-slave con-name team0-5 ifname ens41 master team0 ```  查看team0状态 ```shell [root@server-1 ]# teamdctl team0 state ```  可以看到五张网卡均已绑定到team0中,实时生效网卡为ens37。 #### 测试 使用ping命令检测到team0 IP是否通畅,测试通过  尝试关闭ens37网卡,模拟网卡损坏的情况。 ```shell [root@server-1 net]# ifconfig ens37 down ```  再次查看team0状态,可以看到ens37已为down状态,实时生效网卡变成了ens41 ```shell [root@server-1 net]# teamdctl team0 state ```  此时再次测试连通性,可以看到网卡切换的过程中会丢几个包,随后恢复正常。  ## Bond模式配置 #### 环境设置 为了确保可远程连接到系统,我们为虚拟机配置三张虚拟网卡。  其中ens33为外网网卡,配置静态IP以供远程连接。 剩余的ens37、ens38为空闲网卡,配置为主备链路聚合功能。  最小化安装的麒麟系统/Centos 7不能tab补全命令,我们为主机安装一个bash的插件包 ```shell [root@server-1 ~]# yum install bash-completion -y ```  退出终端,重新连接终端即可 #### 开始配置基于bond的链路聚合 创建名为bond0的链路聚合虚拟网卡,使用主备模式(active-backup),指定IP为192.168.30.206 ```shell [root@server-1 ~]# nmcli connection add con-name bond0 ifname bond0 type bond mode active-backup ip4 192.168.30.206/24 ```  查看网卡状态,可以看到bond0已经存在,ens37/ens38为空闲状态 ```shell [root@server-1 ~]# nmcli device status ```  将ens37配置为bond0的slave网卡 ```shell [root@server-1 ~]# nmcli connection add con-name ens37 ifname ens37 type bond-slave master bond0 ```  将ens38配置为bond0的slave网卡 ```shell [root@server-1 ~]# nmcli connection add con-name ens38 ifname ens38 type bond-slave master bond0 ```  查看bond0的运行情况,可以看到ens37/ens38都为UP状态,速率1000兆,全双工。实时生效的网卡为ens37 ```shell [root@server-1 ~]# cat /proc/net/bonding/bond0 ```  #### 测试 使用ping命令检测到bond0 IP是否通畅,测试通过  将ens37设置成关闭状态 ```shell [root@server-1 ~]# ifconfig ens37 down ```  查看bond0的运行情况,可以看到ens37已经是down状态,激活网卡转变为ens38  再次使用ping命令检测到bond0的网络连通性,在经过短暂的切换后,网络连通性恢复正常。  至此,实现了在bond0模式下的主备链路聚合。 最后一次更新于2023-01-24 centos 麒麟系统 链路聚合
0 条评论