Page 1 of 1

freedns.afraid.org Script

Posted: Fri Apr 04, 2014 11:09 am
by kneuzgi
How can a mikrotik router do an automatic update of the public ip address via script?

I'm using the service from "freedns.afraid.org" (e.g. myprivatecomputer.chickenkiller.com)

I guess I can not simply use the script from "http://wiki.mikrotik.com/wiki/Dynamic_D ... for_dynDNS"
and replace the first three lines ??

I'm running v6.10 on my mikrotik router.

Thanks for you help

Re: freedns.afraid.org Script

Posted: Fri Apr 04, 2014 4:22 pm
by bingo220
I've never used "freedns.afraid.org".
I use "no-ip.com" (".biz" domain).
I'll show my script.

System-Scripts:
Name: noip
Policy: write,test,read
Source:
##############Script Settings##################

:local NOIPUser "WriteHereName"
:local NOIPPass "WriteHerePassword"
:local WANInter "WriteHereWanInterfaceName"

###############################################

:local NOIPDomain "$NOIPUser.no-ip.biz"
: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=http user=$NOIPUser password=$NOIPPass url="http://dynupdate.no-ip.com/nic/update\3Fhostname=$NOIPDomain&myip=$NewIP" keep-result=no
      :log info "NO-IP Update: $NOIPDomain - $NewIP"
     }
   } 
}
Then create shedule:
System-Sheduler:
Name: noip
Start Date: Jan/01/1970
Start Time: 00:00:00
Interval: 00:02:00
On Event: /system script run noip
Policy: write,test,read

Because of free-account and rarely changing ip-address I would have to visit a no-ip site every twenty days.
Otherwise the account will be blocked.
But I made a second script. It sends fake-ip-address (192.168.1.1) every sunday in 01:15am.
Now I can forget about the inconvenience.

System-Scripts:
Name: fake-noip
Policy: write,test,read
Source:
##############Script Settings##################

:local NOIPUser "WriteHereName"
:local NOIPPass "WriteHerePassword"
:local WANInter "WriteHereWanInterfaceName"

###############################################

:local NOIPDomain "$NOIPUser.no-ip.biz"
: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];
      /tool fetch mode=http user=$NOIPUser password=$NOIPPass url="http://dynupdate.no-ip.com/nic/update\3Fhostname=$NOIPDomain&myip=192.168.1.1" keep-result=no
      :log info "FAKE NO-IP Update: Done! $NOIPDomain - 192.168.1.1"
   } 
}
Then create shedule:
System-Sheduler:
Name: fake-noip
Start Date: Feb/23/2014
Start Time: 01:15:00
Interval: 7d 00:00:00
On Event: /system script run fake-noip
Policy: write,test,read

Re: freedns.afraid.org Script

Posted: Fri Apr 04, 2014 5:20 pm
by plisken
By :local WANInter "WriteHereWanInterfaceName"

What name must i set there? the name from ether1 for example?

Re: freedns.afraid.org Script

Posted: Fri Apr 04, 2014 5:27 pm
by jarda
Because of free-account and rarely changing ip-address I would have to visit a no-ip site every twenty days.
Otherwise the account will be blocked.
But I made a second script. It sends fake-ip-address (192.168.1.1) every sunday in 01:15am.
Now I can forget about the inconvenience.
The fake ip makes that you do not need to visit their re-activation page?

I am using DNSExit. They do not want to keep alive the service by doing regular exercises like no-ip. For them it is enough to put their tiny button somewhere at your webpage. And they checked it for the first time in my case after maybe 3 years of using their service. Then they stopped my service. So I put the button "somewhere" and point them to it (via e-mail), they were happy and I have not seen any hassle with them anymore.

Re: freedns.afraid.org Script

Posted: Fri Apr 04, 2014 5:46 pm
by bingo220
By :local WANInter "WriteHereWanInterfaceName"
What name must i set there? the name from ether1 for example?
I use name "pppoe2-isp2"
If you don't use a ppp-session you need to use name of interface - ether1 etc.
The fake ip makes that you do not need to visit their re-activation page?
exactly.

Re: freedns.afraid.org Script

Posted: Mon Apr 07, 2014 1:09 pm
by kneuzgi
Is there anybody who have a working script for freedns.afraid.org ?

