Wed Mar 02, 2016 5:28 am
the put script below in your system scripts
:local hostnamesToUpdate { \
"hostname, service, interface"; \
"hostname, service, interface" }
:local dyndnsUsername ""
:local dyndnsPassword ""
:local noipUsername ""
:local noipPassword ""
:local changeipUsername ""
:local changeipPassword ""
:local forceUpdate false
:local flushDNSCache true
:local forceUpdateTime 15
#
# Script
#
:global lastUpdate
# Date Calculations
:local date [ /system clock get date ]
:local months ("jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec");
:local month [ :pick $date 0 3 ]; :local day [ :pick $date 4 6 ]; :local year [ :pick $date 7 11 ];
:local mm ([ :find $months $month -1 ] + 1);
:if ($mm < 10) do={ :set month ("0" . $mm); } else={ :set month $mm; }
:set date ($year . $month . $day);
:if ([:typeof $lastUpdate] = "nothing" || (($date-$lastUpdate) >= $forceUpdate && $forceUpdate > 0)) do={
:set forceUpdate true
}
:local hadUpdate false;
:foreach i in $hostnamesToUpdate do={
:local tempArray [:toarray $i]
:local ddnsHostname [:pick $temparray 0]
:local ddnsService [:pick $temparray 1]
:local interfaceName [:pick $temparray 2]
:local ddnsAddress [:resolve $ddnsHostname]
:local currentAddress [/ip address get [/ip address find interface=$interfaceName disabled=no] address]
:set currentAddress [:pick $currentAddress 0 [:find $currentAddress "/" -1]]
:local elseIf true
:if (($force = true) || ($currentAddress != $ddnsAddress)) do={
:if ($ddnsService = "dyndns") do={
/tool fetch user=$username password=$password mode=http address="members.dyndns.org" \
src-path="/nic/update?hostname=$ddnsHostname&myip=$currentAddress" dst-path="/output.txt"
:set elseIf false
}
:if ($elseIf && $ddnsService = "noip") do={
/tool fetch user=$username password=$password mode=http address="dynupdate.no-ip.com" \
src-path="/nic/update?hostname=$ddnsHostname&myip=$currentAddress" dst-path="/output.txt"
:set elseIf false
}
:if ($elseIf && $service = "changeip") do={
/tool fetch user=$username password=$password mode=http address="nic.changeip.com" \
src-path="/nic/update?hostname=$ddnsHostname&myip=$currentAddress" dst-path="/output.txt"
:set elseIf false
}
:set hadUpdate true
}
:if ($hadUpdate && $flushDNSCache) do={
/ip dns cache flush
}