SPDNS Update Script

Hi Guys n Gals,

does anyone have a working script for Updating DNS on Spdns.de?

Thanks!

Ok, this is late, but I used another script from the forum and this works right now:

# Set needed variables
:local password "YOUR-PASSWORD"
:local hostname "YOUR-HOSTNAME"

:global dyndnsForce
:global previousIP

# print some debug info
:log info ("UpdateDynDNS: hostname = $hostname")
:log info ("UpdateDynDNS: previousIP = $previousIP")

# get the current IP address from the internet (in case of double-nat)
/tool fetch mode=http address="checkip4.spdns.de" src-path="/" dst-path="/dyndns.checkip.html"
:local result [/file get dyndns.checkip.html contents]

:local currentIP $result
:log info "UpdateDynDNS: currentIP = $currentIP"

# Remove the # on next line to force an update every single time - useful for debugging,
# but you could end up getting blacklisted by DynDNS!

#:set dyndnsForce true


# Determine if dyndns update is needed
# more dyndns updater request details available at Perform Update - Dyn
:if (($currentIP != $previousIP) || ($dyndnsForce = true)) do={
:set dyndnsForce false
:set previousIP $currentIP
/tool fetch mode=https address="update.spdyn.de" \
src-path="nic/update?hostname=$hostname&myip=$currentIP&user=$hostname&pass=$password" dst-path="/dyndns.txt"
:local result [/file get dyndns.txt contents]
:log info ("UpdateDynDNS: Dyndns update needed")
:log info ("UpdateDynDNS: Dyndns Update Result: ".$result)
:put ("Dyndns Update Result: ".$result)
} else={
:log info ("UpdateDynDNS: No dyndns update needed")
}

Important: The script needs the following policies: ftp, read, policy, write, test. Without policy it would constantly force-update the record. And in this case I use the “Update-Token” as a password.

Thanks to all who shared their examples and the hints about the policy.

Even better is following script because it doesn’t need to save to NAND. Source: http://forum.mikrotik.com/t/dyndns-org-script-now-to-remove-all-log-info/53828/1

:global currentIP;
:local password "YOUR-PASSWORD"
:local hostname "YOUR-HOSTNAME"

:local tmpIP [/ip address get [find interface="pppoe-out1"] address];
:local myIP [:pick $tmpIP 0 [:find $tmpIP "/"]];

:if ($myIP != $currentIP) do={
    :log info "WAN IP address changed from $currentIP to $myIP"
    :set currentIP $myIP;
    /tool fetch mode=https address="update.spdyn.de" \
src-path="nic/update?hostname=$hostname&myip=$currentIP&user=$hostname&pass=$password" keep-result=no;
}

im watching last 2 script
and where is user ?
i see password and hostname .. but user ??

User is the same as hostname, see

user=$hostname

in the second script. The password is the token that you can create at the SPDYN user backend.

I don’t know what changed, but lately the script from above failed to update. This is what I changed it to, it works at the moment:

:global currentIP;
:local password "XXXXXX";
:local hostname "XXXXXX";

:local tmpIP [/ip address get [find interface="pppoe-out1"] address];
:local myIP [:pick $tmpIP 0 [:find $tmpIP "/"]];

:if ($myIP != $currentIP) do={
    :log info "WAN IP address changed from $currentIP to $myIP"
    :set currentIP $myIP;
    /tool fetch mode=https url="https://update.spdyn.de/nic/update\?hostname=$hostname&myip=$currentIP&user=$hostname&pass=$password" keep-result=no;
}