Community discussions

MikroTik App
 
ovdeathiam
just joined
Topic Author
Posts: 20
Joined: Wed Jul 16, 2014 11:15 am

DDNS script for no-ip dyndns ipchange

Wed Jul 16, 2014 12:13 pm

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

ros code

: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?ho ... ip=$CURRip" mode=http user=$DDNSuser password=$DDNSpass dst-path=DDNShost keep-result=no;
    /log info message=("DDNS: Updating $DDNShost to:$CURRip")
    }
NO-IP

ros code

: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?h ... ip=$CURRip" mode=http user=$DDNSuser password=$DDNSpass dst-path=DDNShost keep-result=no;
    /log info message=("DDNS: Updating $DDNShost to:$CURRip")
    }
ChangeIP

ros code

: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")
    }
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 2954
Joined: Tue Feb 25, 2014 12:49 pm
Location: Capalbio, Tuscany, Italy

Re: DDNS script for no-ip dyndns ipchange

Wed Jul 16, 2014 1:16 pm

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);
};
Last edited by rextended on Wed Jul 16, 2014 2:07 pm, edited 1 time in total.
I'm Italian, not English. Sorry for my imperfect grammar.
 
ovdeathiam
just joined
Topic Author
Posts: 20
Joined: Wed Jul 16, 2014 11:15 am

Re: DDNS script for no-ip dyndns ipchange

Wed Jul 16, 2014 1:34 pm

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]
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 2954
Joined: Tue Feb 25, 2014 12:49 pm
Location: Capalbio, Tuscany, Italy

Re: DDNS script for no-ip dyndns ipchange

Wed Jul 16, 2014 2:05 pm

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
I'm Italian, not English. Sorry for my imperfect grammar.
 
wcsnet
Frequent Visitor
Frequent Visitor
Posts: 59
Joined: Mon Apr 29, 2013 12:43 pm
Location: South Africa

Re: DDNS script for no-ip dyndns ipchange

Wed Jul 30, 2014 9:23 am

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\3 ... ipchecknow" 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\3 ... ipchecknow" dst-path="ddns update result.txt" keep-result=yes

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

: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 ********************"
Kind Regards

WERNER VENTER
Technical Support Engineer

Werner.venter.mail@gmail.com
 
kei888
newbie
Posts: 47
Joined: Fri Feb 07, 2014 7:54 am

Re: DDNS script for no-ip dyndns ipchange

Fri Aug 29, 2014 4:40 am

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.
 
wcsnet
Frequent Visitor
Frequent Visitor
Posts: 59
Joined: Mon Apr 29, 2013 12:43 pm
Location: South Africa

Re: DDNS script for no-ip dyndns ipchange

Fri Aug 29, 2014 9:27 pm

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

WERNER VENTER
Technical Support Engineer

Werner.venter.mail@gmail.com
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 2954
Joined: Tue Feb 25, 2014 12:49 pm
Location: Capalbio, Tuscany, Italy

Re: DDNS script for no-ip dyndns ipchange

Fri Aug 29, 2014 10:09 pm

Send me a email and ill send it to you werner.venter.mail@gmail.com
Why not post it here instead requre the email?
I'm Italian, not English. Sorry for my imperfect grammar.
 
kei888
newbie
Posts: 47
Joined: Fri Feb 07, 2014 7:54 am

Re: DDNS script for no-ip dyndns ipchange

Tue Sep 02, 2014 2:53 pm

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\3 ... ost1&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.
 
wcsnet
Frequent Visitor
Frequent Visitor
Posts: 59
Joined: Mon Apr 29, 2013 12:43 pm
Location: South Africa

Re: DDNS script for no-ip dyndns ipchange

Tue Sep 02, 2014 3:10 pm

Initially you just have to add

/ip firewall address-list add comment=0.0.0.0 list="my wan ip"
Kind Regards

WERNER VENTER
Technical Support Engineer

Werner.venter.mail@gmail.com
 
freemannnn
Long time Member
Long time Member
Posts: 683
Joined: Sun Oct 13, 2013 7:29 pm

Re: DDNS script for no-ip dyndns ipchange

Tue Sep 02, 2014 8:40 pm

Cloud ip in mikrotik firewall works great for me and i forgot all about those like dydns sites!
 
kei888
newbie
Posts: 47
Joined: Fri Feb 07, 2014 7:54 am

Re: DDNS script for no-ip dyndns ipchange

Wed Sep 03, 2014 3:33 am

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?
 
Kampfwurst
Member Candidate
Member Candidate
Posts: 101
Joined: Mon Mar 24, 2014 2:53 pm

Re: DDNS script for no-ip dyndns ipchange

Sat Nov 22, 2014 12:08 am

has anyone a working script for dyndns.org?
 
wcsnet
Frequent Visitor
Frequent Visitor
Posts: 59
Joined: Mon Apr 29, 2013 12:43 pm
Location: South Africa

Re: DDNS script for no-ip dyndns ipchange

Sun Nov 23, 2014 2:53 pm

Check my script futhet up
Kind Regards

WERNER VENTER
Technical Support Engineer

Werner.venter.mail@gmail.com
 
lustyffh
newbie
Posts: 37
Joined: Thu Jul 05, 2012 11:46 pm

Re: DDNS script for no-ip dyndns ipchange

Fri Jan 09, 2015 12:34 pm

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?

Who is online

Users browsing this forum: igaunis and 26 guests