AD SPACE AVAILABLE · BRAND PARTNERS WELCOME

Put 365 Wiki to work with your AI

Copy the prompt below, paste it into the AI you already use, then ask your question.

Download full Skill

Try it with the prompt first. If you use 365 Wiki often, install the full 365Wiki Skill so you do not have to paste it again. No regular AI? Gemini or Microsoft Copilot on the web will work.

365Wiki Skill

i365Finds Editorial is the independent research and editorial organization behind 365 Wiki. We follow changes in tools, products, services, entertainment, and digital life around the world, turning scattered and fast-moving information into clearly sourced, well-structured public content that is easier to understand and compare.
Indexed 92,250 Wiki articles

How to Configure Policy-Based Routing on a Home VPN Router

Ana Flávia Magalhães · 365Finds Editorial

Routing your entire home network through a single commercial VPN tunnel is almost always an exercise in frustration. The romantic vision of total household privacy quickly collapses the moment a banking app flags account access from an unexpected datacenter IP, a PlayStation registers unplayable ping spikes on local multiplayer servers, or a smart television loses access to regional broadcast libraries.

At 365Finds, we have seen this scenario play out repeatedly: an all-or-nothing VPN toggle creates more friction than security. Policy-Based Routing (PBR)—often referred to as selective routing or split tunneling at the gateway level—solves this problem. Instead of forcing every packet through the same pipe based solely on destination addresses, PBR allows your router to make forwarding decisions based on source device, destination network, port, or protocol.

Here is how to design, configure, and troubleshoot policy-based routing on consumer and enthusiast router platforms so that privacy-sensitive hardware tunnels out securely while latency-critical and domestic services remain on your clean ISP gateway.


1. Core Principles: Source vs. Destination Routing

Standard IP routing is blind to who initiates the connection. The router looks strictly at the destination IP in a packet header, checks its main routing table (table main), and dispatches the packet through the default WAN gateway.

Policy-Based Routing bypasses this default behavior using policy tables and Netfilter marks (fwmark):


2. The Non-Negotiable Prerequisite: Static IP Allocation

Before writing a single routing rule, every client device targeted by a policy must have an invariant IP address. If your streaming box reboots and receives a new address via dynamic DHCP, your carefully crafted policy rule becomes useless.

  1. Log into your router's administration interface.
  2. Navigate to LAN > DHCP Server (or Network > DHCP and DNS depending on your firmware).
  3. Locate the DHCP Static Leases or MAC IP Reservation table.
  4. Bind each target hardware MAC address to a predictable internal IP (e.g., 192.168.1.150 for Apple TV, 192.168.1.160 for a privacy workstation).
  5. Alternatively, create a dedicated guest VLAN or secondary subnet (e.g., 192.168.10.0/24) specifically for VPN-bound hardware. This allows you to route an entire CIDR block rather than babysitting individual device reservations.

3. Platform Walkthroughs

Router firmware implementations vary widely. Below is how the policy pipeline works across the five most common router ecosystems.

Asuswrt-Merlin (VPN Director)

Asuswrt-Merlin replaced legacy OpenVPN policy routing with VPN Director, storing routing tables in the router's non-volatile JFFS partition rather than cramped NVRAM.

  1. Establish your active tunnel under VPN > VPN Client (OpenVPN or WireGuard). Ensure the tunnel status shows active and connected.
  2. In the left navigation tree, select VPN Director.
  3. Under the Rules table, click the Add (+) icon.
  4. Configure the policy parameters:
    • Interface: Select your target tunnel (e.g., OVPN1 or WDG1).
    • Local IP / Source: Input the single reserved IP (e.g., 192.168.1.150) or a subnet (192.168.1.128/28).
    • Remote IP / Destination: Leave blank or set to 0.0.0.0/0 to send all traffic from this source through the tunnel.
  5. Handling WAN Bypasses: Asuswrt-Merlin evaluates WAN redirect rules before VPN redirect rules. If you route an entire subnet to a VPN but want a gaming console at 192.168.1.100 exempted, create a rule with Interface: WAN for 192.168.1.100 and position it in the rule table.
  6. Enable the Killswitch setting within the VPN Client configuration if you require selected devices to immediately lose internet access rather than fall back to the unencrypted WAN interface when the tunnel drops.

GL.iNet (VPN Dashboard - Policy Mode)

GL.iNet's proprietary UI (built atop OpenWrt) abstracts Linux policy tables into direct toggle controls.

  1. Open the Admin Panel and navigate to VPN > VPN Dashboard.
  2. Connect your WireGuard or OpenVPN client profile.
  3. In the upper-right corner of the VPN management panel, click the default Global Mode button and select Policy Mode.
  4. Click Apply, then open the rule configuration settings:
    • To route specific devices: Select Based on the Client Device, choose Only use VPN for the following devices, and check the checkboxes for your static hardware entries.
    • To bypass domestic services: Under destination rules, enable Do not use VPN for local networks to ensure communication with local network printers, smart switches, and upstream gateways remains functional.

