First Commit

This commit is contained in:
Peter Baumann 2013-07-15 17:01:18 +02:00
commit a0a93dd98a
2 changed files with 48 additions and 0 deletions

0
README.md Normal file
View file

48
src/dns-update.rsc Normal file
View file

@ -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."
}
}