Njalla

From MikroTik Wiki
Revision as of 14:58, 27 December 2017 by Normis (talk | contribs)
Jump to navigation Jump to search

Script to update the Njalla Dynamic DNS from RouterOS.

  1. ___ ___
  2. ________ ___ ______ / / / / _____
  3. \ \ \__\_\___ \/ / / /_\___ \
  4. / \ / / / _ / /_/ // _ /
  5. / // /\/ / / / / / / /
  6. / __//__/ /\_______\____\___\_______\
  7. \/ \____/
  8. Njal.la Dynamic DNS v1.0
  9. This script requires these policies: read, policy, test.
  10. To add this to the scheduler, first add this script as "njalla", then use: /system scheduler add interval=5m name=njalla on-event=njalla policy=read,write,policy,test start-time=startup
  11. Configurable items here:
local domain "<your-domain>"
local key "<your-key>"
local WANinterface "<your-wan-interface>"
  1. Leave the rest of the script as is.
global NjallaIP
local ipv4addr
set ipv4addr [/ip address get [/ip address find interface="$WANinterface"] address]
set ipv4addr [:pick [:tostr $ipv4addr] 0 [:find [:tostr $ipv4addr] "/"]]
if ([:len $ipv4addr] = 0) do={
  :log error ("Could not get IP for interface " . $WANinterface)
  :error ("Could not get IP for interface " . $WANinterface)

}

if ($ipv4addr != $NjallaIP) do={
   :put "IPv4 address changed to $ipv4addr";
   :set NjallaIP $ipv4addr;
   :log info ("Updating dynamic IPv4 address to IP " . $ipv4addr)
   /tool fetch check-certificate=no keep-result=no mode=https url="https://njal.la/update/?h=$domain&k=$key&a=$ipv4addr&quiet"

} else {

   :log info ("Dynamic IPv4 address is still " . $ipv4addr)

}