This tutorial will walk you through setting up DNS level Ad Blocking on your network by installing Adblock on an OpenWrt router.
If you’re looking to set up an OpenWrt router of your own, check out our guide to setting up OpenWrt on a repurposed BT HomeHub.
What is OpenWrt?
OpenWrt is a Linux-based operating system designed to be run on routers and other embedded devices. It’s a full computer OS so you can do whatever you want with it, but its primary use (and the purpose of most of the tools and interfaces that ship with it by default) is for networking.
Adblock on OpenWRT for Ad Blocking
There are several options available for ad-blocking on OpenWrt.
I’ve chosen to use the adblock and luci-app-adblock packages. Why? because they’re up to date, support many block lists, and the luci GUI app makes configuration easy – everything is integrated with the existing OpenWrt web interface.
Configuring DNS Server on OpenWrt
Your OpenWrt router will be configured as the default DNS server for any networks it is acting as DHCP server for.
Ensure that your DHCP server is enabled in the OpenWrt LuCi web interface. I have also set up DNS forwardings for public DNS requests to use CloudFlare’s 220.127.116.11 secure DNS servers.
Install Adblock Packages
Next, navigate to:
Click on ‘Update Lists’ to get the list of available packages, and then search for ‘adblock’.
Click on the ‘Install’ button next to the adblock and luci-app-adblock packages.
While we’re here, we can also install the curl and tcpdump-mini packages which adblock relies on for some of the functionality we’ll enable later.
While packages are being installed, a log of the actions taken will be displayed. It can be dismissed to continue.
Now that the Adblock packages are installed, you can navigate to
Services -> Adblock
In the OpenWrt web interface to begin configuring the Adblock service.
Configuring Adblock on OpenWrt
When you first visit the Adblock configuration page, you will probably see it in an error state – there’s still some configuring to be done to get things up and running.
At any point during configuration, you can visit the ‘Log View’ tab to see exactly what issues are preventing Adblock from working. Adblocks’ log entries are descriptive, so it should make troubleshooting straightforward.
OpenWrt devices tend to have limited storage space, so I have installed a USB stick to provide some additional storage space.
In the below screenshots, you can see that I have set a different path for each of the storage directories in each configuration tab so that they will be stored on the USB storage:
- Base temp directory
- Backup directory
- DNS directory
- Report directory
I have also enabled the DNS Report option so I can view statistics about what ads are being blocked.
The Download utility has been set to curl – this was the most reliable option, the other options sometimes didn’t work correctly even though they were properly installed.
After hitting the ‘Save and Apply’ button and giving Adblock some time to download the block lists…
Success! Adblock is enabled and working and we can see that it has generated a list of blocked domains.
Viewing Adblock Reports
As reporting is enabled, the ‘DNS Report’ tab is populated with information about the ads blocked – useful information for troubleshooting network issues, or just something to look at out of curiosity.