How to Set up AdBlock DNS Ad Blocking in OpenWRT

Setting Up Adblock Ad Blocking on OpenWRT

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 1.1.1.1 secure DNS servers.

 

openwrt adblock 1

Install Adblock Packages

Next, navigate to:

System->Software

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.

openwrt adblock 2

 

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.

 

openwrt adblock 14

openwrt adblock 13

While packages are being installed, a log of the actions taken will be displayed.  It can be dismissed to continue.

 

xopenwrt adblock 3

 

Now that the Adblock packages are installed, you can navigate to

Services -> Adblock

In the OpenWrt web interface to begin configuring the Adblock service.

 

openwrt adblock 5

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.

openwrt adblock 6

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 adblock 7

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.

 

openwrt adblock 10 openwrt adblock 15 openwrt adblock 11openwrt adblock 9

 

After hitting the ‘Save and Apply’ button and giving Adblock some time to download the block lists…

 

openwrt adblock 8 openwrt adblock 16

 

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.

openwrt adblock 17

SHARE:
nv-author-image

Brad Morton

I'm Brad, and I'm nearing 20 years of experience with Linux. I've worked in just about every IT role there is before taking the leap into software development. Currently, I'm building desktop and web-based solutions with NodeJS and PHP hosted on Linux infrastructure. Visit my blog or find me on Twitter to see what I'm up to.

Leave a Reply

Your email address will not be published. Required fields are marked *