Community discussions

 
chryoung
just joined
Topic Author
Posts: 11
Joined: Sun Dec 18, 2016 8:31 pm

Dynu.com script for dynamic DNS

Sun Dec 18, 2016 8:36 pm

Hi,

My first post here and I'm also new to Router OS. I'm using Dynu for dynamic DNS so that I can remote to devices on my network which uses a dynamic IP for the WAN. Dynu provides this script but when I load it there are errors. Maybe someone here can see obvious problems with the syntax? Thanks in advance for your help.

/system script
add name=Dynu
policy=read,write,test
source=":global ddnsuser your_Dynu_username
:global ddnspass "your_Dynu_password"
:global theinterface "WAN_Interface_Name"
:global ddnshost "your_Dynu_hostname"
:global ipddns [:resolve $ddnshost];
:global ipfresh [ /ip address get [/ip address find interface=$theinterface ] address ]
:if ([ :typeof $ipfresh ] = nil ) do={
:log info ("DynuDDNS: 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 ("DynuDDNS: IP-Dynu = $ipddns")
:log info ("DynuDDNS: IP-Fresh = $ipfresh")
:log info "DynuDDNS: Update IP needed, Sending UPDATE...!"
:global str "/nic/update?hostname=$ddnshost&myip=$ipfresh"
/tool fetch address=api.dynu.com src-path=$str mode=http user=$ddnsuser password=$ddnspass dst-path=("/Dynu.".$ddnshost)
:delay 1
:global str [/file find name="Dynu.$ddnshost"];
/file remove $str
:global ipddns $ipfresh
:log info "DynuDDNS: IP updated to $ipfresh!"
} else={
:log info "DynuDDNS: dont need changes";
} }
 
Matellito
just joined
Posts: 4
Joined: Fri Sep 14, 2012 5:02 am

Re: Dynu.com script for dynamic DNS

Sat Dec 31, 2016 12:59 am

Change your data
Configure in scheduler every 30 minutes
:global ddnsuser "Usernam Dynu.com"
:global ddnspass "Password Dynu.com"
:global theinterface "Interface"
:global ddnshost "domain.dynu.com"
:global ipddns [:resolve $ddnshost];
:global ipfresh [ /ip address get [/ip address find interface=$theinterface ] address ]
:if ([ :typeof $ipfresh ] = nil ) do={
:log info ("dynu: 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 ("dynu: IP-dynu = $ipddns")
:log info ("dynu: IP-Fresh = $ipfresh")
:log info "dynu: Update IP needed, Sending UPDATE...!"
:global str "/nic/update?hostname=$ddnshost&myip=$ipfresh"
/tool fetch address=api.dynu.com src-path=$str mode=http user=$ddnsuser password=$ddnspass dst-path=("/Dynu.".$ddnshost)
:delay 1
:global str [/file find name="Dynu.$ddnshost"];
/file remove $str
:global ipddns $ipfresh
:log info "dynu: IP updated to $ipfresh!"
} else={
:log info "dynu: dont need changes";
}
}
 
User avatar
k6ccc
Member
Member
Posts: 479
Joined: Fri May 13, 2016 12:01 am
Location: Glendora, CA, USA (near Los Angeles)

Re: Dynu.com script for dynamic DNS

Tue Feb 12, 2019 5:57 am

I know this is a two year old thread, but I'm in the same boat. I added info log entries all over the place and remarked every line and ran the script. Obviously it ran fine with just the log full of the log entries. I then started at the top and removed the remarks one line at a time until it bombed. In this configuration, I get the "Starting Dynu script", "Globals set", and "line 1" log entries and then nothing. Yes, the interface name is correct (in fact, I copied it directly from last night's .rsc file). Doing this on a model = RouterBOARD 750 r2 running RouterOS 6.43.2
:log info "Starting Dynu script"
:global ddnsuser "user name redacted"
:global ddnspass "password redacted"
:global theinterface "E1-p10_DSL_Internet"
:global ddnshost "The domain I'm trying to apply this to"
:log info "Globals set"
:global ipddns [:resolve $ddnshost];
:log info "line 1"
:global ipfresh [ /ip address get [/ip address find interface=$theinterface ] address ]
:log info "line 2"
# :if ([ :typeof $ipfresh ] = nil ) do={
:log info "line 3"
# :log info ("DynuDDNS: No IP address on $theinterface .")
:log info "line 4"
# } else={
:log info "line 5"
# :for i from=( [:len $ipfresh] - 1) to=0 do={
:log info "line 6"
# :if ( [:pick $ipfresh $i] = "/") do={
:log info "line 7"
# :set ipfresh [:pick $ipfresh 0 $i];
:log info "line 8"
# }
:log info "line 9"
# }
:log info "line 10"
# :if ($ipddns != $ipfresh) do={
:log info "line 11"
# :log info ("DynuDDNS: IP-Dynu = $ipddns")
:log info "line 12"
# :log info ("DynuDDNS: IP-Fresh = $ipfresh")
:log info "line 13"
# :log info "DynuDDNS: Update IP needed, Sending UPDATE...!"
:log info "line 14"
# :global str "/nic/update?hostname=$ddnshost&myip=$ipfresh"
:log info "line 15"
# /tool fetch address=api.dynu.com src-path=$str mode=http user=$ddnsuser password=$ddnspass dst-path=# ("/Dynu.".$ddnshost)
:log info "line 16"
# :delay 1
:log info "line 17"
# :global str [/file find name="Dynu.$ddnshost"];
:log info "line 18"
# /file remove $str
:log info "line 19"
# :global ipddns $ipfresh
:log info "line 20"
# :log info "DynuDDNS: IP updated to $ipfresh!"
:log info "line 21"
# } else={
:log info "line 22"
# :log info "DynuDDNS: dont need changes";
:log info "line 23"
# } }"
Any ideas? I fully admit that I know VERY little about scripting...
RB750Gr3, RB750r2, CRS326-24G-2S (in SwitchOS), CSS326-24G-2S, CSS106-5G-1S, RB260GS
Not sure if I beat them in submission, or they beat me into submission


Jim
 
HzMeister
Frequent Visitor
Frequent Visitor
Posts: 68
Joined: Sun Jan 28, 2018 9:48 pm

Re: Dynu.com script for dynamic DNS

Tue Feb 12, 2019 10:13 am

I just add the mikrotik ddns to "dns records" in dynu. No scripting necessary.
 
Kampfwurst
Frequent Visitor
Frequent Visitor
Posts: 68
Joined: Mon Mar 24, 2014 2:53 pm

Re: Dynu.com script for dynamic DNS

Fri Jul 05, 2019 9:12 am

I just add the mikrotik ddns to "dns records" in dynu. No scripting necessary.
can you explain it?

Who is online

Users browsing this forum: MSN [Bot] and 4 guests