From a0a93dd98ad9a8f43fc506d2f8e722c11769a7c1 Mon Sep 17 00:00:00 2001 From: Peter Baumann Date: Mon, 15 Jul 2013 17:01:18 +0200 Subject: [PATCH] First Commit --- README.md | 0 src/dns-update.rsc | 48 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 README.md create mode 100644 src/dns-update.rsc diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/src/dns-update.rsc b/src/dns-update.rsc new file mode 100644 index 0000000..db43d86 --- /dev/null +++ b/src/dns-update.rsc @@ -0,0 +1,48 @@ +{ +# Automatic Dynamic DNS update + +#--------------- Change Values in this section to match your setup ------------------ + +# Set the hostname/domainname or label of network to be updated. +:local hostname "host01" +:local domainname "dyn.domain.ch" +:local fqdnhost "" +:set fqdnhost "$hostname.$domainname" + +# Change to the name of interface that gets the dynamic IP address +:local inetinterface "WAN" + +#------------------------------------------------------------------------------------ +# No more changes need + +:global previousIP + +:if ([/interface get $inetinterface value-name=running]) do={ +# Get the current IP on the interface + :local currentIP [/ip address get [find interface="$inetinterface" disabled=no] address] + +# Strip the net mask off the IP address + :for i from=( [:len $currentIP] - 1) to=0 do={ + :if ( [:pick $currentIP $i] = "/") do={ + :set currentIP [:pick $currentIP 0 $i] + } + } + + :if ($currentIP != $previousIP) do={ + :log info "DynDNS: Current IP $currentIP is not equal to previous IP, update needed" + :set previousIP $currentIP + + :local fqdnhostarray + :set fqdnhostarray [:toarray $fqdnhost] + :foreach host in=$fqdnhostarray do={ + :log info "DynDNS: Sending update for $host" + /tool dns-update dns-server=1.2.3.4 name=$hostname zone=$domainname address=$currentIP key-name=dyndns key="987Hkjh789hjlukhzz=="; + :log info "DynDNS: Host $host updated on $domainname with IP $currentIP" + } + } else={ + :log info "DynDNS: Previous IP $previousIP is equal to current IP, no update needed" + } +} else={ + :log info "DynDNS: $inetinterface is not currently running, so therefore will not update." +} +}