Community discussions

MikroTik App
 
routiti
just joined
Topic Author
Posts: 14
Joined: Mon May 02, 2016 10:39 pm
Location: Spain

Bug in RouterOS 6.38.1 with DDNS script

Wed Jan 25, 2017 7:35 pm

Hello. I have a script for update DDNS with a DNSoMatic Service . The last week I updated my router RB3011 the 6.38 to 6.38.1. Since the update the RouterOS doesn´t work my DNSoMatic script. I don´t change the configuration in this migration.

# DNSoMatic automatic DNS updates

#--------------- Change Values in this section to match your setup ------------------

# User account info of DNSoMatic

:local maticuser "email"
:local maticpass "password"

# Set the hostname or label of network to be updated. This is the part after the double colon (::) on the DNSoMatic services page.
# Hostnames with spaces are unsupported. Replace the value in the quotations below with your host names.
# To specify multiple hosts, separate them with commas.
# Use "all.dnsomatic.com" for the matichost to update all items in dnsomatic with this IP.

:local matichost "all.dnsomatic.com"

#------------------------------------------------------------------------------------

# No more changes need

:global previousIP;

:log info "Fetching current IP"

# Get the current public IP using DNS-O-Matic service.
/tool fetch url="https://myip.dnsomatic.com/" mode=https dst-path=mypublicip.txt

# Read the current public IP into the currentIP variable.
:local currentIP [/file get mypublicip.txt contents]

:log info "Fetched current IP as $currentIP"

:if ($currentIP != $previousIP) do={
:log info "DNSoMatic: Update needed"
:set previousIP $currentIP

# The update URL. Note the "\3F" is hex for question mark (?). Required since ? is a special character in commands.
:local url "https://updates.dnsomatic.com/nic/updat ... ckmx=NOCHG"
:local matichostarray;
:set matichostarray [:toarray $matichost];
:foreach host in=$matichostarray do={
:log info "DNSoMatic: Sending update for $host"
/tool fetch url=($url . "&hostname=$host") user=$maticuser password=$maticpass mode=http dst-path=("dnsomaticupdate-" . $host . ".txt")
:log info "DNSoMatic: Host $host updated on DNSoMatic with IP $currentIP"
}
} else={
:log info "DNSoMatic: Previous IP $previousIP and current IP equal, no update need"
}
 
IntrusDave
Forum Guru
Forum Guru
Posts: 1286
Joined: Fri May 09, 2014 4:36 am
Location: Rancho Cucamonga, CA

Re: Bug in RouterOS 6.38.1 with DDNS script

Wed Jan 25, 2017 8:37 pm

I get no errors with the script.
 
routiti
just joined
Topic Author
Posts: 14
Joined: Mon May 02, 2016 10:39 pm
Location: Spain

Re: Bug in RouterOS 6.38.1 with DDNS script

Wed Jan 25, 2017 8:51 pm

The script execute correctly but does not synchronize the ip with dnsomatic
 
IntrusDave
Forum Guru
Forum Guru
Posts: 1286
Joined: Fri May 09, 2014 4:36 am
Location: Rancho Cucamonga, CA

Re: Bug in RouterOS 6.38.1 with DDNS script

Wed Jan 25, 2017 8:55 pm

Do not appear to be an issue with RouterOS. Tested on 6.38.1 and it updated correctly.
 
SystemErrorMessage
Member
Member
Posts: 383
Joined: Sat Dec 22, 2012 9:04 pm

Re: Bug in RouterOS 6.38.1 with DDNS script

Wed Feb 15, 2017 4:32 am

i use a better method instead. I take the IP address of the interface and use that so theres no writing to flash or any need to add more global variables.

its good to see the scripts updated with https instead. My DDNS script isnt just to update DDNS but also to update openDNS as well but i use a seperate script for that. The scheduler that i set to run it every 5 minutes doesnt work ever since routerOS 6.37.

For those curious my script is really simple.
:local IpCurrent [/ip address get [find interface=$WANInter] address];
:for i from=( [:len $IpCurrent] - 1) to=0 do={
:if ( [:pick $IpCurrent $i] = "/") do={
:local NewIP [:pick $IpCurrent 0 $i];
#:if ([:resolve $NOIPDomain] != $NewIP) do={
/tool fetch mode=https user=$NOIPUser password=$NOIPPass url="https://dynupdate.no-ip.com/nic/update\ ... yip=$NewIP" keep-result=no
:log info "NO-IP Update: $NOIPDomain - $NewIP"
#}
}
}

with https your password isnt sent using plaintext (weakness of mikrotik scripting). You only need to use an external result for your IP address and store if your router is behind another router and it doesnt have a public IP address (in the case of double NAT). I imagine it is easy to use with ipv6 or even different services as well and i can run this script often without wearing out the flash. If only we could use one of the standard scripting languages common on linux such as python or perl.
 
IntrusDave
Forum Guru
Forum Guru
Posts: 1286
Joined: Fri May 09, 2014 4:36 am
Location: Rancho Cucamonga, CA

Re: Bug in RouterOS 6.38.1 with DDNS script

Wed Feb 15, 2017 4:36 am

If possible, you should use
/ip cloud public-address
. The Interface address may not always be a public IP address.
 
SystemErrorMessage
Member
Member
Posts: 383
Joined: Sat Dec 22, 2012 9:04 pm

Re: Bug in RouterOS 6.38.1 with DDNS script

Wed Feb 15, 2017 5:11 am

If possible, you should use
/ip cloud public-address
. The Interface address may not always be a public IP address.
Good one, i wasnt sure how to use it. Being able to use that directly rather than writing to flash is a lot better as you could simplify scripts even more.

Who is online

Users browsing this forum: Google [Bot], jaclaz, MikeKulls, reman6110, roemer, tikmakro and 109 guests