Hansxia 发表于 2006-4-24 21:09:33

多线负载均衡情况下的动态域名脚本--脚本的风采

在Mikrotik论坛看到了changeip.com的sam写的一段关于多线情况下的动态域名更新脚本本,适合多线,多动态域名时使用,我现在没条件测

试其中的脚本,粗略翻译一下发布出来,希望有条件的可以测试一下:lol:

注意事项:

1、此教本是BETA版本,不能保证100%正确运行,如果发现问题,可直接发邮件联系Support@ChangeIP.com

2、多线情况下的动态域名,最多可支持10线

3、如果你在changeip.com上已经申请了多个域名,为了能够实现多动态域名的更新,你需要把你所有已经注册的用户名发邮件到

Support@ChangeIP.com ,请他们为你设置好此项功能,不申请不能使用。

如果你觉得写邮件有点儿困难,我这里提供一个,你稍做修改就可以发送或者你自己写一个,诚恳一些,别忘了感谢一下就行了:
Hi Sam:

Pls enable my accounts below with inbound load balancing across multiple providers,thank you very much.

Account1:
Account2:

Best Regards

!!!!你的签名!!!!

5、代码部份:
# Dynamic DNS Update / Round Robin Edition
# Written by Sam Norris, ChangeIP.com
# Copyright ChangeIP.com 2005
# For support send mail to Support@ChangeIP.com
#
# Revision 0.10 beta - Initial script written (09/20/05)
# Revision 0.11 beta - Bypass list help thanks to STEN. (09/26/05)
#
# OVERVIEW:          %
#This script will update a ChangeIP.com dynamic dns hostname
#with a set of ip addresses to accomplish inbound load balancing
#using round robin dns.When an ip address is no longer valid
#on the Mikrotik it will update the dynamic dns account to remove
#it therefore keeping incoming traffic from using it.
#                  %
# ENHANCED DDNS OFFERING!REQUIRED UPGRADE!
#   This update script can only be used if your ChangeIP.com account
#   has the "Dynamic DNS Round Robin Upgrade".This can be
#   enabled by visiting http://www.ChangeIP.com/2.0/dns/roundrobin.aspx
#   note:as of 09/25/05 you should email Support@ChangeIP.com to
#   enable this.   %
#                  %
# NOTES:             %
#   Inbound load balancing requires more than 1 WAN connection, each
#   with about equal bandwidth performance.If one connection is a
#   modem and the other is broadband you will probably kill the modem
#   and cause intermittent connection to your servers.This service
#   does not take into account how busy each WAN port is, it simply
#   advertises all available IP addresses to the DNS system to allow
#   and use connections from multiple internet providers.When an IP
#   address on the Mikrotik router is no longer present or disabled a
#   dynamic dns update will occur and new ip addresses will be served
#   via DNS to the outside world.Detection, update, replication time
#   should typically be less than 1 minute.IF THIS SCRIPT DOES NOT
#   PRODUCE ANY OUTPUT PLEASE COPY AND PASTE IT AGAIN.THERE PROBABLY
#   IS A LINE BREAK IN THE WRONG PLACE!PLEASE ASK MT FOR BETTER SCRIPT
#   ERROR HANDLING.%
#                  %
# 变量部份:
#注释
#   变量ddns-user:你在ChangeIP.com上的用户名.
#   变量ddns-pass:ddns-user对应的密码.
#   变量ddns-host:动态域名.
#   变量ddns-interfaces:外线网卡名字,!!!!大小写敏感,切记!!!!!.
#   变量ddns-bypass:更新时忽律的IP地址.
#                  %
#                  %
#                  %
#                  %
#                  %
#                  %
#                %   %   %
#               %%%
#                  % % %
#                  %
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 开始定义变量 ,可根据你外线的数量及名称修改相应部份
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:global ddns-user "用户名"
:global ddns-pass "密码"
:global ddns-host "域名"
:global ddns-interfaces "ether1,ether2,ether3,ether4,public,wan,wan1,outside,1-coxBiz"
:global ddns-bypass "10.0.0.0/8,172.16.0.0/12,192.168.0.0/16"

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 脚本开始,以下无需修改(除非你会改 : ) )
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#                  %
#                  % % %
#               %%%
#                %   %   %
#                  %
#                  %
#                  %
#                  %
#                  %

:log debug "DDNS: Start"
:global ddns-valid-interfaces ""

# Gather list of valid interfaces
:foreach i in=[:toarray $ddns-interfaces] do={
   :if ( [:toid ] != nil ) do={
          :log debug ("DDNS: Found Interface: " . $i)
          :global ddns-valid-interfaces ($ddns-valid-interfaces . "," . $i )
   }
}
:global ddns-valid-interfaces [:toarray $ddns-valid-interfaces]
:log debug ("DDNS: Valid interface list: " . $ddns-valid-interfaces )

