找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 4542|回复: 4

[脚本] PCC拨号变化后自动修改参数

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

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

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

×
  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**************"
复制代码

评分

参与人数 2铜板 +22 收起 理由
WGHBOY + 10
zooyo + 12 谢谢分享

查看全部评分

routeros
发表于 2011-3-8 12:10:52 | 显示全部楼层
好复杂啊,脚本不是越简单效率越高越好吗?
routeros
回复

使用道具 举报

发表于 2011-3-8 14:11:30 | 显示全部楼层
楼主的并不复杂,只是只要已经连接上的线路数不同就全删了,然后再重新建立

原理上不属于修改了
routeros
回复

使用道具 举报

发表于 2011-3-10 23:50:48 | 显示全部楼层
呵呵!!有点难度哟!!
routeros
回复

使用道具 举报

发表于 2011-3-11 11:19:03 | 显示全部楼层
这个是复杂呀
不用删除,禁用就行,
省点资源
routeros
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-5 03:21 , Processed in 0.076467 second(s), 5 queries , Gzip On, Redis On.

Powered by Discuz! X3.5 Licensed

© 2001-2023 Discuz! Team.

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