dynDNS Update Script
RouterOS Scripting and API

131 posts   •   Page 1 of 3   •   1, 2, 3
hacki
just joined
 
Posts: 18
Joined: Fri Aug 28, 2009 1:18 am

dynDNS Update Script

by hacki » Sun Aug 30, 2009 3:01 pm

in order to support dyndns i took some parts from the changeip script and made it work for.

1) add a script called dynDNS:
Code: Select all
# Define User Variables
:global ddnsuser "DYNDNSUSER"
:global ddnspass "DYNDNSPASS"
:global ddnshost "DYNDNSHOST"
 
# Define Global Variables
:global ddnsip
:global ddnslastip
:if ([ :typeof $ddnslastip ] = nil ) do={ :global ddnslastip "0" }
 
:global ddnsinterface
:global ddnssystem ("mt-" . [/system package get system version] )
 
# Define Local Variables
:local int
 
# Loop thru interfaces and look for ones containing
# default gateways without routing-marks
:foreach int in=[/ip route find dst-address=0.0.0.0/0 active=yes ] do={
  :if ([:typeof [/ip route get $int routing-mark ]] != str ) do={
     :global ddnsinterface [/ip route get $int interface]
  }
}
 
# Grab the current IP address on that interface.
:global ddnsip [ /ip address get [/ip address find interface=$ddnsinterface ] address ]
 
# Did we get an IP address to compare?
:if ([ :typeof $ddnsip ] = nil ) do={
   :log info ("DynDNS: No ip address present on " . $ddnsinterface . ", please check.")
} else={
  :if ($ddnsip != $ddnslastip) do={
    :log info "DynDNS: Sending UPDATE!"
    :local str "/nic/update?hostname=$ddnshost&myip=$ddnsip&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG"
    /tool fetch address=members.dyndns.org src-path=$str mode=http user=$ddnsuser password=$ddnspass dst-path=("/DynDNS.".$ddnshost)
    :delay 1
    :local str [/file find name="DynDNS.$ddnshost"];
    /file remove $str
    :global ddnslastip $ddnsip
  }
}


2) Add a scheduler entry to run every minute
Code: Select all
/system scheduler add name=dynDNS interval=00:01 on-event="/system script run dynDns\r\n"


Thanks to the creator of changeip/everydns-script, i hope it's no problem to use the base or some parts!

hacki

opampca
just joined
 
Posts: 8
Joined: Wed Sep 02, 2009 7:28 am
Location: Montréal Québec Canada

Re: dynDNS Update Script

by opampca » Wed Sep 02, 2009 7:30 am

Thank you...
This is working great !!!

johnvam
newbie
 
Posts: 27
Joined: Thu Sep 03, 2009 8:34 pm

Re: dynDNS Update Script

by johnvam » Thu Sep 03, 2009 8:36 pm

Hey!

I bought yesterday an RB 750 and I'm trying to setup DynDNS using this script.

I want to ask if the only variables that I have to change is those :

:global ddnsuser "DYNDNSUSER"
:global ddnspass "DYNDNSPASS"
:global ddnshost "DYNDNSHOST"

or I need to change and something else....

I changed those variables but the IP is not changing...

Thanks!

hacki
just joined
 
Posts: 18
Joined: Fri Aug 28, 2009 1:18 am

Re: dynDNS Update Script

by hacki » Fri Sep 04, 2009 1:05 pm

these are the only variables.
what happens if you run the script manually: /system script run dynDNS
have you set the scheduler?

johnvam
newbie
 
Posts: 27
Joined: Thu Sep 03, 2009 8:34 pm

Re: dynDNS Update Script

by johnvam » Fri Sep 04, 2009 3:39 pm

when I executed this

/system script run dynDNS

the script run succesfully and the IP changed!!!

But I have put this script to run on scheduler every 1 minute....

hacki
just joined
 
Posts: 18
Joined: Fri Aug 28, 2009 1:18 am

Re: dynDNS Update Script

by hacki » Fri Sep 04, 2009 4:05 pm

have you added the scheduler job in gui or commandline?

it's important to add the \r\n characters, otherwise the command is not executed

johnvam
newbie
 
Posts: 27
Joined: Thu Sep 03, 2009 8:34 pm

Re: dynDNS Update Script

by johnvam » Fri Sep 04, 2009 6:37 pm

ok!

my scheduler line is :

/system script run dynDNS \r\n

let's see if it's working...

johnvam
newbie
 
Posts: 27
Joined: Thu Sep 03, 2009 8:34 pm

Re: dynDNS Update Script

by johnvam » Sat Sep 05, 2009 11:09 am

It's not working....

Scheduler counting but the IP is not changing...

User avatar
Chupaka
Forum Guru
Forum Guru
 
Posts: 7229
Joined: Mon Jun 19, 2006 11:15 pm
Location: Home Network Ltd., Minsk, Belarus

Re: dynDNS Update Script

by Chupaka » Sat Sep 05, 2009 12:22 pm

have you set Policy correctly?
For every complex problem, there is a solution that is simple, neat, and wrong.

¡ɹǝ|SOɹǝʇnoɹ ʞıʇoɹʞıW ɯ‚|

MikroTik. Your life. Your routing.

skype: pavel.skuratovich

hacki
just joined
 
Posts: 18
Joined: Fri Aug 28, 2009 1:18 am

Re: dynDNS Update Script

by hacki » Sat Sep 05, 2009 4:47 pm

please make "/system scheduler export" and paste it here.
the execute command should be with "" like "/system script run dynDNS\r\n"
you have a whitespace between S and \r, perhaps this is your issue.

you can add the following line on top of the script in order to check wether your script is executed:
:log info "dynDNS script executed"

changeip
Forum Guru
Forum Guru
 
Posts: 3730
Joined: Fri May 28, 2004 5:22 pm

Re: dynDNS Update Script

by changeip » Sat Sep 05, 2009 6:28 pm

your scheduler entry should only have "dynDNS" and nothing else ... it's the _name_ of a script to run, not an actual script to run. You do not need \r\n or any of that. I think this changed recently because you used to be able to put scripts in the scheduler directly, now it is just the name of the script you enter.
Colo and Wholesale Bandwidth Available! Sales at SanDiegoBroadband dot com

hacki
just joined
 
Posts: 18
Joined: Fri Aug 28, 2009 1:18 am

Re: dynDNS Update Script

by hacki » Sat Sep 05, 2009 6:33 pm

i set the entry in the gui without \r\n and the script wasn't executed. after adding them it worked so i thought, could be helpful too

yarikne
just joined
 
Posts: 1
Joined: Sun Sep 06, 2009 1:46 am

Re: dynDNS Update Script

by yarikne » Sun Sep 06, 2009 2:06 am

Must I leave " " in variable?
I have error in terminal:
invalid value for argument address

WAN is pppoe to ADSL modem
MikroTik RouterOS 3.22
sorry for my English
Last edited by yarikne on Sun Sep 06, 2009 4:45 pm, edited 1 time in total.

mrzero
just joined
 
Posts: 8
Joined: Sun Sep 06, 2009 9:47 am

Re: dynDNS Update Script

by mrzero » Sun Sep 06, 2009 9:51 am

It says in log file
DynDNS: Sending UPDATE!
fetch: ignoring username and password, only for FTP mode
I'm using Mikrotik 3.13
so anyone know waht's wrong? plz help I need it badly :D

hacki
just joined
 
Posts: 18
Joined: Fri Aug 28, 2009 1:18 am

Re: dynDNS Update Script

by hacki » Sun Sep 06, 2009 12:01 pm

it seems your fetch version won't support usernames in http-mode.
you could try the fetch command with the url tag instead of the address tag.

the address tag was added in version 3.23, so you have to update your box

mrzero
just joined
 
Posts: 8
Joined: Sun Sep 06, 2009 9:47 am

Re: dynDNS Update Script

by mrzero » Sun Sep 06, 2009 6:29 pm

Thank you hacki for replying..
But i open the box terminal and /tool then fetch command and press tab to see available fetch arguments and explore the following:

[admin@mRzErO] /tool> fetch
dst-path host mode password port user address src-path

so what is meant by these arguments; there is an address, user and password :?
but you said it doesn't support address and it said ignoring username and password!!
is it a Bug in MT manual? :)

hacki
just joined
 
Posts: 18
Joined: Fri Aug 28, 2009 1:18 am

Re: dynDNS Update Script

by hacki » Sun Sep 06, 2009 7:34 pm

the http mode won't support user authentification in your version.
your fetch just can auth over ftp

mrzero
just joined
 
Posts: 8
Joined: Sun Sep 06, 2009 9:47 am

Re: dynDNS Update Script

by mrzero » Mon Sep 07, 2009 12:28 am

So, can i install only a one package to do that?
I like the 3.13 version as it is stable version..
and what's version of MT that supports fetch http auth, 3.23 is it?
thanks.. :wink: :wink:

hacki
just joined
 
Posts: 18
Joined: Fri Aug 28, 2009 1:18 am

Re: dynDNS Update Script

by hacki » Mon Sep 07, 2009 12:37 am

sry, not sure for that

mrzero
just joined
 
Posts: 8
Joined: Sun Sep 06, 2009 9:47 am

Re: dynDNS Update Script

by mrzero » Mon Sep 07, 2009 1:00 am

Ok thanks for replying...
I'll try to downgrade the advanced-tools-3.28.npk 8)

User avatar
Chupaka
Forum Guru
Forum Guru
 
Posts: 7229
Joined: Mon Jun 19, 2006 11:15 pm
Location: Home Network Ltd., Minsk, Belarus

Re: dynDNS Update Script

by Chupaka » Mon Sep 07, 2009 1:55 am

you cannot use different versions of packages on the same router. you should upgrade
For every complex problem, there is a solution that is simple, neat, and wrong.

¡ɹǝ|SOɹǝʇnoɹ ʞıʇoɹʞıW ɯ‚|

MikroTik. Your life. Your routing.

skype: pavel.skuratovich

mrzero
just joined
 
Posts: 8
Joined: Sun Sep 06, 2009 9:47 am

Re: dynDNS Update Script

by mrzero » Mon Sep 07, 2009 2:53 am

Yes you are right i tried but it said that the system package must be same as the advanced-tools package..
cheers

johnvam
newbie
 
Posts: 27
Joined: Thu Sep 03, 2009 8:34 pm

Re: dynDNS Update Script

by johnvam » Mon Sep 07, 2009 9:23 am

what I have to select at policy..?

scheduler and script...

My configuration is this :

http://img196.imageshack.us/img196/5932/scriptw.png

http://img401.imageshack.us/img401/8265/scheduler.png

User avatar
mrz
MikroTik Support
MikroTik Support
 
Posts: 4080
Joined: Wed Feb 07, 2007 1:45 pm
Location: Latvia

Re: dynDNS Update Script

by mrz » Mon Sep 07, 2009 9:47 am

In scheduler specify only scripts name not a command to run script.
You need at least, read,write,test and ftp policies.

johnvam
newbie
 
Posts: 27
Joined: Thu Sep 03, 2009 8:34 pm

Re: dynDNS Update Script

by johnvam » Mon Sep 07, 2009 10:13 am

OK!

scheduler works perfect!

maybe the problem in on script...

I used the script which is at the top of the thread and I only changed the 3 first variable like this :


:global ddnsuser "xxxxxxx"
:global ddnspass "xxxxxxxx"
:global ddnshost "xxxxxxx.ath.cx"

changeip
Forum Guru
Forum Guru
 
Posts: 3730
Joined: Fri May 28, 2004 5:22 pm

Re: dynDNS Update Script

by changeip » Mon Sep 07, 2009 6:50 pm

your scheduler has run the script 1000+ times. Start at the beginning again, what's not working and what are you getting the logs? The script runs fine manually, but not under scheduler? Are you on the latest version?
Colo and Wholesale Bandwidth Available! Sales at SanDiegoBroadband dot com

randomseed
just joined
 
Posts: 24
Joined: Mon Dec 15, 2008 1:52 am

Re: dynDNS Update Script

by randomseed » Thu Sep 10, 2009 4:23 pm

Thanks for the script Hacki. I've inputted my credentials into the ddnsuser, ddnspass and ddnshost string values, but I keep getting the following message:

"[admin@MikroTik] /system script> run script1
interrupted
invalid internal item number"

The only thing I changed was the first three global variables:

:global ddnsuser "xxxx"
:global ddnspass "xxxxxxx"
:global ddnshost "xxxx.dnsalias.net"

Running router OS 3.28 on an RB450.

Tim

changeip
Forum Guru
Forum Guru
 
Posts: 3730
Joined: Fri May 28, 2004 5:22 pm

Re: dynDNS Update Script

