Advertisement
Guest User

Untitled

a guest
Aug 11th, 2017
444
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. # No-IP automatic Dynamic DNS update
  2.  
  3. #--------------- Change Values in this section to match your setup ------------------
  4.  
  5. :local noipuser "alexrudenkiy2014@gmail.com"
  6. :local noippass "СуперПуперМегаПароль"
  7. :local noiphost "alexserver.bounceme.net"
  8.  
  9. # Change to the name of interface that gets the dynamic IP address
  10. :local inetinterface "ether1"
  11.  
  12. #------------------------------------------------------------------------------------
  13. # No more changes need
  14.  
  15. :if ([/interface get $inetinterface value-name=running]) do={
  16. # Get the current IP on the interface
  17. :local currentIP [/ip address get [find interface="$inetinterface" disabled=no] address]
  18.  
  19. # Strip the net mask off the IP address
  20. :for i from=( [:len $currentIP] - 1) to=0 do={
  21. :if ( [:pick $currentIP $i] = "/") do={
  22. :set currentIP [:pick $currentIP 0 $i]
  23. }
  24. }
  25.  
  26. # The update URL. Note the "3F" is hex for question mark (?). Required since ? is a special character in commands.
  27. :local url "http://dynupdate.no-ip.com/nic/update3Fmyip=$currentIP"
  28. :local noiphostarray
  29. :set noiphostarray [:toarray $noiphost]
  30.  
  31. :foreach host in=$noiphostarray do={
  32. # Check 1 - resolved IP
  33. :local resolvedIP [:resolve $host];
  34.  
  35. # Check 2 - Saved response from NO-IP
  36. :local filename ("no-ip_ddns_update-" . $host . ".txt")
  37. :local savedMatch -1
  38. :local savedIP "No File";
  39.  
  40. if ( [:len [/file find name=$filename]] > 0 ) do={
  41. :set savedIP [/file get $filename contents]
  42. :set savedMatch [:find $savedIP $currentIP -1]
  43. }
  44.  
  45. # If either check fails, update IP
  46. :if (($currentIP = $resolvedIP) && ($savedMatch >= 0)) do={
  47. :log info "No-IP: Host $host already on No-IP with IP $resolvedIP"
  48. } else={
  49. :log info "No-IP: Sending update for $host - $resolvedIP saved as $savedIP"
  50. /tool fetch url=($url . "&hostname=$host") user=$noipuser password=$noippass mode=http dst-path=$filename
  51. :log info "No-IP: Host $host updated on No-IP with IP $currentIP"
  52. }
  53. }
  54. } else={
  55. :log info "No-IP: $inetinterface is not currently running, so therefore will not update."
  56. }
  57.  
  58. Chain : dstnat
  59. Protocol : 6 (tcp)
  60. Dst. Port : 5665
  61. In. Interface : ether1
  62.  
  63. Action : dst-nat
  64. To Addresses : 192.168.88.245 (адрес моего компа в локалке)
  65. To Ports : 5665
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement