How do I block ads on YouTube?

For youtube ads, essentially, Google has an entire array of domains to point to. Which is why it seems hard to pin down YouTube adblocking for Pihole.

I've been testing out and gathering data about the domains for entire GoogleVideo parent domain (seems to be the only connection for all the ad domains). Using wildcards through the dnsmasq.d doesn't work. Youtube will not playback any video at all. The only way to stop ads from rolling is to blacklist them one by one.

Luckily, it seems that you only need to add this seemingly simple domain structure in the pihole -b domain1 domain2 ... command :

r{N..M}---fingerprint.googlevideo.com
and/or
r{N..M}.fingerprint.googlevideo.com

where N is the beginning and M is the end. (Basically recursively adding the domains.)

Explanation:

Each domain starts with an r followed by a number. This number doesn't seem to go beyond 20. It is then followed by either three dashes, its unique ID (fingerprint) then .googlevideo.com

e.g. r7---sn-vgqs7ne7.googlevideo.com

Sometimes, the domain doesn't have the three dashes:

e.g. r7.sn-vgqs7ne7.googlevideo.com

Basically, to block an entire unique ID domain, you have to know the fingerprint of each and every variants (from r1 to r20).

So far I've found these fingerprints:

  1. sn-8xgp1vo-xfgk
  2. sn-8xgp1vo-xfge7
  3. sn-p5qlsnll
  4. sn-a5mekner
  5. sn-vgqs7nez
  6. sn-vgqs7n7k
  7. sn-vgqsenes

By knowing this, you are creating a whole entire array of possible ad-serving DNS for youtube. But using this means that you'll end up having 100s or even 1000s of googlevideo domains.

Edit: This also takes care of ads going to mobile and Chromecast. But knowing the whole entire fingerprint army is another question.

Edit 2: You can help ID the fingerprint army by using Whitelist Assistant by DNSThingy for Chrome, and surf youtube and watch cat videos. If you spot an ad, open the extension and take note of the fingerprint and post it here.

5 Likes