Community discussions

just joined
Topic Author
Posts: 1
Joined: Fri Jun 15, 2018 6:09 pm

DNSdynamic script for RouterOS v6

Fri Jun 15, 2018 6:23 pm

I want to use script to inform DNSdynamic about my ip.
I has changed example for No-IP and composed this script for DNSdynamic:
# DNSdynamic update
#User account info
:local dnsdynamicuser ""
:local dnsdynamicpass "YL6a1##DynaPietist"
:local dnsdynamichost ""

# Change to the name of interface that gets the dynamic IP address
:local inetinterface "pppoe-out-langate"

:global previousIP

:if ([/interface get $inetinterface value-name=running]) do={
# Get the current IP on the interfacea
   :local currentIP [/ip address get [find interface="$inetinterface" disabled=no] address]

# Strip the net mask off the IP address
   :for i from=( [:len $currentIP] - 1) to=0 do={
       :if ( [:pick $currentIP $i] = "/") do={ 
           :set currentIP [:pick $currentIP 0 $i]

   :if ($currentIP != $previousIP) do={
       :log info "IP: Current IP $currentIP is not equal to previous IP, update needed"
       :set previousIP $currentIP

# The update dnsdynamic URL. Note the "\3F" is hex for question mark (?). Required since ? is a special character in commands.
       :local url "\3Fhostname=$dnsdynamichost&myip=$currentIP"
       :log info "dnsdynamic: $url"
       :local dnsdynamichostarray
       :set dnsdynamichostarray [:toarray $dnsdynamichost]
       :foreach host in=$dnsdynamichostarray do={
           :log info "dnsdynamic: Sending update for $host"
           /tool fetch url=$url user=$dnsdynamicuser password=$dnsdynamicpass mode=https dst-path=("dnsdynamic_ddns_update-" . $host . ".txt")
           :log info "dnsdynamic: Host $host updated on dnsdynamic with IP $currentIP"
   }  else={
       :log info "IP: Previous IP $previousIP is equal to current IP, no update needed"
} else={
   :log info "IP: $inetinterface is not currently running, so therefore will not update."
I suppose, something is not correct here because "dnsdynamic: Host $host updated on dnsdynamic with IP $currentIP" doesn't appear in log.
Could you please help me to figure out what is incorrect?

RouterOS v6.40.4
Posts: 26
Joined: Thu Mar 01, 2018 3:32 pm

Re: DNSdynamic script for RouterOS v6

Tue Jul 17, 2018 7:28 pm

if you want you can use the DNS options that the mikrotik brings.

IP > Cloud - DNS Enable

And then use the DNS name that give you. I hope can help you.

And very important. I recommend you delete your information about your loggin in the because any can loggin and use that information against you.

User avatar
Posts: 232
Joined: Fri Jan 30, 2009 11:41 am
Location: Reading, UK

Re: DNSdynamic script for RouterOS v6

Tue Jul 17, 2018 7:38 pm

OMG, MSandoval! I didn't notice, that he included his real login information in the script! Thanks for pointing it out loud, so all of us now can notice it! :)
Forum Veteran
Forum Veteran
Posts: 735
Joined: Mon May 14, 2012 9:30 pm

Re: DNSdynamic script for RouterOS v6

Tue Jul 17, 2018 11:40 pm

I have resorted to using a script that writes all the user/pass/hostname to global variables at start up. Then my dyndns updater calls that info... so i don't make that mistake right there.
"It ain't what you don't know that gets you into trouble. It's what you know for sure that just ain't so."
Mark Twain

Who is online

Users browsing this forum: No registered users and 12 guests