Debugging and checking done.
Made because of the unreliability of long-term work without confirmation on NO-IP service.
I am sorry for my bad english
Code: Select all
# No-IP, DNSdynamic update
#--------------- Change Values in this section to match your setup ------------------
#User account info
:local noipuser "NO-IP_User_Name"
:local noippass "NO-IP_password"
:local dnsdynamicuser "DNSdynamic_User_Name"
:local dnsdynamicpass "DNSdynamic_password"
:local noiphost "NO-IP_host"
:local dnsdynamichost "DNSdynamic_host"
# Change to the name of interface that gets the dynamic IP address
:local inetinterface "Internet_Interface_Name"
#-------------------No more changes need---------------------------------------------
:global previousIP
:if ([/interface get $inetinterface value-name=running]) do={
# Get the current IP on the interface
:local currentIP [/ip address get [find interface="$inetinterface" disabled=no] address]
# Strip the net mask off the IP address
:for i from=( [:len $currentIP] - 1) to=0 do={
:if ( [:pick $currentIP $i] = "/") do={
:set currentIP [:pick $currentIP 0 $i]
}
}
:if ($currentIP != $previousIP) do={
:log info "IP: Current IP $currentIP is not equal to previous IP, update needed"
:set previousIP $currentIP
# The update No-Ip URL. Note the "\3F" is hex for question mark (?). Required since ? is a special character in commands.
:local url "http://dynupdate.no-ip.com/nic/update\3Fmyip=$currentIP"
:local noiphostarray
:set noiphostarray [:toarray $noiphost]
:foreach host in=$noiphostarray do={
:log info "No-IP: Sending update for $host"
/tool fetch url=($url . "&hostname=$host") user=$noipuser password=$noippass mode=http dst-path=("no-ip_ddns_update-" . $host . ".txt")
:log info "No-IP: Host $host updated on No-IP with IP $currentIP"
}
# The update dnsdynamic URL. Note the "\3F" is hex for question mark (?). Required since ? is a special character in commands.
:local url "https://www.dnsdynamic.org/nic/nic/update\3Fmyip=$currentIP"
:local dnsdynamichostarray
:set dnsdynamichostarray [:toarray $dnsdynamichost]
:foreach host in=$dnsdynamichostarray do={
:log info "dnsdynamic: Sending update for $host"
/tool fetch url=($url . "&hostname=$host") user=$dnsdynamicuser password=$dnsdynamicpass mode=http dst-path=("dnsdynamic_ddns_update-" . $host . ".txt")
:log info "dnsdynamic: Host $host updated on dnsdynamic with IP $currentIP"
}
} else={
:log info "IP: Previous IP $previousIP is equal to current IP, no update needed"
}
} else={
:log info "IP: $inetinterface is not currently running, so therefore will not update."
}