PCC掉线切换修改版
已有 787 次阅读2011-2-28 21:34
:local pccstatus
:local status
:local pccold
:local pccnew
:local link
:local ncm
:local nrm
:local y
:local z
:local x
:set x 4
:set link 0
:for i from=1 to="$x" do={
:set status [/interface get [/interface find name=("pppoe-out" . "$i")] running]
:if ("$status" = true) do={
:set link ($link + 1)
}
}
:if ("$link" > 1) do={
:set z "$link"
:set y 0
:for i from=1 to="$x" do={
:set status [/interface get [/interface find name=("pppoe-out" . "$i")] running]
:set ncm ("adsl" . "$i" . "conn")
:set nrm ("ADSL" . "$i")
:if ("$status" = true) do={
:set pccnew ("both-addresses" . ":" . "$z" . "/" . "$y")
:set pccold [/ip firewall mangle get [ /ip firewall mangle find chain=bonding new-connection-mark="$ncm"] per-connection-classifier]
:set pccstatus [/ip firewall mangle get [/ip firewall mangle find chain=bonding new-connection-mark="$ncm"] disable]
:if (("$pccnew" != $pccold) || ("$pccstatus" = true)) do={
/ip firewall mangle set [ /ip firewall mangle find chain=bonding new-connection-mark="$ncm"] per-connection-classifier=$pccnew disabled=no
/ip firewall mangle set [ /ip firewall mangle find chain=bonding new-routing-mark="$nrm"] disabled=no
}
:set y ($y + 1)
} else {
:set pccstatus [/ip firewall mangle get [/ip firewall mangle find chain=bonding new-connection-mark="$ncm"] disable]
:if ("$pccstatus" = false) do={
/ip firewall mangle disable [ /ip firewall mangle find chain=bonding new-connection-mark="$ncm"]
/ip firewall mangle disable [/ip firewall mangle find chain=bonding new-routing-mark="$nrm"]
}
}
}
}
}