AdGuard Home is a network-wide ad-and-tracker blocking DNS server. Its purpose is to let you control your entire network and all your devices, and it does not require using a client-side program. It is a fully-fledged server application which runs on a separete machine (your home router or even a VPS), and provide cross-device protection over your network with a mechanism to actively block certain requests from the websites you visit. In this short guide, I will show you how to setup your own AdGuard Home on a VPS (preferred Ubuntu 18.04).
How does AdGuard Home work?
Whenever you navigate to a website using its URL (https://baidu.com, for example), your device needs to know which IP address that domain refers to. In order to determine the IP address, your device makes a DNS (domain name system) query to a DNS nameserver which will respond with a DNS record for that domain, containing its IP address and many other infomation.
But how does your device know which DNS servers to call for each request? Well, it’s generally the job of your router’s DHCP. It is entirely possible to override the DNS server on the router, but for most people won’t do that and leave the one configured by your ISP (Internet service provider).
There are thousands of public DNS servers out in the world. Like Google’s public DNS servers (18.104.22.168 & 22.214.171.124) or Cloudflare’s 126.96.36.199. When you’re running the AdGuard Home in your network, you can configure your router’s DHCP service to use AdGuard Home’s DNS address as the DNS nameserver instead. Doing so, AdGuard Home now has carte blanche to device which DNS queries are allowd, and which ones are blocked.
AdGuard Home is effectively a DNS proxy, whereby it acts as your network’s primary DNS nameserver, filter requests, then relays the requests that satisfy your configured filters to certain “upstream” DNS nameserver, which does the real DNS resolution.
So, AdGuard Home is working at the DNS level that guards your DNS requests with a layer of filtering.
Install AdGuard Home on VPS
This section is originated from AdGuard Home’s official wiki. All commands are adapted to a Ubuntu server.
Install necessary requirement:
sudo apt install bind9-host
Download AdGuard Home’s binaries and unpack it:
tar xvf AdGuardHome_linux_amd64.tar.gz
Then, install AdGuard Home as a system service:
sudo ./AdGuardHome -s install
If no errors prompt, AdGuard Home is now runing on the server.
Here are the other commands you might need to control the service.
sudo ./AdGuardHome -s uninstall - uninstall the AdGuard Home service.
sudo ./AdGuardHome -s start - start the service.
sudo ./AdGuardHome -s stop - stop the service.
sudo ./AdGuardHome -s restart - restart the service.
sudo ./AdGuardHome -s status - check the status of the service.
You can also use
systemctl to manage the
AdGuardHome service, e.g.,
sudo systemctl restart AdGuardHome.
After installation, you can access the AdGuard Home’s web interface on port
3000. For example,
188.8.131.52 with your VPS’s public IP address, or a binded domain name.
Follow the instructions on the web interface to finish the setup.
Some ports maybe used by other programs on the same server, just replace them with desired ones and allow traffics of these ports in your firewall. I have set the default web interface port to
3000 instead of
80, which is already used by Nginx.
If you need to use the
53 port, just follow up the following section.
Getting rid of systemd-resolved consuming port 53
This section is based on this post: Getting rid of systemd-resolved consuming port 53.
In case the
53 port is used by systemd-resolved, and you still need to use the
53 port for AdGuard Home, you can get rid of systemd-resolved using
53 port safely.
sudo systemctl stop systemd-resolved
sudo nano /etc/systemd/resolved.conf
resolved.conf, and comment out & set
DNSStubListener=no. For example:
127.0.0.1 is configured to AdGuard Home on my server, thus all DNS queries from my server will be listened by AdGuard Home.
Then, you need to link the configured file:
sudo ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf
sudo systemctl restart systemd-resolved
Now, you can use the
53 port in AdGuard Home.
If you have used other port in AdGuard Home during setting up, you can go to AdGuardHome’s folder, edit the port number in
AdGuardHome.yaml, then restart AdGuard Home service to make effect.
Enable DNS-over-HTTPS & DNS-over-TLS
Both DNS-over-HTTPS (DoH) and DNS-over-TLS (DoH) are based on TLS encryption so in order to use them, you will need to acquire an SSL certificate for your registed domain name. You can get the certificate for free from Let’s Encrypt, and follow the steps in a previous post to get a certificate with Nginx.
Here’s another example to get an SSL certificate using DNS challenge instead of using Nginx:
sudo apt install software-properties-common
sudo add-apt-repository ppa:certbot/certbot
sudo apt update
sudo apt install certbot
sudo certbot certonly --manual --preferred-challenges=dns
In the end, you’ll get two
.pem files that required by AdGuard Home:
fullchain.pem – your PEM-encoded SSL certificate
privkey.pem – your PEM-encoded private key
Now, open AdGuard Home’s web interface (
your-server-ip:3000, for example) and go to
Settings > Encryption settings. Follow the page’s instructions and set Server name to your desired domain name and configure a port number for HTTPS port. Please leave the default port number
853 for DNS-over-TLS port that required by Android devices to work properly.
In the Certificates section, you can now set the file path refer to the
- Set a certificates file path:
- Set a private key file:
Then, don’t forget to Save config.
The core of AdGuard Home is to filter DNS queries. But that relies on the filters you defined.
Here’s a list of filters I used:
uBlock filters – Badware risks
uBlock filters – Privacy
uBlock filters – Resource abuse
uBlock filters – Unbreak
Fanboy’s Annoyance List
Peter Lowe’s Ad and tracking server list
Filter unblocking search ads and self-promotion
More available ad-filters can be found at https://filterlists.com/.
Configure in the browser/Android device
Please note that encrypted DNS protocols are supported only on Android 9 and above.
To configure it, go to
Setting > Network & internet > Advanced > Private DNS and enter your domain name there.
On my OnePlus phone (OxygenOS 9.0.9), it’s
Settings > WiFi & Internet > Private DNS.
You can try my AdGuard Home with ZG5zLmluZGV2LnRr (base64, double click to reveal) to have a taste. Note that query logs are enabled on my side…
I found that if I use Chrome on Android a lot, the connection to my private DNS often get lost, which shows couldn’t connect. Things getting better when I switched my primary browser to Firefox on my phone. That’s interesting…
Firefox & Chrome
Firefox now supports DoH, you can manually enabling and disabling DNS-over-HTTPS at
Preferences > General > Network Setting > Enable DNS over HTTPS.
Custom in the Use Provider and set the query url to the one shown on AdGuard Home’s web interface under
The same to Chrome’s settings, but I haven’t use Chrome for a long time. This post may help for Chrome users: https://techcodex.com/how-to-enable-dns-over-https-doh-in-firefox-and-chrome/.
Also, there’s a long list of available DoH server you can choose: https://github.com/curl/curl/wiki/DNS-over-HTTPS. Some of them also configured with AdBlock filters.
It seems that you can also specify the DoH on Firefox for Android, details are discussed here: https://android.stackexchange.com/questions/214574/how-do-i-enable-dns-over-https-on-firefox-for-android. If you’re using older Android versions, worth to try inside a browser.