Regex block slipping through the cracks (YouTube)

Please follow the below template, it will help us to help you!

If you are Experiencing issues with a Pi-hole install that has non-standard elements (e.g you are using nginx instead of lighttpd, or there is some other aspect of your install that is customised) - please use the Community Help category.

Expected Behaviour:

Youtube ad should be blocked

Actual Behaviour:

A preroll ad shows up on an iPhone X, but doesn't on my Mac, however the link shows up in the query log, which seems to match the regex.

Debug Token:

https://tricorder.pi-hole.net/0NvYTvUA/

Please provide an example of

  • log excerpts from /var/log/pihole/pihole.log showing
    -- a request blocked as expected (Mac)
    -- a forwarded request that should also have been blocked (iPhone)
  • the respective regex

Sorry for the late response.

Request doesn't seem to be blocked, checking the log shows

Sep  6 06:36:45 dnsmasq[591]: forwarded rr7---sn-8pxuuxa-nbozs.googlevideo.com to 127.0.0.1#5335

and

Sep  6 06:36:46 dnsmasq[591]: reply rr7---sn-8pxuuxa-nbozs.googlevideo.com is <CNAME>
Sep  6 06:36:46 dnsmasq[591]: reply rr7.sn-8pxuuxa-nbozs.googlevideo.com is 27.71.243.82

The regexes I use to block these domains are
r\d---sn--[\-\d\w]*.googlevideo.com
r\d\.sn-[\d\w]*.googlevideo.com
r*\d---sn-*[\-\d\w]*.googlevideo.com

It would be most useful to see all log lines for a blocked query (originating from your Mac) and a forwarded query (originating from your iPhone) each, so we could take a closer look at the differences you state to have observed for different clients.

For that domain from your logs, none of your regexs would produce a match when run through Pi-hole's regex test mode:

~$ pihole-FTL regex-test rr7---sn-8pxuuxa-nbozs.googlevideo.com "r\d---sn--[\-\d\w]*.googlevideo.com"
[i] Compiling regex filter...
    Compiled regex filter in 0.615 msec

Checking domain...
    NO MATCH!
   Time: 0.113 msec
~$ pihole-FTL regex-test rr7---sn-8pxuuxa-nbozs.googlevideo.com "r\d\.sn-[\d\w]*.googlevideo.com"
[i] Compiling regex filter...
    Compiled regex filter in 0.568 msec

Checking domain...
    NO MATCH!
   Time: 0.121 msec
~$ pihole-FTL regex-test rr7---sn-8pxuuxa-nbozs.googlevideo.com "r*\d---sn-*[\-\d\w]*.googlevideo.com"
[i] Compiling regex filter...
    Compiled regex filter in 0.647 msec

Checking domain...
    NO MATCH!
   Time: 0.119 msec

Well that's weird. When running it through regex101 it shows a match. Here's the link for the regex.

After some regex crafting, I got this regex which seems to work on Pi-Hole
.*sn-[a-zA-Z0-9]*.[a-zA-Z0-9]*\.googlevideo\.com
I'll tell you if it works
(and also, pihole doesn't like \d and \w)

For some reason, adding the regex to the regex blocks gives an empty box

Known bug, already fixed by
https://github.com/pi-hole/AdminLTE/pull/2336


Use pihole -b --regex "regex" as a workaround at the moment.

After adding the regex, videos just won't work at all, and will just throw a loading screen.

This is expected. YT serves videos and ads from the same domain. You can't block one without the other. Pi-hole can't block YT ads

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.