Skip to content

Instantly share code, notes, and snippets.

@elico
Last active January 14, 2025 03:30
Show Gist options
  • Save elico/ce829a33f6eb288b64738aca138e86c4 to your computer and use it in GitHub Desktop.
Save elico/ce829a33f6eb288b64738aca138e86c4 to your computer and use it in GitHub Desktop.
An example of domains check with regex in the dns cache of mikrotik
:foreach i in=[/ip dns cache find name~"(youtube-ui.l.google.com|youtube.com|googlevideo.com)\$" && $type ~ "^(A|CNAME)\$" ] do={
:local tmpAddress [/ip dns cache get $i data];
:local cacheName [/ip dns cache get $i name] ;
delay delay-time=10ms
:if ( [/ip firewall address-list find where address=$tmpAddress list=YOUTUBE_DOMAINS ] = "") do={
:log info ("added entry: $cacheName $tmpAddress");
/ip firewall address-list add address=$tmpAddress list=YOUTUBE_DOMAINS comment=$cacheName;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment