DDNS script for no-ip dyndns ipchange

I’ve seen some ddns scripts around here but usually these were having some compatibility issues on on newer RouterOS. I’d like to share what I use.

It works even if you’re behind 2nd nat since it relies on an external service to get your ip.

DynDNS
:local DDNSuser “login”
:local DDNSpass “password”
:local DDNShost “domain.dyndns.info”

:local CURRip [/tool fetch url=“http://myip.dnsomatic.com/index.html” mode=http dst-path=CURRip; :delay 1; /file get CURRip contents; /file remove CURRip]
if ([:resolve $DDNShost] != $CURRip) do={
/tool fetch url=“http://members.dyndns.org/nic/update?hostname=$DDNShost&myip=$CURRip” mode=http user=$DDNSuser password=$DDNSpass dst-path=DDNShost keep-result=no;
/log info message=(“DDNS: Updating $DDNShost to:$CURRip”)
}NO-IP
:local DDNSuser “login”
:local DDNSpass “password”
:local DDNShost “domain.no-ip.com

:local CURRip [/tool fetch url=“http://myip.dnsomatic.com/index.html” mode=http dst-path=CURRip; :delay 1; /file get CURRip contents; /file remove CURRip]
if ([:resolve $DDNShost] != $CURRip) do={
/tool fetch url=“http://dynupdate.no-ip.com/nic/update?hostname=$DDNShost&myip=$CURRip” mode=http user=$DDNSuser password=$DDNSpass dst-path=DDNShost keep-result=no;
/log info message=(“DDNS: Updating $DDNShost to:$CURRip”)
}ChangeIP
:local DDNSuser “login”
:local DDNSpass “password”
:local DDNShost “domain.changeip.com

:local CURRip [/tool fetch url=“http://myip.dnsomatic.com/index.html” mode=http dst-path=CURRip; :delay 1; /file get CURRip contents; /file remove CURRip]
if ([:resolve $DDNShost] != $CURRip) do={
/tool dns-update name=$DDNShost address=$CURRip key-name=$DDNSuser key=$DDNSpass
/log info message=(“DDNS: Updating $DDNShost to:$CURRip”)
}

I fix some minor errors.

:local DDNSuser value="login";
:local DDNSpass value="password";
:local DDNShost value="domain.dyndns.info";

# possible value are DynDNS, No-IP, ChangeIP;
:local DDNStype value="DynDNS";

/tool fetch mode=http keep-result=yes url="http://myip.dnsomatic.com/index.html" dst-path="CURRip";
/delay delay-time=2s;
:local CURRip value=[:toip [/file get "CURRip" value-name=contents]];
/delay delay-time=2s;
/file remove "CURRip";

:if ([:resolve $DDNShost] != $CURRip) do={
 :if ($DDNStype = "DynDNS") do={ /tool fetch mode=http keep-result=no url="http://members.dyndns.org/nic/update?hostname=$DDNShost&myip=$CURRip" user=$DDNSuser password=$DDNSpass; };
 :if ($DDNStype = "No-IP") do={ /tool fetch mode=http keep-result=no url="http://dynupdate.no-ip.com/nic/update?hostname=$DDNShost&myip=$CURRip" user=$DDNSuser password=$DDNSpass; };
 :if ($DDNStype = "ChangeIP") do={ /tool dns-update name=$DDNShost address=$CURRip key-name=$DDNSuser key=$DDNSpass; };
 /log info message=($DDNStype.": Updating ".$DDNShost." to:".$CURRip);
};

Any chances that there will be a feature implemented to use

:local CURRip [/tool fetch url="http://myip.dnsomatic.com/index.html" mode=http dst-path=CURRip keep-file=no;]

instead of

:local CURRip [/tool fetch url="http://myip.dnsomatic.com/index.html" mode=http dst-path=CURRip; :delay 1; /file get CURRip contents; /file remove CURRip]

it’s norma behaviour, because fetch is one command to get file, not one remote variable.
At max add one paramater like continue-script-when-done=true/false

This is the no-ip script I use:



:global scriptemail
:global ddnsurl1
:global ddnsurl2

:local wanipchecklast
:local wanipchecknow
:local wanipchanged “no”

:local ddnsuser “xxx”
:local ddnspass "xxx
:local ddnshost1 “xxx”
:local ddnshost2 “xxx”


:log info “******************** starting - ddns********************”
:log info “-”

/tool fetch url=“http://www.ipmon.co.za/ip.php” dst-path=“ddns wan ip address.txt”
:log info “checkking for wan ip address”

:set wanipchecklast [/ip firewall address-list get value-name=comment number=[find list=“my wan ip”]]
:set wanipchecknow "$[/file get “ddns wan ip address.txt” contents] "

:log info “current wan ip address: $wanipchecknow”
:log info “prevouis wan ip address: $wanipchecklast”

:log info “$[/system identity get name] wan ip address http://$wanipchecknow

:if ($wanipchecknow != $wanipchecklast) do={

:log info “wan ip address has chaged”

:set wanipchanged “yes”

/ip firewall address-list set comment=$wanipchecknow number=[find list=“my wan ip”]

:log warning “$[/system identity get name] wan ip address changed: $wanipchecklast → $wanipchecknow”

:log info “updateing ddns host $ddnshost”

/tool fetch mode=http user=$ddnsuser password=$ddnspass url=“http://dynupdate.no-ip.com/nic/update\3Fhostname=$ddnshost1&myip=$wanipchecknow” dst-path=“ddns update result.txt” keep-result=yes

:delay 15s;

/tool fetch mode=http user=$ddnsuser password=$ddnspass url=“http://dynupdate.no-ip.com/nic/update\3Fhostname=$ddnshost2&myip=$wanipchecknow” dst-path=“ddns update result.txt” keep-result=yes

:set ddnsurl1 “http://dynupdate.no-ip.com/nic/update\3Fhostname=$ddnshost1&myip=$wanipchecknow
:set ddnsurl2 “http://dynupdate.no-ip.com/nic/update\3Fhostname=$ddnshost2&myip=$wanipchecknow

:log info "ddns result: $[/file get “ddns update result.txt” contents] "

}

:if ($wanipchanged = “yes”) do={

:log info “generating ddns email report”

:global scriptemail

:local logcontenttemp “”
:local logcontent “”

:set logcontenttemp “Good Day \n\r”
:set logcontent (“$logcontent
" .”$logcontenttemp")

:set logcontenttemp “This is an automated notification, please do not reply to this email”
:set logcontent (“$logcontent
" .”$logcontenttemp")

:set logcontenttemp “Please see below ddns update email report: \n\r”
:set logcontent (“$logcontent
" .”$logcontenttemp")

:set logcontenttemp “******ddns report
:set logcontent (“$logcontent
" .”$logcontenttemp")

:set logcontenttemp “Current wan ip address: $wanipchecknow \n\r”
:set logcontent (“$logcontent
" .”$logcontenttemp")

:set logcontenttemp “Prevouis wan ip address: $wanipchecklast \n\r”
:set logcontent (“$logcontent
" .”$logcontenttemp")

:set logcontenttemp “Update url: $ddnsurl1 \n\r”
:set logcontent (“$logcontent
" .”$logcontenttemp")

:set logcontenttemp “Update url: $ddnsurl2 \n\r”
:set logcontent (“$logcontent
" .”$logcontenttemp")

:set logcontenttemp “Update url result: $[/file get “ddns update result.txt” contents] \n\r”
:set logcontent (“$logcontent
" .”$logcontenttemp")

:set logcontenttemp “\n\r”
:set logcontent (“$logcontent
" .”$logcontenttemp")

:set logcontenttemp “***************************************************************************************”
:set logcontent (“$logcontent
" .”$logcontenttemp")

:set logcontenttemp “KEY: \n\r”
:set logcontent (“$logcontent
" .”$logcontenttemp")

:set logcontenttemp “Should you have any queries, please contact your account manager”
:set logcontent (“$logcontent
" .”$logcontenttemp")

:set logcontenttemp “\n\r”
:set logcontent (“$logcontent
" .”$logcontenttemp")

:set logcontenttemp “Kind Regrads”
:set logcontent (“$logcontent
" .”$logcontenttemp")

/tool e-mail send to=$scriptemail subject=“$[/system identity get name] ddns report” body=“$logcontent” start-tls=yes

}

:log info “******************** ending - ddns ********************”

Hi folks!

Can you re-post the whole working update script for 6.18/ 6.19?

Kindly highlight the fields that needs to be edited.

Thank you.

Send me a email and ill send it to you werner.venter.mail@gmail.com

Why not post it here instead requre the email?

Hi folks!

Below is the script shared to me by Mr. Werner:


:global lastddnsupdate
:global ddnsurl1

:local wanipchecklast
:local wanipchecknow
:local wanipchanged “no”

:local ddnsuser “user”
:local ddnspass “password”
:local ddnshost1 “x.zapto.org

:log info “******************** starting - ddns********************”
:log info “-”

/tool fetch url=“http://www.ipmon.co.za/ip.php” dst-path="ddns wan ip

address.txt"
:log info “checkking for wan ip address”

:set wanipchecklast [/ip firewall address-list get value-name=comment number=

[find list=“my wan ip”]]
:set wanipchecknow "$[/file get “ddns wan ip address.txt” contents] "

:log info “current wan ip address: $wanipchecknow”
:log info “prevouis wan ip address: $wanipchecklast”

:log warning “$[/system identity get name] wan ip address http://$wanipchecknow

:if ($wanipchecknow != $wanipchecklast) do={

:log info “wan ip address has chaged”

:set wanipchanged “yes”

/ip firewall address-list set comment=$wanipchecknow number=[find list="my wan

ip"]

:log warning "$[/system identity get name] wan ip address changed:

$wanipchecklast → $wanipchecknow"

:log info “updateing ddns host $ddnshost”

/tool fetch mode=http user=$ddnsuser password=$ddnspass

url="http://dynupdate.no-ip.com/nic/update\3Fhostname=$ddnshost1&myip=

$wanipchecknow" dst-path=“ddns update result.txt” keep-result=yes

:delay 15s;

:set ddnsurl1 "http://dynupdate.no-ip.com/nic/update\3Fhostname=

$ddnshost1&myip=$wanipchecknow"

:log info "ddns result: $[/file get “ddns update result.txt” contents] "

}

Mr. Werner’s note: "Just remember to add a address list item list = my wan ip as this is used to store the wan ip

/ip firewall address-list
add comment=0.0.0.0 list=“my wan ip” "

Can someone verify the script?

Thank you.

Initially you just have to add

/ip firewall address-list add comment=0.0.0.0 list=“my wan ip”

Cloud ip in mikrotik firewall works great for me and i forgot all about those like dydns sites!

O yeah!

Thanks, men. No script needed. I was able to obtain a DNS Name.

I’m just wondering with the security of this feature?

has anyone a working script for dyndns.org?

Check my script futhet up

Hi Folks,

an original script posted on Mikrotik wiki was based on comparing interface IP.
The new scripts posted above rely on web services. This new method doesn’t work if one have multiple ISPs.
Can anyone share a script that works for specific WAN interface for multiple ISP environment?