I'm not very familar with creating scripts ...

Thanks

Re: freedns.afraid.org Script

Posted: Tue Apr 15, 2014 3:55 pm
by a.devecerski
This one works for me

According to http://freedns.afraid.org/signup/moreinfo/ "...For users that want to host their site off their home dial-up connection / cable modem / DSL or equivalent, a special fetchable URL to auto-update the network address in FreeDNS is available in the 'Dynamic DNS' section for those whose IP address changes at random...."

Change user_name, password, WAN_interface_name and domain_name with yours, get your particular fetchable URL from Dynamic DNS menu and enter it as an argument in /tool fetch command below (it should look something like h*p://freedns.afraid.org/dynamic/update.php?MB34Mlp12asdc1FvWjNsakFGdlUmWQlYOjExMIA1Njg6, h*p being http of course)

If you like, enter it in scheduler
/system scheduler
add interval=5m name=Afraid.org on-event="/system script run Afraid.org"

*-where Afraid.org is the script name
:global AfraidUser "user_name"
:global AfraidPass "password"
:global WANInter "interface_name"
:global AfraidDomain "domain_name"

:global IpCurrent [/ip address get [find interface=$WANInter] address];
:for i from=( [:len $IpCurrent] - 1) to=0 do={ 
  :if ( [:pick $IpCurrent $i] = "/") do={ 
    :global NewIP [:pick $IpCurrent 0 $i];
    :if ([:resolve $AfraidDomain] != $NewIP) do={
      /tool fetch mode=http url="fetchable_URL_goes_here" keep-result=no
      :log info "Afraid.org Update: $AfraidDomain - $NewIP"
     } else={
     :log info "Afraid.org: don't need updates";
    }
   } 
}

Re: freedns.afraid.org Script

Posted: Wed Aug 13, 2014 2:01 am
by omnedon
I am attempting to set up and run the script given in the prior post by a.devecerski and the router does not seem to be saving the script. It keeps popping up a notice saying 'Could not save script' and something about a 13 second timeout. A few times while trying to set up the script it would drop me to the login screen.

My goal is to set up port forwarding, but it won't be very useful if I can't find home from the outside.

Can someone give a more detailed walkthrough of setting this up?

Thank you.

Re: freedns.afraid.org Script

Posted: Tue Aug 26, 2014 1:37 pm
by LESHIYODESSA
Hello

Sorry, I do not know English and therefore I use the translator.

I wrote my own script for freedns.afraid.org

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##################
The script may not work if you set not all policy in schedule.
/system scheduler
add disabled=no interval=1m name=freedns.afraid.org on-event="/system script run freedns.afraid.org" policy=ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive,api start-time=startup

Add-ons for Script

Color log messages

RED — log error ("Service Dynamic DNS: old IP address $"dns-domain-ip" for $"dns-domain" CHANGED to -> $"current-ip"")

BLUE — :log warning ("IP address is NOT CHANGED, the update is not required")

Image

Re: freedns.afraid.org Script

Posted: Fri Aug 29, 2014 11:34 pm
by omnedon
Hello

Sorry, I do not know English and therefore I use the translator.

I wrote my own script for freedns.afraid.org

The most important thing!!! The script works if you have multiple domains.
##############	Script FreeDNS.afraid.org	##################
##############	PARSER EDITION	##################
##############	CREATED LESHIY_ODESSA	##################

I have had problems getting scripts onto the router, I have version 5.26 and everything so far has failed. Does the web console work for this, or would it be better to SSH in (in which case, best way to edit?)?

Does it run at startup or as timed event? What permissions does it require?

Everything else has been easy up to this point.

Re: freedns.afraid.org Script

Posted: Mon Sep 01, 2014 12:17 pm
by LESHIYODESSA

I have had problems getting scripts onto the router, I have version 5.26 and everything so far has failed. Does the web console work for this, or would it be better to SSH in (in which case, best way to edit?)?
Use WinBox to create the script.

No need to use or debug the script in the console. The script 100% working condition :

1. In front of the sign "?" put a backslash "\".
2. If RouterOS version 5.xx, then remove from the URL encryption - "https" change this to "http".

Read the comments in the script.


Does it run at startup or as timed event? What permissions does it require?

ros code

/system scheduler
add disabled=no interval=1m name=freedns.afraid.org on-event=\
    "/system script run freedns.afraid.org" policy=\
    ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive,api \
    start-time=startup

Re: freedns.afraid.org Script

Posted: Tue Sep 02, 2014 1:04 am
by jmsierra
Hello

Sorry, I do not know English and therefore I use the translator.

I wrote my own script for freedns.afraid.org

The most important thing!!! The script works if you have multiple domains.
Thanks, works fine for me.

WinBox v6.19 on RB951G-2HnD

Re: freedns.afraid.org Script

Posted: Sat Sep 06, 2014 9:19 pm
by omnedon

1. In front of the sign "?" put a backslash "\".
I think this may have been the problem I was having earlier.

I am pretty sure I have it working now, won't know for certain until IP changes. I was able to use the web console, just drag into the 'source' box and edit for the personal links. This time it saved without error and appears to be working.

Thanks!

Re: freedns.afraid.org Script

Posted: Sun Aug 09, 2015 11:11 pm
by seb364
LESHIYODESSA: thank you! your script worked perfect for me.

at the begining i was in a hurry and i did't pay attention to guides/comments; today i read letter by letter, I made the corresponding changes and then it worked! kind of magic! 8)

As always, read de fu! manual!

Thanks again!

by the way, this script does not appear at mikrotik/agraid.org references and it would be great if it was there: "NOTE: If you've written a client, or have added afraid.org support to your product, please drop me a note so I can add it to the supported clients list. dnsadmin@afraid.org"

Re: freedns.afraid.org Script

Posted: Mon Aug 10, 2015 4:47 pm
by LESHIYODESSA
by the way, this script does not appear at mikrotik/agraid.org references and it would be great if it was there: "NOTE: If you've written a client, or have added afraid.org support to your product, please drop me a note so I can add it to the supported clients list. dnsadmin@afraid.org"
I have already written to dnsadmin@afraid.org, but received no response.

Re: freedns.afraid.org Script

Posted: Sat Sep 12, 2015 2:24 am
by LESHIYODESSA
Hurrah!!!

Joshua Anderson added my script on the official site.

There was a misunderstanding, my first letter to it didn't reach.

Josh is very cool guy, and his service is the coolest of all Dynamic DNS.

Re: freedns.afraid.org Script

Posted: Thu Sep 17, 2015 1:21 am
by LESHIYODESSA
Add-ons for Script

Color log messages

RED — log error ("Service Dynamic DNS: old IP address $"dns-domain-ip" for $"dns-domain" CHANGED to -> $"current-ip"")

BLUE — :log warning ("IP address is NOT CHANGED, the update is not required")

Image

Re: freedns.afraid.org Script

Posted: Thu Feb 04, 2016 9:19 am
by Kuchkro01
I'm using the service from "freedns.afraid.org" (e.g. myprivatecomputer.chickenkiller.com)

Re: freedns.afraid.org Script

Posted: Mon Feb 15, 2016 9:54 am
by james442
I've never used "freedns.afraid.org".
I use "no-ip.com" (".biz" domain).
I'll show my script.

Re: freedns.afraid.org Script

Posted: Fri Jun 10, 2016 1:59 pm
by SparcAsia
The others aren't working properly for me anymore. I've updated the earlier one to my needs. This script below now works for me from behind another router (DMZ) even!
Please don't abuse the External Public IP source by running this constantly.
It's just so I can find it for administration, and not as a public access, so about 30+ minutes is likely good enough for the scheduling part. Besides the TTL for the domain I'm using at Afraid is an hour (3600) so greater then 30 minutes makes sense.

You'll need to set your afraidDomain and the domainUpdateLink
The domain update link has a cryptic string that's unique for each record.
It's hidden slightly in their relatively newer Version 2 (prefered method #1 Randomized Update Token)
http://freedns.afraid.org/dynamic/v2/
With this script you could probably use different links and/or provider.

Note: the main difference here is it finds a Public IP via ICanHazIP.com so if you're behind another router it still works.
Since the Public IP is the one needed to access via Dynamic DNS it's the right one to make sure is registered.

# Author: MasterJames 
# Date:   2016:06:10
# Corp:   SparcAsia Holdings Inc.

:global afraidDomain "yourCustom.AfraidDomain.top"
:global domainUpdateLink "http://sync.afraid.org/u/CrypticV2UpdateStringFromAfraidOrg/"

/tool fetch url="http://icanhazip.com/" dst-path="/whatsMyIP.txt";
:global pubIP [/file get whatsMyIP.txt contents]

:for i from=( [:len $pubIP] - 1 ) to=0 do={ 
  :if ( [:pick $pubIP $i] = "\n") do={ 
    :global curIP [:pick $pubIP 0 $i];
    :if ([:resolve $afraidDomain] != $curIP) do={
      /tool fetch url="$domainUpdateLink" keep-result=no;
      :log info "Afraid.org Update: $afraidDomain - $curIP";
    } else={
      :log info "Afraid.org: does NOT need updating: $curIP";
    }
  } 
}

Re: freedns.afraid.org Script

Posted: Wed May 03, 2017 7:27 pm
by qbek
Please, can somebody check my settings?
Scheduler
name=freedns start-time=startup interval=30m on-event=/system script run freedns owner=kuba policy=ftp,reboot,read,writ
e,policy,test,password,sniff,sensitive
Script
name="freedns" owner="kuba" policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive
##############   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\?blablabla"

# 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&v=2&sha=blablabla"
	
# Specify your domain or subdomain.
:global "blablabla.mooo.com"

# Define variables for the external (WAN) interface
# Case sensitive.
:global "pppoe-out1_VDSL"
       
# !!!!!!!!!!!!!!!!! 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##################

Re: freedns.afraid.org Script

Posted: Wed May 03, 2017 8:58 pm
by LESHIYODESSA
Please, can somebody check my settings?
Image

Image

Re: freedns.afraid.org Script

Posted: Fri May 05, 2017 7:29 pm
by qbek
Please, can somebody check my settings?
Image
For example I have freedns.mooo.com and my WAN internet connection name is "pppoe-out1_VDSL".
I'm sorry but I still don't understand what have you marked. For noip ddns I used almost same values and it was ok.
Can you just type what it should like to be.

# Specify your domain or subdomain.
# :global "dns-domain" "name.com"

# Define variables for the external (WAN) interface
# Case sensitive.
# :global "out-interface" "pppoe"
Image
OK, in API link I figure out where was the problem.
You should update comment in the script in API section to remove string "v=2&" from the API link.

Re: freedns.afraid.org Script

Posted: Fri May 05, 2017 9:31 pm
by LESHIYODESSA
qbek

1. :global "out-interface" "pppoe-out1_VDSL"

2. GO --> https://freedns.afraid.org/api/ —> copy URL "ASCII" --> Paste to script —> ADD Before the question mark, put a backslash "\".

freedns change URL —> &v=2. Try it with or without it. I work without him.
:global "out-interface" "pppoe-out1_VDSL"
:global "api-url" "https://freedns.afraid.org/api/\?action=getdyndns&sha=blablabla"


Re: freedns.afraid.org Script

Posted: Mon May 08, 2017 9:09 pm
by qbek
LESHIYODESSA thanks for help, it's working now :-)

I'm observing now how it works etc. I noticed something strange. As I have VDSL, ISP auto reboot my connection after 24h and my external IP doesn't change but it should, right? Then freedns script says "IP address is NOT CHANGED, the update is not required". My last DDNS IP was working 2 maybe 3 days until this day.
Script interval time=30min.
06:12:13 system,info router rebooted
06:12:20 pppoe,ppp,info pppoe-out1_VDSL: initializing...
06:12:20 pppoe,ppp,info pppoe-out1_VDSL: connecting...
06:12:25 pppoe,ppp,info pppoe-out1_VDSL: authenticated
06:12:25 pppoe,ppp,info pppoe-out1_VDSL: connected 
I run script manually
06:19:20 script,info IP address is NOT CHANGED, the update is not required 
06:37:59 script,info IP address is NOT CHANGED, the update is not required 
06:43:50 script,info IP address is NOT CHANGED, the update is not required 
07:07:59 script,info IP address is NOT CHANGED, the update is not required 
07:37:59 script,info IP address is NOT CHANGED, the update is not required 
08:07:59 script,info IP address is NOT CHANGED, the update is not required 
08:37:59 script,info IP address is NOT CHANGED, the update is not required 
08:41:03 system,info changed script settings by xxx

here I added "s" :global "direct-url" "https://
Because https, it see that external IP has changed? when I got:
09:07:59 script,info Service Dynamic DNS: old IP address 83.24.xxx.xxx for freednsname.mooo.com CHANGED to -> 83.9.xx.xxx
09:08:06 info fetch: file "freedns.txt" downloaded 
09:37:59 script,info IP address is NOT CHANGED, the update is not required 
10:07:59 script,info IP address is NOT CHANGED, the update is not required 
10:37:59 script,info IP address is NOT CHANGED, the update is not required 
11:07:59 script,info IP address is NOT CHANGED, the update is not required

Just I must wait 24h and see what happens next.

Re: freedns.afraid.org Script

Posted: Mon May 08, 2017 10:52 pm
by LESHIYODESSA

Re: freedns.afraid.org Script

Posted: Fri Jun 16, 2017 12:22 am
by xaotikos
Can someone please review the following?
Script seems not to work, in log I get IP HAS NOT CHANGED even though it's different than this of the domain.
I run script manually in order to test it.
Thanks
##############   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" "https://freedns.afraid.org/dynamic/update.php\?xxxxxxx"

# 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" "https://freedns.afraid.org/api/\?action=getdyndns&sha=31313131313131"
  
# Specify your domain or subdomain.
:global "dns-domain" "test.to"

# Define variables for the external (WAN) interface
# Case sensitive.
:global "out-interface" "pppoe-out1"
       
# !!!!!!!!!!!!!!!!! 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 mode=https 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 mode=https url=$"direct-url" keep-result=no
# Download the file with the new IP after 5 sec.
:delay 5
/tool fetch mode=https 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"


#      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##################

Re: freedns.afraid.org Script

Posted: Fri Jun 16, 2017 12:39 pm
by xaotikos
It worked!
I had two domains registered in freedns.afraid.org with different target ips (unlinked). I deleted the second one.
Moreover, for some reason in script source (winbox) text was unformatted (without spaces, tabs etc) so I uploaded again correctly.

I dont know which of these two affected the script

Re: freedns.afraid.org Script

Posted: Fri Jun 16, 2017 12:45 pm
by LESHIYODESSA
It worked!
I had two domains registered in freedns.afraid.org with different target ips (unlinked). I deleted the second one.
Moreover, for some reason in script source (winbox) text was unformatted (without spaces, tabs etc) so I uploaded again correctly.
The script works if you have multiple domains.

Image

Re: freedns.afraid.org Script

Posted: Mon Sep 25, 2017 4:12 am
by easyyu
This is the only script what worked for me:
https://github.com/midenok/hardware/blob/master/mikrotik/freedns.rsc

Re: freedns.afraid.org Script

Posted: Fri Oct 27, 2017 1:22 pm
by DaOs
Something more easy using freedns v2.

See attachment.

Modify your freedns v2 key.

Run import script.
freedns-v2-opic-import.rsc

Re: freedns.afraid.org Script

Posted: Wed May 02, 2018 2:53 am
by qbek
Did it works on the newest 6.42.1? I need to known that before software update.

Re: freedns.afraid.org Script

Posted: Wed May 02, 2018 10:41 am
by LESHIYODESSA
Did it works on the newest 6.42.1?
Sorry, but I do not have the opportunity to check.

In order not to lose access, you can simultaneously use — https://wiki.mikrotik.com/wiki/Manual:IP/Cloud (Starting with RouterOS v6.14).

Re: freedns.afraid.org Script

Posted: Wed May 02, 2018 5:24 pm
by juliokato
Did it works on the newest 6.42.1?
Sorry, but I do not have the opportunity to check.

In order not to lose access, you can simultaneously use — https://wiki.mikrotik.com/wiki/Manual:IP/Cloud (Starting with RouterOS v6.14).
MT cloud is very unstable and NTP is almost always incorrect.
As soon as they resolve the outages, We will consider using them.

Re: freedns.afraid.org Script

Posted: Wed May 09, 2018 8:54 pm
by qbek
Works good on 6.43rc7 :-)