Community discussions

MikroTik App
 
Jeeva
newbie
Topic Author
Posts: 37
Joined: Fri Sep 01, 2006 12:53 am
Location: Stellenbosch, South Africa
Contact:

Wget Afraid - FREEDNS script help

Fri Aug 22, 2008 7:54 pm

Hi

freedns.afraig.org offers 'n Dynamic DNS service, but it order to do so, i need to be able to run the following linux script on the mikrotik. Is there someone that can help me out with it. Want it to update every 5mins and then delete the url it downloaded a few seconds later (otherwise i will sit with 288 entries a day)

Code from afraid.org:
rem my.domain.co.za
wget -q --read-timeout=0.0 --waitretry=5 --tries=400 --background http://freedns.afraid.org/dynamic/update.php?U3hWWThhdE8wcHFRMzN<rest of the url>
or I can just download the url:
http://freedns.afraid.org/dynamic/update.php?U3hWWThhdE8wcHFRMzN<rest of the url>
but it must also delete the url aswell

Thanks
 
tagno25
newbie
Posts: 38
Joined: Wed Feb 25, 2009 11:24 pm
Location: Kansas City, MO

Re: Wget Afraid - FREEDNS script help

Wed Feb 25, 2009 11:31 pm

Hi

freedns.afraig.org offers 'n Dynamic DNS service, but it order to do so, i need to be able to run the following linux script on the mikrotik. Is there someone that can help me out with it. Want it to update every 5mins and then delete the url it downloaded a few seconds later (otherwise i will sit with 288 entries a day)

Code from afraid.org:
rem my.domain.co.za
wget -q --read-timeout=0.0 --waitretry=5 --tries=400 --background http://freedns.afraid.org/dynamic/update.php?U3hWWThhdE8wcHFRMzN<rest of the url>
or I can just download the url:
http://freedns.afraid.org/dynamic/update.php?U3hWWThhdE8wcHFRMzN<rest of the url>
but it must also delete the url aswell

Thanks
change your code to
rem my.domain.co.za
wget -q --read-timeout=0.0 --waitretry=5 --tries=400 --background http://freedns.afraid.org/dynamic/update.php?U3hWWThhdE8wcHFRMzN<rest of the url> -O=afraid.org
added " -O=afraid.org" to write over the same file (in this case I called the file afraid.org, but you can change it)

Have you found out where to put the code?
 
User avatar
S1ghup
just joined
Posts: 7
Joined: Mon Oct 27, 2008 7:41 pm
Location: Joplin, MO. USA

Re: Wget Afraid - FREEDNS script help

Wed Jun 03, 2009 10:08 pm

In regards to using wget to update your dynamic IP address with afraid.org, I'm afraid (no pun intended) it is not possible at this time. However if you are running RouterOS 3.+ you can achieve this using the fetch tool as seen below. I currently run this on RoS 3.16 and it works with out flaw.

Note: The update token in the example below has been changed to protect the innocent and my router. :)
/tool fetch address="freedns.afraid.org" host="freedns.afraid.org" mode=http src-path="dynamic/update.php\?bnptVU90TjcTWDVsMjNlAMk81WUg6MzYyNjYxMg==" keep-result=no
Important things to notice/remember:
1. Parameter: src-path take notice of the "\" after the .php this is required to escape the ?
2. Parameter: keep-result - Can be set to yes or no -
No - By setting this to no we tell the router to ignore the response file from afraid.org
Yes - By setting this to yes we tell the router to store the result of the last update in /file with the name .php?<your-unique-token>

You can use the system scheduler to execute this script on a timed interval if you like.

Regards,
John Annis - Vortex Consulting
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7044
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: Wget Afraid - FREEDNS script help

Thu Jun 04, 2009 8:54 am

In the latest version you can also use "/tool fetch url=..."
 
stefanz
just joined
Posts: 11
Joined: Wed Mar 09, 2011 9:47 am

Re: Wget Afraid - FREEDNS script help

Mon Mar 26, 2012 10:24 am

