Routeros双线负载均衡自动切换
/system
script
add name=cncdown policy=\
ftp,reboot,read,write,policy,test,winbox,password,sniff
source=\
"/ip route
disable [/ip route find gateway=网通网关]"
add name=cncup
policy=ftp,reboot,read,write,policy,test,winbox,password,sniff
\
source="/ip
route enable [/ip route find gateway=网通网关]"
add name=dxdown policy=\
ftp,reboot,read,write,policy,test,winbox,password,sniff
source=\
"/ip route
set [/ip route find comment=tel] gateway=电信网关"
add name=dxup
policy=ftp,reboot,read,write,policy,test,winbox,password,sniff
\
source="/ip
route set [/ip route find comment=tel] gateway=电信网关;\
\n\
\n/ip route
set [/ip route find comment=tel] disable=no;"
/tool netwatch add host=电信网关 timeout=1s interval=5s up-script=dxup
down-script=dxdown
/tool netwatch add host=网通网关 timeout=1s interval=5s up-script=cncup
down-script=cncdown
-------------------------------------------------------------------------------------------------
#以上信息剪贴到终端即可
#更详细:
#电信或网通双线之一掉线自动切换的功能实现
#首先,需要配制netwatch检测功能,
#左侧tools->netwatch,+号,HOST添电信的网关,UP中添dxup,DOWN中添dxdown,OK,
#同样再添加网通的网关,和cncup,cncdown.
#然后添加执行的脚本文件,下面的这个是我自己用的,差点,不过能用就好..呵呵....
#注意,我是在router
list中电信0.0.0.0/0做了comment注释为tel.
#切换的原理是
#dxup 修改comment为tel的项的gateway为电信 (电信可用时默认0.0.0.0/0为电信网关)
#dxdown 修改comment为tel的项gateway为网通 (电信不可用修改0.0.0.0/0为网通)
#cncup 启用所有gateway为网通的项 (当网通可用进行路由选择~)
#cncdown 禁用所有gateway 为网通的项~ (当网通不可用走默认线路不经过选择)
---------------------------------------------------------------------------------------------------
下面是2.X的 请分开复制
-----------------------------------------------------------------------------------------------------
ROS双线负载均衡自动切换
/ system script
add name="dxup" source="/ip route set \[/ip route find
comment=tel\] gateway=电信网关;\n\n/ip route set \[/ip route find
comment=tel\] disable=no;"
policy=ftp,reboot,read,write,policy,test,winbox,password
add name="cncup" source="/ip route enable \[/ip route find
gateway=网通网关\]"
policy=ftp,reboot,read,write,policy,test,winbox,password
add name="dxdown" source="/ip route set \[/ip route find
comment=tel\] gateway=网通网关"
policy=ftp,reboot,read,write,policy,test,winbox,password
add name="cncdown" source="/ip route disable \[/ip route find
gateway=网通网关\]"
policy=ftp,reboot,read,write,policy,test,winbox,password
/tool netwatch add host=电信网关 timeout=1s interval=5s up-script=dxup
down-script=dxdown
/tool netwatch add host=网通网关 timeout=1s interval=5s up-script=cncup
down-script=cncdown
更详细:
电信或网通双线之一掉线自动切换的功能实现
首先,需要配制netwatch检测功能,
左侧tools->netwatch,+号,HOST添电信的网关,UP中添dxup,DOWN中添dxdown,OK,
同样再添加网通的网关,和cncup,cncdown.
然后添加执行的脚本文件,下面的这个是我自己用的,差点,不过能用就好..呵呵....
将红字部分添上自己的网关,注意,我是在router list中电信0.0.0.0/0做了comment注释为tel.
/ system script
add name="dxup" source="/ip route set \[/ip route find
comment=tel\] \
gateway=电信网关;
\n/ip route set \[/ip route find comment=tel\] \
disable=no;"
policy=ftp,reboot,read,write,policy,test,winbox,password
add name="cncup" source="/ip route enable \[/ip route find \
gateway=网通网关\]" \
policy=ftp,reboot,read,write,policy,test,winbox,password
add name="dxdown" source="/ip route set \[/ip route find
comment=tel\] \
gateway=网通网关" \
policy=ftp,reboot,read,write,policy,test,winbox,password
add name="cncdown" source="/ip route disable \[/ip route find
\
gateway=网通网关\]" \
policy=ftp,reboot,read,write,policy,test,winbox,password
在new terminal 中右键paste回车就可以了~~
切换的原理是
dxup 修改comment为tel的项的gateway为电信 (电信可用时默认0.0.0.0/0为电信网关)
dxdown 修改comment为tel的项gateway为网通 (电信不可用修改0.0.0.0/0为网通)
cncup 启用所有gateway为网通的项 (当网通可用进行路由选择~)
cncdown 禁用所有gateway 为网通的项~ (当网通不可用走默认线路不经过选择)
|