找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 45|回复: 0

[脚本] 请大神们帮忙修改一下脚本。谢谢!

[复制链接]
10 铜板 回复本帖可获得 10 铜板奖励! 每人限 1 次
发表于 前天 17:17 | 显示全部楼层 |阅读模式

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

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

×
以下rosv7版本 这个脚本多线路,只有路由表 打开或者关闭 出现不可用。没有反应。其他功能都正常。

请大神们帮忙修改一下。谢谢!

:local pccstatus
:local status
:local pccold
:local pccnew
:local link
:local ncm
:local nrm
:local y
:local z
:local x
:set x 4
#这里是adsl的数量
:set link 0
:for i from=1 to="$x" do={
    :set status [/interface get [/interface find  name=("PPPOE-ADSL-" . "$i")] running]
    :if ("$status" = true) do={
    :set link ($link + 1)
  }
}
:if ("$link" > 0) do={
    :set z "$link"
    :set y 0
    :for i from=1 to="$x" do={
         :set status [/interface get [/interface find  name=("PPPOE-ADSL-" . "$i")] running]
         :set ncm ("PCC_" . "$i")
#这里是连接标记
         :set nrm ("PCC_ROUT-" . "$i")
#这里是路由标记
         :if ("$status" = true) do={
                    :set pccnew ("both-addresses-and-ports" . ":" . "$z" . "/" . "$y")
                    :set pccold [/ip firewall mangle get [ /ip firewall mangle find chain=prerouting new-connection-mark="$ncm"] per-connection-classifier]
                    :set pccstatus [/ip firewall mangle get [/ip firewall mangle find chain=prerouting new-connection-mark="$ncm"] disable]
                    :if (("$pccnew" != $pccold) || ("$pccstatus" = true)) do={
                          /ip firewall mangle set [ /ip firewall mangle find chain=prerouting new-connection-mark="$ncm"] per-connection-classifier=$pccnew disabled=no
                          /ip firewall mangle set [ /ip firewall mangle find chain=prerouting new-routing-mark="$nrm"] disabled=no
                          /ip firewall mangle set [ /ip firewall mangle find chain=input new-connection-mark="$ncm"] per-connection-classifier=$pccnew disabled=no
                          /ip firewall mangle set [ /ip firewall mangle find chain=output new-routing-mark="$nrm"] disabled=no
                          /ip firewall nat set [/ip firewall nat find action=src-nat chain=srcnat out-interface="PPPOE-ADSL-" . "$i"] disabled=no
                          /ip route set [/ip route find dst-address="0.0.0.0/0" gateway="PPPOE-ADSL-" . "$i" routing-mark="$nrm"] disabled=no
                          /ip route set [/ip route find dst-address="0.0.0.0/0" gateway="PPPOE-ADSL-" . "$i" distance="$i"] disabled=no
                      }
             :set y ($y + 1)
          } else {
                  :set pccstatus [/ip firewall mangle get [/ip firewall mangle find chain=prerouting new-connection-mark="$ncm"] disable]
                  :if ("$pccstatus" = false) do={
                         /ip firewall mangle disable [ /ip firewall mangle find chain=prerouting new-connection-mark="$ncm"]
                         /ip firewall mangle disable [/ip firewall mangle find chain=prerouting new-routing-mark="$nrm"]
                         /ip firewall mangle disable [ /ip firewall mangle find chain=input new-connection-mark="$ncm"]
                         /ip firewall mangle disable [/ip firewall mangle find chain=output new-routing-mark="$nrm"]
                         /ip firewall nat disable [/ip firewall nat find action=src-nat chain=srcnat out-interface="PPPOE-ADSL-" . "$i"]
                         /ip route disable [/ip route find dst-address="0.0.0.0/0" gateway="PPPOE-ADSL-" . "$i" routing-mark="$nrm"]
                         /ip route disable [/ip route find dst-address="0.0.0.0/0" gateway="PPPOE-ADSL-" . "$i" distance="$i"]
             }
        }
    }
  }
}

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

本版积分规则

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

GMT+8, 2025-8-2 17:53 , Processed in 0.129557 second(s), 15 queries , Gzip On, Redis On.

Powered by Discuz! X3.5 Licensed

© 2001-2025 Discuz! Team.

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