Advertisement
rem_lex

Mikrotik resolve

Sep 21st, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. # define variables
  2. :local list
  3. :local comment
  4. :local newip
  5.  
  6. # Loop through each entry in the address list.
  7. :foreach i in=[/ip firewall address-list find list="blocked-site" disabled=no] do={
  8.  
  9. # Get the comment for this address list item (this is the host name to use)
  10. :set comment [/ip firewall address-list get $i comment]
  11.  
  12. # Resolve it and set the address list entry accordingly.
  13. #:log info "dns resolve $comment"
  14. :do {
  15. :set newip [:resolve $comment]
  16. :if ( [:len [/ip firewall address-list find list="blocked-host" address=$newip]] = 0 ) do={
  17. /ip firewall address-list add address=$newip list=blocked-host comment=$comment
  18. }
  19. } on-error={
  20. :log error "dns normal resolve failure $comment"
  21. }
  22.  
  23. :do {
  24. :set newip [:resolve $comment server=8.8.8.8]
  25. :if ( [:len [/ip firewall address-list find list="blocked-host" address=$newip]] = 0 ) do={
  26. /ip firewall address-list add address=$newip list=blocked-host comment=$comment
  27. }
  28. } on-error={
  29. :log error "dns google resolve failure $comment"
  30. }
  31.  
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement