Skip to content

WireGuard split tunneling that does not leak

How to route only specific traffic through a WireGuard tunnel — AllowedIPs design, DNS hygiene, route precedence, and the leak-test we run before shipping a profile.

Split tunneling sends only some traffic through the VPN and lets the rest exit the local internet connection. We use it when the goal is “access internal services” rather than “anonymize all traffic” — engineers who need to hit a 10.0.0.0/8 corp range but want zoom calls to ride their home Wi-Fi directly. WireGuard supports split tunneling natively through AllowedIPs, but the leaks come from places people forget: DNS, IPv6, and route precedence with overlapping CIDRs. This article shows the configuration and the verification dance we use before signing off a profile.

How to verify

Before changing anything, check what the current tunnel actually carries.

wg show wg0 allowed-ips
ip route show table all
resolvectl status 2>/dev/null | grep -E 'DNS Servers|DNS Domain'
curl -s https://ifconfig.me
curl -s https://ifconfig.me --interface wg0

If both curl calls return the same address, you have a full tunnel, not a split one. If resolvectl shows the VPN’s DNS as the global resolver while you intended split DNS, every DNS query leaks intent to the VPN even when the underlying flow does not go through it.

What’s happening

WireGuard’s routing is controlled by AllowedIPs on each peer. The wg-quick script (the userland helper that brings up most tunnels) does two things with those values:

  1. Cryptokey routing — packets to those destinations are encrypted and sent to the peer.
  2. Kernel routes — wg-quick installs routes for each AllowedIPs entry pointing at the wg0 interface.

A full tunnel uses AllowedIPs = 0.0.0.0/0, ::/0 (everything). A split tunnel narrows it to just the destinations you want covered, e.g. AllowedIPs = 10.0.0.0/8, 172.16.0.0/12, 192.168.50.0/24. The kernel then routes those CIDRs through the tunnel and everything else through whatever route was there before.

The three leak vectors:

  • DNS — if the VPN pushes a resolver, every query (including for hosts outside the tunnel CIDRs) goes through the tunnel. A network observer sees what you are looking up, even if the connection itself goes elsewhere.
  • IPv6 — if you only listed IPv4 in AllowedIPs and the destination has an AAAA record, the kernel picks the IPv6 path which is not tunneled. Classic “VPN said it routed, IPv6 said otherwise” leak.
  • Overlapping CIDRs — if you push 10.0.0.0/8 through the tunnel but the local LAN is 10.10.10.0/24, that LAN traffic gets pulled into the tunnel too, sometimes against intent.

The procedure

  1. Decide which CIDRs belong in the tunnel. This is the deliverable, not the config. Talk to whoever asked for the VPN: “what hosts are we trying to reach?”

    Typical answers we encounter:

    • Corp networks: 10.0.0.0/8, 172.16.0.0/12
    • Office subnets: 192.168.50.0/24
    • Specific cloud VPCs: 10.42.0.0/16
    • Internal DNS suffix (split DNS): *.corp.example.org
  2. Build the AllowedIPs list. Be explicit; do not start from 0.0.0.0/0 and try to subtract.

    [Peer]
    PublicKey  = <server-pub>
    Endpoint   = vpn.example.org:51820
    AllowedIPs = 10.0.0.0/8, 172.16.0.0/12, 192.168.50.0/24
    PersistentKeepalive = 25
  3. Handle DNS deliberately. Three patterns, pick one:

    Split DNS via systemd-resolved. On Linux, wg-quick can push DNS per-interface. With PostUp = resolvectl dns wg0 10.0.0.53; resolvectl domain wg0 ~corp.example.org, only queries for *.corp.example.org go to the VPN resolver.

    No DNS push at all. Strip DNS = ... from the config; use the local resolver for everything. Add /etc/hosts entries for the few internal names if needed.

    Full DNS through the tunnel. Acceptable if you understand that every lookup is now visible to the VPN, even for non-tunneled traffic.

  4. Decide on IPv6. If your corp network has no IPv6, disable IPv6 routing through the tunnel and let local IPv6 work natively. If it does, list the IPv6 CIDRs in AllowedIPs too: AllowedIPs = 10.0.0.0/8, fd00:10::/48.

  5. Bring the tunnel up.

    wg-quick up wg0
    ip route show | grep wg0

    Confirm only the CIDRs you listed point to wg0.

  6. Leak-test before sign-off. Five checks we run before handing a split-tunnel profile to a user:

    # Public IP — should be your local ISP, not the VPN.
    curl -s https://ifconfig.me
    curl -s -6 https://ifconfig.me
    # DNS leak — should be your local resolver for non-VPN domains.
    resolvectl query example.com
    resolvectl query internal.corp.example.org
    # IPv6 leak.
    curl -s -6 https://ipv6.icanhazip.com
    # Specific corp host.
    ping -c 3 -W 2 10.42.0.5
    # Trace to confirm the route used.
    traceroute -n 10.42.0.5
    traceroute -n 1.1.1.1

    The traceroute outputs are the cleanest signal: corp traffic should show the tunnel hop; public traffic should show the local ISP path.

  7. Document the policy. In the user’s profile or onboarding doc, write what is and is not covered: “this VPN routes only corporate ranges; your home/work Wi-Fi handles everything else.”

Common pitfalls

  • Listing AllowedIPs = 0.0.0.0/0 and assuming “split” because the client UI has a toggle — wg-quick honours the config, not the toggle. The CIDR list is the source of truth.
  • Pushing the VPN’s DNS without a search-domain filter — every query leaks even when traffic does not. Use resolvectl domain wg0 ~corp.example.org for split DNS.
  • Forgetting IPv6 — modern hosts prefer AAAA records. An IPv4-only split tunnel can leak the whole TCP flow over IPv6 the user did not realize they had.
  • Overlapping local LAN with corp CIDR — if your home Wi-Fi is 192.168.1.0/24 and corp pushes 192.168.0.0/16, your local LAN goes into the tunnel. List the LAN explicitly excluded via a more-specific route or change corp’s push.
  • Not retesting after every kernel/config change — Linux’s route table can shift on suspend/resume; we re-run the leak tests on the user’s laptop, not just on a clean VM.

In the engagements we run, split tunneling is the default for engineering laptops — full tunnels create more friction than they prevent leaks for that audience. The leak tests are part of the Managed Operations onboarding checklist; without them, you have a configuration that looks right and behaves wrong in ways nobody notices until an auditor does.