3x系列 ADSL双线Nth负载+DDNS自动更新+网银 #
本帖最后由 kekolike 于 2010-5-4 14:12 编辑#脚本名称:ADSL双线Nth负载+DDNS自动更新+网银 #
#运行环境:RouterOS 3x系列版本 # #
#注意的事项:注意网卡名和拨号用户名及密码、还有DNS地址(202.96.128.143..广州的DNS)#
# LAN=局域, PPoE_01和PPoE_02=用于拨号的网卡名 #
# 请按照步骤一步步添加脚本,以免出错 #
# 第六步—>七步,请手动到system-Scheduler中添加运行,运行时间建议10秒/次#
####################################################################################
#--------------------------------------第一步------------------------------#
#-------------------------------添加ADSL_01拨号网卡------------------------#
/interface pppoe-client add name="ADSL_01" interface=PPoE_01 user="***" password="***" add-default-route=no disabled=no
/interface pppoe-client enable ADSL_01
#-------------------------------添加ADSL_02拨号网卡------------------------#
/interface pppoe-client add name="ADSL_02" interface=PPoE_02 user="****" password="***" add-default-route=no disabled=no
/interface pppoe-client enable ADSL_02
#--------------------------------------第二步------------------------------#
#-------------------------------添加路由地址-------------------------------#
/ip address add address=10.110.0.1/24 comment=1 interface=ADSL_01
/ip address add address=10.112.0.1/24 comment=2 interface=ADSL_02
/ip route add dst-address=0.0.0.0/0 gateway=10.110.0.1 routing-mark=ADSL_01 comment=1 disabled=no
/ip route add dst-address=0.0.0.0/0 gateway=10.112.0.1 routing-mark=ADSL_02 comment=2 disabled=no
/ip route add dst-address=0.0.0.0/0 gateway=10.110.0.1 comment=3 disabled=no
#--------------------------------------第三步------------------------------#
#----------------ADSL_01网银分流(如果不添加这一步网银将无法登陆)-----------#
/ip firewall mangle add chain=prerouting protocol=tcp dst-port=443 action=mark-routing new-routing-mark=ADSL_01 passthrough=no comment="ADSL_01网银分流" disabled=no
#--------------------------------------第四步------------------------------#
#-------------------------------ADSL_01_Nth--------------------------------#
/ip firewall mangle add chain=prerouting in-interface=LAN connection-state=new nth=2,1 action=mark-connection new-connection-mark=ADSL_01_Conn passthrough=yes comment="ADSL_01_Nth" disabled=no
/ip firewall mangle add chain=prerouting action=mark-packet connection-mark=ADSL_01_Conn new-packet-mark=ADSL_01 passthrough=yes disabled=no
/ip firewall mangle add chain=prerouting in-interface=LAN connection-mark=ADSL_01_Conn action=mark-routing new-routing-mark=ADSL_01 passthrough=no disabled=no
#-------------------------------ADSL_02_Nth--------------------------------#
/ip firewall mangle add chain=prerouting in-interface=LAN connection-state=new nth=2,2 action=mark-connection new-connection-mark=ADSL_02_Conn passthrough=yes comment="ADSL_02_Nth" disabled=no
/ip firewall mangle add chain=prerouting action=mark-packet connection-mark=ADSL_02_Conn new-packet-mark=ADSL_02 passthrough=yes disabled=no
/ip firewall mangle add chain=prerouting in-interface=LAN connection-mark=ADSL_02_Conn action=mark-routing new-routing-mark=ADSL_02 passthrough=no disabled=no
#---------------------------------第五步(IP-Net转发、DNS、MSS)-------------#
/ip firewall nat add chain=srcnat action=masquerade src-address=192.168.0.0/255.255.0.0 comment="IP转发"
/ip dns set primary-dns=202.96.128.143 secondary-dns=202.96.128.68
/ip firewall mangle add chain=forward protocol=tcp tcp-flags=syn action=change-mss new-mss=1440 comment="设置MSS值等于1440"
#--------------------------------------第六步------------------------------#
#-------------------------------自动刷新网关-------------------------------#
:global assign
:global new
:global status
:global x
:global link
:set x 2
:set link 3
:for i from=1 to=$x do={
:set status running]
:if ($status=true) do={
:set new address]
:set new [:pick $new 0 ([:len $new] -3)]
:set assign address]
:set assign [:pick $assign 0 ([:len $assign] -3)]
:if ($assign != $new) do={ /ip address set address=$new network=$new broadcast=$new
/ip route set gateway=$new
:if ($i=1) do={/ip route set gateway=$new}
}
}
}
#--------------------------------------第七步------------------------------#
#-------------------------------Ros_DDNS-----------------------------------#
#-----------------申请地址:http://www.changeip.com------------------------#
:global ddnsuser "gzmickey" #-----------------------------------------用户名
:global ddnspass "mickeywan"#-----------------------------------------密码
:global ddnshost "mickey.zyns.com" #----------------------------------域名
:global ddnsip
:global ddnsipfn
:global ddnslastip [:tostr [:resolve $ddnshost] ]
:if ([ :typeof $ddnslastip ] = nil ) do={ :global ddnslastip "0" }
:global ddnsinterface "ADSL_01" #----------------这里的ADSL_01为拨号网卡名称
:global ddnssystem ("mt-" . )
:local int
:local ddnsipfn [ /ip address get address ]
:global ddnsip [:pick $ddnsipfn 0 [:find $ddnsipfn "/" ] ]
:if ([ :typeof $ddnsip ] = nil ) do={
:log info ("DDNS: No ip address present on " . $ddnsinterface . ", please check.")
} else={
:if ($ddnsip != $ddnslastip) do={
:log info "DDNS: Sending UPDATE!"
:log info [ :put ]
:global ddnslastip $ddnsip
}
} 我试验了4.6不能通过ddns 謝謝受益! 是3.x系列的哦 要是有PCC和DSCP的详细教程哪就完美了 支持一下。顶。 这个要支持 要是有更多线怎么处理,英文水平差 好文,定一个收藏起来! 好文,定一个收藏起来! 顶替 无私奉献了 大家给点鼓励哦 楼主是不是MM来的,要是的话真的一顶再顶 谢谢分享。。。。。。。 幽幽 那多顶几下哈 小妹妹先谢了