找回密码
 注册

QQ登录

只需一步,快速开始

搜索
楼主: guaidetian

[基础] (教程)双ADSL相同网关加负载

[复制链接]
发表于 2007-10-13 12:14:06 | 显示全部楼层
精神大大的好,绝对性支持这样共享精神,,,,神会祝福你的。
routeros
回复

使用道具 举报

发表于 2007-10-15 21:08:01 | 显示全部楼层
说起来复杂,其实做了反尔是简单的
routeros
回复

使用道具 举报

发表于 2008-7-30 12:13:10 | 显示全部楼层
这么麻烦啊。。。。
routeros
回复

使用道具 举报

发表于 2008-8-15 14:57:10 | 显示全部楼层
要顶了才能下????
routeros
回复

使用道具 举报

发表于 2008-8-15 18:27:52 | 显示全部楼层


thanks!!
routeros
回复

使用道具 举报

发表于 2008-8-15 18:33:49 | 显示全部楼层
再回一个~~

刚才没下好。。
routeros
回复

使用道具 举报

发表于 2008-8-15 20:09:55 | 显示全部楼层
都是07年的帖子了,还是小顶一下吧。
routeros
回复

使用道具 举报

发表于 2008-8-15 20:13:28 | 显示全部楼层
HAI 看不大懂,以后慢慢研究
routeros
回复

使用道具 举报

发表于 2008-8-16 00:56:22 | 显示全部楼层
ggggggggggggggggg
routeros
回复

使用道具 举报

发表于 2008-8-18 16:17:20 | 显示全部楼层
DDDDDDDDDDD
routeros
回复

使用道具 举报

发表于 2008-8-29 16:54:58 | 显示全部楼层
支持一個。
routeros
回复

使用道具 举报

发表于 2008-8-30 19:08:02 | 显示全部楼层
EBDGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
routeros
回复

使用道具 举报

发表于 2008-9-11 01:32:17 | 显示全部楼层
zaslfdkgsal  asdf;alsdkf
routeros
回复

使用道具 举报

发表于 2008-9-11 15:56:31 | 显示全部楼层
啊,但是不知道一个固定ip和一个opppe拨号怎么均衡啊
routeros
回复

使用道具 举报

发表于 2008-9-18 04:32:55 | 显示全部楼层
修正后:

1.设置PPPOECLIENT 这个不用说了吧^_^ (注意:加的时候把2个中的的一个 "Add Default Route"前面的勾勾掉)

2.改pppoe-out1和pppoe-out2的名字:如改pppoe-out1为ADSL1 改pppoe-out2为ADSL2

改名字的脚本如下:
直接复制
==================
/int set [/int find name=pppoe-out1] name "ADSL1"
/int set [/int find name=pppoe-out2] name "ADSL2"

3.在IP-ADDRESS里加IP地址

自动加IP地址的<脚本>如下:
直接复制
==================
:local ip1 [/ip add get [/ip add find broa=0.0.0.0 interface="ADSL1"] address]
:local ip2 [/ip add get [/ip add find broa=0.0.0.0 interface="ADSL2"] address]
:set ip1 [:pick $ip1 0 ([:len $ip1]-3)]
:set ip2 [:pick $ip2 0 ([:len $ip2]-3)]
/ip add add address=($ip1 . "/32") interface="ADSL1" comment= "ADSL1" disabled=no
/ip add add address=($ip2 . "/32") interface="ADSL2" comment= "ADSL2" disabled=no

4.标记连接和路由、IP伪装、路由表添加
直接复制

1:       标记连接和路由

==================
/ ip firewall mangle
add chain=prerouting in-interface="LAN" connection-state=new nth=1,1,0 \
    action=mark-connection new-connection-mark=odd passthrough=yes comment="" \
    disabled=no
add chain=prerouting in-interface="LAN" connection-mark=odd action=mark-routing \
    new-routing-mark=odd passthrough=no comment="" disabled=no

add chain=prerouting in-interface="LAN" connection-state=new nth=1,1,1 \
    action=mark-connection new-connection-mark=even passthrough=yes comment="" \
    disabled=no
add chain=prerouting in-interface="LAN" connection-mark=even action=mark-routing \
    new-routing-mark=even passthrough=no comment="" disabled=no

