ROS软路由论坛 ROSABC.com 网络方案网络工程交流

 找回密码
 会员注册

QQ登录

只需一步,快速开始

查看: 11101|回复: 2

[交流] RouteROS软路由 动态ADSL脚本(相同网关和不同网关)

[复制链接]
发表于 2009-9-17 21:22:29 | 显示全部楼层 |阅读模式

马上注册成为ROSABC会员,随时发帖回复。

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

x
### 相同网关,动态IP
:global newaddress
:global assignip
:global status
:local x
:set x 2
:for i from=1 to=$x do={
:set status [/interface get [/interface find name=("pppoe-out" . $i)] running]
:if ($status=true) do={
:set newaddress [/ip address get [/ip address find dynamic=yes interface=("pppoe-out" . $i)] address]
:set newaddress [:pick $newaddress 0 ([:len $newaddress] -3)]
:set assignip [/ip address get [/ip address find dynamic=no interface=("pppoe-out" . $i)] address]
:set assignip [:pick $assignip 0 ([:len $assignip] -3)]
:if ($assignip != $newaddress) do={
/ip address set [/ip address find comment=$i] address=$newaddress network=$newaddress broadcast=$newaddress
/ip route set [/ip route find comment=$i] gateway=$newaddress
/ip fir nat set [/ip fir nat find comment=$i] to-addresses=$newaddress
/ip route set [/ip route find comment=$i] gateway=$newaddress
}
}
}


### 网关不同,但动态变化
:local newaddress :local assignip
:local status :local x :set x 2
:for i from=1 to=$x do={
:set status [/interface get [/interface find name=("pppoe-out" . $i)] running]
:if ($status=true) do={
:set newaddress [/ip address get [/ip address find dynamic=yes interface=("pppoe-out" . $i)] network]
:set assignip [/ip route get [/ip route find comment="$i" interface=("pppoe-out" . $i)] gateway]
:if ($assignip != $newaddress) do={
/ip route set [/ip route find comment=$i] gateway=$newaddress
/ip route set [/ip route find comment=$i] gateway=$newaddress
}
}
}
发表于 2009-9-20 20:29:01 | 显示全部楼层
请问管理员是不是用于2.X的版本????????
发表于 2009-9-26 10:39:19 | 显示全部楼层
请问管理员是不是用于3.X的版本????????
您需要登录后才可以回帖 登录 | 会员注册

本版积分规则

不良信息举报Q:2000617

软路由

不良信息举报Q:2000617|Archiver|ROS软路由论坛 ROSABC.com 网络方案网络工程交流

GMT+8, 2025-8-5 17:08 , Processed in 0.058432 second(s), 19 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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