|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
×
我从网上找来的双ADSL分流,然后自己做做
双ADSL,lan,wan1,wan2,设好后,上不了网,如果将pppoe-out1设为默认路由就可以上,应该是/ip 路由 出问题了;
/ip 路由中,IP不会动态刷新,但检查脚本好像没有问题,请大家帮找找是哪里出错了
建立PPP拨号,把其中一条拨号名命名为wan1,另一个命明为wan2,并把内网网卡命名为lan,然后等待拨号成功
拨号成功后,PPPOE会自动添加IP地址和网关,找到地址和网关,复制下来
把192.168.1.1-192.168.1.120替换成你需要分流到wan1的第一个网段,把192.168.1.121-192.168.1.240替换成你需要分流到wan22的第二个网段
之后慢慢添脚本,添完成功后,把拨号的Add Default Route的勾去掉,看分流是否可以正常工作!
下面是在/IP add 下看到的地址
ADSL1ip=10.64.64.84
ADSL1网关=10.112.112.132
ADSL2ip=218.18.194.24
ADLS2网关=202.104.97.1
1.普通脚本设置
/ ip route
add dst-address=0.0.0.0/0 gateway=10.112.112.132 scope=255 target-scope=10 comment="3" disabled=yes
/ ip firewall nat
add chain=srcnat action=masquerade comment="" disabled=no
/ ip firewall mangle
add chain=prerouting src-address=192.168.1.1-192.168.1.120 action=mark-routing new-routing-mark=1 passthrough=yes \
comment="1" disabled=no
add chain=prerouting src-address=192.168.1.121-192.168.1.240 action=mark-routing new-routing-mark=2 passthrough=yes \
comment="2" disabled=no
/ ip address
add address=10.64.64.84 interface=wan1 comment="1" disabled=no
add address=218.18.194.24 interface=wan2 comment="2" disabled=no
/ ip route
add dst-address=10.64.64.84 gateway=10.112.112.132 routing-mark=1 comment="1"
add dst-address=218.18.194.24 gateway=202.104.97.1 routing-mark=2 comment="2"
3.同步ADSL动态IP,网关脚本:
位置winbox-system-script 点“+ ”号,改name为sync,然后复制下面的脚本到source里
: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 [:find $new-address "/"]]
:set assign-address [/ip address get [/ip address find dynamic=no interface=("pppoe-out" . $i)] address]
:set assign-address [:pick $assign-address 0 [:find $assign-address "/"]]
:if ($assign-address != $new-address) do={
/ip address set [/ip address find comment=("wan" . $i)] address=$new-address network=$new-address broadcast=$new-address
/ip route set [/ip route find comment=("wanl" . $i)] gateway=$new-address
}
}
}
4.添加ADSL1当线脚本A1Down,自动停用NTH负载所需的参数,并将标记3的网关设为ADSL2的网关
位置winbox-system-script 点“+ ”号,改name为A1Down,然后复制下面的脚本到source里
:local new-gateway
:set new-gateway [/ ip address get [/ip address find dynamic=yes interface=wan2] network]
/ip route set [/ip route find comment=3] gateway=$new-gateway
/ip route enable [/ip route find comment=3]
/ip route disabled [/ip route find comment=1]
/ip route disabled [/ip route find comment=2]
/ ip firewall mangle disabled [/ ip firewall mangle find comment=1]
/ ip firewall mangle disabled [/ ip firewall mangle find comment=2]
5.添加ADSL2当线脚本A2Down,自动停用NTH负载所需的参数,并将标记3的网关设为ADSL1的网关
位置winbox-system-script 点“+ ”号,改name为A2Down,然后复制下面的脚本到source里
:local new-gateway
:set new-gateway [/ ip address get [/ip address find dynamic=yes interface=wan1] network]
/ip route set [/ip route find comment=3] gateway=$new-gateway
/ip route enable [/ip route find comment=3]
/ip route disabled [/ip route find comment=1]
/ip route disabled [/ip route find comment=2]
/ ip firewall mangle disabled [/ ip firewall mangle find comment=1]
/ ip firewall mangle disabled [/ ip firewall mangle find comment=2]
6.添加ADSL掉线判断NETWATCH
/ tool netwatch
add host=10.112.112.122 timeout=1s interval=1m up-script="" down-script="A1Down" comment="1"
add host=10.112.112.124 timeout=1s interval=1m up-script="" down-script="A2Down" comment="2"
7.添加双线判断正常脚本allup。即两条线路UP的时候开启NTH负载均衡。
位置winbox-system-script 点“+ ”号,改name为allup,然后复制下面的脚本到source里
:global a
:global b
:set a [/tool netwatch get [/tool netwatch find comment=1] status]
:set b [/tool netwatch get [/tool netwatch find comment=2] status]
:if (($a="up") & ($b="up")) do={
/ip route disabled [/ip route find comment=3]
/ip route enable [/ip route find comment=1]
/ip route enable [/ip route find comment=2]
/ ip firewall mangle enable [/ ip firewall mangle find comment=1]
/ ip firewall mangle enable [/ ip firewall mangle find comment=2]
8.添加脚本计划任务
/ system scheduler
add name="tasksync" on-event=sync start-date=jan/01/1970 start-time=00:00:00 interval=10s comment=""
add name="taskup" on-event=allup start-date=jan/01/1970 start-time=00:00:00 interval=10s comment="" |
|