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”;
} }
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…!”
I found this thread when googling how to get my system to work with dynu. It helped me to understand what to do.
However, I don’t think it’s necessary for the script to keep track of IP address.
Sure it works, but your DDNS provider may be less excited, because you’re doing useless updates that don’t really change anything, and putting extra load on their server. And obviously, you’re not going to overload it yourself, but if everyone did it this way, and not everyone would see once an hour as enough, … you get the idea.
Why is that no one keeps track of the current dynamic IPv6 from the router? Is that because the obtained IPv6 is a suffixed address and not a complete one as you can get from a peripheral?