Community discussions

 
dattl
just joined
Topic Author
Posts: 10
Joined: Sun Sep 27, 2015 1:57 pm

DDNS script for *.sn.mynetname.net with WAN interface behind NAT

Sun Sep 27, 2015 2:34 pm

#get mynetname hostname
:local hostname [/ip cloud get dns-name]

#resolve current dns-address
:local resolvedIP [:resolve "$hostname"]

#get current external IP
:local resolver [:resolve resolver1.opendns.com]
:local currentIP [:resolve myip.opendns.com server=$resolver]

#determine if DNS update is needed
:if ($currentIP != $resolvedIP) do={
   :log info ("Mynetname update needed: Current-IP: $currentIP Resolved-IP: $resolvedIP")
   /ip cloud force-update
} else={
   :log info ("Mynetname: No update needed ($currentIP=$resolvedIP)")
}
#schedule script every 5 minutes or so
#special thanks to thiagomedeiros for the trick with opendns
Last edited by dattl on Thu Sep 29, 2016 1:58 pm, edited 1 time in total.
 
User avatar
usef
just joined
Posts: 2
Joined: Sun Jul 10, 2016 8:10 am

Re: DDNS script for *.sn.mynetname.net with WAN interface behind NAT

Sun Jul 10, 2016 8:14 am

#some Variables
:local hostname [/ip cloud get dns-name]

#resolve current dns-address
:local resolvedIP [:resolve "$hostname"]

#get current external IP
tool fetch mode=http url="http://myip.dnsomatic.com/mypublicip.txt"
:delay 1
:local currentIP [/file get mypublicip.txt contents ]
/file remove "mypublicip.txt"

# Determine if DNS update is needed
:if ($currentIP != $resolvedIP) do={
   :log info ("Mynetname update needed: Current-IP: $currentIP Resolved-IP: $resolvedIP") 
   /ip cloud force-update
} else={
   :log info ("Mynetname: No update needed ($currentIP=$resolvedIP)")
}
#schedule script every 5 minutes or so
Hi
Great script.
Thank you
 
flynno
Member Candidate
Member Candidate
Posts: 241
Joined: Wed Aug 27, 2014 8:11 pm

Re: DDNS script for *.sn.mynetname.net with WAN interface behind NAT

Mon Jul 11, 2016 2:20 pm

Great, thank you
 
thiagomedeiros
just joined
Posts: 16
Joined: Tue Apr 03, 2012 10:38 pm

Re: DDNS script for *.sn.mynetname.net with WAN interface behind NAT

Sun Jul 31, 2016 9:19 pm

You don't need to fetch a file, replace this:
#get current external IP
tool fetch mode=http url="http://myip.dnsomatic.com/mypublicip.txt"
:delay 1
:local currentIP [/file get mypublicip.txt contents ]
/file remove "mypublicip.txt"
To this:
:global currentIP [:resolve myip.opendns.com server=208.67.222.222];
Will always return your public IP. Not needed to download/fetch a file.
Work in NAT too.
 
MasterXP
just joined
Posts: 24
Joined: Fri Jun 12, 2009 9:05 am

Re: DDNS script for *.sn.mynetname.net with WAN interface behind NAT

Fri Sep 09, 2016 4:01 pm

Great script, Thanks!
#some Variables
:local hostname [/ip cloud get dns-name]

#resolve current dns-address
:local resolvedIP [:resolve "$hostname"]

#get current external IP
tool fetch mode=http url="http://myip.dnsomatic.com/mypublicip.txt"
:delay 1
:local currentIP [/file get mypublicip.txt contents ]
/file remove "mypublicip.txt"

# Determine if DNS update is needed
:if ($currentIP != $resolvedIP) do={
   :log info ("Mynetname update needed: Current-IP: $currentIP Resolved-IP: $resolvedIP") 
   /ip cloud force-update
} else={
   :log info ("Mynetname: No update needed ($currentIP=$resolvedIP)")
}
#schedule script every 5 minutes or so
 
dattl
just joined
Topic Author
Posts: 10
Joined: Sun Sep 27, 2015 1:57 pm

Re: DDNS script for *.sn.mynetname.net with WAN interface behind NAT

Thu Sep 29, 2016 1:39 pm

You don't need to fetch a file, replace this:
#get current external IP
tool fetch mode=http url="http://myip.dnsomatic.com/mypublicip.txt"
:delay 1
:local currentIP [/file get mypublicip.txt contents ]
/file remove "mypublicip.txt"
To this:
:global currentIP [:resolve myip.opendns.com server=208.67.222.222];
Will always return your public IP. Not needed to download/fetch a file.
Work in NAT too.
Wonderful, I hated the fetch-file-part. Especially because i couldn`t get rid of the log entry produced by that!
Thank you!
 
Almohalla
just joined
Posts: 10
Joined: Fri Jan 15, 2016 7:31 pm

Re: DDNS script for *.sn.mynetname.net with WAN interface behind NAT

Wed Sep 06, 2017 10:15 pm

#get mynetname hostname
:local hostname [/ip cloud get dns-name]

#resolve current dns-address
:local resolvedIP [:resolve "$hostname"]

#get current external IP
:local resolver [:resolve resolver1.opendns.com]
:local currentIP [:resolve myip.opendns.com server=$resolver]

#determine if DNS update is needed
:if ($currentIP != $resolvedIP) do={
   :log info ("Mynetname update needed: Current-IP: $currentIP Resolved-IP: $resolvedIP")
   /ip cloud force-update
} else={
   :log info ("Mynetname: No update needed ($currentIP=$resolvedIP)")
}
#schedule script every 5 minutes or so
#special thanks to thiagomedeiros for the trick with opendns
Thanks for sharing..
It works with my rb750g which is for load balancing but with the main router i can ping the DNS Name but i can't connect to it with winbox !! any suggestion ?

Who is online

Users browsing this forum: No registered users and 10 guests