How do I block ads on YouTube?

The browser plugin works like a local proxy (that's why is isolated to the device and not network wide).
It looks for specific content (not only hostname) in the way the video/url is called.

Pi-hole is only a DNS resolver at it's roots.

1 Like

What do you think about this regex ^r+.\.googlevideo.com$ ? I see only YT logo for 5 sec (or this is lucky case?)

Try loading a video with the regex in place on your mobile device. Is the video loading or is the video black and not loading?

(Either on the youtube app or a mobile browser).

I'm testing on LG TV with webOS

I've been using this regex entry from @brattanek for a few days and haven't got any ads on YouTube yet.
^r+.\.googlevideo.com$ ?

Weird thing though, when looking at the query log, the addresses don't appear as pi-holed.

(Tested with Apple TV and an Android phone)

yeah ^r+.\.googlevideo.com$ didnt work, on my vizio I get the PPG ad still. (hands beer to @anon55913113 ;-P)

^r[^.]+.googlevideo.com$

Anyone have a Solution yet?

Ok so i validated that the following regex are able to match the required r patterns of google.video, however pihole doesnt seem to be blacklisting them, they are still being forwarded. can someone explain this?

here are the two regexs I made and I know they work:

(^r\d+\.+[a-z]+\-\w+\.)googlevideo\.com$ // for rXX.sn type pattern

(^r\d+\-+[a-z]+\-\w+\.)googlevideo\.com$ //for rXX--sn type pattern

could it be that there is something before the rXX that we are not seeing example some encoding charaters?

Sorry @pk198105 but it doesn't work here (netherlands), i use on my laptop chrome without any browserextension but the ad video's are not blocked at all.

Here's what I came up with:
^(r[0-9]+(-{3}|.).+.googlevideo.com)$

I am no pro at regex...
It matched the following domains:
r1---sn-hp57ynel.googlevideo.com
r4---sn-p5qlsndk.googlevideo.com
r12.sn-bvvbax-hn26.googlevideo.com
r1.sn-5hne6n7e.googlevideo.com

NOTE: See the very top of this page: some things will work, some will not. You're better off getting the fingerprints/definitions from the variations of the script(s) above and having it block the ads for you that way. Otherwise, it becomes to tedious to keep up with and is really hit-or-miss.

Best Regards,

Jayke P.

@jaykepeters, the regular video's are with your regex command blocked, in my case anyway.
When i delete your regex it works again

I'm sorry, I forgot to mention that it breaks YouTube for me too. I am experimenting with other ways to block YouTube ads using pi-hole.

OK @jaykepeters , no problem.
To block all youtube ads with pihole is impossible, i spend may hours in all topics on these forum, i read and treid a lot of things until i ruined my pihole and start over from scratch again... haha, the only way is to add "uBlock Origin" as browser extension, anyway, that is what i use on my regular PC.
So it has no sence to block any googlevideo.com domain, there are many thousands of them.

I auto download new vids from my sub feed on my NAS, no ads that way

1 Like

How do you manage to do that?

If I had the time, I would create a Google Chrome extension that detects video ads and submits those domains to pi-hole via the api. I don’t even know how that would work, but I could create a php script to add it to a file in the web root and then pihole will use that as an ad list and update every Sunday night or whenever that cron job is scheduled. Still working on some other projects at the moment.

That will only work if you load youtube on a PC (no blocking extension needed).

Anything that will be loaded on a mobile device (connected to the same network with Pi-hole as DNS, phone or tablet) will never load due to the way the mobile platform queries youtube.

It seems that anything loaded via mobile (youtube app or browser) has a bit check or something (some sort of validation) at video load, originating from those (seemingly) random domain names that never validates, and the video will not load.

1 Like

Using synology download station

1 Like

Hey guys,

I've been following all of this here, Reddit and the web pretty closely and been playing with DD-WRT IPTables to intercept all port 53 requests and redirect them to Pi-Hole / some other DNS server.

I've also tried several Regex expressions and it's mostly a failure, and the videos get broken quickly and the ads keep playing anyway.

One thing I might have noticed is that, depending on the upstream DNS used, you get "more" or "less" ads. For example, if I leave my DNS from the ISP, Cloudflare or similar, I get all the crappy cookie, cleaners, etc. local ads. If I use a crazy russian DNS (I'd rather not post it here so Google spies don't get a heads up! :slight_smile:), I mostly stop seeing ads; maybe that white YouTube logo 5 second silent thing at most, every so often. But if I leave my local DNS from the ISP, I get bombarded with ads.

Have any of you guys noticed this behavior and can confirm it? Maybe we can find an even crazier DNS that show even less ads? My silly theory is that, since ads seem to be localized, a DNS in a specific country might not have advertisers paying to show ads there; hence why I'm experiencing this behavior. Or, I'm going crazy after having wasted countless hours with this! :stuck_out_tongue:

Also, as another solution, wouldn't it be great to have a proxy service running on a computer/server that would intercept the YouTube Chromecast calls, get the video, if it's less than 1 minute (check by size or whatever), drop it and send the Chromecast the next video? How crazy is that?

Thanks and let me know what you think!