|
马上注册成为ROSABC会员,随时发帖回复。
您需要 登录 才可以下载或查看,没有账号?会员注册
x
不等不同带宽的多线按比例权重配置负载均衡
不等不同带宽的多线按比例权重配置负载均衡
不等不同带宽的多线按比例权重配置负载均衡
前几天一个朋友的网络有这样一个需求,他说自己有2条电信出口,一条8M,一条是25M,想做策略将两条线路实现权重的路由策略,他说hillstone的防火墙可以实现,但价格就是比较贵,想问问RouterOS是否能实现,我想了想,应该可以。
实现方式通过PCC(per connection classifie),平常我们都是用PCC做多条相同带宽出口的负载均衡,而这次我则是通过他的分类原理实现比例权重的路由策略,当然Nth也可以实现,不过Nth众所周知稳定性还欠缺,不然PCC好。
实现原理比较简单,一条8M,一条是25M,后者大概是前者的3倍出口,所以就看看1:3,那就是要按照1:3的比例分配路由,我的策略是将PCC策略看成4份,然后路由指定按照1:3的路由规则分配。
配置PCC规则,即把2条出口,看成4份数据进行PCC的策略配置,mangle策略配置如下
/ip firewall mangle
add action=mark-connection chain=prerouting dst-address-type=! new-connection-mark=pcc1 passthrough=yes \
per-connection-classifier=both-addresses:4/0 src-address-list=userip
add action=mark-routing chain=prerouting connection-mark=pcc1 new-routing-mark=r1 passthrough=yes src-address-list=userip
add action=mark-connection chain=prerouting dst-address-type=! new-connection-mark=pcc2 passthrough=yes \
per-connection-classifier=both-addresses:4/1 src-address-list=userip
add action=mark-routing chain=prerouting connection-mark=pcc2 new-routing-mark=r2 passthrough=yes src-address-list=userip
add action=mark-connection chain=prerouting dst-address-type=! new-connection-mark=pcc3 passthrough=yes \
per-connection-classifier=both-addresses:4/2 src-address-list=userip
add action=mark-routing chain=prerouting connection-mark=pcc3 new-routing-mark=r3 passthrough=yes src-address-list=userip
add action=mark-connection chain=prerouting dst-address-type=! new-connection-mark=pcc4 passthrough=yes \
per-connection-classifier=both-addresses:4/3 src-address-list=userip
add action=mark-routing chain=prerouting connection-mark=pcc4 new-routing-mark=r4 passthrough=yes src-address-list=userip
路由配置
将分配好的路由标记按照1:3的比例分配到各条线路上
/ip route
add check-gateway=ping gateway=8M routing-mark=r1
add check-gateway=ping gateway=25M routing-mark=r2
add check-gateway=ping gateway=25M routing-mark=r3
add check-gateway=ping gateway=25M routing-mark=r4
nat配置
/ip firewall nat
add chain=srcnat action=masquerade out-interface=8M
add chain=srcnat action=masquerade out-interface=25M
配置完成后流量几乎按照预想的方式运行 ,这样的操作建议使用到相同类型的出口,比如不同带宽的线路都是电信,或者都是网通。不建议在不同运营商出口上跑
[RouterOS通过PCC实现比例权重路由策略 ]
|
|