Skip to content

How to setup adguard home to block ads in your home network

Updated: at 06:59 PM

AdGuard Home is a versatile and powerful DNS-level ad blocker that lets you block ads, trackers, and malicious websites across your entire network. Setting it up on a Virtual Private Server (VPS) using Docker ensures high availability, while configuring a TP-Link router ensures seamless DNS integration for all connected devices. Here’s how to do it step-by-step.


Prerequisites

Before diving into the setup, ensure the following:

  1. VPS: A running Linux-based VPS (e.g., Ubuntu 20.04 or Debian 11).

  2. Docker and Docker Compose: Installed on your VPS.

  3. Domain or Static IP: To point your router to the AdGuard DNS.

  4. TP-Link Router: Admin access to configure DNS settings.

  5. Firewall or Security Group Rules:

    Depending on your VPS provider, ensure that the following ports are open in your firewall or security group settings:

    • TCP/UDP Port 53: For DNS queries.
    • TCP Port 80 and 443: For the web interface and secure connections.
    • TCP Port 3000: For accessing the AdGuard Home setup interface.

    Use your VPS provider’s dashboard or tools like ufw to allow these ports:

    • To allow using ufw: ufw allow 53/tcp ufw allow 53/udp ufw allow 80/tcp ufw allow 443/tcp ufw allow 3000/tcp

Step 1: Install Docker on Your VPS

  1. Run the Official Docker Installation Script:

       curl -fsSL https://get.docker.com -o get-docker.sh
       sh get-docker.sh
    
  2. Verify Docker Installation:

       docker version
       docker compose version
    

Step 2: Deploy AdGuard Home Using Docker

AdGuard Home is an open-source DNS-based ad blocker available on GitHub. We’ll deploy it using Docker.

  1. Create a Directory for AdGuard Home:

       mkdir -p ~/adguard && cd ~/adguard
    
  2. Create a docker-compose.yml File:

    Use the following configuration:

       version: '3'
       services:
       adguard:
          container_name: adguard
          image: adguard/adguardhome
          restart: always
          network_mode: "host"
          volumes:
             - ./data:/opt/adguardhome/work
             - ./config:/opt/adguardhome/conf
          ports:
             - 53:53/tcp
             - 53:53/udp
             - 80:80/tcp
             - 443:443/tcp
             - 3000:3000/tcp
    
  3. Deploy AdGuard Home:

       docker-compose up -d
    
  4. Access the AdGuard Home Setup Interface:

    Open your browser and navigate to http://<VPS_IP>:3000. Follow the setup wizard to configure AdGuard Home.


Once AdGuard Home is running, you need to set it as the primary DNS server in your TP-Link router:

  1. Log in to Your Router:

    Open a browser and go to http://192.168.0.1 or http://192.168.1.1. Enter your admin credentials.

  2. Navigate to DNS Settings:

    Go to Advanced SettingsNetworkWAN or Internet Settings.

  3. Set Custom DNS Servers:

    • Primary DNS: <VPS_IP> (your VPS’s IP address)
    • Secondary DNS: 1.1.1.1 (Cloudflare) or any other public DNS for fallback
  4. Save Changes:

    Apply the settings and reboot the router if necessary.


Step 4: Test the Setup

  1. Check DNS Leak:

    Visit dnsleaktest.com to ensure your queries are routed through AdGuard.

  2. Monitor AdGuard Home Dashboard:

    Open the AdGuard Home web interface and verify that queries are being logged.

Step 5: Verify Ad Blocking with Adblock Tester

To confirm that AdGuard Home is effectively blocking ads and trackers, you can use the Adblock Tester tool:

  1. Visit Adblock Tester:

    Open your browser and go to https://adblock-tester.com.

  2. Run the Test:

    Click the “Start Test” button on the website. It will analyze your DNS configuration and detect if ads and trackers are being blocked.

  3. Review the Results:

    • If AdGuard Home is configured correctly, the test should show a high blocking score with most ads and trackers marked as blocked.
    • If the test shows a low score, double-check your AdGuard Home configuration and DNS settings on your TP-Link router.

Using Adblock Tester ensures that your setup is functioning as intended and provides an easy way to validate the effectiveness of your ad-blocking system.


Additional Tips

  1. Enable HTTPS:

    Secure your AdGuard Home with HTTPS by setting up a reverse proxy like Nginx and obtaining a free SSL certificate from Let’s Encrypt.

  2. Regular Updates:

    Keep your Docker images and system updated to ensure security and stability:

    docker-compose pull docker-compose up -d

  3. Whitelist Critical Services:

    If certain apps or websites are blocked unintentionally, add them to the whitelist in the AdGuard dashboard.


Limitations of AdGuard Home

While AdGuard Home is a powerful DNS-level ad blocker, it has some inherent limitations. DNS-based blocking works by preventing domains associated with ads and trackers from being accessed, but it cannot block all types of advertisements. Here are some examples:

Future Possibilities

According to the AdGuard Home GitHub page, handling these limitations might require using a content-blocking proxy. This approach, already implemented in standalone AdGuard applications, may be introduced to AdGuard Home in the future. However, even with this feature, there could still be cases requiring advanced configurations or where blocking is not entirely possible.

This limitation is essential to keep in mind while setting up AdGuard Home, as it highlights the trade-offs of DNS-level blocking compared to browser-based or system-wide content blockers.

By hosting AdGuard Home on a VPS, you not only centralize DNS filtering but also enjoy improved performance and reliability. Integrating it with your TP-Link router ensures that all devices on your network benefit from ad-free, secure browsing.


Previous Post
Setting Up MetalLB Load Balancer on Kubernetes
Next Post
Setup Node Exporter with Systemd