AdGuard Home on my Home Assistant
This is a shortish article explaining my installation of AdGuard Home on my Home Assistant (HA) system. But you might wonder what it is and why I’ve installed it.
What and why and which?
Rather perversely, I’ll start with the why? Browsing the web comes with the pain of adverts. Some websites are reasonably restrained in their use of adverts while others are all but unusable because of them. Local UK newspaper websites are notorious for this, they are simply awful. I’ve used browser adblockers for many years which have been wonderful. However, many websites are now blocking their content if you have an adblocker active. You have to disable the adblocker and you’re back at square one! I recently heard about an alternative approach to blocking ads using AdGuard Home or Pi-Hole.
Now the what? AdGuard Home and Pi-Hole are DNS sinkholes. Very simply, most adverts on websites are served from different domains to the main web page (think adservice.google.com and doubleclick.com). When you display a webpage, your browser needs to find all the elements in the webpage and it uses something called a Domain Name Server (DNS) to know exactly where to ask for the element (for example, a DNS routes your request for, say, bbc.co.uk to a proper internet address, a little like translating a postcode to an address but more precise). A DNS sinkhole just ignores any elements with advertising domains and no advert is displayed, just an empty rectangle (for example, when a DNS sinkhole sees a request for an element starting with doubleclick.com, it goes “meh”). And this works for any application using the DNS sinkhole, not just a browser.
A DNS sinkhole works by comparing the requested domain against a (very long!) list(s) of blocked domains, going “meh” if a requested domain is on the list. Another advantage is that it can block other unwanted content such as known malware domains and phishing sites. Note there are many block lists and they are updated regularly.
And finally the which? Comparisons of Pi-Hole and AdGuard Home seem to indicate there’s very little difference between them. In the end, I chose AdGuard Home as there’s an add-on for it in Home Assistant.
Installation
Installing AdGuard Home in Home Assistant is very straightforward, simply follow the instructions in the link at the very start of this article (note it’s a community add-on, if you don’t have community add-ons enabled then, on the Add-on Store page, click on the 3 dots in the top right corner, click on Repositories, paste in this URL https://github.com/hassio-addons/repository and click on Add which will then give you access to the many community add-ons).
For myself, on the add-ons Configuration tab I kept all the standard options except I changed the log_level to info. Back on the Info tab, I selected the Start on Boot and Watchdog (in the unlikely event it crashes, I want it to restart automatically) and Show in sidebar (so I can easily access the UI) but not the Auto update (I prefer to update add-ons when it’s convenient for me). Then I started the add-on, installation complete! (I said it was straightforward.)
Configuring AdGuard Home
There’s very little configuration needed for AdGuard Home unless you want to go “off piste”. Configuration is done through its UI and I made the following changes:
Settings>DNS settings
I added the tls://unfiltered.adguard-dns.com upstream DNS server and enabled Parallel requests. I also added my HA server as a Private reverse DNS server and enabled its use as shown below:
Otherwise I kept the default options in all Settings.
Filters>DNS blocklists
I enabled the AdAway Default Blocklist and kept all other defaults in Filters. Note this is a key configuration section as, for example, you can block particular services, such as WhatsApp, should you wish.
This has AdGuard Home up and running but so far nothing is using it.
Routing through AdGuard Home
OK, so far so good but you’re probably wondering where all this is going. I’ve now got AdGuard Home on my HA server (a Raspberry Pi 4 btw) and it sounds good but my laptop, phone, etc are still showing ads as usual. I need to configure things so they use AdGuard Home to service DNS requests and there are basically two options:
Configure each device separately. A pain, especially for devices other than mine as I’ll still have to do it.
Configure my WiFi router to use AdGuard Home for servicing DNS requests. Any devices connected to the WiFi would automatically then use AdGuard Home.
Obviously I chose the second approach, especially as everyone will not only see fewer ads, they’d also have the protection AdGuard Home offers against malware and phishing sites.
Each router is different. I explain here how I configured mine but you’ll have to work out what to do for yours, although in general it’ll be similar.
I have a slightly atypical configuration, I use a Deco mesh system which is connected by ethernet to my broadband supplier’s router. My Deco router does not allow me to explicitly change the DNS server in the DNS settings (which you’d think would be the obvious place to change it). Instead, I have to edit my DHCP Server settings to change the DNS server as shown below:
172.16.0.125 is the local address of my Raspberry Pi with AdGuard Home. Note I left the secondary DNS blank - AdGuard Home deals with any need for a secondary DNS.
Results
I’ve now had this working for a few days and it seems to be working exactly as I hoped. I can now view websites without being flooded with ads. I’ve disabled my browser adblocker and those websites that hitherto would block me because of an adblocker no longer block me.
In the event I want to see the ads [Ed. why?], I can drop onto the WiFi from my broadband router (which nobody normally uses) that does not use my AdGuard Home server.
Finally, as to the moral question of browsing websites without adverts and so denying them revenue, it’s a fair point and I don’t have an answer for it if I’m honest. If websites weren’t so flooded with adverts then I wouldn’t have blocked them. In the future I might whitelist some sites to allow them to show adverts. At least I’ll be in control.