-
-
Save sgeto/ae4a941756137474fd78ececb279d45b to your computer and use it in GitHub Desktop.
Mikrotik script generate address list from DNS cache entries
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:foreach i in=[/ip dns cache find] do={ | |
:local bNew "true"; | |
:local cacheName [/ip dns cache all get $i name] ; | |
# :put $cacheName; | |
:if (([:find $cacheName "facebook" -1] >= 0) || ([:find $cacheName "outlook" -1] >= 0)) do={ | |
:local tmpAddress [/ip dns cache get $i address] ; | |
:put $cacheName; | |
:put $tmpAddress; | |
# if address list is empty do not check | |
:if ( [/ip firewall address-list find ] = "") do={ | |
:log info ("added entry: $[/ip dns cache get $i name] IP $tmpAddress"); | |
/ip firewall address-list add address=$tmpAddress list=youtube_dns_ips comment=$cacheName; | |
} else={ | |
:foreach j in=[/ip firewall address-list find ] do={ | |
:if ( [/ip firewall address-list get $j address] = $tmpAddress ) do={ | |
:set bNew "false"; | |
} | |
} | |
:if ( $bNew = "true" ) do={ | |
:log info ("added entry: $[/ip dns cache get $i name] IP $tmpAddress"); | |
/ip firewall address-list add address=$tmpAddress list=youtube_dns_ips comment=$cacheName; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment