|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
×
下面是我使用的8线切换脚本。很不错。可惜是2.927下能用的。哪个高人能帮我改成3.30的NTH能用就好了。
:local newad
:local line [:len [/interface find running=true type="pppoe-out"]]
:local pt [/int find running=true type=pppoe-out]
:local pf [/int find running=false type=pppoe-out]
:local nt1 [:pick [/ip fir mang get [/ip fir mang find comm=con1] nth] 2 3]
:for i from=1 to=8 do={
:if ([/int get [/int fi name=("pppoe-out" . $i)] run] = yes) do={
:set newad [/ip ad get [/ip ad find dyna=true inte=("pppoe-out" . $i)] add]
:set newad [:pick $newad 0 [:find $newad "/"]]
:set oldad [/ip add get [/ip add find comment=$i] addr]
:set oldad [:pick $oldad 0 [:find $oldad "/"]]
:if ($oldad != $newad) do={
/ip ad set [/ip ad find comm=$i] addr=$newad netw=$newad broa=$newad
/ip route set [/ip route find comment=$i] gateway=$newad
/ip fire nat set [/ip fire nat find comm=$i] to-address=$newad }}}
:if (($line=8) && ($nt1 != 8)) do={
/ip fir nat set [/ip firewall nat find comment=all] disable=yes
/ip fir mangle set [/ip fir mangle find comment=con1] nth=7,8,0
/ip fir mangle set [/ip fir mangle find comment=con2] nth=7,8,1
/ip fir mangle set [/ip fir mangle find comment=con3] nth=7,8,2
/ip fir mangle set [/ip fir mangle find comment=con4] nth=7,8,3
/ip fir mangle set [/ip fir mangle find comment=con5] nth=7,8,4
/ip fir mangle set [/ip fir mangle find comment=con6] nth=7,8,5
/ip fir mangle set [/ip fir mangle find comment=con7] nth=7,8,6
/ip fir mangle set [/ip fir mangle find comment=con8] nth=7,8,7
/ip fir mangle set [/ip fir mangle find comment=con1] disable=no
/ip fir mangle set [/ip fir mangle find comment=rou1] disable=no
/ip fir mangle set [/ip fir mangle find comment=con2] disable=no
/ip fir mangle set [/ip fir mangle find comment=rou2] disable=no
/ip fir mangle set [/ip fir mangle find comment=con3] disable=no
/ip fir mangle set [/ip fir mangle find comment=rou3] disable=no
/ip fir mangle set [/ip fir mangle find comment=con4] disable=no
/ip fir mangle set [/ip fir mangle find comment=rou4] disable=no
/ip fir mangle set [/ip fir mangle find comment=con5] disable=no
/ip fir mangle set [/ip fir mangle find comment=rou5] disable=no
/ip fir mangle set [/ip fir mangle find comment=con6] disable=no
/ip fir mangle set [/ip fir mangle find comment=rou6] disable=no
/ip fir mangle set [/ip fir mangle find comment=con7] disable=no
/ip fir mangle set [/ip fir mangle find comment=rou7] disable=no
/ip fir mangle set [/ip fir mangle find comment=con8] disable=no
/ip fir mangle set [/ip fir mangle find comment=rou8] disable=no}
:if (($line=7) && ($nt1 != 7)) do={
/ip fir nat set [/ip firewall nat find comment=all] disable=yes
/ip fir mangle set [/ip fir mangle find comment=con1] nth=6,7,0
/ip fir mangle set [/ip fir mangle find comment=con2] nth=6,7,1
/ip fir mangle set [/ip fir mangle find comment=con3] nth=6,7,2
/ip fir mangle set [/ip fir mangle find comment=con4] nth=6,7,3
/ip fir mangle set [/ip fir mangle find comment=con5] nth=6,7,4
/ip fir mangle set [/ip fir mangle find comment=con6] nth=6,7,5
/ip fir mangle set [/ip fir mangle find comment=con7] nth=6,7,6
/ip fir mangle set [/ip fir mangle find comment=con1] disable=no
/ip fir mangle set [/ip fir mangle find comment=rou1] disable=no
/ip fir mangle set [/ip fir mangle find comment=con2] disable=no
/ip fir mangle set [/ip fir mangle find comment=rou2] disable=no
/ip fir mangle set [/ip fir mangle find comment=con3] disable=no
/ip fir mangle set [/ip fir mangle find comment=rou3] disable=no
/ip fir mangle set [/ip fir mangle find comment=con4] disable=no
/ip fir mangle set [/ip fir mangle find comment=rou4] disable=no
/ip fir mangle set [/ip fir mangle find comment=con5] disable=no
/ip fir mangle set [/ip fir mangle find comment=rou5] disable=no
/ip fir mangle set [/ip fir mangle find comment=con6] disable=no
/ip fir mangle set [/ip fir mangle find comment=rou6] disable=no
/ip fir mangle set [/ip fir mangle find comment=con7] disable=no
/ip fir mangle set [/ip fir mangle find comment=rou7] disable=no
/ip fir mangle set [/ip fir mangle find comment=con8] disable=yes
/ip fir mangle set [/ip fir mangle find comment=rou8] disable=yes}
:if (($line=6) && ($nt1 != 6)) do={
/ip fir nat set [/ip firewall nat find comment=all] disable=yes
/ip fir mangle set [/ip fir mangle find comment=con1] nth=5,6,0
/ip fir mangle set [/ip fir mangle find comment=con2] nth=5,6,1
/ip fir mangle set [/ip fir mangle find comment=con3] nth=5,6,2
/ip fir mangle set [/ip fir mangle find comment=con4] nth=5,6,3
/ip fir mangle set [/ip fir mangle find comment=con5] nth=5,6,4
/ip fir mangle set [/ip fir mangle find comment=con6] nth=5,6,5
/ip fir mangle set [/ip fir mangle find comment=con1] disable=no
/ip fir mangle set [/ip fir mangle find comment=rou1] disable=no
/ip fir mangle set [/ip fir mangle find comment=con2] disable=no
/ip fir mangle set [/ip fir mangle find comment=rou2] disable=no
/ip fir mangle set [/ip fir mangle find comment=con3] disable=no
/ip fir mangle set [/ip fir mangle find comment=rou3] disable=no
/ip fir mangle set [/ip fir mangle find comment=con4] disable=no
/ip fir mangle set [/ip fir mangle find comment=rou4] disable=no
/ip fir mangle set [/ip fir mangle find comment=con5] disable=no
/ip fir mangle set [/ip fir mangle find comment=rou5] disable=no
/ip fir mangle set [/ip fir mangle find comment=con6] disable=no
/ip fir mangle set [/ip fir mangle find comment=rou6] disable=no
/ip fir mangle set [/ip fir mangle find comment=con7] disable=yes
/ip fir mangle set [/ip fir mangle find comment=rou7] disable=yes
/ip fir mangle set [/ip fir mangle find comment=con8] disable=yes
/ip fir mangle set [/ip fir mangle find comment=rou8] disable=yes}
:if (($line=5) && ($nt1 != 5)) do={
/ip fir nat set [/ip firewall nat find comment=all] disable=yes
/ip fir mangle set [/ip fir mangle find comment=con1] nth=4,5,0
/ip fir mangle set [/ip fir mangle find comment=con2] nth=4,5,1
/ip fir mangle set [/ip fir mangle find comment=con3] nth=4,5,2
/ip fir mangle set [/ip fir mangle find comment=con4] nth=4,5,3
/ip fir mangle set [/ip fir mangle find comment=con5] nth=4,5,4
/ip fir mangle set [/ip fir mangle find comment=con1] disable=no
/ip fir mangle set [/ip fir mangle find comment=rou1] disable=no
/ip fir mangle set [/ip fir mangle find comment=con2] disable=no
/ip fir mangle set [/ip fir mangle find comment=rou2] disable=no
/ip fir mangle set [/ip fir mangle find comment=con3] disable=no
/ip fir mangle set [/ip fir mangle find comment=rou3] disable=no
/ip fir mangle set [/ip fir mangle find comment=con4] disable=no
/ip fir mangle set [/ip fir mangle find comment=rou4] disable=no
/ip fir mangle set [/ip fir mangle find comment=con5] disable=no
/ip fir mangle set [/ip fir mangle find comment=rou5] disable=no
/ip fir mangle set [/ip fir mangle find comment=con6] disable=yes
/ip fir mangle set [/ip fir mangle find comment=rou6] disable=yes
/ip fir mangle set [/ip fir mangle find comment=con7] disable=yes
/ip fir mangle set [/ip fir mangle find comment=rou7] disable=yes
/ip fir mangle set [/ip fir mangle find comment=con8] disable=yes
/ip fir mangle set [/ip fir mangle find comment=rou8] disable=yes}
:if (($line=4) && ($nt1 != 4)) do={
/ip fir nat set [/ip firewall nat find comment=all] disable=yes
/ip fir mangle set [/ip fir mangle find comment=con1] nth=3,4,0
/ip fir mangle set [/ip fir mangle find comment=con2] nth=3,4,1
/ip fir mangle set [/ip fir mangle find comment=con3] nth=3,4,2
/ip fir mangle set [/ip fir mangle find comment=con4] nth=3,4,3
/ip fir mangle set [/ip fir mangle find comment=con1] disable=no
/ip fir mangle set [/ip fir mangle find comment=rou1] disable=no
/ip fir mangle set [/ip fir mangle find comment=con2] disable=no
/ip fir mangle set [/ip fir mangle find comment=rou2] disable=no
/ip fir mangle set [/ip fir mangle find comment=con3] disable=no
/ip fir mangle set [/ip fir mangle find comment=rou3] disable=no
/ip fir mangle set [/ip fir mangle find comment=con4] disable=no
/ip fir mangle set [/ip fir mangle find comment=rou4] disable=no
/ip fir mangle set [/ip fir mangle find comment=con5] disable=yes
/ip fir mangle set [/ip fir mangle find comment=rou5] disable=yes
/ip fir mangle set [/ip fir mangle find comment=con6] disable=yes
/ip fir mangle set [/ip fir mangle find comment=rou6] disable=yes
/ip fir mangle set [/ip fir mangle find comment=con7] disable=yes
/ip fir mangle set [/ip fir mangle find comment=rou7] disable=yes
/ip fir mangle set [/ip fir mangle find comment=con8] disable=yes
/ip fir mangle set [/ip fir mangle find comment=rou8] disable=yes}
:if (($line=3) && ($nt1 != 3)) do={
/ip fir nat set [/ip firewall nat find comment=all] disable=yes
/ip fir mangle set [/ip fir mangle find comment=con1] nth=2,3,0
/ip fir mangle set [/ip fir mangle find comment=con2] nth=2,3,1
/ip fir mangle set [/ip fir mangle find comment=con3] nth=2,3,2
/ip fir mangle set [/ip fir mangle find comment=con1] disable=no
/ip fir mangle set [/ip fir mangle find comment=rou1] disable=no
/ip fir mangle set [/ip fir mangle find comment=con2] disable=no
/ip fir mangle set [/ip fir mangle find comment=rou2] disable=no
/ip fir mangle set [/ip fir mangle find comment=con3] disable=no
/ip fir mangle set [/ip fir mangle find comment=rou3] disable=no
/ip fir mangle set [/ip fir mangle find comment=con4] disable=yes
/ip fir mangle set [/ip fir mangle find comment=rou4] disable=yes
/ip fir mangle set [/ip fir mangle find comment=con5] disable=yes
/ip fir mangle set [/ip fir mangle find comment=rou5] disable=yes
/ip fir mangle set [/ip fir mangle find comment=con6] disable=yes
/ip fir mangle set [/ip fir mangle find comment=rou6] disable=yes
/ip fir mangle set [/ip fir mangle find comment=con7] disable=yes
/ip fir mangle set [/ip fir mangle find comment=rou7] disable=yes
/ip fir mangle set [/ip fir mangle find comment=con8] disable=yes
/ip fir mangle set [/ip fir mangle find comment=rou8] disable=yes}
:if ($line=2) do={
/ip fir nat set [/ip firewall nat find comment=all] disable=yes
:if ($nt1 != 2) do={
/ip fir mangle set [/ip fir mangle find comment=con1] nth="1,2,0"
/ip fir mangle set [/ip fir mangle find comment=con2] nth="1,2,1"
/ip fir mangle set [/ip fir mangle find comment=con1] disable=no
/ip fir mangle set [/ip fir mangle find comment=rou1] disable=no
/ip fir mangle set [/ip fir mangle find comment=con2] disable=no
/ip fir mangle set [/ip fir mangle find comment=rou2] disable=no
/ip fir mangle set [/ip fir mangle find comment=con3] disable=yes
/ip fir mangle set [/ip fir mangle find comment=rou3] disable=yes
/ip fir mangle set [/ip fir mangle find comment=con4] disable=yes
/ip fir mangle set [/ip fir mangle find comment=rou4] disable=yes
/ip fir mangle set [/ip fir mangle find comment=con5] disable=yes
/ip fir mangle set [/ip fir mangle find comment=rou5] disable=yes
/ip fir mangle set [/ip fir mangle find comment=con6] disable=yes
/ip fir mangle set [/ip fir mangle find comment=rou6] disable=yes
/ip fir mangle set [/ip fir mangle find comment=con7] disable=yes
/ip fir mangle set [/ip fir mangle find comment=rou7] disable=yes
/ip fir mangle set [/ip fir mangle find comment=con8] disable=yes
/ip fir mangle set [/ip fir mangle find comment=rou8] disable=yes }}
:if ($line=1) do={
/ip firewall nat set [/ip firewall nat find comment=all] disable=no
:for i from=1 to=8 do={
/ip fir nat set [/ip fir nat find comment=$i] disable=yes
/ip rou set [/ip rou find comment=$i] disable=yes
/ip rou unset [/ip rou find comment=$i] routing-mark }}
:local disx [:len [/ip rou find disable=true]]
:local aa [/ip rou get [/ip rou find comm=1] routing-m]
:local bb [/ip rou get [/ip rou find comm=2] routing-m]
:local cc [/ip rou get [/ip rou find comm=3] routing-m]
:local dd [/ip rou get [/ip rou find comm=4] routing-m]
:local ee [/ip rou get [/ip rou find comm=5] routing-m]
:local ff [/ip rou get [/ip rou find comm=6] routing-m]
:local gg [/ip rou get [/ip rou find comm=7] routing-m]
:local hh [/ip rou get [/ip rou find comm=8] routing-m]
:set aa [:len ($aa . $bb . $cc . $dd . $ee . $ff . $gg . $hh)]
:if (($line>=2)&&(($disx !=(8-$line)||($aa != ($line*2))))) do={
:for i from=1 to=$line do={
/ip fir nat set [/ip fir nat find comment=[/int get [:pick $pt ($i -1) $i] comment]] disable=no
/ip fir nat set [/ip fir nat find comment=[/int get [:pick $pt ($i -1) $i] comment]] connection-mark=("c" . $i)
/ip rou set [/ip rou find comment=[/int get [:pick $pt ($i -1) $i] comment]] disable=no
/ip rou set [/ip rou find comment=[/int get [:pick $pt ($i -1) $i] comme]] routing-mark=("r" . $i) }}
:if ($line>=2) do={
:for i from=1 to=(8-$line) do={
/ip fir nat set [/ip fir nat find comment=[/int get [:pick $pf ($i -1) $i] comment]] disable=yes
/ip fir nat unset [/ip fir nat find comment=[/int get [:pick $pf ($i -1) $i] comment]] connection-mark
/ip rou set [/ip rou find comment=[/int get [:pick $pf ($i -1) $i] comment]] disable=yes
/ip rou unset [/ip rou find comment=[/int get [:pick $pf ($i -1) $i] comment]] routing-mark }}
:delay 2s
:if ([/ip rou get [/ip rou find comm=9] active] != true) do={
:set newad [/ip add get [/int get [/int find runn=true type=pppoe-out] comm] netw]
/ip route set [/ip route find comment=9] gateway=$newad } |
|