| 
 | 
 
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册 
 
 
 
×
 
各位同仁大家好. 
--------------------------------------------先交待背景------------------------------------------------------------ 
我经营的公司网络(利比亚,北非),外网接入速度慢,质量差(WIMAX,一种城域无线接入技术).公司要求高,有两千多员工,分三个部分,总公司,十四个分公司和监理.需要用到的ros功能有按IP限速,防火墙,Hotspot认证,Webproxy透明代理,多线(四线以上)负载均衡等. 
 
目前三个部分,每个部门两台ROS,其中一台做hotspot认证,队列限速和防火墙,第二层ROS做NTH负载均衡和透明代理.这里使用两个ROS的原因是,队列限速hotspot等功能可能会影响到负载均衡.于是干脆用两台ROS,其中第一层使用ROS2.9.27,第二层使用ROS3.22. 
 
-------------------------------------------------------问题-------------------------------------------------------- 
在具体使用的时候发现,webproxy也会影响到负载均衡.因为NTH负载会标记每一个跟ROS新建立的连接.并且选择路由,但是透明代理功能里需要把所有80端口的连接重定向到ROS,再通过ROS建立与网站的连接,这样先前被标记的连接就失效了,而访问网页的数据则从ROS内部发出,并随机选择网关.我现在是四线均衡,这样就造成了有时候其中的一条线被挤得满满的,而其它三条线却是空的.同事上网的时候会时快时慢,如果撞到了空的那条线,速度就快,如果撞到了挤的那条,可能根本无法打开网页,我也不清楚为什么总是第三条线很挤. 
----------------------------------------------目前有待测试的解决办法--------------------------------------------------------- 
前面说到透明代理会把forward裢变成output裢,于是就想办法把ROS内部发现的连接也打上标记,并让这些连接均衡地选择四个网关,而不是随机的.以下是代码: 
/ip firewall mangle 
下面这一部分是NTH负载均衡,大家都知道的. 
************************************************************************* 
add action=mark-connection chain=prerouting comment=1nth connection-state=new \ 
    disabled=no in-interface=lan new-connection-mark=1 nth=4,1 passthrough=\ 
    yes protocol=tcp 
add action=mark-routing chain=prerouting comment="" connection-mark=1 \ 
    disabled=no in-interface=lan new-routing-mark=1nth passthrough=yes 
add action=mark-connection chain=prerouting comment=2nth connection-state=new \ 
    disabled=no in-interface=lan new-connection-mark=2 nth=4,2 passthrough=\ 
    yes protocol=tcp 
add action=mark-routing chain=prerouting comment="" connection-mark=2 \ 
    disabled=no in-interface=lan new-routing-mark=2nth passthrough=yes 
add action=mark-connection chain=prerouting comment=3nth connection-state=new \ 
    disabled=no in-interface=lan new-connection-mark=3 nth=4,3 passthrough=\ 
    yes protocol=tcp 
add action=mark-routing chain=prerouting comment="" connection-mark=3 \ 
    disabled=no in-interface=lan new-routing-mark=3nth passthrough=yes 
add action=mark-connection chain=prerouting comment=4nth connection-state=new \ 
    disabled=no in-interface=lan new-connection-mark=4 nth=4,4 passthrough=\ 
    yes protocol=tcp 
add action=mark-routing chain=prerouting comment="" connection-mark=4 \ 
    disabled=no in-interface=lan new-routing-mark=4nth passthrough=yes 
********************************************************************* 
下面这一部分是对output裢作标记. 
********************************************************************* 
首先选择output裢,因为从ROS到内网数据也在output裢之内,所以在dst-address里面加上一个条件就是不标记发向内网的数据.然后这里使用了Random均衡的方法,因为是四条线,第一条填25%,第二条填33%,第三条填50%,第四条不填,这个是在"我非黑客"的帖子"Random负载均衡里百分比的填法里学到的",在此感谢您的分享.其它的都跟NTH差不多. 
add action=mark-connection chain=output comment=Output connection-state=new \ 
    disabled=no dst-address=!62.192.148.102 dst-port=80 new-connection-mark=1 \ 
    passthrough=yes protocol=tcp random=25 
add action=mark-routing chain=output comment="" connection-mark=1 disabled=no \ 
    dst-address=!62.192.148.102 new-routing-mark=1nth passthrough=no \ 
    protocol=tcp 
add action=mark-connection chain=output comment="" connection-state=new \ 
    disabled=no dst-address=!62.192.148.102 dst-port=80 new-connection-mark=2 \ 
    passthrough=yes protocol=tcp random=33 
add action=mark-routing chain=output comment="" connection-mark=2 disabled=no \ 
    dst-address=!62.192.148.102 new-routing-mark=2nth passthrough=no \ 
    protocol=tcp 
add action=mark-connection chain=output comment="" connection-state=new \ 
    disabled=no dst-address=!62.192.148.102 dst-port=80 new-connection-mark=3 \ 
    passthrough=yes protocol=tcp random=50 
add action=mark-routing chain=output comment="" connection-mark=3 disabled=no \ 
    dst-address=!62.192.148.102 new-routing-mark=3nth passthrough=no \ 
    protocol=tcp 
add action=mark-connection chain=output comment="" connection-state=new \ 
    disabled=no dst-address=!62.192.148.102 dst-port=80 new-connection-mark=4 \ 
    passthrough=yes protocol=tcp 
add action=mark-routing chain=output comment="" connection-mark=4 disabled=no \ 
    dst-address=!62.192.148.102 new-routing-mark=4nth passthrough=no \ 
    protocol=tcp 
********************************************************************* 
做完上面的工作后,在connection里查看,以前从ROS内发出的连接都没有标记的,现在也有标记了,而且数量比较均衡. 
具体的实用效果还待下午测试. 
在这里发出这个办法,是希望向同仁们交流学习,望大家能指出有哪些不足和不对的地方,或者有哪些办法能更好地解决ROS内部发出的数据不能均衡的问题.望大家多多指教.谢谢. |   
 
 
 
 |