找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 14176|回复: 13

[策略设置] 多线负载均衡情况下的动态域名脚本--脚本的风采

[复制链接]
发表于 2006-4-24 21:09:33 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

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

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

注意事项:

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

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

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

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

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

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

  3. Account1:
  4. Account2:

  5. Best Regards

  6. !!!!你的签名!!!!
复制代码


5、代码部份:
[code]# 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 [/interface find name=$i ] ] != 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=[/ip address find interface=$i disabled=no] 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
routeros
发表于 2006-4-24 21:10:51 | 显示全部楼层
终于抢到沙发了  顶
routeros
回复

使用道具 举报

发表于 2006-4-25 00:15:57 | 显示全部楼层
我来板凳
routeros
回复

使用道具 举报

 楼主| 发表于 2006-4-26 11:33:44 | 显示全部楼层
除了灌水还是灌水。。。
routeros
回复

使用道具 举报

发表于 2006-4-27 06:38:04 | 显示全部楼层
能否把他修改一下变成单ADSL的?

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

使用道具 举报

 楼主| 发表于 2006-4-27 13:48:57 | 显示全部楼层
原帖由 专卖精品 于 2006-4-27 06:38 发表
能否把他修改一下变成单ADSL的?

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


自2.9开始,ROS内置支持了,你可以参考官方的脚本
地址: http://wiki.mikrotik.com:3280/wi ... pt_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 [/ip address find interface=$ddns-interface] 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"
========================
routeros
回复

使用道具 举报

 楼主| 发表于 2006-4-27 13:49:55 | 显示全部楼层
原帖由 专卖精品 于 2006-4-27 06:38 发表
能否把他修改一下变成单ADSL的?

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


自2.9开始,ROS内置支持了,你可以参考官方的脚本
地址: http://wiki.mikrotik.com:3280/wi ... pt_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 [/ip address find interface=$ddns-interface] 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"
========================
routeros
回复

使用道具 举报

 楼主| 发表于 2006-4-27 13:52:15 | 显示全部楼层
晕,怎么发了两个帖子
routeros
回复

使用道具 举报

发表于 2006-10-13 08:34:25 | 显示全部楼层
谢谢  收了  辛苦
routeros
回复

使用道具 举报

发表于 2006-10-13 08:43:37 | 显示全部楼层
bingo
routeros
回复

使用道具 举报

发表于 2007-11-4 12:56:06 | 显示全部楼层
routeros
回复

使用道具 举报

发表于 2011-2-9 20:27:50 | 显示全部楼层
单线双线的不都一样吗?
routeros
回复

使用道具 举报

发表于 2011-3-10 22:14:43 | 显示全部楼层
双线的一样的吧
routeros
回复

使用道具 举报

发表于 2011-3-10 22:21:46 | 显示全部楼层
这个早就不支持了,怎么把古董帖子都给翻出来了
routeros
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-5-10 20:44 , Processed in 0.085292 second(s), 6 queries , Gzip On, Redis On.

Powered by Discuz! X3.5 Licensed

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表