Community discussions

MikroTik App
 
Stfn
just joined
Topic Author
Posts: 1
Joined: Sun Apr 23, 2017 12:46 am

SPDNS Update Script

Sun Apr 23, 2017 12:47 am

Hi Guys n Gals,

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

Thanks!
 
petertosh
Frequent Visitor
Frequent Visitor
Posts: 58
Joined: Wed Mar 21, 2018 9:42 am

Re: SPDNS Update Script

Thu Jan 17, 2019 11:02 pm

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: viewtopic.php?t=58904#p301494
: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;
}
 
dadoremix
Member Candidate
Member Candidate
Posts: 133
Joined: Sat May 14, 2011 11:31 am

Re: SPDNS Update Script

Mon Jan 28, 2019 10:46 pm

im watching last 2 script
and where is user ?
i see password and hostname .. but user ??
 
petertosh
Frequent Visitor
Frequent Visitor
Posts: 58
Joined: Wed Mar 21, 2018 9:42 am

Re: SPDNS Update Script

Tue Aug 13, 2019 6:31 pm

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.
 
petertosh
Frequent Visitor
Frequent Visitor
Posts: 58
Joined: Wed Mar 21, 2018 9:42 am

Re: SPDNS Update Script

Tue Feb 04, 2020 10:49 am

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;
}

Who is online

Users browsing this forum: Mosfet, pellerb and 64 guests