ROS多线叠加PCC参数掉线自动修正
发布于2023-10-17 15:38 阅读901次 ros多拨会存在某线断开,无法实现PCC分线问题,分享一段PCC在多拨下的自动修正程序:
#将脚本命名保存,创建计划任务 执行:execute script="脚本名称"
```
:local status
:local i 0
:local x 0
:local y 0
:local z 0
:set x [:len [/interface pppoe-client find running=yes]]
:set i [:len [/interface pppoe-client find ]]
:if ($x<=$i) do={
:for ii from=1 to=$i do={
:set status [/interface get [find name=("pppoe-out".$ii)] running]
:if ($status=true) do={
/ip firewall mangle set [find chain="prerouting" action="mark-connection" new-connection-mark="pppoe-out".$ii."-pcc"] per-connection-classifier=("both-addresses:".$x."/".$y) disable=no
/ip firewall mangle set [find chain="prerouting" connection-mark="pppoe-out".$ii."-pcc" action="mark-routing" new-routing-mark="pppoe-out".$ii."-route"] disable=no
/ip firewall mangle set [find chain="input" in-interface="pppoe-out".$ii action="mark-connection" new-connection-mark="pppoe-out".$ii."-pcc"] disable=no
/ip firewall mangle set [find chain="output" connection-mark="pppoe-out".$ii."-pcc" action="mark-routing" new-routing-mark="pppoe-out".$ii."-route"] disable=no
/ip firewall nat set [find chain="srcnat" out-interface="pppoe-out".$ii] disable=no
:set y ($y+1)
} else={
/ip firewall mangle set [find chain="prerouting" action="mark-connection" new-connection-mark="pppoe-out".$ii."-pcc"] disable=yes
/ip firewall mangle set [find chain="prerouting" connection-mark="pppoe-out".$ii."-pcc" action="mark-routing" new-routing-mark="pppoe-out".$ii."-route"] disable=yes
/ip firewall mangle set [find chain="input" in-interface="pppoe-out".$ii action="mark-connection" new-connection-mark="pppoe-out".$ii."-pcc"] disable=yes
/ip firewall mangle set [find chain="output" connection-mark="pppoe-out".$ii."-pcc" action="mark-routing" new-routing-mark="pppoe-out".$ii."-route"] disable=yes
/ip firewall nat set [find chain="srcnat" out-interface="pppoe-out".$ii] disable=yes
}
}
}
```