brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

πŸ›œ Guide: AdGuard Home + Tailscale (Secure Split-Horizon DNS)

πŸ›œ Guide: AdGuard Home + Tailscale (Secure Split-Horizon DNS)

Guide dns

10 steps 4 min read

Step 1 of 10: Introduction

This guide covers my split-horizon DNS setup. AdGuard Home, Tailscale and Cloudflare Tunnels on an Unraid 7 server need no open ports on the router (Ubiquiti Dream Router) and still give you access from anywhere to your local services like Emby, Sonarr, and Home Assistant. Recently I completely migrated to Tailscale.

Step 2 of 10: Why this setup

Running Tailscale next to web services often causes port conflicts. This configuration fixes a specific conflict inside the container and gives you:

  • At Home: Low latency via local connections.
  • Remote: Full encryption and ad-blocking via Tailscale VPN.
  • Safety: No manual port forwarding needed.
  • Trust: Valid Let’s Encrypt certificates managed via Nginx Proxy Manager.

Step 3 of 10: Phase 1: configure the Unraid container

We use the ghcr.io/mainfrezzer/adguardhome container, which has Tailscale built-in.

Network Settings:

  • Network Type: Custom: br0
  • Fixed IP Address: 192.168.1.3 (Your dedicated AdGuard IP)

Volume Mappings:

Map your certificates correctly, so AdGuard can serve DoH (DNS-over-HTTPS) securely.

  1. /opt/adguardhome/conf ↔ /mnt/user/appdata/adguard/config
  2. /opt/adguardhome/work ↔ /mnt/user/appdata/adguard/workingdir
  3. Certificates:
    • Container Path: /certs
    • Host Path: /mnt/user/appdata/Nginx-Proxy-Manager-Official/letsencrypt/
    • Access Mode: Read Only (ro)

Environment Variables:

Add these manual variables to prevent the container from trying to manage its own certificates or internal serving:

  • TAILSCALE_ADVERTISE_ROUTES: 192.168.1.0/24
  • TAILSCALE_SERVE: 0
  • TAILSCALE_CERTS: 0

Step 4 of 10: Phase 2: fix the port conflict (YAML edit)

By default, the Tailscale service in this specific container often hijacks port 443. To fix this, we move the AdGuard Home HTTPS interface to port 4443.

  1. Stop the AdGuard-Home-Unbound container.
  2. Open the Unraid Terminal.
  3. Edit your configuration file: nano /mnt/user/appdata/adguard/config/AdGuardHome.yaml.
  4. Locate the tls: section and update the port:YAMLtls: enabled: true port: 4443 # Changed from 443 certificate_path: /certs/live/npm-1/fullchain.pem private_key_path: /certs/live/npm-1/privkey.pem (Note: Double-check that npm-1 is your correct certificate folder using ls -l).
  5. Save (Ctrl+O) and Exit (Ctrl+X), then restart the container.

Step 5 of 10: Phase 3: Cloudflare Tunnel

To make your DNS reachable via DNS-over-HTTPS (DoH) without opening ports, we use a Cloudflare Tunnel.

  1. Navigate to the Cloudflare Zero Trust Dashboard.
  2. Go to Access > Tunnels and edit your active tunnel.
  3. Add a Public Hostname (e.g., dns.example.com):
    • Service Type: HTTPS
    • URL: https://192.168.1.3:4443
    • TLS Settings: Enable No TLS Verify (since we are using internal certificates).

Step 6 of 10: Phase 4: Tailscale as a global VPN

Now make sure all your Tailscale devices (like your Samsung S25 Ultra) use AdGuard Home as their primary DNS.

Step A: Approve Subnet Routes

In the Tailscale Admin Console, find your AdGuard machine. Click the three dots β†’ Edit route settings. Enable the checkbox for 192.168.1.0/24. This allows you to reach your local IPs (like your P1 Monitor on 192.168.1.42) from anywhere.

Step B: Global DNS Settings

In the DNS tab of the Tailscale Admin Console:

  1. Under Global Nameservers, click Add nameserver β†’ Custom.
  2. Enter the Tailscale IP of your AdGuard container (e.g., 100.x.x.x).
  3. Disable “Restrict to domain”.
  4. Toggle Override local DNS to ON.

Step 7 of 10: Phase 5: mobile devices (Android/iOS)

To stop your phone from bypassing your settings:

  1. Android Settings: Go to Connections > More Connection Settings > Private DNS. Set this to OFF. If left on “Automatic,” Android might ignore your Tailscale DNS in favor of Google’s DNS.
  2. Tailscale App: Ensure it is active.
  3. The 4G Test: Turn off Wi-Fi. Try to access http://192.168.1.2 (your Nginx Proxy Manager). If it loads, the tunnel works.

Step 8 of 10: Phase 6: local optimization (split-brain DNS)

Local traffic should stay in the house, so you get gigabit speed on your own Wi-Fi.

1. UDM Configuration:

On your Ubiquiti Dream Router, set the DHCP DNS Server to 192.168.1.3. Now every device in your house uses AdGuard by default.

2. AdGuard DNS Rewrites:

Add the following rules in AdGuard Home under Filters > DNS Rewrites:

  • dns.example.com β†’ 192.168.1.3 (Keeps DNS traffic local).
  • *.example.com β†’ 192.168.1.2 (Points all apps like Emby or Sonarr to Nginx).

Step 9 of 10: Traffic flow

LocationActionTraffic Path
At Home (Wi-Fi)Accessing emby.example.comPhone β†’ AdGuard (Local) β†’ Nginx (Local) β†’ Direct Connection
On the Go (4G + Tailscale)Accessing emby.example.comPhone β†’ Tailscale Tunnel β†’ AdGuard Home β†’ Subnet Route β†’ Secure Tunnel
Public PCAccessing dns.example.comBrowser β†’ Cloudflare Tunnel β†’ AdGuard Port 4443 β†’ Secure DoH

Step 10 of 10: Conclusion

With this split-horizon setup my connection to my Unraid server is fast and secure, and ad-free too, whether I am in my living room in Leiden or abroad.

Happy hosting!

Link