RouterOS 2.9.27 ADSL带宽叠加(负载均衡)断线自动切换脚本RouterOS 2.9.27 ADSL带宽叠加(负载均衡)断线自动切换脚本
:global NewIp
:global OldIp
:global Count
:global IsRun
:global Runid
:global Icount
:global Status
:global RuningCount
:global NewNthCache
:global OldNthCache
:set Runid ("a","a")
:set Count 9
:set Icount 1
:set ...
RouterOS 2.9.27 ADSL带宽叠加(负载均衡)断线自动切换脚本
:global NewIp
:global OldIp
:global Count
:global IsRun
:global Runid
:global Icount
:global Status
:global RuningCount
:global NewNthCache
:global OldNthCache
:set Runid ("a","a")
:set Count 9
:set Icount 1
:set RuningCount 0
:for i from=1 to=$Count do={
:set Status [/int get [/int find name=("pppoe-out" . $i)] running] :set IsRun [/ip fir man get [/ip fir man find comment=("route-" . $i)] disabled] :if ($Status = true) do={
:set NewIp [/ip address get [/ip address find dynamic=yes interface=("pppoe-out" . $i)] address]
:set NewIp [:pick $NewIp 0 [:find $NewIp "/"]]
:set OldIp [/ip address get [/ip address find dynamic=no interface=("pppoe-out" . $i)] address]
:set OldIp [:pick $OldIp 0 [:find $OldIp "/"]]
:set RuningCount ($RuningCount + 1)
:set Runid ($Runid + $i)
:if ($OldIp != $NewIp) do={
/ip address set [/ip address find comment=("adsl-" . $i)] address=$NewIp network=$NewIp broadcast=$NewIp
/ip route set [/ip route find comment=("adsl-" . $i)] gateway=$NewIp /ip fir nat set [/ip fir nat find comment=("adsl-" . $i)] to-addresses=$NewIp }
:if ($IsRun = true) do={
/ip fir man set [/ip fir man find comment=("route-" . $i)] disabled=no /ip fir man set [/ip fir man find comment=("conn-" . $i)] disabled=no /ip fir nat set [/ip fir nat find comment=("adsl-" . $i)] disabled=no /ip rou set [/ip rou find comment=("adsl-" . $i)] disabled=no :log info ( "第<" . $i . ">号网络线路故障恢复,分流开启~" . [/sys cl get date] .
" " . [/sys cl get time] . "检测")
}
} else={
:if ($IsRun != true) do={
/ip fir man set [/ip fir man find comment=("route-" . $i)] disabled=yes /ip fir man set [/ip fir man find comment=("conn-" . $i)] disabled=yes
/ip fir nat set [/ip fir nat find comment=("adsl-" . $i)] disabled=yes /ip rou set [/ip rou find comment=("adsl-" . $i)] disabled=yes :log info ( "第<" . $i . ">号网络线路出现故障,分流关闭~" . [/sys cl get date] . " " . [/sys cl get time] . "检测")
}
}
}
:foreach x in=$Runid do={
:if ($x != "a") do={
:set OldNthCache [/ip fir man get [/ip fir man find comment=("conn-" . $x)] nth]
:set NewNthCache ($RuningCount . "," . $Icount)
:if ($OldNthCache != $NewNthCache) do={
/ip fir man set [/ip fir man find comment=("conn-" . $x)] nth=$NewNthCache :log info ( "第<" . $x . ">号网络线路修改分流设置成功~" . [/sys cl get date] . " " . [/sys cl get time] . "检测")
}
:set Icount ($Icount + 1)
}
:if ($Mainid != $i) do={
:if ($MainKey != true) do={
:set MainKey false
}
} else={
:set MainKey true
}
}
:if ($MainKey != true) do={
:set MainCache [:pick $Runid 2 3]
:set NewIP [/ip address get [/ip address find dynamic=yes interface=("pppoe-out" .
$MainCache)] address]
:set NewIP [:pick $NewIP 0 [:find $NewIP "/"]]
:if ($Mainip != $NewIP) do={
:log info ( "默认网关检测失败,默认网关转换成<" . $MainCache . ">号线路" .
[/sys cl get date] . " " . [/sys cl get time] . "检测")
/ip rou set [/ip route find distance=1] comment = $MainCache
/ip rou set [/ip rou find comment=$MainCache] gateway=$NewIP
}
} else={
:set NewIP [/ip address get [/ip address find dynamic=yes interface=("pppoe-out" .
$Mainid)] address]
:set NewIP [:pick $NewIP 0 [:find $NewIP "/"]]
:if ($Mainip != $NewIP) do={
/ip rou set [/ip route find distance=1] comment = $Mainid
/ip rou set [/ip rou find comment=$Mainid] gateway=$NewIP
}
}
本文档为【RouterOS 2.9.27 ADSL带宽叠加(负载均衡)断线自动切换脚本】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑,
图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。