1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
| # 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?MnRXazdTb1\*\*\*\*\*\*\*\*\*\*\*\*\*ZndoZG1BOjE3MDczNDY1"
# 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" "\*\*\*\*\*\*\*.us.to|180.112.220.65|http://freedns.afraid.org/dynamic/update.php?MnRXazdT\*\*\*\*\*\*\*\*\*\*\*\*\*\*ZndoZG1BOjE3MDczNDY1" # Specify your domain or subdomain. :global "\*\*\*\*\*\*\*.us.to"
# Define variables for the external (WAN) interface # Case sensitive. :global "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 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\?UVdjU2lzQmQw\*\*\*\*\*\*\*\*\*\*\*\*\*dXFtOjg2NTI0NzE="
# 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## ## ## ## ## ## ## ## ##
|