How to Install AdGuard Home on a VPS for Private DNS Filtering

One Blocker per Device, and the Ads Still Find a Way In

The phone has an ad blocker. So does the laptop. Then the living-room TV plays an ad before the video starts, and the game console shows a banner that cannot be dismissed. Every device has its own method, and no single point of control covers all of them.

DNS filtering takes a different route. Instead of installing software on each device, you send every domain lookup through one filter. Domains on a blocklist never get resolved, so the ad or tracker content behind them never loads. Devices that cannot run blocker apps are covered too, because the filtering happens at the network layer, not inside an app.

AdGuard Home does this job: a DNS server with a web dashboard, filter lists, and a query log you can inspect. This guide installs it on a VPS with Docker Compose, including the port 53 conflict that shows up on nearly every Ubuntu host, and walks through the initial setup down to per-device rules.

What You Need Before Starting

One VPS with Docker and Docker Compose installed, SSH access as root or a sudo user, and the VPS public IP address. The resource demands are modest: a small VPS handles personal use or a single household without strain.

One warning belongs at the top, not the bottom: port 53 left open to the whole internet turns your VPS into an open resolver, a free DNS server strangers can abuse. The hardening section later in this guide closes that gap. Do not skip it on a publicly reachable VPS.

Step 1: Free Port 53 from systemd-resolved

On Ubuntu, systemd-resolved already sits on port 53 at 127.0.0.53. The AdGuard Home container then fails to bind port 53 and reports a bind error. The official AdGuard documentation recommends disabling its stub listener rather than killing the service outright.

Check who holds port 53 first:

ss -tulpn | grep ':53'

If the output points to systemd-resolved on 127.0.0.53:53, create this configuration file:

sudo mkdir -p /etc/systemd/resolved.conf.d

Put the following in /etc/systemd/resolved.conf.d/adguardhome.conf:

[Resolve]
DNS=127.0.0.1
DNSStubListener=no

The DNS=127.0.0.1 line is not decoration. Without the stub listener, 127.0.0.53 stops answering, so the host itself needs another DNS pointer to keep downloading images and packages.

Next, repoint resolv.conf and reload the service:

sudo mv /etc/resolv.conf /etc/resolv.conf.backup
sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
sudo systemctl reload-or-restart systemd-resolved

Run the ss command again. Port 53 on 127.0.0.53 should be gone. If it persists, recheck the contents of adguardhome.conf — a single mistyped letter in DNSStubListener is enough to undo the whole step.

Step 2: Write the Docker Compose File

Create the project directory and the Compose file inside it:

mkdir -p /opt/adguardhome
cd /opt/adguardhome

Fill /opt/adguardhome/docker-compose.yml with:

services:
  adguardhome:
    image: adguard/adguardhome:latest
    container_name: adguardhome
    restart: unless-stopped
    volumes:
      - ./work:/opt/adguardhome/work
      - ./conf:/opt/adguardhome/conf
    ports:
      - "53:53/tcp"
      - "53:53/udp"
      - "80:80/tcp"
      - "3000:3000/tcp"

Each port mapping has a distinct job. Port 53 serves DNS queries from your devices, over both TCP and UDP. Port 80 becomes the main dashboard once setup is done. Port 3000 is used exactly once, for the initial setup wizard. The two volumes keep configuration and data on the host, so the container can be removed and recreated without losing the filter rules you built.

Start the container:

docker compose up -d

The expected result: the command finishes without errors, and docker compose ps shows the adguardhome container running. If it restarts in a loop, read the logs before changing anything:

docker compose logs -f adguardhome

An address already in use message on port 53 means Step 1 did not fully take effect. Other errors usually point to volume directory permissions or a YAML typo.

Step 3: Complete the Initial Setup Wizard

Open http://YOUR_VPS_IP:3000 in a browser. The wizard walks you through a few screens:

  • Interfaces and ports. Leave the web interface on port 80 and the DNS server on port 53, on all interfaces.
  • Admin account. Create a strong username and password. This account guards the dashboard, so avoid reusing a password from another service.
  • Confirmation. The wizard shows the dashboard address and the DNS address your devices should use.

Once the wizard finishes, the dashboard moves to http://YOUR_VPS_IP (port 80). Port 3000 no longer serves the wizard. If you open port 3000 after setup and see a blank page or an error, that is normal behavior, not breakage — use port 80 from here on.

