什么是bonding?
绑定是一项将多个类似于以太网端口的接口聚合成一个虚拟的接口,从而获取更高的数据速率,并提供故障转移
菜单:
/interface bonding
快速配置实例
假如每个路由器(router1和router2)都有两个NIC(网卡),并需要将两个路由器获取最大的数据速率
- 在router1,router2分别添加绑定接口
[admin@MikroTik] > interface bonding
[admin@MikroTik] /interface bonding> add slaves=ether1,ether2
- 将地址分别添加到绑定接口
[admin@MikroTik] > ip address
[admin@MikroTik] /ip address> add address=172.16.0.1/24 interface=bonding1
[admin@MikroTik] > ip address
[admin@MikroTik] /ip address> add address=172.16.0.2/24 interface=bonding2
- 测试连接
[admin@Router1] interface bonding> /pi 172.16.0.2
172.16.0.2 ping timeout
172.16.0.2 ping timeout
172.16.0.2 ping timeout
172.16.0.2 64 byte ping: ttl=64 time=2 ms
172.16.0.2 64 byte ping: ttl=64 time=2 ms
Link monitoring
什么是连接监控?
假如以上绑定的线路其中一条发生故障,则绑定的驱动程序仍然发送错误的数据包,这将导致网络性能下降。
连接监控有两种方案:
1.MLL监视
2.ARP监控
一、 ARP监控原理:
ARP监控发送ARP查询,并将响应用作指示链路正常的指示。如果设置了balance-rr和balance-xor模式,则应将交换机配置为在所有链路上平均分配数据包
1.启用ARP监控
[admin@Router1] interface bonding> set 0 link-monitoring=arp arp-ip-targets=172.16.0.2
[admin@Router2] interface bonding> set 0 link-monitoring=arp arp-ip-targets=172.16.0.1
2.拔掉一根线缆测试
[admin@Router1] interface bonding> /pi 172.16.0.2
172.16.0.2 ping timeout
172.16.0.2 64 byte ping: ttl=64 time=2 ms
172.16.0.2 ping timeout
172.16.0.2 64 byte ping: ttl=64 time=2 ms
172.16.0.2 ping timeout
172.16.0.2 64 byte ping: ttl=64 time=2 ms
172.16.0.2 64 byte ping: ttl=64 time=2 ms
172.16.0.2 64 byte ping: ttl=64 time=2 ms
二、MII监控原理:
MII监视只监视本地接口的状态,通过设备驱动程序来确定链接是打开还是关闭状态。缺点是,即使检测到链路正常,MII监视也无法判断该链路是否可以实际通过数据包。
通过设置变量链接监视模式和间隔时间来配置MII监视。
1.启用MII监控
[admin@Router1] interface bonding> set 0 link-monitoring=mii
[admin@Router2] interface bonding> set 0 link-monitoring=mii
Bonding modes
一、802.3ad模式
802.3ad是标准的IEEE标准,也称为LACP(链路聚合控制协议)。
配置实例:
R1路由器配置:
/inteface bonding add slaves=ether1,ether2 mode=802.3ad lacp-rate=30secs link-monitoring=mii \
transmit-hash-policy=layer-2-and-3
Switch配置:
Intelligent Switch : Trunk Configuration
==================
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 M1 M2
1 - v - v - - - - - - - - - - - - - - - - - - - - - -
2 - - - - - - - - - - - - - - - - - - - - - - - - - -
3 - - - - - - - - - - - - - - - - - - - - - - - - - -
4 - - - - - - - - - - - - - - - - - - - - - - - - - -
5 - - - - - - - - - - - - - - - - - - - - - - - - - -
6 - - - - - - - - - - - - - - - - - - - - - - - - - -
7 - - - - - - - - - - - - - - - - - - - - - - - - - -
TRK1 LACP
TRK2 Disable
TRK3 Disable
TRK4 Disable
TRK5 Disable
TRK6 Disable
TRK7 Disable
验证LACP是否正常工作:在交换机上,我们首先应验证LACP协议是否已启用并正在运行:
Intelligent Switch : LACP Port State Active Configuration
==================
Port State Activity Port State Activity
--------------------------- ---------------------------
2 Active
4 Active
之后,我们可以确保LACP与我们的路由器协商。 如果您在列表中都没有看到两个端口,则说明出了点问题,因此LACP无法正常工作。
Intelligent Switch : LACP Group Status
==================
Group
[Actor] [Partner]
Priority: 1 65535
MAC : 000E2E2206A9 000C42409426
Port_No Key Priority Active Port_No Key Priority
2 513 1 selected 1 9 255
4 513 1 selected 2 9 255
验证交换机与路由器成功LACP之后,查看client1和client2之间到服务器的流量,检查它们是如何均匀转发流量:
[admin@test-host] /interface> monitor-traffic ether1,ether2,bonding1
rx-packets-per-second: 8158 8120 16278
rx-drops-per-second: 0 0 0
rx-errors-per-second: 0 0 0
rx-bits-per-second: 98.8Mbps 98.2Mbps 197.0Mbps
tx-packets-per-second: 4833 4560 9394
tx-drops-per-second: 0 0 0
tx-errors-per-second: 0 0 0
tx-bits-per-second: 2.7Mbps 3.0Mbps 5.8Mbps
二、balance-rr(平衡模式)
如果设置了此模式,则将数据包从第一个可用从设备到最后一个从设备按顺序传输。
Balance-rr是唯一一种可在属于同一TCP / IP连接的多个接口上发送数据包的模式。
当利用多个发送和多个接收链路时,数据包通常会乱序接收,将导致段重传,对与UDP则没有问题
三、active-backup(主动备份)
此模式仅使用一个活动从端口来传输数据包。仅当主从端口发生故障时,附加从端口才变为活动状态。
四、active-backup(冗余备份)
此模式仅使用一个活动从端口来传输数据包。 仅当主端口发生故障时,附加端口才变为活动状态。 绑定接口的MAC地址显示在活动端口上,以避免混淆交换机。 在具有互连的多个交换机的高可用性设置中,主动备份是最佳选择
假如两个端口速率不同
配置实例:
/interface bonding add mode=balance-tlb slaves=ether1,ether2 primary=ether1