对于链路聚合,linux中已有bonding驱动,在CentOS 7中又引入一个teaming驱动。

相比bonding,teaming更强调是在用户空间配置聚合,也比bonding支持更多特性。

具体可以参考官方的Networking guide文档。

teaming驱动本身工作在内核里,创建聚合端口要靠teamd(或者自己写代码调用libteam)。
teaming本身可以不依靠交换机配置创建聚合,支持的runner是activebackup。
如果采用broadcast,loadbalance(基于hash),LACP这几种runner则连接的交换机那边,必须参与配置。
下边用H3C S5500-HI交换机举例,说明一下如何配置teaming的LACP runner。
一、H3C S5500-HI端配置
(1)# 创建二层聚合接口1,并配置该接口为动态聚合模式。
[DeviceA] interface bridge-aggregation 1
[DeviceA-Bridge-Aggregation1] link-aggregation mode
dynamic
[DeviceA-Bridge-Aggregation1] quit
(2)# 分别将端口GigabitEthernet1/0/1至
GigabitEthernet1/0/2加入到聚合组1中。
# 配置端口的LACP超时时间为短超时(即1秒)
[DeviceA] interface gigabitethernet 1/0/1
[DeviceA-gigabitethernet1/0/1] port link-aggregation group
1
[Sysname-GigabitEthernet1/0/1] lacp period short
[DeviceA-gigabitethernet1/0/1] quit
[DeviceA] interface gigabitethernet 1/0/2
[DeviceA-gigabitethernet1/0/2] port link-aggregation group
1
[Sysname-GigabitEthernet1/0/1] lacp period short
[DeviceA-gigabitethernet1/0/2] quit
(3)# 配置二层聚合接口1为Trunk端口,并允许VLAN 10和20的报文通过。
注:这里只是为了说明问题,如果不需要Trunk,可以配置成普通接口即可。
[DeviceA] interface bridge-aggregation 1
[DeviceA-Bridge-Aggregation1] port link-type trunk
[DeviceA-Bridge-Aggregation1] port trunk permit vlan 10
20
[DeviceA-Bridge-Aggregation1] quit
(4)# 配置全局按照报文的源MAC地址和目的MAC地址进行聚合负载分担。
[DeviceA] link-aggregation load-sharing mode source-mac
destination-mac
# 查看交换机上所有聚合组的摘要信息。
[Switch] display link-aggregation summary
Aggregation Interface Type:
BAGG -- Bridge-Aggregation, RAGG -- Route-Aggregation
Aggregation Mode: S -- Static, D -- Dynamic
Loadsharing Type: Shar -- Loadsharing, NonS --
Non-Loadsharing
Actor System ID: 0x8000, 000f-e2ff-0001
AGG  AGG  Partner ID  Select Unselect
Share
Interface  Mode  Ports  Ports
Type
-------------------------------------------------------------------------------
BAGG1  D  0x8000, 000f-e2ff-0002  2
0
Shar
以上信息表明,聚合组1为负载分担类型的二层动态聚合组,包含有2个选中端口。
# 查看交换机上全局采用的聚合负载分担类型。
[Switch] display link-aggregation load-sharing mode
Link-Aggregation Load-Sharing Mode:
destination-mac address, source-mac
address
以上信息表明,所有聚合组都按照报文的源MAC地址和目的MAC地址进行聚合负载分担。
二、Linux主机配置
(0)# 安装teamd
~]# yum install teamd
(1)# 创建team接口配置文件
~]# vi /etc/sysconfig/network-scripts/ifcfg-team0
DEVICE=team0
DEVICETYPE=Team
ONBOOT=yes
BOOTPROTO=none
TEAM_CONFIG='{
"runner": {
"name": "lacp",
"active": false,
"fast_rate": true,
"tx_hash": ["eth"]
},
"link_watch": {"name": "ethtool"},
"ports": {"em1": {}, "em2": {}}
}'
注意:
fast_rate配置LACP超时要和H3C交换机上的对应
tx_hash的方法选择"eth",即使用源MAC和目的MAC做hash计算,也与H3C交换机配置对应
(2)# 创建成员接口配置文件
~]# vi /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
HWADDR=D4:85:64:01:46:9E
DEVICETYPE=TeamPort
ONBOOT=yes
TEAM_MASTER=team0
~]# vi /etc/sysconfig/network-scripts/ifcfg-eth2
DEVICE=eth2
HWADDR=D4:85:64:01:46:9F
DEVICETYPE=TeamPort
ONBOOT=yes
TEAM_MASTER=team0
(3)配置team接口的VLAN子接口,以VLAN 10为例
~]# vi /etc/sysconfig/network-scripts/ifcfg-team0.10
DEVICE=team0.10
IPADDR=192.168.99.88
NETMASK=255.255.255.0
ONBOOT=static
VLAN=yes
(4)# 重新启动网络服务,如果报错,可能需要reboot一下
~]# systemctl restart network
# 确认team接口成员
~]# teamnl team0 ports
# 确认team接口状态
~]#teamdctl team0
state

CentOS 7支持多种网卡命名方式,此处网卡的命名规则,我选择了原始的eth方式,主要是因为习惯了。

系统启动后会首先查看/usr/lib/udev/rules.d/60-net.rules,通知/lib/udev/rename_device去查看所有的ifcfg文件。如果发现一个接口MAC地址匹配到一个ifcfg文件中的HWADDR项,则使用该ifcfg文件中的DEVICE项的名字来命名该接口。

参考文档:

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html-single/networking_guide/

https://www.kernel.org/doc/Documentation/networking/bonding.txt

http://www.h3c.com.cn/Service/Document_Center/Switches/Catalog/S5500/S5500-EI/Configure/Operation_Manual/H3C_S5500-SI[EI]_CG-Release_2208-6W100/03/201101/707252_30005_0.htm

http://www.h3c.com.cn/Service/Document_Center/Switches/Catalog/S5500/S5500-EI/Command/Command_Manual/H3C_S5500-EI[SI]_CR-Release_2220-6W100/03/201503/858785_30005_0.htm

https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Networking_Guide/ch-Introduction_to_RHEL_Networking.html

https://github.com/jpirko/libteam/wiki/Tutorial

http://techgnat.blogspot.hk/2014/12/centos-teaming-with-vlans.html

http://ceyes.github.io/2014-07/Study-Linux-Team/

http://vinzlinux.blogspot.hk/2014/12/configuring-network-teaming-using-nmcli.html

https://ervikrant06.wordpress.com/2014/06/06/how-to-configure-network-teaming-in-rhel-7/

https://blog.headdesk.me/2015/02/teaming-nics-with-teamd/

https://www.mankier.com/5/teamd.conf

https://docs.fedoraproject.org/en-US/Fedora/23/html/Networking_Guide/sec-Configuring_a_VLAN_over_a_Bond.html

http://blog.vikki.in/network-teaming-rhel7/