DynDNS update script

This is working with Loopia today…

:global ddnsuser "loopia-login"
:global ddnspass "loopia-password"
:global ddnshost "your-domain.se"
:global interfac "ether1-gateway"

:global ipfresh [ /ip address get [/ip address find interface=$interfac ] address ]

:if ([ :typeof $ipfresh ] = nil ) do={
   :log info ("DynDNS: No ip address on $interfac .")
} else={
    :for i from=( [:len $ipfresh] - 1) to=0 do={ 
      :if ( [:pick $ipfresh $i] = "/") do={ 
        :set ipfresh [:pick $ipfresh 0 $i];
      } 
    }

  :global ipddns [:resolve $ddnshost];

  :if ($ipddns != $ipfresh) do={
    :log info "DynDNS: $ipddns != $ipfresh, Sending update!";
    /tool fetch user=$ddnsuser password=$ddnspass keep-result="no" \
     url="https://dyndns.loopia.se/index.html?hostname=$ddnshost&myip=$ipfresh&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG" 
    :log info "DynDNS: IP updated to $ipfresh!"
  } else={
    :log info "DynDNS: $ipddns == $ipfresh, No update needed";
  }
}