找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 4001|回复: 11

[脚本] 我使用的8线切换脚本

  [复制链接]
发表于 2011-4-20 01:31:48 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

×
下面是我使用的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  }
routeros
发表于 2011-4-20 01:53:39 | 显示全部楼层
呵呵这脚本够强的
routeros
回复

使用道具 举报

 楼主| 发表于 2011-4-20 02:13:25 | 显示全部楼层
怎么改能改成3.3可以用啊。
routeros
回复

使用道具 举报

发表于 2011-4-20 09:41:32 | 显示全部楼层
看起来怎么这么复杂,不过还是顶你。3。30可以用么?
routeros
回复

使用道具 举报

发表于 2011-4-20 09:41:59 | 显示全部楼层
够强都没看到给加分
routeros
回复

使用道具 举报

发表于 2011-4-20 12:24:14 | 显示全部楼层
好长啊,哈哈,强悍
routeros
回复

使用道具 举报

发表于 2011-4-20 12:42:43 | 显示全部楼层
最笨的写法
routeros
回复

使用道具 举报

发表于 2011-4-20 20:52:19 | 显示全部楼层
这不叫脚本吧?
routeros
回复

使用道具 举报

发表于 2011-4-21 12:32:56 | 显示全部楼层
本帖最后由 9939781 于 2011-4-21 12:33 编辑

我靠,这么长,看都把人看死了。
http://www.cat-home.org/?action=show&id=26
你直接去下我的免费版生成器得了。
routeros
回复

使用道具 举报

发表于 2011-4-25 01:14:54 | 显示全部楼层
好长的脚本……
routeros
回复

使用道具 举报

发表于 2011-4-25 09:04:30 | 显示全部楼层
很好。可惜没真实环境调试。呵呵
routeros
回复

使用道具 举报

发表于 2011-4-26 10:22:47 | 显示全部楼层
这脚本没什么用处,只耗cpu
routeros
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|手机版|小黑屋|软路由 ( 渝ICP备15001194号-1|渝公网安备 50011602500124号 )

GMT+8, 2024-11-22 01:47 , Processed in 0.072294 second(s), 4 queries , Gzip On, Redis On.

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表