Does anyone use www.freedns.afraid.org DDNS services on Mikrotik devices? I'm trying to configure on a Mikrotik router to use the DDNS service provided by freedns.afraid.org but I didn't find any script or solution.
 
ayufan
Member
Member
Posts: 334
Joined: Sun Jun 03, 2007 9:35 pm
Contact:

Re: Wget Afraid - FREEDNS script help

Wed Apr 18, 2012 11:55 pm

I use this simple own script. Just copy and run in command line. Than you have to update System/Scheduler script with your external interface and update key. This script gets ip address from pppoe-client interface. However, you can easily change that.

/system scheduler
add disabled=no interval=30s name="dynamic dns" on-event="/ interface pppoe-clie\
    nt {\r\
    \n\t:global ExternalIP\r\
    \n\t:local clientip\r\
    \n\t:local clientstatus\r\
    \n\tmonitor External once do={:set clientip \$\"local-address\"; :set client\
    status \$status}\r\
    \n\t:if (\$clientstatus=\"connected\" and \$ExternalIP!=\$clientip) do={\r\
    \n\t\t:log info \"External IP changed from \$ExternalIP to \$clientip\"\r\
    \n\t\t/ tool fetch url=\"http://freedns.afraid.org/dynamic/update.php\\\?<put_key>\" dst-path=ExternalIP.txt\r\
    \n\t\t:set ExternalIP \$clientip\r\
    \n\t}\r\
    \n}" policy=ftp,read,write,policy,test,winbox,password,sniff,api \
    start-time=startup
Last edited by ayufan on Thu Apr 19, 2012 11:55 am, edited 1 time in total.
 
stefanz
just joined
Posts: 11
Joined: Wed Mar 09, 2011 9:47 am

Re: Wget Afraid - FREEDNS script help

Thu Apr 19, 2012 11:16 am

Thank you
 
User avatar
bax
Member Candidate
Member Candidate
Posts: 268
Joined: Mon Dec 20, 2004 8:45 pm
Location: Croatia

Re: Wget Afraid - FREEDNS script help

Fri Apr 20, 2012 12:43 pm

I use this simple own script. Just copy and run in command line. Than you have to update System/Scheduler script with your external interface and update key. This script gets ip address from pppoe-client interface. However, you can easily change that.

/system scheduler
add disabled=no interval=30s name="dynamic dns" on-event="/ interface pppoe-clie\
    nt {\r\
    \n\t:global ExternalIP\r\
    \n\t:local clientip\r\
    \n\t:local clientstatus\r\
    \n\tmonitor External once do={:set clientip \$\"local-address\"; :set client\
    status \$status}\r\
    \n\t:if (\$clientstatus=\"connected\" and \$ExternalIP!=\$clientip) do={\r\
    \n\t\t:log info \"External IP changed from \$ExternalIP to \$clientip\"\r\
    \n\t\t/ tool fetch url=\"http://freedns.afraid.org/dynamic/update.php\\\?<put_key>\" dst-path=ExternalIP.txt\r\
    \n\t\t:set ExternalIP \$clientip\r\
    \n\t}\r\
    \n}" policy=ftp,read,write,policy,test,winbox,password,sniff,api \
    start-time=startup
