Advertisement
Guest User

Untitled

a guest
Oct 6th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. Implementation
  2.  
  3. What we do here is check the IP on the interface in question every minute (less or more if you want) using the system scheduler. The main script included below keeps an internal record of the IP of the interface it is checking and if the IP is seen to change it send off an update.
  4.  
  5. The other 2 scripts are to see what the system thinks the last known IP was, and to reset the know IP so as to force an update.
  6.  
  7.  
  8. ==DynDNS==
  9.  
  10. # Define Variables
  11.  
  12. :local ddnsuser "username"
  13. :local ddnspass "password"
  14. :local ddnshost "host.domain.name"
  15. :local ddnsinterface "interface name"
  16. :global ddnsip
  17. :global ddnslastip
  18.  
  19. #Set empty to 0 value
  20. :if ([ :typeof $ddnslastip ] = nil ) do={ :global ddnslastip "0" }
  21.  
  22. # Grab the current IP address on that interface.
  23. :global ddnsip [ /ip address get [/ip address find interface=$ddnsinterface ] address ]
  24. :local endloc [:find $ddnsip "/" -1]
  25. :set ddnsip [:pick $ddnsip 0 $endloc]
  26.  
  27. # Did we get an IP address to compare?
  28. :if ([ :typeof $ddnsip ] = nil ) do={
  29. :log info ("DynDNS: No ip address present on " . $ddnsinterface . ", please check.")
  30. } else={
  31. :if ($ddnsip != $ddnslastip) do={
  32. :log info "Address Changed from $ddnslastip to $ddnsip"
  33. :log info "DynDNS: Sending UPDATE!"
  34. :local str "/nic/update?hostname=$ddnshost&myip=$ddnsip&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG"
  35. /tool fetch address=members.dyndns.org src-path=$str mode=http user=$ddnsuser password=$ddnspass dst-path=("/DynDNS.".$ddnshost)
  36. :delay 1
  37. :local str [/file find name="DynDNS.$ddnshost"];
  38. /file remove $str
  39. :global ddnslastip $ddnsip
  40. }
  41. }
  42.  
  43.  
  44. ==DynInfo==
  45.  
  46. :global ddnslastip
  47. :log info "IP was $ddnslastip"
  48.  
  49. ==DynReset==
  50.  
  51. :global ddnslastip "0"
  52.  
  53.  
  54. =======
  55. Add this line to the scheduler, called DynDNS, set the interval to 00:01:00, Start Date to Jan/01/1970 and allow all access in the policies.
  56. =======
  57.  
  58. /system script run DynDNS
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement