Youtube adverts and same domain issue

I've been messing with reg-ex in an attempt to get pi-hole to filter youtube adverts across all networked devices, however youtube uses the same domain for the video stream and the advert, so this is proving problematic.

What happens is, when you request a video on youtube it calls the same server twice. It'll have 2 dns queries looking like this....

The 1st lookup is the video and the second is the advert stream. Ideally, I need a way of getting the pi-hole to filter the second dns lookup but allow the 1st one.

Is there a way to use regex to allow the first requests to and block the second request to the same domain for say 1000ms? thus stopping all adverts being allowed through?

As you already figured out:

There is no reliable way to filter youtube ads with Pi-hole.

Such a function does not only rely on the regex-filter but also needs some type of counter (how often was the domain already requested?). This is not possible with Pi-hole at the moment.
Additionally, you would need to disable all caches along the DNS path: your browser might cache the IP, and your OS might also cache it. If they answer the request directly, Pi-hole isn't involved at all.

1 Like

Maybe someone could reverse engineer Ublock to see exactly how that manages to block youtube adverts then, and see if it could be replicated in some way at the network level?

It appears Ublock has the ability to also block script within the browser, which is probably what happens, so Pie-Hole won't work in this way.

I came to realize this a few months ago after reading every other user post on YouTube blocking through pihole and then using that combined knowledge to do my own person testing which was pretty manic in all honesty for a bit. There is a reddit post that is the top post on this website regarding YouTube blocking and he found out that if you use nslookup on, the IP address it returns can be used in a host file along with the domain itself and I have come to believe this is doing something along the lines of what you are asking about.... which is to block one of the dns queries that carries the advertisement and immediately bypass and load the second query that holds the video you actually want to see. After implementing his instructions per the reddit post I just mentioned I have had a massive decrease in YouTube ads especially on devices like amazon firetv where there are no good options for ad blocking software the way that pc browsers have available to them.

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