分类

ROS软路由

ADSL在网吧的应用(ADSL动态网关脚本和光纤零点自动切换)

ADSL在网吧的应用(ADSL动态网关脚本和光纤零点自动切换)

大小:202 KB

语言:简体中文系统:Win2003, WinXP, Win2000, NT, WinME

类别:ROS软路由时间:2009-06-19

因为在当地的ADSL是动态网关,而且光纤每天早上到凌晨12点断线,所以配合一条家用的ADSL线路来通宵营运,我简单设计了一个方案,每15秒自动检查一次ADSL网关是否与路由表里的符合,做了一个NETWATCH监控光纤线路是否掉线,如果掉线了就切换成ADSL的网关.

有不足的地方希望网友们斧正,仅此抛砖引玉.

动态网关脚本:


:global adsl "ADSL连接的名字"
: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="adsl"] gateway ]
:if ($new-ip != $old-ip) do={
      :log info [/ip route set [/ip route find comm="adsl"] gateway=$new-ip]
      :log info "〖ADSL网关修改完毕〗"
  }

cableup脚本:
/ip route set [/ip route find comm="cable"] disable=no
/ip route set [/ip route find comm="adsl"] disable=yes

cabledown脚本:
/ip route set [/ip route find comm="cable"] disable=yes
/ip route set [/ip route find comm="adsl"] disable=no

以上标记的红字均可根据你的实际情况进行替换.

光纤和ADSL实现线路切换的原理是,当光纤掉线以后,自动禁用光纤的路由,激活ADSL路由(动态网关脚本会15秒自动检测).当光纤恢复以后,则规则反之执行.

∨ 展开

网友评论

我要跟帖
取消
所有评论 共 0