注册 登录
自由的生活_软路由 返回首页

javaobc的个人空间 https://bbs.routerclub.com/?42037 [收藏] [复制] [分享] [RSS]

日志

PCC掉线切换修改版

已有 787 次阅读2011-2-28 21:34

:local pccstatus
:local status
:local pccold
:local pccnew
:local link
:local ncm
:local nrm
:local y
:local z
:local x
:set x 4
:set link 0
:for i from=1 to="$x" do={
    :set status [/interface get [/interface find  name=("pppoe-out" . "$i")] running]
    :if ("$status" = true) do={
    :set link ($link + 1)
  }
}
:if ("$link" > 1) do={
    :set z "$link"
    :set y 0
    :for i from=1 to="$x" do={
         :set status [/interface get [/interface find  name=("pppoe-out" . "$i")] running]
         :set ncm ("adsl" . "$i" . "conn")
         :set nrm ("ADSL" . "$i")
         :if ("$status" = true) do={
                    :set pccnew ("both-addresses" . ":" . "$z" . "/" . "$y")
                    :set pccold [/ip firewall mangle get [ /ip firewall mangle find chain=bonding new-connection-mark="$ncm"] per-connection-classifier]
                    :set pccstatus [/ip firewall mangle get [/ip firewall mangle find chain=bonding new-connection-mark="$ncm"] disable]
                    :if (("$pccnew" != $pccold) || ("$pccstatus" = true)) do={
                          /ip firewall mangle set [ /ip firewall mangle find chain=bonding new-connection-mark="$ncm"] per-connection-classifier=$pccnew disabled=no
                          /ip firewall mangle set [ /ip firewall mangle find chain=bonding new-routing-mark="$nrm"] disabled=no
                      }
             :set y ($y + 1)
          } else {
                  :set pccstatus [/ip firewall mangle get [/ip firewall mangle find chain=bonding new-connection-mark="$ncm"] disable]
                  :if ("$pccstatus" = false) do={
                         /ip firewall mangle disable [ /ip firewall mangle find chain=bonding new-connection-mark="$ncm"]
                         /ip firewall mangle disable [/ip firewall mangle find chain=bonding new-routing-mark="$nrm"]
             }
        }
    }
  }
}

路过

雷人

握手

鲜花

鸡蛋

评论 (0 个评论)

facelist doodle 涂鸦板

您需要登录后才可以评论 登录 | 注册

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

GMT+8, 2024-11-6 00:24 , Processed in 0.038587 second(s), 5 queries , Gzip On, Redis On.

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

返回顶部