How to block ads on Youtube on Smart TV

After buying new Samsung Smart TV I noticed lot of ads on Youtube. I was surprised as on my Android phone and PC I have ads blocked (uBlock Origin for Firefox and AdAway for Android) for many years already.

First I was thinking about setting a proxy on my home router, which would block the ads. However the TV does not have any proxy settings (probably because it would help circumvent GeoIP restrictions on paid streaming content?). I would say, no problem, we have transparent proxying. However proxy in transparent mode does not support https connections, which are used on many websites (including Youtube) nowadays. So no proxy solution possible. But if anyone wants it for devices which do support proxy settings, use Privoxy package for OpenWrt and privoxy-blocklist script.

Then I have found a DNS-based solution. It works by returning modified DNS responses for domains which host ads. It is not as good as URL-based filtering, but still good enough (inc. Youtube ads, as well as video ads in SME TV application) and works for https or other protocols. I use Google DNS in my home. Its IPs are returned by my DHCP for all devices. I have manually configured TV to use DNS of my router instead. This way I can have “normal” DNS for most devices, but ad-blocking DNS for the TV.

For OpenWrt (I am using 15.05 Chaos Calmer), install package adblock (and optionally luci-app-adblock for web interface). They are not included in the repository for CC, but can be downloaded from OpenWrt’s adblock github page. There you can find also detailed installation instructions (basically just download the packages to your router and use opkg install). You can configure a cron job to automatically renew the list of blocked domains. You can also choose which blocklists to use. You can find Adblock easylist sources among the supported ones. Adding blocklists in different format is also easy, just add regexp which will filter the domain names from the list.

openwrt-adblock

The whole solution works by using dnsmasq (built in OpenWrt) to return special local IP (192.0.2.1) for ad serving domains. There is an instance of uhttpd webserver running on this IP on router, which returns empty page / empty gif for every request.

If you are not running OpenWrt on your router, the same can be accomplished on any linux machine (does not even have to be in your home network), where you will run DNS server together with the script, which will populate the list of ad domains.

Tagged with: , , , , , , ,