by changeip » Thu Sep 10, 2009 8:06 pm

Hello,

This is okay, I do not mind. Please, anyone using services other than ChangeIP.com, please be aware that your passwords are being sent across in the internet in clear text. If not using https then it will be easy for someone to detect your credentials.

I love Mikrotik. I have here because of that. I am a Dynamic DNS guy. We provide free services, but I do not feel bad if you choose not to use our services. Of course I know we offer a better service with less hassle, but it's always your choice. : )

Sam
Colo and Wholesale Bandwidth Available! Sales at SanDiegoBroadband dot com

User avatar
Ibersystems
Forum Guru
Forum Guru
 
Posts: 1675
Joined: Wed Apr 12, 2006 12:29 am
Location: Cabrils, Barcelona - Spain

Re: dynDNS Update Script

by Ibersystems » Sat Sep 12, 2009 9:24 pm

HI,

It's a problem if I delete this from the script?

Code: Select all
:if ($ddnsip != $ddnslastip) do={


I have problems updating my ADSL line. First time works, but the others don't. I reboot the router to make the IP change but it doesn't update it in the web. If I delete this line, it works.


The problem now is that every minute my ROS updates or rewrite the IP in dyndns.. Can I have problems doing this?

Thanks,
Martín
martinruiz at ibersystems.es
Experto en redes WiFi y enlaces WiFi.

Facebook: @Ibersystems
Twitter: @Ibersystems

Certified in Traffic Shaping, Wireless, Internetworking, Routing and User Management.
MTCTCE - MTCWE - MTCINE - MTCUME - MTCRE

hacki
just joined
 
Posts: 18
Joined: Fri Aug 28, 2009 1:18 am

Re: dynDNS Update Script

by hacki » Sat Sep 12, 2009 10:09 pm

I'm not sure, but i think dynDNS will ban you for some time if you update so often.

try to input the following commands in your terminal and poste the output

/ip route find dst-address=0.0.0.0/0 active=yes
/ip route get <your ppp Interface> routing-mark
/ip route get <your ppp interface interface
/ip address get [/ip address find interface=<your ppp interface> ] address ]

User avatar
Ibersystems
Forum Guru
Forum Guru
 
Posts: 1675
Joined: Wed Apr 12, 2006 12:29 am
Location: Cabrils, Barcelona - Spain

Re: dynDNS Update Script

by Ibersystems » Sun Sep 13, 2009 12:40 am

HI,

I don't have ppp in my ROS. ppp is configured in my router. I have a static IP in my ROS eth0 like 192.168.1.x.
Martín
martinruiz at ibersystems.es
Experto en redes WiFi y enlaces WiFi.

Facebook: @Ibersystems
Twitter: @Ibersystems

Certified in Traffic Shaping, Wireless, Internetworking, Routing and User Management.
MTCTCE - MTCWE - MTCINE - MTCUME - MTCRE

dssmiktik
Forum Veteran
Forum Veteran
 
Posts: 730
Joined: Fri Aug 17, 2007 8:42 am

Re: dynDNS Update Script

by dssmiktik » Sun Sep 13, 2009 10:38 pm

Just wanted to say nice work on the script! It's been a long time coming, many people have wanted this for some time now.


Thanks again!
Doug

hacki
just joined
 
Posts: 18
Joined: Fri Aug 28, 2009 1:18 am

Re: dynDNS Update Script

by hacki » Mon Sep 14, 2009 12:58 am

glad to hear!

to complete it, i added the script to the wiki.

hacki
just joined
 
Posts: 18
Joined: Fri Aug 28, 2009 1:18 am

Re: dynDNS Update Script

by hacki » Mon Sep 14, 2009 1:05 am

Ibersystems wrote:HI,

I don't have ppp in my ROS. ppp is configured in my router. I have a static IP in my ROS eth0 like 192.168.1.x.


dynDNS wrote: If this parameter is not specified, the best IP address the server can determine will be used (some proxy configurations pass the IP in a header, and that is detected by the server). If the IP address passed to the system is not properly formed, it will be ignored and the system's best guess will be used.


you could try to remove the ip parameter from the ":local str" variable
remove: &myip=$ddnsip
and try again

if it won't work you could try to do a fetch on http://checkip.dyndns.com/ and compare the content every minute. if the ip address changed, you could parse the ip out of the file and complete the update.
i think this script can help you to work this out: http://wiki.mikrotik.com/wiki/Using_Fetch_and_Scripting_to_add_IP_Address_Lists

