|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
×
本帖最后由 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 [/interface get [/interface find name=("ADSL_0" . $i)] running]
:if ($status=true) do={
:set new [/ip address get [/ip address find dynamic=yes interface=("ADSL_0" . $i)] address]
:set new [:pick $new 0 ([:len $new] -3)]
:set assign [/ip address get [/ip address find dynamic=no interface=("ADSL_0" . $i)] address]
:set assign [:pick $assign 0 ([:len $assign] -3)]
:if ($assign != $new) do={ /ip address set [/ip address find comment=$i] address=$new network=$new broadcast=$new
/ip route set [/ip route find comment=$i] gateway=$new
:if ($i=1) do={/ip route set [/ip route find comment=$link] 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-" . [/system package get system version] )
:local int
:local ddnsipfn [ /ip address get [/ip address find interface=$ddnsinterface ] 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 [/tool dns-update name=$ddnshost address=$ddnsip key-name=$ddnsuser key=$ddnspass ] ]
:global ddnslastip $ddnsip
}
} |
|