ksw520 发表于 2010-9-18 01:17:53

讨论下热议中的 光纤(vpn)走上行 ADSL走下行

本帖最后由 zooyo 于 2011-2-9 20:22 编辑

看大坛友讨论比较激烈。还有哥们吵了起来,真是伤和气。
先发规则,脚本。

/ip firewall mangle
add action=jump chain=prerouting comment=adsl_bonding disabled=no dst-port=80,81,82,8080 jump-target=bonding protocol=tcp src-address=192.168.0.0/16
add action=jump chain=prerouting comment="" disabled=no jump-target=bonding src-address-list=other_list
add action=mark-connection chain=bonding comment="" disabled=no dst-address-type=!local in-interface=LAN new-connection-mark=adsl1conn passthrough=yes per-connection-classifier=both-addresses:3/0
add action=mark-routing chain=bonding comment="" connection-mark=adsl1conn disabled=no in-interface=LAN new-routing-mark=main passthrough=yes
add action=mark-connection chain=bonding comment="" disabled=no dst-address-type=!local in-interface=LAN new-connection-mark=adsl2conn passthrough=yes per-connection-classifier=both-addresses:3/1
add action=mark-routing chain=bonding comment="" connection-mark=adsl2conn disabled=no in-interface=LAN new-routing-mark=main passthrough=yes
add action=mark-connection chain=bonding comment="" disabled=no dst-address-type=!local in-interface=LAN new-connection-mark=adsl3conn passthrough=yes per-connection-classifier=both-addresses:3/2
add action=mark-routing chain=bonding comment="" connection-mark=adsl3conn disabled=no in-interface=LAN new-routing-mark=main passthrough=yes

要让哪走上行就new-routing-mark=main 到哪,当然vpn也行。按常规方式添加VPN网关(vpn服务器是要未做NAT伪装的)。

/ip firewall nat
add action=src-nat chain=srcnat comment=ADSL1 connection-mark=adsl1conn disabled=yes src-address=192.168.0.0/16 to-addresses=121.69.45.22
add action=src-nat chain=srcnat comment=ADSL2 connection-mark=adsl2conn disabled=yes src-address=192.168.0.0/16 to-addresses=121.71.114.11
add action=src-nat chain=srcnat comment=ADSL3 connection-mark=adsl3conn disabled=yes src-address=192.168.0.0/16 to-addresses=121.69.47.21
add action=src-nat chain=srcnat comment="" disabled=yes src-address=192.168.0.0/16 to-addresses=221.219.144.111

虽然mark-routing 到了指定的线路,但src-nat 伪装到了ADSL线路IP,回来的数据(下载)就通过ADSL返回了,连接正常建立,当然也就不会断线。

:local curaddress
:local newaddress
:local status
:local x
:set x 3
:for i from=1 to=$x do={
    :set status running]
    :if ($status=true) do={
    :set newaddress address ]
    :set newaddress [:pick $newaddress 0 [:find $newaddress "/"]]
    :set curaddress [ /ip firewall nat get to-addresses ]
    :if ($curaddress != $newaddress) do={
       /ip firewall nat set [ /ip firewall nat find comment=("ADSL" . $i) ] to-addresses=$newaddress
       :log info ("Change ADSL" . $i . " NAT IP" )
         }
   }
}

自动修改 NAT ip脚本 注意 comment=ADSL1这样的格式。

不是所有运营商都会不检测源地址是否合法,具体能否这样成功应用,自己测。

WGHBOY 发表于 2010-9-18 01:21:20

深圳的目前可以,不过我的做法跟你的不同,看看有十么区别

阿木DE 发表于 2010-9-18 02:50:53

感谢楼主.依葫芦已经画出瓢了.对楼主今天的2贴技术和金钱含量给予无尚的敬意.

火蚂蚁 发表于 2010-9-18 06:46:52

感谢楼主.依葫芦已经画出瓢了.对楼主今天的2贴技术和金钱含量给予无尚的敬意

3148715 发表于 2010-9-18 07:29:05

恩,不错,非常有技术含量

qdcv123 发表于 2010-9-18 08:59:45

学习了 谢谢!!

qdcv123 发表于 2010-9-18 09:38:39

看了40多人 结果回帖只有几个人 到底是 不需要呢 还是 就没有回帖的精神呢?纳闷ing。。。。。。。。。。。。

supermp3 发表于 2010-9-18 11:09:53

40多人都是观望,因为这些人都没有搞懂!

cpanda 发表于 2010-9-18 11:45:35

这功能实用,多谢楼主分享

9939781 发表于 2010-9-18 12:09:46

感谢楼主,虽然还没有看明白

peterchen 发表于 2010-9-18 12:26:36

就是src-nat吧

winepo 发表于 2010-9-18 12:53:00

技术贴 支持楼主

tangdong 发表于 2010-9-18 17:04:55

总算看到了有技术含量的!:lol

ksw520 发表于 2010-9-18 17:44:22

根本就没啥技术含量,而且还是个很过时的技术,仅仅是个思路问题。

加了个回复可见,想看的就回吧。

qq3475534 发表于 2010-9-18 18:38:16

看看了哦呵呵。
页: [1] 2 3 4 5 6 7 8 9 10
查看完整版本: 讨论下热议中的 光纤(vpn)走上行 ADSL走下行