找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2960|回复: 1

[负载平衡] PCC

[复制链接]
发表于 2010-11-8 22:45:30 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

×
  1. :global activeroutesold;
  2. :local activeroutes 0;
  3. :local route;
  4. :local tes;
  5. :local divs 0;
  6. :local less;
  7. :local routingmarks;
  8. :local arrayrouting;
  9. :local routemark;


  10. :log info "BEGIN************"
  11. :foreach route in=[/ip route find where comment~"^[a-z]*balanceo" active=yes] do={
  12.    :set tes [ /ip route get $route routing-mark ];
  13.    :set activeroutes ($activeroutes + 1)
  14.    :set routingmarks ($routingmarks, $tes);
  15. }
  16. :if ($activeroutes != $activeroutesold) do={
  17.    /ip firewall
  18.       mangle {
  19.          :foreach a in=[find where comment~"^[a-z]*balance" ] do={
  20.             remove $a }
  21.    }
  22.    :set arrayrouting [:toarray $routingmarks]
  23.    :set divs $activeroutes;
  24.    :set less $activeroutes;



  25.    :log info "email enviado";
  26.    :for i from=0 to=($activeroutes-1) do={
  27.       :set routemark [:pick $routingmarks $i]
  28.       :set divs ($activeroutes - $less);
  29.       :set less ($less - 1);
  30.       :log info "$routemark";
  31.       :log info "$activeroutes/$divs"
  32.        /ip firewall mangle
  33.       :log info "Setting filters";
  34.       add action=mark-connection chain=prerouting comment="balance conn $routemark" \
  35.           disabled=no dst-address-type=!local in-interface=local \
  36.           new-connection-mark="$routemark" passthrough=yes per-connection-classifier=\
  37.           "both-addresses:$activeroutes/$divs" place-before=3
  38.       add action=mark-routing chain=prerouting comment="balance route $routemark" \
  39.          connection-mark="$routemark" disabled=no in-interface=local new-routing-mark=\
  40.          "$routemark" passthrough=no place-before=3
  41.     }
  42. } else={:log info "rutas no han cambiado"};
  43. :log info ("$activeroutes rutas activas");
  44. :set activeroutesold $activeroutes;
  45. :log info "END**************"
复制代码
routeros
发表于 2010-11-9 00:27:33 | 显示全部楼层
很好很好
routeros
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|手机版|小黑屋|软路由 ( 渝ICP备15001194号-1|渝公网安备 50011602500124号 )

GMT+8, 2024-5-3 01:32 , Processed in 0.067069 second(s), 4 queries , Gzip On, Redis On.

Powered by Discuz! X3.5 Licensed

© 2001-2023 Discuz! Team.

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