0
点赞
收藏
分享

微信扫一扫

Centos7 team 绑定多网卡

舍予兄 2022-02-13 阅读 68


1、nmcli connection show 查看所有的网络连接

nmcli connection show

Centos7 team 绑定多网卡_javascript



接下来我们要使用 ens37 ens38 两个网卡绑定 , 绑定的网卡取名: agg-eth0


 2、创建 team 口 ,  con-name team0 ,  con-name team0 

nmcli connection add type team con-name team0 ifname agg-eth0 config '{"runner":{"name":"activebackup"}}'

Centos7 team 绑定多网卡_javascript_02


 说明:

按照下面的语法,用 nmcli 命令为网络组接口创建一个连接。

# nmcli con add type team con-name CNAME ifname INAME [config JSON]

CNAME 指代连接的名称,INAME 是接口名称,JSON (JavaScript Object Notation) 指定所使用的处理器(runner)。JSON语法格式如下:

'{"runner":{"name":"METHOD"}}'

METHOD 是以下的其中一个:broadcast、activebackup、roundrobin、loadbalance 或者 lacp。



若想改变team的模式可以编辑/etc/sysconfig/network-scripts/ifcfg-team0

在里面更改模式,改完之后我们要用nmcli connection  reload 来识别

然后再重启以此网络服务 systemctl restart network 即可。


此时我们看到ip a 中有一张网卡 agg-eth0,  nmcli connection show 中有一个 team0

Centos7 team 绑定多网卡_网卡绑定_03


3、 给team0 配置IP Gateway DNS

nmcli connection modify team0 ipv4.addresses "192.168.1.250/24"
nmcli connection modify team0 ipv4.gateway "192.168.1.1"
nmcli connection modify team0 ipv4.dns "192.168.1.1"
nmcli connection modify team0 ipv4.method manual

Centos7 team 绑定多网卡_javascript_04




4、将 ens37 ens38 加入team0, 

nmcli connection add type team-slave con-name team0-port1 ifname ens37 master team0
nmcli connection add type team-slave con-name team0-port2 ifname ens38 master team0

Centos7 team 绑定多网卡_javascript_05




此时查看 nmcli connection show 网卡信息, 



 Centos7 team 绑定多网卡_json_06




5、 激活 team0  team0-port1 team0-port2

nmcli connection up team0
nmcli connection up team0-port1
nmcli connection up team0-port2

激活 team0 和 team0-port1 时候,  agg-eth0 网卡就up起来了

Centos7 team 绑定多网卡_json_07




再次查看 nmcli connectioon show 信息,  Wired conncetion 2 和 3 就处于未激活状态

Centos7 team 绑定多网卡_网卡绑定_08




6、验证

查看 agg-eth0 网卡绑定的信息

teamdctl agg-eth0 state view

Centos7 team 绑定多网卡_javascript_09



 此时的 runner 为 ens37  及 team0-port1


我们长ping 192.168.1.250, 然后再 down team0中的 team0-port1, 看看 是否还能ping通

Centos7 team 绑定多网卡_网卡绑定_10



 执行 nmcli connection down team0-port1

nmcli connection down team0-port1

Centos7 team 绑定多网卡_网卡绑定_11Centos7 team 绑定多网卡_javascript_12转存失败重新上传取消Centos7 team 绑定多网卡_网卡绑定_11




ping 中断了三个包时间

ens38 成为 runner

Centos7 team 绑定多网卡_json_14




激活 team0-port1 ,  中断了6个包时间

Centos7 team 绑定多网卡_json_15



同样,  ip link set dev ens38 down,  也会中断8个包时间,  

但是对 backup 端口操作, 则没有影响

Centos7 team 绑定多网卡_网卡绑定_16



举报

相关推荐

0 条评论