# Set needed variables :local ddnsuser "username" :local ddnspass "password" :local theinterface "interface" :local ddnshost "hostname.no-ip.org" :local ipddns [:resolve $ddnshost]; :local ipfresh [ /ip address get [/ip address find interface=$theinterface ] address ] :if ([ :typeof $ipfresh ] = nil ) do={ :log info ("No-IPDNS: No ip address on $theinterface .") } else={ :for i from=( [:len $ipfresh] - 1) to=0 do={ :if ( [:pick $ipfresh $i] = "/") do={ :set ipfresh [:pick $ipfresh 0 $i]; } } :if ($ipddns != $ipfresh) do={ :log info ("No-IPDNS: IP-DynDNS = $ipddns") :log info ("No-IPDNS: IP-Fresh = $ipfresh") :log info "No-IPDNS: Update IP needed, Sending UPDATE...!" :local str "/nic/update?hostname=$ddnshost&myip=$ipfresh" /tool fetch address=dynupdate.no-ip.com src-path=$str mode=http user=$ddnsuser \ password=$ddnspass dst-path=("/No-IPDNS.".$ddnshost) :delay 1 :local str [/file find name="No-IPDNS.$ddnshost"]; /file remove $str :global ipddns $ipfresh :log info "No-IPDNS: IP updated to $ipfresh!" } else={ :log info "No-IPDNS: dont need changes"; } } |
# No-ip DNS control automatic updates # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # EDIT YOUR DETAILS / CONFIGURATION HERE # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :local username "No-IP Username" :local password "No-IP Password" :local hostname "Your No-IP Hostname" # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # END OF USER DEFINED CONFIGURATION # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :global dyndnsForce :global previousIP # print some debug info #:log info ("No-IPddns-update: username = $username") #:log info ("No-IPddns-update: password = $password") #:log info ("No-IPddns-update: hostname = $hostname") #:log info ("No-IPddns-update: previousIP = $previousIP") # get the current IP address from the internet (in case of double-nat) /tool fetch mode=http address="checkip.dyndns.org" src-path="/" dst-path="/dyndns.checkip.html" :local result [/file get dyndns.checkip.html contents] # parse the current IP result :local resultLen [:len $result] :local startLoc [:find $result ": " -1] :set startLoc ($startLoc + 2) :local endLoc [:find $result "</body>" -1] :local currentIP [:pick $result $startLoc $endLoc] :log info "dyndns-update: currentIP = $currentIP" # Determine if dyndns update is needed # more dyndns updater request details available at http://www.dyndns.com/developers/specs/syntax.html (http://www.dyndns.com/developers/specs/syntax.html) :if (($currentIP != $previousIP) || ($dyndnsForce = true)) do={ :set dyndnsForce false :set previousIP $currentIP /tool fetch user=$username password=$password mode=http address="dynupdate.no-ip.com" src-path="/nic/update?hostname=$hostname&myip=$currentIP" :local result [/file get dyndns.txt contents] :log info ("No-IPddns-update: No-IPddns update needed") :log info ("No-IPddns-update: No-IPddns Update Result: ".$result) :put ("No-IPddns Update Result: ".$result) } else={ :log info ("No-IPddns-update: No No-IPddns update needed") } } |
# No-ip DNS control automatic updates
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# EDIT YOUR DETAILS / CONFIGURATION HERE
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:local username "No-IP Username"
:local password "No-IP Password"
:local hostname "Your No-IP Hostname"
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# END OF USER DEFINED CONFIGURATION
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:global dyndnsForce
:global previousIP
# print some debug info
#:log info ("No-IPddns-update: username = $username")
#:log info ("No-IPddns-update: password = $password")
#:log info ("No-IPddns-update: hostname = $hostname")
#:log info ("No-IPddns-update: previousIP = $previousIP")
# get the current IP address from the internet (in case of double-nat)
/tool fetch mode=http address="checkip.dyndns.org" src-path="/" dst-path="/dyndns.checkip.html"
:local result [/file get dyndns.checkip.html contents]
# parse the current IP result
:local resultLen [:len $result]
:local startLoc [:find $result ": " -1]
:set startLoc ($startLoc + 2)
:local endLoc [:find $result "</body>" -1]
:local currentIP [:pick $result $startLoc $endLoc]
:log info "dyndns-update: currentIP = $currentIP"
# Determine if dyndns update is needed
# more dyndns updater request details available at http://www.dyndns.com/developers/specs/syntax.html
:if (($currentIP != $previousIP) || ($dyndnsForce = true)) do={
:set dyndnsForce false
:set previousIP $currentIP
/tool fetch user=$username password=$password mode=http address="dynupdate.no-ip.com" src-path="/nic/update?hostname=$hostname&myip=$currentIP"
:local result [/file get dyndns.txt contents]
:log info ("No-IPddns-update: No-IPddns update needed")
:log info ("No-IPddns-update: No-IPddns Update Result: ".$result)
:put ("No-IPddns Update Result: ".$result)
} else={
:log info ("No-IPddns-update: No No-IPddns update needed")
}
}