蓝色动力网络

 找回密码
 立即注册

扫一扫,访问微社区

QQ登录

只需一步,快速开始

查看: 3080|回复: 0

多ADSL负载–掉线后自动修改pcc/nth参数 保证网络畅通

[复制链接]
发表于 2011-8-31 19:38:54 | 显示全部楼层 |阅读模式
很多朋友提出了这个问题,假如有4条ADSL跑PCC负载,掉了其中一条后网络就会出现问题,网页打不开或者很慢等等,这是由于PCC参数不匹配造成的。针对这样的情况WGHBOY兄已经发过一脚本,今天应一个朋友的需要测试后发现该脚本判断不太准确,呵呵。遂花了点时间重新编写达到所要目的。



以4线为例,其中某条线路断了后,会自动判断剩余可用的线路数量然后修改PCC规则的参数,线路恢复正常后会自动把参数修改回正常状态,注意连接标记名称一定要以纯数字“1、2、3、4…”来命名。一般该脚本设置30秒间隔就比较合适。
  1. PCC:
  2. {
  3. :local status
  4. :local i "5"
  5. :local x "0"
  6. :local y "0"
  7. :local z "0"
  8. :set x [:len [/interface pppoe-client find running=yes]]
  9. :if ($x<$i) do={
  10. :for ii from=1 to=$i do={
  11. :set status [/interface get [find name=("pppoe-out".$ii)] running]
  12. :if ($status=true) do={
  13. /ip fir man set [find new-connection-mark=$ii] per-connection-classifier=("both-addresses:".$x."/".$y) disable=no;:set y ($y+1)} else={
  14. /ip fir man set [find new-connection-mark=$ii] disable=yes}}}
  15. :if ($x=$i) do={
  16. :set z [:len [/ip fir man find action="mark-connection" disabled=yes chain=prerouting]]
  17. :if ($z>0) do={
  18. :for ii from=1 to=$i do={
  19. /ip fi man set [find new-connection-mark=$ii] per-connection-classifier=("both-addresses:".$x."/".$y) disable=no;:set y ($y+1)}}}}
  20. NTH:
  21. {
  22. :local status
  23. :local i "5"
  24. :local x "0"
  25. :local y "1"
  26. :local z "0"
  27. :set x [:len [/interface pppoe-client find running=yes]]
  28. :if ($x<$i) do={
  29. :for ii from=1 to=$i do={
  30. :set status [/interface get [find name=("pppoe-out".$ii)] running]
  31. :if ($status=true) do={
  32. /ip fir man set [find new-connection-mark=$ii] nth=($x.",".$y) disable=no;:set y ($y+1)} else={
  33. /ip fir man set [find new-connection-mark=$ii] disable=yes}}}
  34. :if ($x=$i) do={
  35. :set z [:len [/ip fir man find action="mark-connection" disabled=yes chain=prerouting]]
  36. :if ($z>0) do={
  37. :for ii from=1 to=$i do={
  38. /ip fi man set [find new-connection-mark=$ii] nth=($x.",".$y) disable=no;:set y ($y+1)}}}}
复制代码
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

蓝色动力网络微信平台
网站管理,业务合作联系邮箱: admin#lansedongli.com    QQ:13412492 限网站业务问题.
网站帐号、密码、密保找回请使用注册邮箱,发送邮件至 password#lansedongli.com ,否则不予受理.
免责声明:本论坛所有文字和图片仅代表其个人观点.
本站某些资料或文章来自于互联网,不代表本站观点,如果侵犯了您的权益,请来信告知,我们会在三天内删除.
为了给大家一个更好的交流场所,请勿在本论坛发表与中华人民共和国法律相抵触的言论,请合作,谢谢!
Copyright © 2007-2019 Corporation Powered by网吧系统 版权所有    转载请注明!
浙ICP备11043737号-1 程序:Discuz! x3.4

湘公网安备 43018102000145号

手机版|Archiver|蓝色动力网络   

快速回复 返回顶部 返回列表