找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 3493|回复: 6

[其它] 动态ADSL 更新网关的问题!

[复制链接]
发表于 2009-7-18 16:33:32 | 显示全部楼层 |阅读模式

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

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

×
wan网接口是1条动态ADSL  每次拨号后网关有变化!! 从网上找到的自动更新网关。。 不灵!!

请教大家。。 有什么好的办法!!

网上下的脚本文件

  /interface pppoe-client
  :foreach pppoeClient in[find disable=no] do={
    :local pppoeClientName [get $pppoeClient name]
    :local pppoeInterface [get $pppoeClient interface]
    :local interfaceComment [/interface get [/interface find name=$pppoeInterface] comment]
    monitor $pppoeClientName once do={
      :local findIndex [:find $interfaceComment "-"]
      :local oldStatus ""
      :local oldIP ""
      :local ipAddress ""
      :local newIP ""
      :if (findIndex!=nothing) do={
        :set oldStatus [:pick $interfaceComment 0 $findIndex]
        :set oldIP [:pick $interfaceComment ($findIndex+1) [:len $interfaceComment]]
      } else={
        :set oldStatus $interfaceComment
      }
      :if ($status="connected") do={
        :set ipAddress [/ip address get [/ip address find interface=$pppoeClientName dynamic=yes] address]
        :set newIP [:pick $ipAddress 0 [:find $ipAddress "/"]]
      }
      :if ($status!=$oldStatus||($status="connected"&&$oldStatus="connected"&&$oldIP!=$newIP)) do={
        :if ($oldStatus="connected") do={
          /ip address remove ($pppoeClientName . "_IP_Address")
          /ip route remove ($pppoeClientName . "_Route")
        }
        :if ($status="connected") do={
          /ip address add comment=($pppoeClientName . "_IP_Address") address=$ipAddress network=$newIP broadcast=$newIP interface=$pppoeClientName disabled=no
          /ip route add comment=($pppoeClientName . "_Route") gateway=$newIP routing-mark=($pppoeClientName . "_Routing_Mark")
          /interface set [/interface find name=$pppoeInterface] comment=($status . "-" . $newIP)
        }
        :if ($status="disconnected"||$status="dialing...") do={
          /interface set [/interface find name=$pppoeInterface] comment=$status
        }
      }
    }
  }
  /interface pppoe-client
  :foreach pppoeClient in[find disable=yes] do={
    :local pppoeClientName [get $pppoeClient name]
    :local pppoeInterface [get $pppoeClient interface]
    :local interfaceComment [/interface get [/interface find name=$pppoeInterface] comment]
    :if ($interfaceComment!="")
    {
      :if ([:find $interfaceComment "connected"]!=nothing) do={
        /ip address remove ($pppoeClientName . "_IP_Address")
        /ip route remove ($pppoeClientName . "_Route")
      }
      /interface set [/interface find name=$pppoeInterface] comment=""
    }
  }
routeros
发表于 2009-7-18 17:21:06 | 显示全部楼层
routeros
回复

使用道具 举报

发表于 2009-7-18 19:52:17 | 显示全部楼层
你要动态更新干什么用呢?
routeros
回复

使用道具 举报

发表于 2009-7-18 22:55:14 | 显示全部楼层
映射
routeros
回复

使用道具 举报

发表于 2009-7-20 02:42:54 | 显示全部楼层
更新网关吧???你搞那么复杂做什么???


:global adsl "pppoe-out1"
:global new-ip [ /ip address get [/ip address find broa=0.0.0.0 int=$adsl] network ]
:global old-ip [ /ip route get [/ip route find comm="cnc"] gateway ]
:if ($new-ip != $old-ip) do={
        :log info [/ip route set [/ip route find comm="cnc"] gateway=$new-ip]
        :log info "adsl gateway ok"
       }


就搞定了。
routeros
回复

使用道具 举报

发表于 2009-7-20 15:44:03 | 显示全部楼层
一条用得着网关更新吗???
routeros
回复

使用道具 举报

发表于 2009-7-20 18:57:39 | 显示全部楼层
用interface来映射,而不用IP就行了
routeros
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-9-30 19:41 , Processed in 0.058664 second(s), 6 queries , Gzip On, Redis On.

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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