Community discussions

MikroTik App
 
1001001
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 71
Joined: Mon Sep 24, 2012 12:46 pm

DynDNS update script periodically doesn't update

Fri Sep 04, 2015 9:53 am

Hi,

we have a self written dynDNS script running on our routers that work 99% of the time but doesn't in some cases.
We use dns as a means to get a heartbeat from all our routers, so its important that they phone home every minute or so.
I've checked erverything i can think of but can't figure out why in some cases it doesn't update dns.
The script itself runs just fine, it logs that it has checked for an updated ip and so on but the update doesn't make it to the server.

Does anyone have experience with dyndns scripts and their behaviour?
# set mandatory variables
:local username [/system identity get name ]
:local password "nrtestcase1"

:global dyndnsForce
:global previousIP

:log info ("previous IP is $previousIP")

# get currentIP to file currentip.txt
/tool fetch  mode=http url="http://ddns.xxxx.xx/nic/checkip" dst-path=/currentip.txt
# parse file currentip.txt for current IP
:local currentIP [/file get currentip.txt contents]

:set dyndnsForce true

# Update dynlan1.de
# The following checks first whether or not the currentIP matches the previousIP and based on that information either in case they don't match updates $username.dynlan1.de with the currentIP or in case they do match logs that no update was needed
:if (($currentIP != $previousIP) || ($dyndnsForce = true)) do={

:set dyndnsForce true
:set previousIP $currentIP
/tool fetch mode=http url="http://$username:$password@ddns.xxxx.xx/nic/update?hostname=$username&myip=$currentIP&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG" dst-path=/dyn.txt 
:set previousIP $currentIP
:log info ("Updated $username.xxxx.xx to $currentIP")
:log info ("current IP is $currentIP")
} else={
:log info ("$currentIP = $previousIP No update needed!")
}
 
dadoremix
Member Candidate
Member Candidate
Posts: 133
Joined: Sat May 14, 2011 11:31 am

DynDNS update script periodically doesn't update

Fri Sep 04, 2015 8:23 pm

See others post about dyndns, i have posted a working script
 
patrickmkt
Member Candidate
Member Candidate
Posts: 209
Joined: Sat Jul 28, 2012 5:21 pm

Re: DynDNS update script periodically doesn't update

Sun Sep 06, 2015 7:56 am

How often does your script run? Is there a limitation on your ddns server /checkip target that would refuse too many request within a short timeframe?

Same thing with the dns update, you've set the force to true. Your ddns will probably blacklist you when too many request to change an IP that hasn't changed.
 
dadoremix
Member Candidate
Member Candidate
Posts: 133
Joined: Sat May 14, 2011 11:31 am

DynDNS update script periodically doesn't update

Sun Sep 06, 2015 10:07 am

Time 6 min
Will not be blocked, because dyndns is payed account, vip user... That was with too many request in free option problem.
But dyndns was gone with free, now only works with payed acc