Njalla: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
Script to update the Njalla Dynamic DNS from RouterOS. | Script to update the Njalla Dynamic DNS from RouterOS. | ||
# ___ ___ | |||
# ___ ___ | # ________ ___ ______ / / / / _____ | ||
# ________ ___ ______ / / / / _____ | # \ \ \__\_\___ \/ / / /_\___ \ | ||
# \ \ \__\_\___ \/ / / /_\___ \ | # / \ / / / _ / /_/ // _ / | ||
# / \ / / / _ / /_/ // _ / | # / // /\/ / / / / / / / | ||
# / // /\/ / / / / / / / | # / __//__/ /\_______\____\___\_______\ | ||
# / __//__/ /\_______\____\___\_______\ | # \/ \____/ | ||
# \/ \____/ | # | ||
# | # Njal.la Dynamic DNS v1.0 | ||
# Njal.la Dynamic DNS v1.0 | # | ||
# | # This script requires these policies: read, policy, test. | ||
# This script requires these policies: read, policy, test. | # | ||
# | # 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 | ||
# 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 | # | ||
# | # Configurable items here: | ||
# Configurable items here: | |||
:local domain "<your-domain>" | |||
:local domain "<your-domain>" | :local key "<your-key>" | ||
:local key "<your-key>" | :local WANinterface "<your-wan-interface>" | ||
:local WANinterface "<your-wan-interface>" | |||
# Leave the rest of the script as is. | |||
# Leave the rest of the script as is. | :global NjallaIP | ||
:global NjallaIP | :local ipv4addr | ||
:local ipv4addr | |||
:set ipv4addr [/ip address get [/ip address find interface="$WANinterface"] address] | |||
:set ipv4addr [/ip address get [/ip address find interface="$WANinterface"] address] | :set ipv4addr [:pick [:tostr $ipv4addr] 0 [:find [:tostr $ipv4addr] "/"]] | ||
:set ipv4addr [:pick [:tostr $ipv4addr] 0 [:find [:tostr $ipv4addr] "/"]] | |||
:if ([:len $ipv4addr] = 0) do={ | |||
: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={ | |||
: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 { | |||
} else { | :log info ("Dynamic IPv4 address is still " . $ipv4addr) | ||
} | |||
} | |||
Latest revision as of 14:59, 27 December 2017
Script to update the Njalla Dynamic DNS from RouterOS.
# ___ ___ # ________ ___ ______ / / / / _____ # \ \ \__\_\___ \/ / / /_\___ \ # / \ / / / _ / /_/ // _ / # / // /\/ / / / / / / / # / __//__/ /\_______\____\___\_______\ # \/ \____/ # # Njal.la Dynamic DNS v1.0 # # This script requires these policies: read, policy, test. # # 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 # # Configurable items here: :local domain "<your-domain>" :local key "<your-key>" :local WANinterface "<your-wan-interface>" # 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) }