Optionally, once setup is complete, you can delete the "3000:3000/tcp" line from docker-compose.yml and run docker compose up -d again to close a port that is no longer needed.

Step 4: Set the Upstream DNS

AdGuard Home filters queries, but allowed domains still need someone to answer them. In the dashboard, go to Settings → DNS settings and find the Upstream DNS servers field. Enter one upstream per line, for example:

https://dns.cloudflare.com/dns-query
https://dns.google/dns-query

Below it sits the Bootstrap DNS servers field, used to resolve the upstream hostnames themselves before the encrypted connection exists. Fill it with:

1.1.1.1
8.8.8.8

Click Apply, then test from the VPS:

dig @127.0.0.1 example.com

If the answer includes an ANSWER SECTION with an IP address, the chain from AdGuard Home to the upstream works. If the query times out, check the VPS firewall: port 53 UDP is often blocked there while the dashboard on port 80 looks perfectly fine.

Step 5: Enable Filter Lists

Go to Filters → DNS blocklists. Several lists ship with the software; enable the ones that fit your needs, such as the general AdGuard list and a tracking list. Each enabled list adds domains recognized as ads, trackers, or malware.

You can also add a list from a URL. Click Add blocklist, give it a clear name, and paste the list URL. Resist the urge to enable every list you find at once. Too many lists slow down loading and raise the odds of false positives, while a general list plus one tracking list already covers most cases.

After adding or changing lists, click Update so AdGuard Home downloads the latest version. The dashboard shows the active rule count and the last update time — two numbers that confirm whether a list actually loaded or only got its name recorded.

Step 6: Write Custom Rules

General lists do not know about the small site that annoys you personally. Custom rules fill that gap. Open Filters → Custom filtering rules and write rules in this syntax:

||annoying-ads.example^
@@||important-site.example^

The first line blocks the domain and all its subdomains. The || anchors the match to the start of the domain name, and ^ marks the end of the name so the pattern does not catch unrelated domains that happen to contain the same word. The second line, starting with @@, allows the domain instead — useful when a general list sweeps up a site you actually need.

Custom rules take effect as soon as they are saved, with no container restart. Test by opening the newly blocked domain from a device whose DNS already points at the VPS. If the domain still opens, check two things: whether the device truly uses the VPS DNS, and whether the browser still holds a cached DNS answer.

Step 7: Set Up Clients per Device

One rule set for every device is rarely ideal. The family TV might need lenient filtering, while a child's phone needs stricter rules. Go to Settings → Client settings, click Add client, and identify the device by its IP address or MAC address. Give it a recognizable name, such as "living room TV" or "work laptop".

For each client, you can:

  • Enable or disable specific filter lists for that device only.
  • Add custom rules that apply to that device only.
  • View that device's query statistics separately.

IP-based identification is the simplest, but home device IPs can change after the router restarts. If a device's rules suddenly stop applying, check whether its IP changed in the client list. On a network you manage yourself, a static address assignment in the router fixes this permanently.

Step 8: Check the Query Log

Open the Query log menu in the dashboard. Every row records the query time, the requesting device, the requested domain, and its status: allowed, blocked, or answered from cache. Filters above the log let you show only blocked queries, or only queries from one device.

The query log is your main diagnostic tool. A site that refuses to load? Search for its domain in the log. If the status is blocked and the cause is a specific list, click the domain and choose Unblock to create an exception, or add an @@ rule as in Step 6. If the domain does not appear in the log at all, the device is not using the VPS DNS — the problem sits in the device settings, not the filter.

Keep in mind that the log holds the browsing history of every device passing through this server. The dashboard lets you set log retention and disable log collection if privacy on your network demands it. That call is yours as the server operator.

Hardening the VPS Against Open Resolver Abuse

This section decides whether the installation helps or harms. If anyone on the internet can reach port 53, anyone can use your server to run DNS amplification attacks. Apply both layers below:

1. Restrict at the firewall. Allow port 53 only from IP addresses or networks you recognize. With UFW, replace YOUR_IP with the public IP of your network:

sudo ufw allow from YOUR_IP to any port 53 proto tcp
sudo ufw allow from YOUR_IP to any port 53 proto udp
sudo ufw allow 80/tcp
sudo ufw enable

The ufw allow 80/tcp line keeps the dashboard reachable, but the dashboard itself should not sit open to the public either. Reaching it through a VPN or an SSH tunnel beats leaving it exposed on the internet.

