Linux下配置网卡绑定team
网卡绑定
链路聚合,备份网卡(虚拟网卡team)
建立网卡绑定
建立虚拟网卡team0
# nmcli connection add type team con-name team0(表示永久写入team0配置文件) ifname team0 autoconnect yes config ‘{"runner": {"name": "activebackup"}}’
team的几种模式:activebackup:主备;loadbalance:负载均衡
格式文件:
参考 man teamd.conf (G,表示到达末尾)
文件内容: ‘{"runner": {"name": "activebackup"}}’
1、添加成员
添加一个类型为
# nmcli connection add type team-slave(奴隶,成员) con-name team0-1 ifname eth1 master team0
# nmcli connection add type team-slave(奴隶,成员) con-name team0-2 ifname eth2 master team0
注释:如果出现错误,会影响进程,通过delete删除之后重新操作。
2、配置IP地址和网关
# nmcli connection modify team0 ipv4.method manual ip4 192.168.1.1/24 gw4 192.168.1.254 connection.autoconnect yes
3、激活虚拟网卡
激活team : # nmcli connection up team0
激活成员 : # nmcli connection up team0-1;nmcli connection up team0-2
查询:ifconfig team0 / teamdctl team0 state
注释:
如果激活之后报错了,需要如下删除操作(错误的文件再次输入不能被覆盖):
# nmcli connection delete team0
# nmcli connection delete team0-1
# nmcli connection delete team0-2