|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
×
#local ip addess list
local1 192.168.1.0/27
local2 192.168.1.44/27
local3 192.168.1.100/27
#wan ip
wan1 222.222.1.1
wan2 222.222.2.1
wan3 222.222.3.1
/ip route
dst:0.0.0.0/0 gw:222.222.1.1 route mark:wan1
dst:0.0.0.0/0 gw:222.222.2.1 route mark:wan2
dst:0.0.0.0/0 gw:222.222.3.1 route mark:wan3
/ip fir man
添加源以地址列表为local1的路由标记为wan1
依次类推为wan2,wan3
添加源以地址列表为local1的连接标记为local1
依次类推为local2,local3
添加以连接标记为local1的包标记wan1
依次类推为wan2 wan3
src address: local1 local2 local3
route mark: wan1 wan2 wan3 可变 多WAN分流与线路互相备份
conn mark: local1 local2 local3 固定 线路切换后清空原有连接
pack mark: wan1 wan2 wan3 可变 其于三个WAN口限速
#scripts
===========autorun==============
开机运行变量声明及复位所有开关
:global wan3 15.12.11.1
:global src3 15.12.11.2
:global wan2 255.0.0.11
:global src2 255.0.0.11
:global wan1 255.0.0.11
:global src1 255.0.0.11
:global chk1 none
:global chk2 none
:global chk3 none
:global ppp1 none
:global ppp2 none
:global tmpa none
:global tmpb none
:global tmpc none
/tool netwatch disable wan1,wan2
/tool traffic!!!!!!!!!!!这个没试能不能在脚本下复位
/tool netwatch set wan3 host=$wan3 disabled=no
/system scheduler enable wan1stat,wan2stat,wan3stat
==========wan1up===============
-----------关闭WAN1线路检查任务
/system scheduler disabled wan1stat
-----------检查local1暂时依附在那个WAN口!!!!!!!!!检查完后应首先判断是不是local1在默认口上:if ($chk1!=wan1) do={
:set chk1 [/ip firewall mangle get local1 new-packet-mark]
-----------检查local1暂时依附端口是否启用了限速!!!!!!!!!!!!!!!!这个有问题,实现不了
:if ([/tool traffic-monitor get $chk1 disabled]!=true) do={
-----------如果限速就删除local1连接,准备将线路切换回来
/ip firewall mangle remove [/ip firewall connection find connection-mark=local1]
-----------如果限速就更新WAN1路由标记
/ip firewall mangle set local1-route new-routing-mark=wan1
-----------如果限速就更新WAN1包标记
/ip firewall mangle set local1 new-packet-mark=wan1
} else={
-----------没限就延时一分钟并激活线路检查,调节运行间隔,避免多次掉线
:delay 60
/system scheduler enable wan1stat}
===============================
===========wan1down============
-----------检查可用线路并记录在变量chk1里
:set chk1 wan2
:if ([/tool netwatch get wan3 status]!=up) do={
:if ([/tool netwatch get wan1 status]=up) do={
:set chk1 wan3} else={
-----------若全掉了就不改,并关闭线路监视;脚本最后会打开线路状态wan1stat来激活的,人工调节间隔算
:set chk1 wan1
/tool netwatch disable wan1}
}
-----------检查依附在WAN1的连接并删除
:for sw from=1 to=3 step=1 do={
:if ([/ip firewall mangle get (local . $sw) new-packet-mark]=wan1) do={
/ip firewall connection remove [/ip firewall connection find connection-mark=(local . $sw)]}
}
-----------更改所有走wan1的路由标记
/ip firewall mangle set [/ip firewall mangle find action=mark-routing new-routing-mark=wan1] new-routing-mark=$chk1
-----------更改所有走wan1的包标记方便针对WAN口限速
/ip firewall mangle set [/ip firewall mangle find action=mark-packet new-packet-mark=wan1] new-packet-mark=$chk1
-----------开启WAN1线路检查任务
/system scheduler enable wan1stat
===============================
==========wan1stat=============PPPOE
/interface pppoe-client monitor pppoe-out1 once do={:set ppp1 $status}
:if ($ppp1="connected") do={
:set wan1 [/ip address get [/ip address find interface=pppoe-out1] network]
:set src1 [/ip route get [/ip route find dst-address=$wan1] pref-src]
/ip route set wan1 gateway=$wan1
/ip firewall nat set wan1 to-addresses=$src1
/tool netwatch set wan1 host=$wan1 disabled=no
} else={
:delay 10
/tool netwatch enable wan1}
===============================
/queue
简单队列或空闲队列都可以针对包标记来限速,当不同WAN达到上限开启,避免限制用其它WAN口的IP |
|