2:       IP伪装

===================
:local ip1 [/ip add get [/ip add find broa=0.0.0.0 interface="ADSL1"] address]
:local ip2 [/ip add get [/ip add find broa=0.0.0.0 interface="ADSL2"] address]
:set ip1 [:pick $ip1 0 ([:len $ip1]-3)]
:set ip2 [:pick $ip2 0 ([:len $ip2]-3)]
/ ip firewall nat
add chain=srcnat connection-mark=odd action=src-nat to-addresses=$ip1 \
    to-ports=0-65535 comment="" disabled=no
add chain=srcnat connection-mark=even action=src-nat to-addresses=$ip2 \
    to-ports=0-65535 comment="" disabled=no
      
3:      路由表添加

==================
:local ip1 [/ip add get [/ip add find comm="ADSL1"] network]
:local ip2 [/ip add get [/ip add find comm="ADSL2"] network]
/ ip route
add dst-address=0.0.0.0/0 gateway=$ip1 scope=255 target-scope=10 routing-mark=odd \
    comment="ADSL1" disabled=no
add dst-address=0.0.0.0/0 gateway=$ip2 scope=255 target-scope=10 routing-mark=even \
    comment="ADSL2" disabled=no

(这条也加标注的原因是为了后面的自动改网关脚本)


========================================================================================
到这里内网的机器已经可以上网了。下面的就是控制IP改动的脚本


把下面的两个脚本添加到SYSTEM-SCRIPT里。命名为"change IP"和"change route"


change IP

==================
:local ip1 [/ip add get [/ip add find broa=0.0.0.0 interface="ADSL1"] address]
:local ip2 [/ip add get [/ip add find broa=0.0.0.0 interface="ADSL2"] address]
:local ip3 [/ip add get [/ip add find comment= "ADSL1"] network]
:local ip4 [/ip add get [/ip add find comment= "ADSL2"] network]
:set ip1 [:pick $ip1 0 ([:len $ip1]-3)]
:set ip2 [:pick $ip2 0 ([:len $ip2]-3)]
:if ($ip1 != $ip3) do={/ip add set [/ip add find comment="ADSL1"] address ($ip1 . "/32") broa $ip1 network $ip1}
:if ($ip2 != $ip4) do={/ip add set [/ip add find comment="ADSL2"] address ($ip2 . "/32") broa $ip1 network $ip1}


change route
==================
:local ip1 [/ip add get [/ip add find broa=0.0.0.0 interface="ADSL1"] address]
:local ip2 [/ip add get [/ip add find broa=0.0.0.0 interface="ADSL2"] address]
:local ip3 [/ip fir nat get [/ip fir nat find connection-mark=odd] to-addresses]
:local ip4 [/ip fir nat get [/ip fir nat find connection-mark=even] to-addresses]
:local ip5 [/ip route get [/ip route find routing-mark=odd] gateway]
:local ip6 [/ip route get [/ip route find routing-mark=even] gateway]
:set ip1 [:pick $ip1 0 ([:len $ip1]-3)]
:set ip2 [:pick $ip2 0 ([:len $ip2]-3)]
:if ($ip1 != $ip3) do={/ip fir nat set [/ip fir nat find connection-mark=odd] to-addresses $ip1}
:if ($ip1 != $ip5) do={/ip route set [/ip route find routing-mark=odd] gateway $ip1}
:if ($ip2 != $ip4) do={/ip fir nat set [/ip fir nat find connection-mark=even] to-addresses $ip2}
:if ($ip2 != $ip6) do={/ip route set [/ip route find routing-mark=even] gateway $ip2}

添加任务
直接复制
==================
/ system scheduler
add name="change ip" on-event="" start-date=jan/01/1970 \
    start-time=00:00:00 interval=2s comment="" disabled=no
add name="change route" on-event="" start-date=jan/01/1970 \
    start-time=00:00:00 interval=2s comment="" disabled=no

[ 本帖最后由 huqingbo 于 2008-9-18 04:35 编辑 ]
routeros
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-6-9 03:44 , Processed in 0.097336 second(s), 6 queries , Gzip On, Redis On.

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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