Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Dynamic DNS Update Script for DynDNS behind nat
- # Set needed variables
- :local username "xxx"
- :local password "xxx"
- :local host "xxx.dyndns.org"
- :global previousIP
- # print some debug info
- # :log info ("Update No-IP DNS: username = $username")
- # :log info ("Update No-IP DNS: hostname = $host")
- :log info ("Update DynDNS: previousIP = $previousIP")
- #
- # behind nat - get the public address using dyndns url http://checkip.dyndns.org
- /tool fetch mode=http address="checkip.dyndns.org" src-path="/" dst-path="/dyndns.checkip.html"
- :delay 2
- :local result [/file get dyndns.checkip.html contents]
- :log info "dyndns result = $result"
- # 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: currentIP = $currentIP"
- :if ($currentIP != $previousIP) do={
- :log info "DynDNS: Current IP $currentIP is not equal to previous IP, update needed"
- :set previousIP $currentIP
- :local url "http://members.dyndns.org/nic/update?system=dyndns&hostname=$host&myip=$currentIP&wildcard=no"
- :log info "DynDNS: Sending update for $host"
- /tool fetch url=$url user=$username password=$password mode=http dst-path=("/dyndns.txt")
- :log info "DynDNS: Host $host updated on DynDNS with IP $currentIP"
- :delay 2
- :local result [/file get "dyndns.txt" contents]
- :log info "Update Result = $result"
- } else={
- :log info "DynDNS: update not needed "
- }
- # end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement