Advertisement
exliko

dyndns mikrotik

Mar 15th, 2016
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. #Dynamic DNS Update Script for DynDNS behind nat
  2. # Set needed variables
  3. :local username "xxx"
  4. :local password "xxx"
  5. :local host "xxx.dyndns.org"
  6. :global previousIP
  7. # print some debug info
  8. # :log info ("Update No-IP DNS: username = $username")
  9. # :log info ("Update No-IP DNS: hostname = $host")
  10. :log info ("Update DynDNS: previousIP = $previousIP")
  11. #
  12. # behind nat - get the public address using dyndns url http://checkip.dyndns.org
  13. /tool fetch mode=http address="checkip.dyndns.org" src-path="/" dst-path="/dyndns.checkip.html"
  14. :delay 2
  15. :local result [/file get dyndns.checkip.html contents]
  16. :log info "dyndns result = $result"
  17. # parse the current IP result
  18. :local resultLen [:len $result]
  19. :local startLoc [:find $result ": " -1]
  20. :set startLoc ($startLoc + 2)
  21. :local endLoc [:find $result "</body>" -1]
  22. :local currentIP [pick $result $startLoc $endLoc]
  23. :log info "DynDNS: currentIP = $currentIP"
  24. :if ($currentIP != $previousIP) do={
  25. :log info "DynDNS: Current IP $currentIP is not equal to previous IP, update needed"
  26. :set previousIP $currentIP
  27. :local url "http://members.dyndns.org/nic/update?system=dyndns&hostname=$host&myip=$currentIP&wildcard=no"
  28. :log info "DynDNS: Sending update for $host"
  29. /tool fetch url=$url user=$username password=$password mode=http dst-path=("/dyndns.txt")
  30. :log info "DynDNS: Host $host updated on DynDNS with IP $currentIP"
  31. :delay 2
  32. :local result [/file get "dyndns.txt" contents]
  33. :log info "Update Result = $result"
  34. } else={
  35. :log info "DynDNS: update not needed "
  36. }
  37. # end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement