Community discussions

MikroTik App
 
ajmacias
newbie
Topic Author
Posts: 25
Joined: Mon Feb 14, 2011 11:44 am

Dyndns update script (another)

Wed Mar 30, 2011 3:20 am

Ok. I've having troubles with wiki dyndns updater script.
So i decide to write my own version.

Dyndns domain TTL is 60 seconds by default, so...
Resolving it after TTL instead check against checkip is NAT ok and flash friendly :)

I run my script every two minutes.
# Variables Locales
:local username "USERNAME"
:local password "PASSWORD"
:local hostname "HOSTNAME"
:local adslinterface "pppoe-out1"

####################################################
# actual IP
:local ipactual [ /ip address get [/ip address find interface=$adslinterface ] address ]
:set ipactual [:pick $ipactual 0 [ : find $ipactual "/" ] ]

# dyndns IP
:local ipremota [ :resolve $hostname ]

:if ($ipactual != $ipremota) do={
  :log info "-----------------= DynDNS Updater =-----------------"
  :log info "Host: $hostname"
  :log info "IP registrada: $ipremota"
  :log info "IP actual: $ipactual"
  :local str "/nic/update?hostname=$hostname&myip=$ipactual&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG"
  /tool fetch address=members.dyndns.org src-path=$str mode=http user=$username password=$password dst-path="ip_actual_dyndns.txt" keep-result=no
  :log info "-----------------=-=-=-= =-=-=-=-=-=-=-=----------------"
}
Sorry for my english!
 
jadu
Frequent Visitor
Frequent Visitor
Posts: 86
Joined: Sat Feb 05, 2011 9:22 am
Location: Bucharest - Constanta

Re: Dyndns update script (another)

Tue Apr 19, 2011 9:51 pm

This does not work for me at all. Nothing in log.
RB750G v5.1
 
ajmacias
newbie
Topic Author
Posts: 25
Joined: Mon Feb 14, 2011 11:44 am

Re: Dyndns update script (another)

Thu May 05, 2011 9:02 pm

Work for me in RB450G, v4.17 and in RB750, v4.17 also...
 
jadu
Frequent Visitor
Frequent Visitor
Posts: 86
Joined: Sat Feb 05, 2011 9:22 am
Location: Bucharest - Constanta

Re: Dyndns update script (another)

Sun May 08, 2011 3:07 pm

I am using this script but i was searching for one which doesn't stress the flash so i cam update it more often.

# Set needed variables
:local username "xxxxxxx"
:local password "xxxxxxx"
:local hostname "xxxxxxx.dyndns.org"

:global dyndnsForce
:global previousIP

# print some debug info
:log info ("pppoe1 - dyndns-update: username = $username")
:log info ("pppoe1 - dyndns-update: password = $password")
:log info ("pppoe1 - dyndns-update: hostname = $hostname")
:log info ("pppoe1 - dyndns-update: previousIP = $previousIP")

#get ip address from interface
#:global ddnsip [/ip address get [/ip address find interface=pppoe-out1] address]
#:global ip [ :pick $ddnsip 0 [ :find $ddnsip "/" ] ]
#:log info $ip

# get the current IP address from the internet (in case of double-nat)
#/tool fetch mode=http address="checkip.dyndns.org" src-path="/" dst-path="/dyndns.checkip1.html"
#:local result [/file get dyndns.checkip1.html contents]
:global ddnsip [/ip address get [/ip address find interface=pppoe-out1] address]
:global currentIP [ :pick $ddnsip 0 [ :find $ddnsip "/" ] ]
#:log info $currentIP

# parse the current IP result
#:local resultLen [:len $result]
#:local startLoc [:find $result ": " -1]
#:set startLoc ($startLoc + 2)
#:local endLoc [:find $result "</body>" -1]
#:local currentIP [:pick $result $startLoc $endLoc]
#:log info "dyndns-update: currentIP = $currentIP"

# Determine if dyndns update is needed
# more dyndns updater request details available at http://www.dyndns.com/developers/specs/syntax.html
:if (($currentIP != $previousIP) || ($dyndnsForce = true)) do={
:set dyndnsForce false
:set previousIP $currentIP
/tool fetch user=$username password=$password mode=http address="members.dyndns.org" src-path="/nic/update?hostname=$hostname&myip=$currentIP" dst-path="/dyndns1.txt"
:local result [/file get dyndns1.txt contents]
:log info ("pppoe1 - dyndns-update: Dyndns update needed")
:log info ("pppoe1 - dyndns-update: Dyndns Update Result: ".$result)
:put ("Dyndns Update Result: ".$result)
} else={
:log info ("pppoe1 - dyndns-update: No dyndns update needed")
}
 
jadu
Frequent Visitor
Frequent Visitor
Posts: 86
Joined: Sat Feb 05, 2011 9:22 am
Location: Bucharest - Constanta

Re: Dyndns update script (another)

Sun May 08, 2011 4:24 pm

I think it was working yours, but i've addes some extra logging to know what is happening.
When it's the same IP your script didn't log.
It's OK now!
 
ericseguin
just joined
Posts: 5
Joined: Mon Jan 25, 2010 5:48 pm

Re: Dyndns update script (another)

Thu Jun 09, 2011 9:38 pm

Can this be applied to the Dude? And if so, how would I go about doing that? I find that when an IP with dyndns changes, i can ping it from a dos box, but the dude doesn't update it. I get a false report saying it's down.
 
donmirko
just joined
Posts: 18
Joined: Tue Oct 06, 2009 3:02 pm

Re: Dyndns update script (another)

Mon Mar 05, 2012 11:33 am

I'm trying to find/create script for updating ddns service no-ip.org from RB750 (OS 5.7). My Internet router doesn't support ddns so I must do it with MT.

All scripts I can find involve getting real IP from my interface, but I need to get the current IP address from the internet (case of double-NAT).

NO-IP.org is my only solution.
 
gsloop
Member Candidate
Member Candidate
Posts: 213
Joined: Wed Jan 04, 2012 11:34 pm
Contact:

Re: Dyndns update script (another)

Wed Mar 07, 2012 6:51 pm

I've just posted a DynDNS update script.

I think it is an improvement over the scripts I've seen. It doesn't handle double-NAT though.

The announcement post is here:
http://forum.mikrotik.com/viewtopic.php?f=2&t=60018

-Greg

Who is online

Users browsing this forum: tikworx and 21 guests