I don’t have time to explain in depth how to set up OpenWRT in general. For you geeks who have already done it, here’s how you can block your smart TV and un-rooted phones and other devices from getting YouTube ads using your router!
In LuCI, go to Network – Firewall – Custom Rules and add this (change 192.168.0.1 to your router’s LAN IP address) and add this line and save/submit:
iptables -A PREROUTING -t nat -p udp --dport 53 -i br-lan -j DNAT --to 192.168.0.1:53
Add the following entries to /etc/hosts (change 192.168.0.1 to your router’s LAN IP address, or try 0.0.0.0 instead):
192.168.0.1 doubleclick.net 192.168.0.1 googleadservices.com 192.168.0.1 pagead2.googlesyndication.com 192.168.0.1 pubads.g.doubleclick.net 192.168.0.1 partnerad.l.doubleclick.net 192.168.0.1 beacons.extremereach.io 192.168.0.1 secure-us.imrworldwide.com 192.168.0.1 sb.scorecardresearch.com 192.168.0.1 secure.insightexpressai.com 192.168.0.1 googleads.g.doubleclick.net 192.168.0.1 ad.doubleclick.net 192.168.0.1 dart.l.doubleclick.net 192.168.0.1 dts.innovid.com 192.168.0.1 s0.2mdn.net
Google has a big list of ad servers so there may be more that I’ve missed, but after blocking these hosts I saw the ads stop without other problems.