javaobc 发表于 2010-11-8 22:45:30

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**************"

47771885 发表于 2010-11-9 00:27:33

很好很好
页: [1]
查看完整版本: PCC