# Now loop thru all interfaces and gather IP addresses.
:global ddns-ip ""
:foreach i in=[:toarray $ddns-valid-interfaces ] do={

    :foreach ipaddr in= do={
      :local tmp [/ ip address get $ipaddr address]
      :local tmp [:pick $tmp 0 [:find $tmp "/"] ]
      :log debug ( "DDNS: Found IP: " . $tmp )

      :set i 0
      :foreach net in=[:toarray $ddns-bypass ] do={

            :log info ( "DDNS: Is " . $tmp . " within network " . $net . " ? ")
            :if ( ([:pick $net 0 [:find $net "/"]] & (255.255.255.255

tufei1011 发表于 2006-4-24 21:10:51

终于抢到沙发了顶

专卖精品 发表于 2006-4-25 00:15:57

我来板凳

Hansxia 发表于 2006-4-26 11:33:44

除了灌水还是灌水。。。

专卖精品 发表于 2006-4-27 06:38:04

能否把他修改一下变成单ADSL的?

论坛里的方法测试了很多,但是都不行,我的是2.9.6版本的

Hansxia 发表于 2006-4-27 13:48:57

原帖由 专卖精品 于 2006-4-27 06:38 发表
能否把他修改一下变成单ADSL的?

论坛里的方法测试了很多,但是都不行,我的是2.9.6版本的

自2.9开始,ROS内置支持了,你可以参考官方的脚本
地址: http://wiki.mikrotik.com:3280/wiki/Dynamic_DNS_Update_Script_for_ChangeIP.com

这是脚本:
========================
:log info "DDNS: Begin"
:global ddns-user "用户名"
:global ddns-pass "密码"
:global ddns-host "*1"
:global ddns-interface "EXACTINTERFACENAME"

:global ddns-ip [ /ip address get address ]

:if ([ :typeof $ddns-lastip ] = nil ) do={ :global ddns-lastip 0.0.0.0/0 }

:if ([ :typeof $ddns-ip ] = nil ) do={

:log info ("DDNS: No ip address present on " . $ddns-interface . ", please check.")

} else={

:if ($ddns-ip != $ddns-lastip) do={

    :log info "DDNS: Sending UPDATE!"
    :log info [ /tool dns-update name=$ddns-host address=[:pick $ddns-ip 0 [:find $ddns-ip "/"] ] key-name=$ddns-user key=$ddns-pass ]
    :global ddns-lastip $ddns-ip

} else={

    :log info "DDNS: No change"

}

}

:log info "DDNS: End"
========================

Hansxia 发表于 2006-4-27 13:49:55

原帖由 专卖精品 于 2006-4-27 06:38 发表
能否把他修改一下变成单ADSL的?

论坛里的方法测试了很多,但是都不行,我的是2.9.6版本的

自2.9开始,ROS内置支持了,你可以参考官方的脚本
地址: http://wiki.mikrotik.com:3280/wiki/Dynamic_DNS_Update_Script_for_ChangeIP.com

这是脚本:
========================
:log info "DDNS: Begin"
:global ddns-user "用户名"
:global ddns-pass "密码"
:global ddns-host "*1"
:global ddns-interface "EXACTINTERFACENAME"

:global ddns-ip [ /ip address get address ]

:if ([ :typeof $ddns-lastip ] = nil ) do={ :global ddns-lastip 0.0.0.0/0 }

:if ([ :typeof $ddns-ip ] = nil ) do={

:log info ("DDNS: No ip address present on " . $ddns-interface . ", please check.")

} else={

:if ($ddns-ip != $ddns-lastip) do={

    :log info "DDNS: Sending UPDATE!"
    :log info [ /tool dns-update name=$ddns-host address=[:pick $ddns-ip 0 [:find $ddns-ip "/"] ] key-name=$ddns-user key=$ddns-pass ]
    :global ddns-lastip $ddns-ip

} else={

    :log info "DDNS: No change"

}

}

:log info "DDNS: End"
========================

Hansxia 发表于 2006-4-27 13:52:15

晕,怎么发了两个帖子

jiaruifly 发表于 2006-10-13 08:34:25

谢谢收了辛苦

wnckmmy 发表于 2006-10-13 08:43:37

bingo

cracks 发表于 2007-11-4 12:56:06

:)

kyer2012 发表于 2011-2-9 20:27:50

单线双线的不都一样吗?

qile 发表于 2011-3-10 22:14:43

双线的一样的吧

zhjchina 发表于 2011-3-10 22:21:46

这个早就不支持了,怎么把古董帖子都给翻出来了
页: [1]
查看完整版本: 多线负载均衡情况下的动态域名脚本--脚本的风采