Dynamic DNS Update Script for EveryDNS

From MikroTik Wiki
Revision as of 13:17, 27 April 2009 by Marisb (talk | contribs)
Jump to: navigation, search

This script allow you to easily maintain dynamic updates at EveryDNS free DNS server.
First you have to setup an account at http://www.everydns.com/, and with few steps create dynamic domain. After that you have to setup EasyDNS servers NS DNS parameters at domain seller site.

Next script is build with target to update DNS with two or more PPPoE connection with dynamics IP addresses.

# Define user variables
# Please NOTE that your username and password will be sent cleartext across the internet!
:local eduser "USERNAME"
:local edpass "PASS"
:local eddomain "mydomain.com" 
:local edinterface "INTERFACE_NAME"

# Change this global variable if you want more than 1 script
:global edlastip1
:local str
:local edip
:local ip

:if ([ :typeof $edlastip1 ] = nil ) do={ :global edlastip1 "0" }

:local ip [ /ip address get [/ip address find interface=$edinterface ] address ]
# TODO: netmask can be more than 2 characters
:local edip [ :pick $ip 0 ([:len $ip]-3)]
:if ([ :typeof $edip ] = nil ) do={
   :log info ("EveryDNS: No ip address on $edinterface .")
} else={

  :if ($edip != $edlastip1) do={

    :log info ("EveryDNS: $eddomain -> $edip")
    :local str "/index.php?ver=0.1&ip=$edip&domain=$eddomain"
    /tool fetch url="http://dyn.everydns.net/$str" mode=http user=$eduser password=$edpass dst-path=("/EveryDNS.".$eddomain)
    :delay 1 
    :local str [/file find name=("EveryDNS.".$eddomain)]
# do not delete file. If something is wrong, useful information can be found in it's contents.
#    /file remove $str
    :global edlastip1 $edip

  } 

}
# Coded by Paxy

You should setup this script, so using username and password as you registered at http://www.everydns.com/. Dynamic domain should be name of sub-domain that you want to be updated automaticly ex. r.paxy.in.rs . Interface name field should be exact name of interface that you want to monitor for IP change, in my case it is PPPoE type interfaces.

If you want to monitor more then one interface, create another script, fill username and pass, change sub-domain to another sub-domain name, and change interface that monitor IP address. Because of spoofing protection, you have to change variable "edlastip1" to any other name, like "edlastip2" in whole script.
Script use server with DNS name dyn.everydns.net.

All what is left now is to make scheduler to run this or those scripts every minute.

/system scheduler add name=EveryDNS1 interval=00:01 on-event="/system script run everyDns1\r\n/system script run everyDns2"


Happy hacking ...

Modified to work with version 3.23