I make a 10 wan load balance (dsl) with PCC, but i have a big problem, in my country sometimes we have a intermitent down of a various adls at same time, sometimes i have 4 or 5 wand down at same time, this is a big problem because the RouterOS send all the traffic of this 5 down wan for the default gateway saturating this link, i make a script that first count the number of active routes and then re-create the mangle rules changing the PCC parameter and inserting the new rules. maybe is more easy to resolve this issue (i wait opinions) but this is the way i think by now.
i dont know much about scripting, maybe there is best and easy way to do this, i'll wait advices.
Code: Select all
: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=[/ip route find where comment~"^[a-z]*balanceo" active=yes] do={
:set tes [ /ip route get $route routing-mark ];
:set activeroutes ($activeroutes + 1)
:set routingmarks ($routingmarks, $tes);
}
:log info $activeroutes;
:log info $activeroutesold;
:if ($activeroutes != $activeroutesold) do={
/ip firewall
mangle {
:foreach a in=[find where comment~"^[a-z]*balance" ] do={
remove $a }
}
:set arrayrouting [:toarray $routingmarks]
:set divs $activeroutes;
:set less $activeroutes;
: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 "routes has no changed"};
:log info ("$activeroute active routes");
:set activeroutesold $activeroutes;
:log info "END********************************************************************"