based on https://wiki.mikrotik.com/wiki/Dynamic_DNS_Update_Script_for_No-IP_DNS
:local ddnsuser "<no-ip_username>"
:local ddnspass "<no-ip_pass>"
:local ddnshostname "<no-ip_host.ddns.net>"
:local ddnsinterface "<ddns_iface_name>"
# global variables definition
:global ddnslastip
#local vars definitions
:local ddnsip
#:local ddnsURL "http://dynupdate.no-ip.com/nic/update?hostname=$ddnshostname&myip=$ddnsip"
# base64 encoded string of username:password used
# https://www.noip.com/integrate/request
:local auth "Authorization:<base64 encoded string>"
:local useragent "User-Agent:Mikrotik-script <maintainer email>"
:local headers
:set $headers "$auth , $useragent"
:if ([ :typeof $ddnslastip ] = nil ) do={ :global ddnslastip "0" }
:local ddnsip [ /ip address get [/ip address find interface=$ddnsinterface ] address ]
:if ([ :typeof $ddnsip ] = nil ) do={
:log info ("ServiceDNS: No ip address on $ddnsinterface .")
} else={
:for i from=( [:len $ddnsip] - 1) to=0 do={
:if ( [:pick $ddnsip $i] = "/") do={
:set ddnsip [:pick $ddnsip 0 $i];
}
}
}
:if ($ddnsip != $ddnslastip) do={
:log info ("ServiceDNS: $ddnshostname -> $ddnsip")
:local ddnsURL "http://dynupdate.no-ip.com/nic/update?hostname=$ddnshostname&myip=$ddnsip"
:local response [ /tool fetch url=$ddnsURL http-header-field=$headers as-value output=user ]
if ($response->"status" = "finished") do={
:local data ($response->"data");
:set $ddnslastip $ddnsip
:log info ("$ddnslastip")
:log info "DDNS: Update succeeded."
} else={
:log error "DDNS: Update failed.";
}
} else {
# :log info "DDNS: No IP change.";
}
}