Sub topic 13
Split tunnelling, full tunnelling and DNS
This chapter assumes you know how a routing table and a default route work, how longest-prefix matching picks a route, and the difference between TCP and UDP. You should also be comfortable on a Linux command line and have seen the idea of a tunnel as a virtual interface. After this chapter you should be able to predict which packets enter a tunnel, where DNS queries go, and what breaks when those two decisions disagree.
The routing table decides what enters the tunnel
A VPN client creates a virtual interface, such as wg0 or tun0. A packet enters the tunnel only if the routing table sends it to that interface. The VPN does not inspect traffic and choose. Routing does the choosing, and the VPN software edits the routing table to set the policy.
Linux picks the route with the longest matching prefix. A route for 10.8.0.0/24 beats a default route 0.0.0.0/0 for any address inside that subnet. This one rule explains both tunnelling styles.
- Split tunnelling: only some destinations are routed into the tunnel. Everything else uses the normal default route and leaves directly through your local network.
- Full tunnelling: the default route points into the tunnel, so nearly all traffic goes through the VPN endpoint.
Notice that the outer packet to the VPN server also needs a route. It must leave through the local gateway, not through the tunnel. Otherwise it would be wrapped in itself forever. Every full-tunnel design has to solve this, as shown below.
Split tunnelling with WireGuard
In WireGuard, AllowedIPs does two jobs. For outgoing packets it acts as a routing table: a packet goes to a peer if its destination is in that peer's AllowedIPs. For incoming packets it acts as a filter: a decrypted packet is accepted only if its source address is in the list.
[Interface]
PrivateKey = <client-private-key>
Address = 10.8.0.2/24
DNS = 10.8.0.1
[Peer]
PublicKey = <server-public-key>
Endpoint = vpn.example.com:51820
AllowedIPs = 10.8.0.0/24
PersistentKeepalive = 25When you bring this up with wg-quick up wg0, it adds a route for 10.8.0.0/24 through wg0. Your default route is untouched, so web browsing goes straight out your local connection. Only traffic to the VPN subnet is encrypted.
You can list more prefixes to reach resources behind the server, for example AllowedIPs = 10.8.0.0/24, 10.20.0.0/16. Each prefix becomes a route.
Full tunnelling with WireGuard
Changing AllowedIPs to the default routes captures everything:
[Peer]
PublicKey = <server-public-key>
Endpoint = vpn.example.com:51820
AllowedIPs = 0.0.0.0/0, ::/0Including ::/0 matters. If you list only IPv4, IPv6 traffic bypasses the tunnel and exposes your real IPv6 address.
On Linux, wg-quick avoids the self-wrapping loop with policy routing. It marks the tunnel's own encrypted packets with a firewall mark, adds a separate routing table (51820) holding the default route through wg0, and adds rules so that marked packets skip that table. You can see the effect:
ip rule show
ip route show table 51820
ip route get 1.1.1.1
ip route get 192.0.2.50 # use the address of your VPN server's endpointThe first lookup for an ordinary internet address should show dev wg0. The lookup for the server's own public address should show your local interface, which proves the outer packets escape the tunnel.
The server must also forward and translate the traffic. Without this, clients connect but cannot reach the internet:
sudo sysctl -w net.ipv4.ip_forward=1
sudo iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADEHere eth0 stands for the server's public interface. Replace it with your own interface name.
Comparing the two
| Aspect | Split tunnel | Full tunnel |
|---|---|---|
| Route installed | Specific VPN prefixes | Default route (and IPv6 default) |
| Internet traffic path | Local ISP directly | Through the VPN server |
| Load on VPN server | Low | High, all client bandwidth |
| Exposure on untrusted Wi-Fi | Non-VPN traffic is unprotected | All traffic is encrypted to the server |
| Local devices (printer, NAS) | Usually still reachable | Often unreachable unless excluded |
| Central inspection or logging | Only VPN-bound traffic | All traffic |
| Typical use | Reach the office network | Untrusted networks, a single exit address |
Split tunnelling is faster and keeps local resources working. Full tunnelling gives one control point and protects traffic on hostile networks. Many organisations prefer full tunnels for security policy. Others use split tunnels to save bandwidth on video calls and software updates.
DNS is a separate decision
Routing handles packets, but DNS handles names, and the client chooses its DNS resolver independently. A resolver is just a server address in the system's configuration. Whether queries to that address go through the tunnel depends on routing, and which resolver is used depends on the DNS settings.
The DNS = 10.8.0.1 line in the WireGuard config is not interpreted by the kernel. wg-quick passes it to a helper such as resolvconf or systemd-resolved. If that helper is missing or conflicts with another network manager, the line may silently have no effect.
Three typical outcomes:
- Split tunnel, VPN DNS only for internal names. Internal names such as
wiki.corp.example.comresolve through the VPN. Public names use the local resolver. - Full tunnel, VPN DNS for everything. All queries go to the VPN's resolver through the tunnel.
- Full tunnel, local DNS left in place (a DNS leak). Packets go through the VPN, but the name lookups still reach your ISP or the Wi-Fi's resolver, revealing every domain you visit.
Split DNS on systemd-resolved
Split DNS sends queries for specific domains to the VPN's resolver and everything else elsewhere. With systemd-resolved you can set this per interface:
sudo resolvectl dns wg0 10.8.0.1
sudo resolvectl domain wg0 '~corp.example.com'
resolvectl status wg0The ~ prefix marks a routing-only domain. Queries for names under corp.example.com go to 10.8.0.1 through wg0. To send all queries to the VPN resolver, use the root routing domain '~.' instead.
Checking where a query goes
resolvectl query wiki.corp.example.com
resolvectl query example.orgThe output names the link and server that answered. Compare it with what you intended.
Common errors
- Overlapping subnets. Your home network uses
192.168.1.0/24and the office also uses192.168.1.0/24. The connected local route wins, so the office hosts are unreachable. Fix this by renumbering one side, or by using NAT on the VPN server. - IPv6 leak. A full tunnel configured only for IPv4 lets IPv6 traffic out directly. Include
::/0, or disable IPv6 on the client deliberately. - DNS leak. The routes are right but the resolver is not changed. Check with
resolvectl statusand a test query. - Resolver unreachable through the tunnel. In a split tunnel,
DNS = 10.8.0.1works only because10.8.0.0/24is inAllowedIPs. If the resolver's address falls outside the routed prefixes, queries leave through the local network and fail. - Local network lost. A full tunnel hides the LAN, because your LAN prefix is more specific only if it is a connected route. Usually the connected route still wins for local addresses, but captive-portal login pages and some DHCP renewals can fail while the tunnel is up.
- Server not forwarding. Clients connect and handshake succeeds, but pages never load. Check forwarding and the NAT rule on the server.
Choosing a policy
Choose according to what you need to protect and what you can afford to carry:
- If users only need internal applications, start with a split tunnel and split DNS. It costs the least bandwidth and breaks the fewest local devices.
- If users work on networks you do not trust, or the organisation requires central filtering and a fixed exit address, use a full tunnel with the VPN's resolver and IPv6 handled explicitly.
- If you need both, use a full tunnel plus explicit exclusions for traffic you want to leave directly, such as a local printer subnet. Excluding specific prefixes means computing
AllowedIPsso that those prefixes are left out of the default range.
Always verify the result rather than trusting the config. Run ip route get for a public address and an internal address, run resolvectl query for a public name and an internal name, and use a leak test from the client while connected.
Exercise
A client uses AllowedIPs = 10.8.0.0/24 and DNS = 10.8.0.1. Users report that internal names resolve, but a security review shows that their traffic to public websites is not protected on café Wi-Fi. What kind of tunnel is this, and what two changes would make all traffic and all name lookups go through the VPN? Then name one extra server-side requirement.
Show answer
It is a split tunnel, because only 10.8.0.0/24 is routed into wg0. Change AllowedIPs to 0.0.0.0/0, ::/0 so IPv4 and IPv6 default routes use the tunnel, and make the VPN resolver the only resolver used, for example by keeping DNS = 10.8.0.1 and, with systemd-resolved, setting the routing domain to '~.' on wg0. The server must also forward packets (net.ipv4.ip_forward=1) and NAT the client subnet to its public interface, otherwise the clients cannot reach the internet.