freedns.afraid.org Script

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

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"

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.

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"

LESHIYODESSA thanks for help, it’s working now :slight_smile:

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.

qbek

https://wiki.mikrotik.com/wiki/Manual:IP/Cloud

https://www.google.com/#q=mikrotik+Cloud&tbm=vid

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

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

The script works if you have multiple domains.

This is the only script what worked for me:

https://github.com/midenok/hardware/blob/master/mikrotik/freedns.rsc

Something more easy using freedns v2.

See attachment.

Modify your freedns v2 key.

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

Did it works on the newest 6.42.1? I need to known that before software update.

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.

Works good on 6.43rc7 :slight_smile:

please help me
i cant download freedns-v2-opic-import.rsc
error “The selected attachment does not exist anymore.”