Friday, July 18, 2014

CHANGEIP Script For Mikrotik with Private IP

update script for ChangeIP on Mikrotik

#BEGINNING OF SCRIPT
:global ddnsuser "user"
:global ddnspass "pass"
:global ddnshost "aasass.changeip.net"
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# END OF USER DEFINED CONFIGURATION
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# begin - khusus utk mikrotik dibelakang modem/router lain
# buat dulu 1 entry di /ip fire address-list dgn comment "mychangeIP", isikan sembarang IP dan Nama List-nya
# first, make an entry on /ip fire address-list and put  "mychangeIP" as comment. any IP and Listname will do
:global IPSaya [/ip fire address-list find comment="mychangeIP"];
{
/tool fetch url="http://myip.dnsomatic.com/" mode=http dst-path=amychangeip.txt
}
:global ddnsip [file get amychangeip.txt contents ]
#:global ddnslastip penikmattahu.blogspot.com
:global ddnslastip [/ip fire address-list get $IPSaya address]

# end of - khusus utk mikrotik dibelakang modem/router lain

  :if ($ddnsip != $ddnslastip) do={

    :log info "DDNS: Sending UPDATE!"
    :log info [ :put [/tool dns-update name=$ddnshost address=$ddnsip key-name=$ddnsuser key=$ddnspass ] ]
    :global ddnslastip $ddnsip

     /ip fire address-list set $IPSaya address=$ddnsip;
     :log info "ChangeIP Update: $ddnshost - $ddnsip"

  } else={

    :log info "ChangeIP DDNS: No changes necessary."

  }


# END OF SCRIPT