User avatar
Ibersystems
Forum Guru
Forum Guru
 
Posts: 1675
Joined: Wed Apr 12, 2006 12:29 am
Location: Cabrils, Barcelona - Spain

Re: dynDNS Update Script

by Ibersystems » Mon Sep 14, 2009 11:29 am

Thanks! ; )
Martín
martinruiz at ibersystems.es
Experto en redes WiFi y enlaces WiFi.

Facebook: @Ibersystems
Twitter: @Ibersystems

Certified in Traffic Shaping, Wireless, Internetworking, Routing and User Management.
MTCTCE - MTCWE - MTCINE - MTCUME - MTCRE

Lefteris
newbie
 
Posts: 28
Joined: Mon Jul 27, 2009 1:24 pm

Re: dynDNS Update Script

by Lefteris » Fri Sep 18, 2009 4:24 am

After numerous tries the script below seems to work fine under any condition with v3.28. For some reason the original script kept on failing to automatically (manually worked) update DynDNS, specially right after a router reboot.

Code: Select all
/system script add name=DynDNS policy=read,test source={
# Define User Variables
:global ddnsuser "user"
:global ddnspass "pass"
:global ddnshost "host"

# Define Global Variables
:global ddnsip
:global ddnslastip
:if ([:typeof $ddnslastip] = nil) do={ :global ddnslastip "0.0.0.0/0" }

:global ddnsinterface
:global ddnssystem ("mt-" . [/system package get system version])

# Define Local Variables
:local int

# Loop thru interfaces and look for ones containing
# default gateways without routing-marks
:foreach int in=[/ip route find dst-address=0.0.0.0/0 active=yes] do={
  :if ([:typeof [/ip route get $int routing-mark]] != str) do={
    :global ddnsinterface [/ip route get $int interface]
  }
}

# Grab the current IP address on that interface.
:global ddnsip [/ip address get [/ip address find interface=$ddnsinterface] address]

# Did we get an IP address to compare
:if ([:typeof $ddnsip] = nil) do={
  :log info ("DynDNS: No ip address present on " . $ddnsinterface . ", please check.")
} else={

  :if ($ddnsip != $ddnslastip) do={

    :log info "DynDNS: Sending IP:$ddnsip UPDATE!"
    /tool fetch keep-result=no url="http://$ddnsuser:$ddnspass@204.13.248.112/nic/update\?hostname=$ddnshost"
    :global ddnslastip $ddnsip

# } else={
#   :log info "DDNS: No update required."
  }

}
}
# End of script

Scheduler:
Code: Select all
/system scheduler add name=DynDNS policy=read,test interval=1m on-event=DynDNS

User avatar
webasdf
Frequent Visitor
Frequent Visitor
 
Posts: 78
Joined: Mon Jan 26, 2009 7:37 pm

Re: dynDNS Update Script

by webasdf » Sat Sep 19, 2009 12:37 am

I've made something similar and have been testing for a few weeks...just saw this post and thought I'd share. I haven't been locked out of dyndns yet, so this should be a good script as well. The main difference is that it queries checkip.dyndns.org for the current publicly facing IP address. I also set up a force update once every day at midnight. This prevents the dyndns domain from expiring due to it not being updated enough (which has happened to me in the past). The script has lots of logs and a few puts in it, but these can be safely deleted if desired. The policies on the scripts mentioned above still apply. Make sure those are set properly as well.

The Script "dyndns-update". Set the local variables username, password and hostname:
Code: Select all
# Set needed variables
:local username "dyndnsUsername"
:local password "dyndnsPassword"
:local hostname "hostname.dyndns.org"

:global dyndnsForce
:global previousIP

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

# 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.checkip.html"
:local result [/file get dyndns.checkip.html contents]

# 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="/dyndns.txt"
    :local result [/file get dyndns.txt contents]
    :log info ("dyndns-update: Dyndns update needed")
    :log info ("dyndns-update: Dyndns Update Result: ".$result)
    :put ("Dyndns Update Result: ".$result)
} else={
    :log info ("dyndns-update: No dyndns update needed")
}

