Community discussions

MikroTik App
 
Beone
Trainer
Trainer
Topic Author
Posts: 250
Joined: Fri Feb 11, 2011 1:11 pm

Dyndns script that DOESN'T write to flash every minute.

Sun Aug 28, 2011 10:57 pm

Hi,

Am I the only one worrying here that the dyndns scripts available here all write to flash every minute? (if you set the scheduler to one minute of course) Isn't there a way to write the result of /tool fetch to a variable in ram instead of a file? Or any other way that doesn't write to the flash of the router?

Kind regards,
B
 
fewi
Forum Guru
Forum Guru
Posts: 7717
Joined: Tue Aug 11, 2009 3:19 am

Re: Dyndns script that DOESN'T write to flash every minute.

Mon Aug 29, 2011 12:00 am

You can't fetch a file into RAM, and you can't check the IP address otherwise. Your only workaround would be to use an external box to check and update DynDNS - either behind the router, or via the API.
 
Beone
Trainer
Trainer
Topic Author
Posts: 250
Joined: Fri Feb 11, 2011 1:11 pm

Re: Dyndns script that DOESN'T write to flash every minute.

Mon Aug 29, 2011 7:47 am

You can't fetch a file into RAM, and you can't check the IP address otherwise. Your only workaround would be to use an external box to check and update DynDNS - either behind the router, or via the API.
Ok, thx. I thought maybe the ip address could be written to a variable in ram instead of to a file, strange this isn't possible.
Do you use it (writing to flash every minute)?
If yes, did you experience problems with broken flash memory on the router?
Another box behind the router is no option in our setups.

Kind regards & thx

PS I would expect a dyndns client is included by default in RouterOS.
 
fewi
Forum Guru
Forum Guru
Posts: 7717
Joined: Tue Aug 11, 2009 3:19 am

Re: Dyndns script that DOESN'T write to flash every minute.

Mon Aug 29, 2011 8:00 am

I do not. I have static IPs.

You can lobby with support@mikrotik.com for a feature request and try to get a built in client that uses RAM.
 
changeip
Forum Guru
Forum Guru
Posts: 3830
Joined: Fri May 28, 2004 5:22 pm

Re: Dyndns script that DOESN'T write to flash every minute.

Mon Aug 29, 2011 6:07 pm

Our changeip.com original script does this all in ram. it works based on the interface changing its ip address, there is no remote detection however. it also uses SSL whereas fetch does not.
 
Beone
Trainer
Trainer
Topic Author
Posts: 250
Joined: Fri Feb 11, 2011 1:11 pm

Re: Dyndns script that DOESN'T write to flash every minute.

Mon Aug 29, 2011 9:33 pm

Our changeip.com original script does this all in ram. it works based on the interface changing its ip address, there is no remote detection however. it also uses SSL whereas fetch does not.
Where can i find that script? I would like to take a look at it.

Kind regards,
B
 
changeip
Forum Guru
Forum Guru
Posts: 3830
Joined: Fri May 28, 2004 5:22 pm

Re: Dyndns script that DOESN'T write to flash every minute.

Mon Aug 29, 2011 11:18 pm

This one should work well to keep writes down since its all in memory:

http://www.changeip.com/mikrotik/

If you use the 5.x link you can see it uses remote detection and will write to flash.

If you cant get that script to run on 5.x let me know, it might just need some syntax changes possibly.

Thx,
Sam
 
Beone
Trainer
Trainer
Topic Author
Posts: 250
Joined: Fri Feb 11, 2011 1:11 pm

Re: Dyndns script that DOESN'T write to flash every minute.

Tue Aug 30, 2011 2:23 pm

This one should work well to keep writes down since its all in memory:

http://www.changeip.com/mikrotik/

If you use the 5.x link you can see it uses remote detection and will write to flash.

If you cant get that script to run on 5.x let me know, it might just need some syntax changes possibly.

Thx,
Sam

Hi Sam,

Thx, I will take a look at it and see if it works for us.

