Adding DNS based ad blocking to Openwrt

May 18, 2023
Tags:adblockopenwrtlinux

I consider ads on the Internet a major hindrance. They usually are large and flashy (especially video ads) and hence distract user from the task at hand. They have are also being used to track users and even being used to spread malware. I have used ad blocking on the browser for a long time, currently I use UBlock Origin.

I became aware of the Pi-Hole-project a few years ago, that seemed like a good way to have ad blocking for all devices on the local network. It operates as a DNS-level ad blocker, so every DNS-request to the DNS-server is blocked if it matches an entry the ad block list. I myself use Openwrt on my routers and noticed it has adblock packages available that would make it operate like the pi-hole. OpenWRT has seperate AD-blocking guide you can use. I installed the following packages:

In addition to the adblock package, you will need SSL-support to fetch block lists over HTTPS. I have the following packages installed:

After installing packages you can update the blocklist sources configuration, quite a few different sources are supported. Just be aware, including many big blocklist sources might slow the router down.

You will also want refresh the list from time to time. The adblock package refreshes the list on startup, so you can add crontab file to reload the adblock service. Like this:

0 06 * * *    /etc/init.d/adblock reload

I have been running the setup for few years and I am happy with it.