javaobc 发表于 2011-3-8 11:47:45

PCC拨号变化后自动修改参数

:global activeroutesold;
:local activeroutes 0;
:local route;
:local tes;
:local divs 0;
:local less;
:local routingmarks;
:local arrayrouting;
:local routemark;


:log info "BEGIN************"
:foreach route in=*balanceo" active=yes] do={
   :set tes [ /ip route get $route routing-mark ];
   :set activeroutes ($activeroutes + 1)
   :set routingmarks ($routingmarks, $tes);
}
:if ($activeroutes != $activeroutesold) do={
   /ip firewall
      mangle {
         :foreach a in=*balance" ] do={
            remove $a }
   }
   :set arrayrouting [:toarray $routingmarks]
   :set divs $activeroutes;
   :set less $activeroutes;



   :log info "email enviado";
   :for i from=0 to=($activeroutes-1) do={
      :set routemark [:pick $routingmarks $i]
      :set divs ($activeroutes - $less);
      :set less ($less - 1);
      :log info "$routemark";
      :log info "$activeroutes/$divs"
       /ip firewall mangle
      :log info "Setting filters";
      add action=mark-connection chain=prerouting comment="balance conn $routemark" \
          disabled=no dst-address-type=!local in-interface=local \
          new-connection-mark="$routemark" passthrough=yes per-connection-classifier=\
          "both-addresses:$activeroutes/$divs" place-before=3
      add action=mark-routing chain=prerouting comment="balance route $routemark" \
         connection-mark="$routemark" disabled=no in-interface=local new-routing-mark=\
         "$routemark" passthrough=no place-before=3
    }
} else={:log info "rutas no han cambiado"};
:log info ("$activeroutes rutas activas");
:set activeroutesold $activeroutes;
:log info "END**************"

zooyo 发表于 2011-3-8 12:10:52

:L 好复杂啊,脚本不是越简单效率越高越好吗?

mxso 发表于 2011-3-8 14:11:30

楼主的并不复杂,只是只要已经连接上的线路数不同就全删了,然后再重新建立

原理上不属于修改了

lai99999 发表于 2011-3-10 23:50:48

呵呵!!有点难度哟!!

tkdpc 发表于 2011-3-11 11:19:03

这个是复杂呀
不用删除,禁用就行,
省点资源
页: [1]
查看完整版本: PCC拨号变化后自动修改参数