Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. # No-IP automatic Dynamic DNS update
  2. #
  3. #--------------- Change Values in this section to match your setup ------------------
  4.  
  5. # No-IP User account info
  6. :local noipuser ""
  7. :local noippass ""
  8.  
  9. # Set the hostname or label of network to be updated.
  10. # Hostnames with spaces are unsupported. Replace the value in the quotations below with your host names.
  11. # To specify multiple hosts, separate them with commas.
  12. :local noiphost ""
  13.  
  14. # Change to the name of interface that gets the dynamic IP address
  15. :local inetinterface ""
  16.  
  17. #------------------------------------------------------------------------------------
  18. # No more changes need
  19.  
  20. :local previousIP
  21.  
  22. if ( [:len [/file find name=("no-ip_ddns_previousip.txt")]] > 0 ) do={
  23. :set previousIP [/file get ("no-ip_ddns_previousip.txt") contents]
  24. }
  25.  
  26.  
  27. :if ([/interface get $inetinterface value-name=running]) do={
  28. # Get the current IP on the interface
  29. :local currentIP [/ip address get [find interface="$inetinterface" disabled=no] address]
  30.  
  31. # Strip the net mask off the IP address
  32. :for i from=( [:len $currentIP] - 1) to=0 do={
  33. :if ( [:pick $currentIP $i] = "/") do={
  34. :set currentIP [:pick $currentIP 0 $i]
  35. }
  36. }
  37.  
  38. :if ($currentIP != $previousIP) do={
  39. :log info "No-IP: Current IP ($currentIP) is not equal to previous IP ($previousIP), update needed"
  40.  
  41. # The update URL. Note the "\3F" is hex for question mark (?). Required since ? is a special character in commands.
  42. :local url "http://dynupdate.no-ip.com/nic/update\3Fmyip=$currentIP"
  43. :local noiphostarray
  44. :set noiphostarray [:toarray $noiphost]
  45. :foreach host in=$noiphostarray do={
  46. :log info "No-IP: Sending update for $host"
  47. /tool fetch url=($url . "&hostname=$host") user=$noipuser password=$noippass mode=http dst-path=("no-ip_ddns_update-" . $host . ".txt")
  48. :log info "No-IP: Host $host updated on No-IP with IP $currentIP"
  49. /file print file=("no-ip_ddns_previousip.txt")
  50. :delay 3
  51. /file set contents="$currentIP" ("no-ip_ddns_previousip.txt")
  52. }
  53. } else={
  54. :log info "No-IP: Previous IP $previousIP is equal to current IP, no update needed"
  55. }
  56. } else={
  57. :log info "No-IP: $inetinterface is not currently running, so therefore will not update."
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement