Community discussions

MikroTik App
 
dg3feh
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 68
Joined: Mon Jan 30, 2017 10:52 am

DDNS for different providers

Wed Feb 01, 2017 12:43 am

Hello!

I did some changes on the DDNS-script given by the Wiki in order to use different providers and protocols:

:global ddnsuser "USERNAME"
:global ddnspass "PASSWORD"
:global theinterface "INTERFACEtoWAN"
:global ddnshost DOMAINNAME
:global ddnsserver SERVERNAME
:global protocol http or https
:global ipddns [:resolve $ddnshost];
:global ipfresh [ /ip address get [/ip address find interface=$theinterface ] address ]
:if ([ :typeof $ipfresh ] = nil ) do={
:log info ("DynDNS: No ip address on $theinterface .")
} else={
:for i from=( [:len $ipfresh] - 1) to=0 do={
:if ( [:pick $ipfresh $i] = "/") do={
:set ipfresh [:pick $ipfresh 0 $i];
}
}

:if ($ipddns != $ipfresh) do={
:log info ("DynDNS: IP-DynDNS = $ipddns")
:log info ("DynDNS: IP-Fresh = $ipfresh")
:log info "DynDNS: Update IP needed, Sending UPDATE...!"
:global str "/nic/update\?hostname=$ddnshost&myip=$ipfresh&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG"
/tool fetch address=$ddnsserver src-path=$str mode=$protocol user=$ddnsuser \
password=$ddnspass dst-path=("/DynDNS.".$ddnshost)
:delay 1
:global str [/file find name="DynDNS.$ddnshost"];
/file remove $str
:global ipddns $ipfresh
:log info "DynDNS: IP updated to $ipfresh!"
} else={
# uncomment line below if u wanna have all checks in the log
# :log info "DynDNS: dont need changes";
}
}


Have fun, Holger