Script "dyndns-force". Intended to update dyndns only once every 24 hrs. If you run this too much, you may get locked out of dyndns.
Code: Select all
:global dyndnsForce true
/system script run dyndns-update

Setup the schedulers. Run dyndns-update every 15 minutes and dyndns-force once every 24 hours:
Code: Select all
/system scheduler add comment="" disabled=no interval=15m name=dyndns-update on-event=\
    dyndns-update start-date=jan/01/1970 start-time=00:00:00
/system scheduler add comment="" disabled=no interval=1d name=dyndns-force on-event=\
    dyndns-force start-date=jan/01/1970 start-time=02:00:00

vdelarenal75
Frequent Visitor
Frequent Visitor
 
Posts: 69
Joined: Fri May 22, 2009 1:28 am

Re: dynDNS Update Script

by vdelarenal75 » Wed Oct 07, 2009 8:10 pm

Thankyou webasfd, you script worked perfectly, thanks for sharing.

webasdf wrote:I've made something similar and have been testing for a few weeks...just saw this post and thought I'd share. I haven't been locked out of dyndns yet, so this should be a good script as well. The main difference is that it queries checkip.dyndns.org for the current publicly facing IP address. I also set up a force update once every day at midnight. This prevents the dyndns domain from expiring due to it not being updated enough (which has happened to me in the past). The script has lots of logs and a few puts in it, but these can be safely deleted if desired. The policies on the scripts mentioned above still apply. Make sure those are set properly as well.

The Script "dyndns-update". Set the local variables username, password and hostname:
Code: Select all
# Set needed variables
:local username "dyndnsUsername"
:local password "dyndnsPassword"
:local hostname "hostname.dyndns.org"

:global dyndnsForce
:global previousIP

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

# 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.checkip.html"
:local result [/file get dyndns.checkip.html contents]

# 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="/dyndns.txt"
    :local result [/file get dyndns.txt contents]
    :log info ("dyndns-update: Dyndns update needed")
    :log info ("dyndns-update: Dyndns Update Result: ".$result)
    :put ("Dyndns Update Result: ".$result)
} else={
    :log info ("dyndns-update: No dyndns update needed")
}

Script "dyndns-force". Intended to update dyndns only once every 24 hrs. If you run this too much, you may get locked out of dyndns.
Code: Select all
:global dyndnsForce true
/system script run dyndns-update

Setup the schedulers. Run dyndns-update every 15 minutes and dyndns-force once every 24 hours:
Code: Select all
/system scheduler add comment="" disabled=no interval=15m name=dyndns-update on-event=\
    dyndns-update start-date=jan/01/1970 start-time=00:00:00
/system scheduler add comment="" disabled=no interval=1d name=dyndns-force on-event=\
    dyndns-force start-date=jan/01/1970 start-time=02:00:00

obolyz
just joined
 
Posts: 2
Joined: Sat Oct 31, 2009 11:37 am

Re: dynDNS Update Script

by obolyz » Sat Oct 31, 2009 8:38 pm

2 hacki:

Script returns:
Code: Select all
interrupted
           input does not match any value of value-name