This was not work for me ... ROS v 5.14 ... :(
I was change interface to my interface name ad fetch url ...
Sorry Im to fast :D It working !
 
jensbodal
just joined
Posts: 11
Joined: Tue Apr 16, 2013 2:39 am

Re: Wget Afraid - FREEDNS script help

Wed Jun 26, 2013 2:57 am

In the latest version you can also use "/tool fetch url=..."
Thanks, that was easy enough. If anyone does this just make sure to escape the ? here as well, for example:

/tool fetch url="http://freedns.afraid.org/dynamic/updat ... ROMTHEURL="

Anyone know if it matters how often you send this request? It looks like the server tells you that nothing needs to update if the IP is the same so I would imagine it's fine to run this every 5 minutes or something.
 
midenok
newbie
Posts: 39
Joined: Fri Dec 27, 2013 5:34 pm

Re: Wget Afraid - FREEDNS script help

Fri Dec 27, 2013 5:37 pm

Or you can try this script.
 
midenok
newbie
Posts: 39
Joined: Fri Dec 27, 2013 5:34 pm

Re: Wget Afraid - FREEDNS script help

Fri Dec 27, 2013 5:40 pm

Or you can try this script.
You do not have the required permissions to view the files attached to this post.
 
User avatar
LESHIYODESSA
just joined
Posts: 14
Joined: Tue Nov 20, 2012 11:20 am

Re: Wget Afraid - FREEDNS script help

Sun Sep 07, 2014 2:04 am

I wrote my own script.

The most important thing!!! The script works if you have multiple domains.

Image
##############	Script FreeDNS.afraid.org	##################
##############	PARSER EDITION	##################
##############	CREATED LESHIY_ODESSA	##################
	
# Specify the "Direct URL", which is https://freedns.afraid.org/dynamic/
# If RouterOS version 5.xx, then remove from the URL encryption - "https" change this to "http". Also see below.
# In front of the sign "?" put a backslash "\".
:global "direct-url" "http://freedns.afraid.org/dynamic/update.php\?dedC0TirYibYdzBYnnhVRiJJb8Q6iDY1Mji3mQ=="

# Specify the URL API "ASCII"
# Log in under your account and open the page https://freedns.afraid.org/api/
# Then copy the URL of your site - Available API Interfaces : ASCII (!!! NOT XML !!!)
# ATTENTION!!!! Before the question mark, put a backslash "\".
# If RouterOS version 5.xx, then remove from the URL encryption - "https" change this to "http".
:global "api-url" "http://freedns.afraid.org/api/\?action=getdyndns&sha=62egb6606ci46cbe6eo8iga61de6ia101858a08n"
 	
# Specify your domain or subdomain.
:global "dns-domain" "name.com"

# Define variables for the external (WAN) interface
# Case sensitive.
:global "out-interface" "pppoe"
 		
# !!!!!!!!!!!!!!!!! Nothing more do not need to edit!!!!!!!!!!!!!!!!!
 		
# Check whether the file with the IP domain - freedns.txt
:if ([:len [/file find name=freedns.txt]] > 0) do={
} else={
/tool fetch url=$"api-url" dst-path="/freedns.txt"
}
# Find out the IP address of the domain using the API and parsing.
# Split the file
:local "result" [/file get freedns.txt contents]
:local "startloc" ([:find $"result" $"dns-domain"] + ([:len $"dns-domain"] + 1))
:local "endloc" ([:find $"result" $"direct-url" -1] -1)
:global "dns-domain-ip" [:pick $"result" $"startloc" $"endloc"]
 		
# Find the current IP address on the external interface
:global "current-ip" [/ip address get [find interface=$"out-interface"] address]
 	
# Obtained from IP addresses to be excluded subnet mask
:set "current-ip" [:pick $"current-ip" 0 ([:len $"current-ip"]-3) ]
 		
# Compare the external IP with the IP address of the DNS domain.
:if ($"current-ip" != $"dns-domain-ip") do={

# If different, then sent to freedns.afraid.org our external IP by using Direct URL
:log info ("Service Dynamic DNS: old IP address $"dns-domain-ip" for $"dns-domain" CHANGED to -> $"current-ip"")
/tool fetch url=$"direct-url" keep-result=no
# Download the file with the new IP after 5 sec.
:delay 5
/tool fetch url=$"api-url" dst-path="/freedns.txt"
} else={
# Not to clog the log, you need to comment out this line.
:log info ("IP address is NOT CHANGED, the update is not required")
}
 	
# Since version RouterOS version 6.0rc12 supported encryption /tool fetch mode=https
# In :global "direct-url" need to change to httpS://
# For RouterOS version 6.xx
# /tool fetch mode=https url=$"direct url"
# :global "direct-url" "https://freedns.afraid.org/dynamic/update.php\?UVdjU2lzQmQwSkdjZW9aWkNleTdJdXFtOjg2NTI0NzE="

#		http://wiki.mikrotik.com/wiki/Manual:Scripting
#		http://wiki.mikrotik.com/wiki/Manual:Scripting-examples
#		http://wiki.mikrotik.com/wiki/Manual:Tools/Fetch
#		http://forum.ixbt.com/topic.cgi?id=14:60498-86#2373

##############Script FreeDNS.afraid.org##################
Last edited by LESHIYODESSA on Sat Sep 12, 2015 3:02 am, edited 3 times in total.
 
vbbojan
just joined
Posts: 1
Joined: Wed Oct 01, 2014 12:10 am

Re: Wget Afraid - FREEDNS script help

Wed Oct 01, 2014 12:18 am

@LESHIYODESSA

Thanks for the script, but I have problem with finding domain IP address because API call:

http://freedns.afraid.org/api/\?action= ... -HERE-----

returns:
ERROR: Could not authenticate.

Any idea why it does not work?
 
dcavni
Member Candidate
Member Candidate
Posts: 108
Joined: Sun Mar 31, 2013 6:02 pm

Re: Wget Afraid - FREEDNS script help

Sun Oct 26, 2014 1:38 pm

I use this simple own script. Just copy and run in command line. Than you have to update System/Scheduler script with your external interface and update key. This script gets ip address from pppoe-client interface. However, you can easily change that.

/system scheduler
add disabled=no interval=30s name="dynamic dns" on-event="/ interface pppoe-clie\
    nt {\r\
    \n\t:global ExternalIP\r\
    \n\t:local clientip\r\
    \n\t:local clientstatus\r\
    \n\tmonitor External once do={:set clientip \$\"local-address\"; :set client\
    status \$status}\r\
    \n\t:if (\$clientstatus=\"connected\" and \$ExternalIP!=\$clientip) do={\r\
    \n\t\t:log info \"External IP changed from \$ExternalIP to \$clientip\"\r\
    \n\t\t/ tool fetch url=\"http://freedns.afraid.org/dynamic/update.php\\\?<put_key>\" dst-path=ExternalIP.txt\r\
    \n\t\t:set ExternalIP \$clientip\r\
    \n\t}\r\
    \n}" policy=ftp,read,write,policy,test,winbox,password,sniff,api \
    start-time=startup
Is there anything that needs to be changed for RouterOS version 6.20. I tried this script, copied my key after question mark with = at the end and changed interface name to "pppoe-out1" since that is the name of PPPoE client interface in interfaces list. What am i doing wrong?

Thank you
 
User avatar
LESHIYODESSA
just joined
Posts: 14
Joined: Tue Nov 20, 2012 11:20 am

Re: Wget Afraid - FREEDNS script help

Mon Nov 03, 2014 1:35 pm

@LESHIYODESSA

Thanks for the script, but I have problem with finding domain IP address because API call:

http://freedns.afraid.org/api/\?action= ... -HERE-----
I don't see the whole your script. Version RouterOS?
returns:
ERROR: Could not authenticate.
Any idea why it does not work?

I don't understand what gives the error.


The script is 100% working on RouterOS 5.xx and RouterOS 6.xx
 
qbek
just joined
Posts: 20
Joined: Mon Sep 21, 2015 3:34 pm
Location: Poland
Contact:

Re: Wget Afraid - FREEDNS script help

Mon May 01, 2017 10:25 pm

I done everything like LESHIYODESSA said. But I don't see any info at logs, it just appear one time when I run script.I just want to see if this works or not.
 
User avatar
LESHIYODESSA
just joined
Posts: 14
Joined: Tue Nov 20, 2012 11:20 am

Re: Wget Afraid - FREEDNS script help

Mon May 01, 2017 10:56 pm

I done everything like LESHIYODESSA said. But I don't see any info at logs, it just appear one time when I run script.I just want to see if this works or not.
Go
 
easyyu
newbie
Posts: 30
Joined: Sun Aug 22, 2010 8:13 am

Re: Wget Afraid - FREEDNS script help

Mon Sep 25, 2017 4:12 am

Or you can try this script.
Thx mate..
This is only script what worked for me!

Who is online

Users browsing this forum: No registered users and 6 guests