Configuring a Network-Wide Adblock with Adguard Home
Author
robeeds
Date Published

Introduction
Sometimes web browsing can be absolutely dreadful with the amount of ads that intrude our browsing experiences. On top of that, some sites make so much effort to monetize off ads that they prevent you from seeing the content that you searched for. Installing an Adblock extension can be effective in many cases, but it can get tedious trying to install the same extension for each device you own. This process can be simplified if you install a network-wide Adblock. In today's article, as part of the homelabbing series, we'll be installing Adguard Home on a home server.
Adguard Home is a network-wide software made with the intent of blocking ads and tracking services, regardless of your device's operating system. We'll be going over the installation of Adguard Home on a home server, and how we can make it more effective for our daily usage.
Installation
Log into Portainer
Creating our Volumes
Navigate to Volumes (Left Hand Side). Click on 'Add volume'. We'll be creating our working directory and our configuration directory. I'll be using the names 'adguardhome_work' and 'adguardhome_conf'

Click on 'Create the volume', then repeat this for the configuration directory
Pulling the Image

Go to Images (Left hand side)
Type adguard/adguardhome
Pull image
Creating the Container
Navigate to Containers (left hand side)
Click on 'New Container'
Name: adguard-home
Image: adguard/adguardhome:latest
Port Mapping Settings

NOTE: If you are going to be using Adguard Home as a DHCP server, port map ports 67-68. If not, you can remove this from the settings.
- 53:53 tcp
- 53:53 udp
- 67:67 udp
- 68:68 udp
- 80:80 tcp
- 443:443 tcp
- 443:443 udp
- 3000:3000 tcp
- 853:853 tcp
- 784:784 udp
- 853:853 udp
- 8853:8853 udp
- 5443:5443 tcp
- 5443:5443 udp
Advanced Settings

Click on 'Volumes'
Set the work volume to 'adguardhome_work', or whatever you had named it. Repeat for config volume.

Click on 'Restart Policy' and set the policy to 'unless stopped'
Now, we can deploy the container and visit it in our browser.
Adguard Setup
Visiting the container at http://<SERVER_IP>:3000, the install page should look like this:

Resolving 'Bind: Address already in use' on Ubuntu
On the second page of the setup guide, an error "validating ports: listen tcp 0.0.0.0:53: bind: address already in use" occurs.

This is because Ubuntu already comes with a local DNS server. We'll need to disable the systemd-resolved daemon.
Since we're installing AdguardHome on Ubuntu, we'll be needing to follow these instructions.
Steps:
SSH into the server
1ssh username@ip_adr
Create the /etc/systemd/resolved.conf.d directory if it doesn't exist already.
1sudo mkdir -p /etc/systemd/resolved.conf.d
Create a new file, adguardhome.conf, with the following content.
1[Resolve]2DNS=127.0.0.13DNSStubListener=no
Activate another resolv.conf file
1sudo mv /etc/resolv.conf /etc/resolv.conf.backup2sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
Restart the DNSStubListener
1sudo systemctl reload-or-restart systemd-resolved
This should resolve our error so we could continue setting up Adguard Home.
Continuing with the Setup
Make your admin account credentials, then continue to follow the guide. I'll be adding my server's IP to the DHCP server > DNS settings in my router. Once that's done, we will log in to the admin page.

On log in, the dashboard can be seen.

In the event that the default upstream DNS server goes down, I'm going to edit my settings. I clicked on Settings > DNS Settings. At the time of writing, Quad9's servers were unreachable, so I added the following entries
1https://dns.adguard-dns.com/dns-query2https://security.cloudflare-dns.com/dns-query3https://dns.nextdns.io
Scrolling a bit down, we can test the upstream servers, then apply the changes.
Adding Blocklists for Better Browsing
With Adguard Home comes the ability to customize the adblock lists that your server uses. To do so, click on Filters > DNS blocklists.

Here I added the HaGeZi's Pro Blocklist, a popular and widely recognized DNS blocklist. You can choose to add more blocklist presets from Add blocklist > Choose from lists. In addition, you could update these blocklists intermittently with the 'Chcek for updates' button.
Summary and Next Steps
We've now created a functional network-wide adblock using Adguard Home, which improves our daily web browsing experience by filtering unwanted advertisements from reaching our devices. Later on into the homelabbing series, we'll discuss how to set up a recursive and caching DNS resolver (UnboundDNS), so that we leave less of a trace of our browsing data for others to see.

Docker is an essential platform that allows homelabbers to create isolated environments for system tools and services. Today we'll discuss...

Docker container management can get a bit silly sometimes. Portainer, a container management platform, can help simplify this activity even further.