ChangeIP.com DDNS, Inbound Load Balancing

Need inbound load balancing across multiple providers and ip address blocks?

Okay all, we’ve spent a few weeks working on this script that will update our systems with multiple IP records from your mikrotiks. Note this is beta and not to be relied upon 100% yet - there will still be some tweaks I’m sure. We need more people to test and get involved so that we get a solid script going.

This script, when run, detects all IP addresses (up to 10) on interfaces that you’ve specificed, removes any bypasses IPs that you’ve noted, and then sends a dynamic dns update to our systems. This esentially gives you inbound load balancing using Dynamic DNS. If a WAN connection goes down it updates our system and yanks that IP address out.

NOTE: This script is not 100% completed. This service is not 100% tested, but is functional and has been in use by us for a month.

NOTE 2: You will need to email Support@ChangeIP.com with your UserID and we will enable your user account for this functionality - otherwise updates will not be accepted. This is a premium service and requires us to enable your account for it. For initial testers a free year or more will be added as thanks for helping.

Here is the script. Please give comments or updates to the script within this thread. Thanks!

# 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.  %
#                    %
# CONFIGURATION FIELD DEFINITIONS:
#   ddns-user:  Enter your ChangeIP.com user id.
#   ddns-pass:  Enter your ChangeIP.com password.
#   ddns-host:  Enter the hostname (www.example.com) to update.
#   ddns-interfaces:  Enter a list of interface names - case sensative.
#   ddns-bypass:  Do not include these addresses in updates.
#                    %
#                    %
#                    %
#                    %
#                    %
#                    %
#                %   %   %
#                 %  %  %
#                  % % %
#                    %
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# BEGIN CONFIGURATION HERE
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:global ddns-user "CHANGEIP_USERID"
:global ddns-pass "CHANGEIP_PASSWORD"
:global ddns-host "HOST.DOMAIN.TLD"
: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"

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# BEGIN SCRIPT - DO _NOT_ MODIFY BELOW
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#                    %
#                  % % %
#                 %  %  %
#                %   %   %
#                    %
#                    %
#                    %
#                    %
#                    %

: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 << \
                (32 - [:pick $net ([:find $net "/"] + 1) [:len $net]]))) = \
                ($tmp & (255.255.255.255 << (32 - [:pick $net \
                ([:find $net "/"] + 1) [:len $net]])))) do={
               :log debug ( "DDNS: Bypassed network: " . $net )
               :set i ($i + 1)
            } else={
               :log debug ( "DDNS: Not a bypassed network: " . $net )
            }

        }

        :if ($i = 0) do={
           :global ddns-ip ( $ddns-ip . "," . $tmp )
        } else={ :log info "I > 0?" }

    }

}
:global ddns-ip [:toarray $ddns-ip ]
:log debug ( "DDNS: Current IP list: " . $ddns-ip )

# initialize variable for comparison - won't compare otherwise.
:if ([ :typeof $ddns-lastip ] = nil ) do={
     :log debug "DDNS: Initializing ddns-lastip.  First run?"
     :global ddns-lastip 0.0.0.0
}

:if ([ :typeof $ddns-ip ] = nil ) do={
     :log debug ("DDNS: Array is invalid, please check.")
} else={

# Now compare the last ip list to this ip list.
  :if ( $ddns-ip != $ddns-lastip ) do={

    :log debug "DDNS: Sending UPDATE now!"
    :global ddns-lastip $ddns-ip
#    :global ddns-lastupdate [/system clock get time]
#    :log debug ("DDNS: Update result: " . [/tool dns-update name=$ddns-host address=$ddns-ip key-name=$ddns-user key=$ddns-pass] )
    /tool dns-update name=$ddns-host address=$ddns-ip key-name=$ddns-user key=$ddns-pass

  } else={ 
    :log debug "DDNS: No change."
  }

}


# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# END SCRIPT - DO _NOT_ MODIFY ABOVE
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#
#
#
# FEATURE REQUEST LIST:
#  Please send suggestions and comments to Support@ChangeIP.com.
#  These are in no particular order.
#   Limiter to protect against update abuse.
#   PING gateways to determine up/down.
#   Send email alert upon update.
#   
#  
#

Sam

sorry, i read this a millenium late…
but, i bloody needed this feature. is this still available today?
i’d like to try it, before buy.
and i need additional script, to update my domains all at once.

thank you Sam