2. Restrict inside AdGuard Home. Under Settings → DNS settings → Access settings, add an allowed-clients list. Queries from addresses outside the list get rejected, even if the firewall rules change one day. The two layers complement each other: the firewall stops traffic at the gate, while the access list stops whatever slips past the gate.

If your devices roam across networks and their IPs keep changing, IP-based firewall rules become impractical. In that case, run AdGuard Home behind a VPN such as WireGuard: devices connect to the VPN first, then use DNS inside the encrypted tunnel. Direct public access to port 53 stays closed.

Pointing Devices at the New DNS

On each device, change the DNS setting to your VPS IP address. The path differs per system, but the pattern is the same: find the network settings, replace the primary DNS with the VPS IP, and leave the secondary empty or set it to the same address.

  • Android: Wi-Fi settings → the network in use → switch to static IP or a private DNS option, then turn off Private DNS if it is active, since it would bypass the VPS DNS entirely.
  • iPhone/iPad: Wi-Fi settings → the info icon on the network → Configure DNS → Manual.
  • Windows: Network adapter settings → IPv4 → Use the following DNS server addresses.
  • Router: If your router allows it, change the DNS in its DHCP settings. Every device joining that network then picks up the VPS DNS automatically, with no per-device setup.

After changing the setting, clear the device DNS cache if needed. On Windows, run ipconfig /flushdns. On a phone, disconnecting and reconnecting Wi-Fi usually does the job. Then open a website and check the Query log: if your device shows up there, the chain is connected end to end.

Summary Table

ComponentDetail
Docker imageadguard/adguardhome:latest
Compose file/opt/adguardhome/docker-compose.yml
Data volume./work:/opt/adguardhome/work
Config volume./conf:/opt/adguardhome/conf
DNS port53/tcp and 53/udp
Dashboard port80/tcp after setup
Setup wizard port3000/tcp, only before setup completes
resolved config/etc/systemd/resolved.conf.d/adguardhome.conf
Main config fileconf/AdGuardHome.yaml (edit only while the container is stopped)
DNS testdig @VPS_IP example.com
Update commanddocker compose pull && docker compose up -d
Backup commandCopy the work and conf directories after docker compose down

Common Errors and Fixes

SymptomLikely causeFix
Container fails to start, port 53 bind errorsystemd-resolved still holds port 53Apply Step 1, then run docker compose up -d again
Dashboard missing on port 3000 after setupWizard finished, dashboard moved to port 80Open http://VPS_IP without :3000
Device still shows adsDevice not using the VPS DNS, or Private DNS activeCheck the device DNS setting, turn off Private DNS
Device queries absent from the Query logFirewall blocking traffic, or client not allowedOpen port 53 UDP/TCP for that IP, check Access settings
Important site blockedOverly aggressive filter listFind the domain in the Query log, add an @@ rule
Server cannot download images after Step 1resolv.conf points at the wrong resolverCheck the /etc/resolv.conf symlink and adguardhome.conf contents
Client rules suddenly stop applyingDevice IP address changedUpdate the IP in Client settings, or assign a static IP in the router

Final Checklist

  • Port 53 freed from systemd-resolved before the container starts
  • The adguardhome container shows as running in docker compose ps
  • Setup wizard finished and the dashboard opens on port 80
  • Upstream and Bootstrap DNS filled in, dig test returns an answer
  • Filter lists active and the rule count visible on the dashboard
  • At least one block rule and one allow exception tested end to end
  • Per-device clients created and visible in the Query log
  • Firewall and Access settings limit port 53 to your networks only
  • A copy of the work and conf directories stored off the VPS

Closing

A DNS server you run yourself changes how a whole home or small-office network meets the internet: fewer trackers slipping through quietly, fewer ads on devices that cannot run blockers, and one log you can open whenever a site misbehaves. The price is the responsibility that comes with it — an open port 53 can be abused, and an overeager filter list can block sites you need. Both are controllable from the same dashboard.

Which domain would you block first once this is running? Share it in the comments — an ad domain haunting the TV, a tracker inside a phone app, or a specific site you want kept off the home network.

Read also: related topics such as How to Set Up Authelia SSO and 2FA Behind an Nginx Reverse Proxy and How to Install SearXNG on a VPS as Your Private Search Engine cover other layers of a personal server.

Diskusi

Ada pertanyaan atau pengalaman yang ingin dibagikan?

0komentar

Komentar ditinjau sebelum ditampilkan. Mari berdiskusi dengan sopan dan sesuai topik.