Advertisement
Guest User

Untitled

a guest
Dec 18th, 2017
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 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 "YOURNOIPUSER"
  7. :local noippass "YOURPASS"
  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 "YOURNOIP.ddns.net"
  13.  
  14. # Change to the name of interface that gets the dynamic IP address
  15. :local inetinterface "pppoe-out1"
  16.  
  17. #------------------------------------------------------------------------------------
  18. # No more changes need
  19.  
  20. #:global previousIP;
  21.  
  22. :if ([/interface get $inetinterface value-name=running]) do={
  23.  
  24. # Get the current IP on the interface
  25.  
  26. :local currentIP [:put [:pick [/ip address get [:pick [find interface=$inetinterface] 1] address] 0 [:find [ip address get [:pick [find interface=$inetinterface] 1] address] "/"]]];
  27.  
  28. # Strip the net mask off the IP address
  29. :for i from=( [:len $currentIP] - 1) to=0 do={
  30. :if ( [:pick $currentIP $i] = "/") do={
  31. :set currentIP [:pick $currentIP 0 $i];
  32. }
  33. }
  34.  
  35. :local previousIP [:resolve "$noiphost"];
  36.  
  37. :log info "DNS IP: $previousIP, interface IP: $currentIP";
  38.  
  39. :if ($currentIP != $previousIP) do={
  40. :log info "No-IP: Current IP $currentIP is not equal to previous IP $previousIP, update needed";
  41. # :set previousIP $currentIP;
  42. :local url "http://dynupdate.no-ip.com/nic/update\3Fmyip=$currentIP";
  43. :log info "No-IP: Sending update for $noiphost";
  44. /tool fetch url=($url . "&hostname=$noiphost") user=$noipuser password=$noippass mode=http dst-path=("no-ip_ddns_update-" . $host . ".txt")
  45. :log info "No-IP: Host $noiphost updated on No-IP with IP $currentIP";
  46.  
  47. } else={
  48. :log info "No-IP: Previous IP $previousIP is equal to current IP, no update needed";
  49. }
  50. } else={
  51. :log info "No-IP: $inetinterface is not currently running, so therefore will not update.";
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement