CentOS7设置网卡team

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

nmcli connection add type team con-name team0 ifname agg-eth0 config '{"runner":{"name":"activebackup"}}'  # 创建接口team,连接名team0,接口agg-eth0,工作模式为activebackup

nmcli connection modify team0 ipv4.addresses "192.168.1.20/24"  # 以下为team0接口配置IP信息
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

nmcli connection add type team-slave con-name team0-port1 ifname ens37 master agg-eth0  # 将 ens37、ens38 加入agg-eth0
nmcli connection add type team-slave con-name team0-port2 ifname ens38 master agg-eth0

nmcli connection up team0  # 激活 team0、team0-port1、team0-port2
nmcli connection up team0-port1
nmcli connection up team0-port2

teamdctl agg-eth0 state view  # 查看 agg-eth0 网卡绑定的信息

nmcli connection down team0-port1  # 执行此命令,并使用ping测试网络连通性

说明:
用 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 命令重启此网络服务即可。

posted @ 2022-04-13 09:33  Varden  阅读(462)  评论(0编辑  收藏  举报