kind regards,
B
 
User avatar
elgo
Member Candidate
Member Candidate
Posts: 151
Joined: Sat Apr 02, 2011 2:34 am
Location: France

Re: Dyndns script that DOESN'T write to flash every minute.

Tue Aug 30, 2011 5:45 pm

OMG, there a PLENTY of dyndns variant scripts! Choose one which doesn't need a flash write for getting its address.
       # Set needed variables
       :local username "fiosdfhgsdfg"
       :local password "koikerterteroi"
       :local hostname "tertertger.dyndns.org"
       :local waninterface "pppoe-fibre"
       :local pingTarget 8.8.8.8

       :global dyndnsForce
       :global previousIP
       #:global dyndnsLock

       # print some debug info
       #:log info ("UpdateDynDNS: username = $username")
       #:log info ("UpdateDynDNS: password = $password")
       #:log info ("UpdateDynDNS: hostname = $hostname")

       # Lock avoiding double execution
       #:if ([ :typeof $dyndnsLock ] = nil ) do={
       #    :set dyndnsLock false
       #}
       #:if ($dyndnsLock = true) do={
       #    :log warning ("UpdateDynDNS: script-dynDNS already running")
       #    :error "UpdateDynDNS: script-dynDNS already running"
       #}

       # set the lock
       #:set dyndnsLock true

       # test WAN link, so that no crash when trying to reach http
       :if ([/ping $pingTarget interval=2 count=3]!=3) do={
           :log warning ("UpdateDynDNS: WAN target unreachable ($pingTarget)")
       # free the lock
       #    :set IPtoGMAILLock false
           :error "UpdateDynDNS: WAN target unreachable ($pingTarget)"
       }
       # disabled because web server doesn't not answer to ping requests
       #:set pingTarget [:resolve members.dyndns.org server=$pingTarget]
       #:if ([/ping $pingTarget interval=2 count=3]!=3) do={
       #    :log warning ("UpdateDynDNS: WAN target unreachable ($pingTarget)")
       # free the lock
       #    :set IPtoGMAILLock false
       #    :error "UpdateDynDNS: WAN target unreachable ($pingTarget)"
       #}

       # get the current IP address from
       :local currentNET [/ip address get [/ip address find interface=$waninterface] address]
       :local currentIP [ :pick $currentNET 0 [ :find $currentNET "/" ] ]

       # Remove the # on next line to force an update every single time - useful for debugging, but you could end up getting blacklisted by DynDNS!
       #:set dyndnsForce true

       # Determine if dyndns update is needed
       # more dyndns updater request details available at http://www.dyndns.com/developers/specs/syntax.html
       # Did we get an IP address to compare?
       :if ([ :typeof $currentIP ] = nil ) do={
          :log info ("UpdateDynDNS: No ip address present on " . $waninterface . ", please check.")
       } else={

           :if (($dyndnsForce = true) || ([ :typeof $previousIP ] = nil) || ($currentIP != $previousIP)) do={
               :set dyndnsForce false
               :log info ("UpdateDynDNS: Dyndns update needed")
               :log info ("UpdateDynDNS: previousIP = $previousIP --> currentIP = $currentIP")
               /tool fetch user=$username password=$password mode=http address="members.dyndns.org" src-path="/nic/update\?hostname=$hostname&myip=$currentIP" dst-path="/dyndns.txt"
               :set previousIP $currentIP
               :local result [/file get dyndns.txt contents]
               :log info ("UpdateDynDNS: Dyndns Update Result: ".$result)
               :put ("Dyndns Update Result: ".$result)
           } else={
       #        :log info ("UpdateDynDNS: No dyndns update needed")
           }
       }

       # free the lock
       #:set dyndnsLock false

This one is now "robust" (lost routerboard many times before figuring out that WAN link had to be ready before doing anything: commands likely crash with the whole shell rather than returning an error code).

Who is online

Users browsing this forum: jcjc81 and 27 guests