:-(

LambdaMaxWELL
just joined
 
Posts: 9
Joined: Sun Jul 26, 2009 3:52 am

Re: dynDNS Update Script

by LambdaMaxWELL » Thu Dec 10, 2009 10:47 am

webasdf wrote:# 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?


Is working fine, thanks!

Question:
How I can modify this script that the current IP will taken out of the dyndns database directly instead of the value stored locally?

Result would be that the update will also be forced in any cases dyndns record was modified by another device etc. for example.

Thanks
Dirk

hacki
just joined
 
Posts: 18
Joined: Fri Aug 28, 2009 1:18 am

Re: dynDNS Update Script

by hacki » Thu Dec 10, 2009 1:23 pm

Code: Select all
PreviousIP = [:resolve your.dynhost.tld]


hacki

LambdaMaxWELL
just joined
 
Posts: 9
Joined: Sun Jul 26, 2009 3:52 am

Re: dynDNS Update Script

by LambdaMaxWELL » Thu Dec 10, 2009 1:29 pm

Hello hacki,

thanks for your feedback!

hacki wrote:
Code: Select all
PreviousIP = [:resolve your.dynhost.tld]


hacki


Could I also specify the dedicated nameserver I'd like to query instead of the standard local configured dns server?

Thanks
Dirk

hacki
just joined
 
Posts: 18
Joined: Fri Aug 28, 2009 1:18 am

Re: dynDNS Update Script

by hacki » Thu Dec 10, 2009 1:59 pm

not sure about that, why do you need this?

LambdaMaxWELL
just joined
 
Posts: 9
Joined: Sun Jul 26, 2009 3:52 am

Re: dynDNS Update Script

by LambdaMaxWELL » Thu Dec 10, 2009 3:09 pm

hacki wrote:not sure about that, why do you need this?


I am happy also with the initial version. But if I would take the current IP directly out of the database or if I could directly request the dyndns.org mailserver than I would get the really currently address - device independent.

Otherwise it could be that the local stored address and the content of the dyndns server is different and the script will not make the necessary update. This would not happen normally - that is true.

Dirk

LambdaMaxWELL
just joined
 
Posts: 9
Joined: Sun Jul 26, 2009 3:52 am

Re: dynDNS Update Script

by LambdaMaxWELL » Thu Dec 10, 2009 3:28 pm

hacki wrote:not sure about that, why do you need this?


Question:
A command like: "/system nslookup my.domain.tld server ns1.dyndns.org querytype=A >currentIP.txt" is not availiable in RouterOK?

Dirk

larryuy
just joined
 
Posts: 22
Joined: Fri Jun 26, 2009 4:34 pm

Re: dynDNS Update Script

by larryuy » Sat Feb 27, 2010 9:29 pm

Thanks for the script, y have 2 scripts now, one for internet with pppoe (your script) and other for internet with dhcp client or static IP address (default route not asociated with an specific interface).

The diferences:

For PPPoE:
Code: Select all
:foreach int in=[/ip route find dst-address=0.0.0.0/0 active=yes ] do={
  :if ([:typeof [/ip route get $int routing-mark ]] != str ) do={
     :global ddnsinterface [/ip route get $int interface]
  }
}


For DHCP or Static IP (senseless for static IP) replace above with this:
Code: Select all
:global ddnsinterface "ether1"


And of course:
Code: Select all
/system scheduler add name=dynDNS interval=00:01 on-event="/system script run dynDNS\r\n"


Thankyou again.

andreico
just joined
 
Posts: 3
Joined: Fri Nov 20, 2009 11:09 pm

Re: dynDNS Update Script

by andreico » Mon Mar 15, 2010 4:12 pm

Good afternoon.
I have a problem: tried all options (in my version mikrotik 2.9), did not want to work.
Is it possible to work with this service correctly on my version?

User avatar
Ibersystems
Forum Guru
Forum Guru
 
Posts: 1675
Joined: Wed Apr 12, 2006 12:29 am
Location: Cabrils, Barcelona - Spain

Re: dynDNS Update Script

by Ibersystems » Mon Mar 15, 2010 4:48 pm

No,

the problem is in fetch tool with the 2.9.x.

3.x solves the script problem with fetch. I think its about validation with fetch in html.
Martín
martinruiz at ibersystems.es
Experto en redes WiFi y enlaces WiFi.

Facebook: @Ibersystems
Twitter: @Ibersystems

Certified in Traffic Shaping, Wireless, Internetworking, Routing and User Management.
MTCTCE - MTCWE - MTCINE - MTCUME - MTCRE

User avatar
mrz
MikroTik Support
MikroTik Support
 
Posts: 4080
Joined: Wed Feb 07, 2007 1:45 pm
Location: Latvia

Re: dynDNS Update Script

by mrz » Mon Mar 15, 2010 4:50 pm

:shock: v2.9 Doesn't have fetch command.

andreico
just joined
 
Posts: 3
Joined: Fri Nov 20, 2009 11:09 pm

Re: dynDNS Update Script

by andreico » Wed Mar 17, 2010 2:31 am

Do I correctly indicates the server address? "208.78.71.100"

And if will work, because this team? "dns-update dns-server=208.78.71.100 name=livexxx \
zone=xxxddns.com address=91.215.xx.xx key-name=xxx key=xxx"

But when you enter commands, writes that an incorrect password.

Finally I need a conclusion, if you want more ram head on this version or better to upgrade mikrotik?

  Next
131 posts   •   Page 1 of 3   •   1, 2, 3

Who is online

Users browsing this forum: No registered users and 19 guests

It is currently Thu Nov 27, 2014 10:23 pm