Script Multiple DDNS on Changeip.com

this script is to update your multiple DNS entry for changeip.com, if you dont supply the variable “hostname” with a name, it will take the interface name and will use it as the hostname entry for your changeip.
the variable “local hostname” is set to use “isp” - if you have multiple internet interface like pppoe or ethernet it will be like
isp1.yourdomain.com
isp2.yourdomain.com

If you don’t supply the “local hostname” with a value and leave it blank, the script will take the interface name and uses it as your hostname and it will become like below

ether1.yourdomain.com
ether2.yourdomain.com
pppoe-out3.yourdomain.com

REMEBER: if you will supply a name to the variable “hostname” below, make sure it does exist in your changeip.com dns registry.
the variable “toggleEth” and “togglePPP” if set to OFF will not include it in the ddns updates.

#============================
#    Scripting by
#    Dan Santillan
#    Cygnaltech Systems
#    Wireless Technologies
#
#============================
 
#==================================
#
#  DO NOT MAKE ANY MODIFICATION        
#  OR THE SCRIPT WILL FAIL TO WORK
#==================================

local ddnsTLD "yourdomain.com"
local ddnsUsername "yourusername"
local ddnsPassword "yourpassword"
local hostname "isp"
local toggleEth "ON"
local togglePPP "ON"
local ddnshostIP
local cnt 0

#---------------------------------------------
# PPPoE Section
#----------------------------------------------

if ( [len $ddnsUsername] >0 && [len $ddnsPassword] > 0 && [len $ddnsTLD] > 0 ) do={

if ( $togglePPP = "ON" ) do={

   foreach m in=[/interface find type=pppoe-out] do={

   local intType [/interface get $m type]
   local intName [/interface get $m name]

   if ( ![/interface get $intName disabled] ) do={

        local dslStatus [:pick [/interface pppoe-client monitor $intName as-value] 11]

        if ( [:len $dslStatus] > 0 ) do={

                do {
                     local boolean false
                     local tempHN
                     local pppoeCM [:pick [/interface pppoe-client monitor $intName as-value] 4]
                     local pppoeIP [:pick [/interface pppoe-client monitor $intName as-value] 6]
       
                    if ( [len $hostname] > 0 ) do={
                        set cnt ($cnt +1)                    
                        set tempHN ( $hostname . "$cnt" . ".$ddnsTLD" ) 
                    } else={ set tempHN ( $intName . ".$ddnsTLD" ) }

                     do {
                           set ddnshostIP [resolve $tempHN]
                           } on-error={ log warn "$tempHN failed to resolved... skipping DDNS Updates...";  set boolean true }

                             if ( $boolean !=  true) do={

                                         if ( $pppoeIP != $ddnshostIP ) do={
                                              do {
                                                    log warn "Old DDNS entry ($tempHN: $ddnshostIP) - [Current IP of $intName: $pppoeIP] -- updating $tempHN ddns entry..."
                                                   [/tool dns-update name=$tempHN address=$pppoeIP key-name=$ddnsUsername key=$ddnsPassword]
                                                } on-error={ log warn "Error updating $tempHN" }
                                          } 
                             }

                   } on-error={ } 
        } 
   }

   } 
} else={ log info "DDNS Updates on PPPPoE interface is $togglePPP" }

#------------------------------------------
# END PPPoE Section
#--------------------------------------------


# ========================
# Ethernet Section
# ========================

if ( $toggleEth = "ON" ) do={

   foreach m in=[/interface find type=ether] do={

   local intType [/interface get $m type]
   local intName [/interface get $m name]

   if ( ![/interface get $intName disabled]  ) do={ 

        local ethStat [:pick [/interface ether monitor $intName as-value] 6]

        if ( [:len $ethStat] > 0 ) do={

               do {
                        local boolean false
                        local tempHN
                        local ethIP
                        local ethCM [/interface ether get $intName comment]

                        if ( ![/ip dhcp-client get [/ip dhcp-client find interface=$intName] disabled] ) do={
                               set ethIP [/ip dhcp-client get [/ip dhcp-client find interface=$intName] address]
                               set ethIP [pick $ethIP 0 [find $ethIP "/"]]
                        } 

                        if ( [len $hostname] > 0 ) do={
                            set cnt ($cnt +1)                    
                            set tempHN ( $hostname . "$cnt" . ".$ddnsTLD" ) 
                        } else={ set tempHN ( $intName . ".$ddnsTLD" ) }

                        do {
                               set ddnshostIP [resolve $tempHN]
                             } on-error={ log warn "$tempHN failed to resolved... skipping DDNS Updates...";  set boolean true }

                             if ( $boolean !=  true) do={

                                     if ( $ethIP != $ddnshostIP ) do={
                                          do {
                                                 log warn "Old DDNS entry ($tempHN: $ddnshostIP) - [Current IP of $intName: $ethIP] -- updating $tempHN ddns entry..."
                                                 [/tool dns-update name=$tempHN address=$ethIP key-name=$ddnsUsername key=$ddnsPassword]
                                               } on-error={ log warn "Error updating $tempHN" }
                                    } 
                             }

                  } on-error= {  } 
         } 
   }

  }
} else={ log info "DDNS Updates on Ethernet interface is $toggleEth" }
# ========================
# END of Ethernet Section
# ========================

} else={ log warn "Please supply DDNS Username/Password and domain name..." }