找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 4376|回复: 2

[策略设置] 用虚拟机做个ROS双线分流,但不知道错在哪

[复制链接]
发表于 2009-6-19 13:36:58 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

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

×
我从网上找来的双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=""
routeros
 楼主| 发表于 2009-6-20 20:29:57 | 显示全部楼层
高手这么多,有人帮我看一下吗
routeros
回复

使用道具 举报

发表于 2009-6-20 22:59:59 | 显示全部楼层
你就不会看看别人怎么做吗
routeros
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|手机版|小黑屋|软路由 ( 渝ICP备15001194号-1|渝公网安备 50011602500124号 )

GMT+8, 2024-12-22 18:45 , Processed in 0.044090 second(s), 5 queries , Gzip On, Redis On.

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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