UniFi Gateway + NordVPN + AdGuard: Domain-Based Routing Setup
🔐 Summary
If you're running a UniFi Gateway and want to route traffic for specific domains (like geo restricted streaming) through a NordVPN tunnel, while using AdGuard Home for DNS filtering, this guide walks you through the full configuration — from VPN client setup to DNS forwarding and policy-based routing. In this post, I'll use example.com to represent a domain that I want to route across a VPN tunnel.
Note: This method can work with any combination of VPN provider and External DNS. If you're just using the Unifi GW for DNS, it's even simpler.
🧭 Overview
- Goal: Route all traffic to example.com and its subdomains through NordVPN.
- Tools Used:
- UniFi Cloud Gateway (Next-Gen UniFi gateway or UniFi Cloud Gateway)
- NordVPN (OpenVPN)
- AdGuard Home (DNS filtering and conditional forwarding)
1. Configure NordVPN as a Client on UniFi Gateway
✅ UI-Based Setup (No SSH Required)
- Navigate to UniFi Network > Settings > VPN > VPN Client
- Click Add VPN Client
- Upload your
.ovpnfile from NordVPN - Enter your NordVPN service credentials (username and password)
📷 See UniFi’s official guide with screenshots:
👉 UniFi Gateway – OpenVPN Client
2. Get NordVPN Service Credentials
NordVPN provides dedicated service credentials for manual configuration (different from your account login):
- Go to your Nord Account dashboard
- Navigate to Advanced Setup > Manual Configuration
- Copy the Service Username and Password
📷 Full instructions:
👉 NordVPN Manual Configuration Guide
3. Create Policy-Based Route (PBR) for Domain Routing
- Go to UniFi Network > Settings > Routing & Firewall > Policy-Based Routing
- Click Create New Route -> Type: Policy Based
- Configure:
- Name:
NordVPN-example.com - Source: Choose Any unless you want to restrict to specific sources. If so, choose LAN network or specific device and select your source.
- Destination: example.com
- Name:
🧠 Note: UniFi requires DNS resolution for PBR target domains to happen on the gateway itself for domain-based routing to work. If you are using external DNS like PiHole or AdGuard, you'll need to configure those solutions for conditional forwarding. I have steps for AdGuard below.
4. Configure AdGuard Home for Conditional DNS Forwarding
If you're using AdGuard Home as your DNS resolver, forward DNS queries for example.com to the UniFi Gateway:
In your AdGuard DNS settings, add the below entry to your Upstream DNS servers. Make sure to change example.com to the actual domain you are sending across the VPN. This also assumes you are using the default IP for a Unif GW of 192.168.1.1, update the entry if you have changed it to something different.
[/example.com/]192.168.1.1
- This ensures UniFi sees the DNS queries and can apply the PBR correctly.
- Restart AdGuard DNS service to apply changes.
🗒 Final Notes
- If you have issues getting content to load across the VPN, consider expanding your domain list to include CDN endpoints. I like to use Chrome or Edge Dev Tools to look at the network traffic while accessing the website.
Comments
Post a Comment