多线ADSL自动更新IP脚本

应该是叫这个名字吧,反正一直用着运行正常.这里提供的是3线ADSL脚本,如果你的是两线或3线以上的环境,请将数字3更改为你的线路数,VM-ROS 2.9.27环境运行正常.

脚本如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
:local assign-address
:local new-address
:local status
:local x
:set x 3
:for i from=1 to=$x do={
:set status [/interface get [/interface find name=("pppoe-out" . $i)] running]
:if ($status=true) do={
:set new-address [/ip address get [/ip address find dynamic=yes interface=("pppoe-out" . $i)] address]
:set new-address [:pick $new-address 0 ([:len $new-address] -3)]
:set assign-address [/ip address get [/ip address find dynamic=no interface=("pppoe-out" . $i)] address]
:set assign-address [:pick $assign-address 0 ([:len $assign-address] -3)]
:if ($assign-address != $new-address) do={ /ip address set [/ip address find comment=$i] address=$new-address network=$new-address broadcast=$new-address
/ip route set [/ip route find comment=$i] gateway=$new-address
/ip firewall nat set [/ip firewall nat find comment=$i] to-addresses=$new-address
/ip route set [/ip route find comment=$i] gateway=$new-address
}
}
}