OpenWrt (pbr / luci-app-pbr)

Modern OpenWrt (versions 22.03, 23.05, and newer) uses the pbr package backed by nftables (via fw4), completely superseding the legacy vpn-policy-routing utility.

  1. Install the requisite packages via the LuCI Web GUI or command line:
    opkg update
    opkg install pbr luci-app-pbr
    
    Note: If domain-based routing is needed, install dnsmasq-full to support dynamic IP-set resolution.
  2. Navigate to Services > Policy Routing.
  3. Under the Interfaces section, ensure your outbound interfaces (wan, wg0, or tun0) are correctly detected.
  4. Go to the Policies tab and create a rule:
    • Name: e.g., tv_box_vpn
    • Source IP / MAC: Specify your target IP (e.g., 192.168.1.150/32) or select from connected DHCP leases.
    • Destination IP: Leave blank for unrestricted routing.
    • Interface: Select your VPN interface (wg0).
  5. Save & Apply. OpenWrt dynamically populates custom routing tables and registers matching nftables mark policies.

pfSense / OPNsense (Firewall Rules with Gateway Selection)

In FreeBSD-based firewall appliances, policy routing is handled directly within the firewall filter rules by assigning a specific Gateway to a traffic match.

  1. Ensure your OpenVPN or WireGuard interface is assigned under Interfaces > Assignments and enabled.
  2. Verify that a valid Gateway entry exists under System > Routing > Gateways.
  3. Navigate to Firewall > Rules > LAN.
  4. Critical Rule Ordering: Rule matching operates top-to-bottom on a "first match wins" basis.
    • Rule 1 (LAN-to-LAN Pass): Create an allow rule at the very top: Source LAN net, Destination RFC1918 (all private IPs: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16), Gateway: Default. This ensures local traffic never gets diverted to the VPN.
    • Rule 2 (VPN Steering): Create a pass rule beneath Rule 1: Source Single Host or Alias (e.g., your streaming device IP 192.168.1.150), Destination Any. Expand Advanced Options, navigate to Gateway, and select your VPN_GATEWAY.
    • Rule 3 (Default Internet): The standard default LAN-to-any rule using Default gateway handles all remaining traffic.
  5. Apply Changes. If traffic fails to shift immediately, go to Diagnostics > States > Reset States to clear lingering connections tied to the default gateway.

Ubiquiti UniFi (Traffic Routes / Policy-Based Routes)

UniFi Gateway environments (UniFi OS running on UDM, UDR, or UXG) consolidate this under Traffic Management.

  1. Go to Settings > Routing (or Policy Engine > Policy-Based Routes depending on your UniFi Network application version).
  2. Create a new Traffic Route:
    • What to Route: Select All Traffic (or specify Domains/IPs).
    • Device / Network: Choose specific clients or an entire Virtual Network / VLAN.
    • Interface: Select your configured VPN Client tunnel instead of Primary WAN.
  3. Save changes. UniFi automatically writes kernel routing rules across connected UniFi switching and gateway hardware.

4. The Three Hidden Traps: DNS, State Tables, and Local Interconnects

At 365Finds, when we audit failed PBR deployments, the issue almost never stems from incorrect routing syntax. It stems from these three architectural blind spots:

1. DNS Leakage and Hijacking

When a client device routes its TCP and UDP traffic through an encrypted tunnel, its DNS queries might still hit the router's local caching resolver (192.168.1.1). If the router forwards those queries upstream to your ISP's recursive DNS server, your true physical location and browsing history are exposed despite the VPN tunnel.

2. Lingering State Tables

Operating system firewalls are stateful. When you save a new policy routing rule, existing TCP connections will continue to use the socket established before the rule was applied. A user tests their IP address immediately after saving, sees their ISP IP, and assumes the rule failed. Always flush the connection tracker table or toggle the client device's network interface to verify routing changes.

3. Local Subnet Isolation

When an entire device is routed out through 0.0.0.0/0 via a VPN gateway without an explicit local bypass, it can no longer communicate with your local network printer, home media server, or Chromecast. Explicitly exclude private address ranges (RFC 1918) before applying catch-all tunnel routing rules.


5. Architectural Comparison

Router EcosystemManagement LayerPrimary Routing MechanismDomain Routing SupportRule Storage
Asuswrt-MerlinVPN Director GUILinux ip rule & ipsetScripting required (dnsmasq)JFFS flash partition
OpenWrtluci-app-pbrLinux ip rule & nftablesNative via dnsmasq-fullSystem config (uci)
pfSense / OPNsenseFirewall Rule OptionsFreeBSD pf gateway tagsAliases with FQDN periodic resolveXML configuration
GL.iNetVPN Dashboard GUIProprietary wrappers over OpenWrtNative domain-based policy listSystem config (uci)
Ubiquiti UniFiTraffic Routes EngineUniFi Controller PBR agentNative Domain & IP categoriesUniFi Core database

On modern multi-core router platforms running WireGuard, policy routing incurs virtually zero measurable CPU penalty compared to running an unselective tunnel.


References