注册 登录
自由的生活_软路由 返回首页

lai99999的个人空间 https://bbs.routerclub.com/?134023 [收藏] [复制] [分享] [RSS]

日志

光纤(vpn)走上行 ADSL走下行 复制论坛别人的贴子!

已有 1286 次阅读2011-4-25 07:42 |个人分类:ROS|

/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 [/interface get [/interface find  name=("pppoe-out" . $i)] running]
    :if ($status=true) do={
    :set newaddress [/ip address get [/ip address find dynamic=yes interface=("pppoe-out" . $i)] address ]
    :set newaddress [:pick $newaddress 0 [:find $newaddress "/"]]
    :set curaddress [ /ip firewall nat get [/ip firewall nat find comment=("ADSL" . $i)] 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  这样的格式。

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

路过

雷人

握手

鲜花

鸡蛋

评论 (0 个评论)

facelist doodle 涂鸦板

您需要登录后才可以评论 登录 | 注册

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

GMT+8, 2024-5-9 06:04 , Processed in 0.037736 second(s), 6 queries , Gzip On, Redis On.

Powered by Discuz! X3.5 Licensed

© 2001-2023 Discuz! Team.

返回顶部