Advertisement
ardhan86net

Simple Script for Dynamic IP Public on Mikrotik Using no-ip.

Apr 29th, 2016
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. # Set needed variables
  2. :global username "yourname"
  3. :global password "yourpasswd"
  4. :global hostname "yourhostname"
  5. :global wanInt "waninterface"
  6. :global noipForce
  7. :global previousIP2
  8. # print some debug info
  9. #:log info ("DDNS: username = $username")
  10. #:log info ("DDNS: password = $password")
  11. :log info ("DDNS: hostname = $hostname")
  12. :log info ("DDNS: previousIP = $previousIP2")
  13. # Grab the current IP address on that interface.
  14. :global ddnsip [/ip address get [/ip address find interface="$wanInt"] address]
  15. :global currentIP [:pick $ddnsip 0 [:find $ddnsip "/"]]
  16. #:log info ("DDNS: ddnsip = $ddnsip")
  17. :log info ("DDNS: currentIP = $currentIP")
  18. # Remove the # on next line to force an update every single time - useful for debugging, but you could end up getting blacklisted by No-IP!
  19. #:set noipForce true
  20. # Determine if no-ip update is needed
  21. # more no-ip updater request details available at http://www.no-ip.com/integrate/request/
  22. :if (($currentIP != $previousIP2) || ($noipForce = true)) do={
  23. :set noipForce false
  24. :set previousIP2 $currentIP
  25. :log info ("DDNS: No-IP update needed")
  26. :log info ("DDNS: Start of Fetch")
  27. global tmp [/tool fetch mode=http port=80 address=dynupdate.no-ip.com host=dynupdate.no-ip.com src-path="/nic/update?hostname=$hostname&myip=$currentIP" user=$username password=$password dst-path="/noip2.txt"]
  28. :log info ("DDNS: End of Fetch")
  29. :global result [/file get noip2.txt contents]
  30. :log info ("DDNS: No-IP Update Result: $result")
  31. :put ("No-IP Update Result: $result")
  32. # Update HE.net Tunnel
  33. # :execute script=HE-NET
  34. } else={
  35. :log info ("DDNS: No No-IP update needed")
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement