Guides · Published · Updated on
How split tunneling works under the hood
Split tunneling sends some of your traffic through a VPN and the rest over your normal connection. What is split tunneling? covers the idea. This page looks at the mechanics: how VPN clients use routes and app rules to decide which traffic enters the tunnel, how Android, Windows, Apple’s systems and Linux each do it, and why DNS so often takes a different path.
It gets technical in places. You don’t need any of this to use a VPN, though it explains a lot of the odd behaviour people run into.
Routes decide what enters the VPN
Most VPN apps on phones, and many on computers, give the system a virtual network interface, usually called a TUN interface. Instead of a cable or a radio, the VPN app sits on the other side of it: packets the system sends there are handed to the app, which encrypts them and sends them to the VPN server over your real connection. Some VPNs work inside the operating system’s kernel instead, kernel WireGuard on Linux for example, but the question is the same for all of them: which packets go into the VPN?
The answer comes from the routing table, a list of address ranges with an interface for each, and on some systems from policy rules on top of it. For every packet the system picks the most specific matching range. A full tunnel sends everything to the VPN, but how it does that varies:
- OpenVPN’s
redirect-gateway def1adds0.0.0.0/1and128.0.0.0/1. Together they cover all of IPv4, and because each is more specific than your normal default route0.0.0.0/0, they win without removing it (OpenVPN manual). - On Linux,
wg-quickputs the VPN route in a separate routing table and marks WireGuard’s own packets so they don’t use it (wg-quick).
The VPN also has to keep its own encrypted packets out of the tunnel, or they’d loop. A VPN client can add a specific route to the server’s address over the real interface, or use policy rules like wg-quick does. On Android, the VPN app marks its own sockets with VpnService.protect() so they use the normal network (VpnService).
Split tunneling changes which traffic enters the VPN. The rest of this page goes through the ways of choosing.
Split by address
The oldest kind of split tunneling routes only some address ranges into the VPN. A company VPN might route only 10.0.0.0/8, the office network, and leave the rest of the internet alone.
In WireGuard this is AllowedIPs. It works in both directions: outgoing, packets to those ranges go to that peer; incoming, packets from that peer are only accepted if their source address is in those ranges. WireGuard calls this cryptokey routing. AllowedIPs only chooses a peer for traffic that has already reached the WireGuard interface. Getting traffic there is the system’s routing, which wg-quick and most WireGuard apps set up from the same list. With Table = off, wg-quick leaves the routes to you.
AllowedIPs has no “except”. To leave out your local network, you list every range you still want in the tunnel, which is a long list. The WireGuard app for Android has an Exclude private IPs option that writes a fixed IPv4 list for you: it leaves out the private address ranges and keeps routes to the config’s DNS servers. It doesn’t look at your actual network and doesn’t change IPv6. Other clients exclude ranges with routing rules instead, and since Android 13 a VPN app can call excludeRoute() (VpnService.Builder).
Splitting by address works well for networks with fixed addresses, such as an office or your home. It works badly for services. A streaming site or a bank uses many addresses that change, often shared with thousands of other sites on the same content delivery network.
Split by app
To route by app, the system has to know which app sent each packet. Every operating system answers that differently.
Android
Android has per-app VPN built in. A VPN app gives Android either a list of apps to include, with addAllowedApplication(), or a list to leave out, with addDisallowedApplication(). It can’t use both (VpnService.Builder). With an include list, only those apps use the VPN. With an exclude list, those apps stay outside it. Android gives almost every app its own Linux user ID, so the system can tell their traffic apart.
Apps left outside normally use Wi-Fi or mobile data as if the VPN weren’t there. With Android’s Block connections without VPN on, they get no connection at all, unless the VPN app carries their traffic itself (the kill switch guide explains it).
The limit on Android is the number of VPNs: one VPN app per user profile (why Android runs only one VPN at a time). Android 17 adds a system screen for excluding apps, for VPNs that Android itself runs through VpnManager, such as IKEv2 profiles. It doesn’t apply to ordinary VPN apps with their own app lists (what Android 17’s setting does).
Windows
Windows can tie a VPN profile to certain apps through its built-in VPN configuration, but that’s mostly set up by company device management. VPN apps for home users that split by app bring their own way of doing it. Mullvad, for example, publishes its split tunnel driver, which hooks into the Windows Filtering Platform, the system’s framework for filtering and redirecting traffic. A driver like that sees which program opened each connection and steers it to the VPN or the normal network.
macOS, iPhone and iPad
Apple’s per-app VPN is set up with configuration profiles, normally by a company or school that manages the device: an administrator decides which apps use which VPN. A VPN app on a personal iPhone or iPad can choose which address ranges go into the tunnel and whether local networks are excluded, but it can’t pick apps. The Mac is less strict: several VPN apps offer per-app split tunneling there, built on Apple’s network extension frameworks. Apple’s VPN overview for deployment and the includeAllNetworks setting describe the options.
Linux
Linux has several ways to route traffic by process. One uses control groups (cgroups): put the program in a cgroup, mark the packets that come from it, and add a policy routing rule so marked packets use a different routing table. With cgroup v1 that’s the net_cls controller; with cgroup v2, nftables matches the cgroup path directly. Mullvad’s mullvad-exclude puts the program it starts into an exclusion cgroup. Another way is a network namespace: run the program in its own small network that has only the VPN interface, so it can’t reach anything else.
Split by website name
Routing tables match IP addresses. By the time a packet leaves, the name you typed is gone, so to route “netflix.com through the VPN, the rest outside”, a client needs the name from DNS or from the connection itself. Three methods are in use, and each one has a weak spot.
- Watch DNS. Note the addresses returned for the names on your list, and add routes for them as they come. It breaks when an address is shared with other sites, when an app has cached an old answer, and when an app does its own DNS over HTTPS that the VPN can’t see.
- Read the name from the connection. A TLS connection starts with the server’s name in plain text (SNI). A client that handles every connection itself, like a proxy engine, can read it and pick a route per connection. Encrypted Client Hello hides that name, so this gets harder as more sites adopt it.
- Synthetic addresses. For address lookups, answer with an address from a reserved range and remember which name it stood for. When a connection to that address arrives, the client knows the name and can look it up for real at whichever exit the connection takes. Lookups for other record types need separate handling.
DNS, the usual leak
Split tunneling decides where packets go. DNS lookups often take a different path from the connection that follows them.
- On Android, DNS belongs to each network. Apps on the VPN use the VPN’s DNS servers, apps left out use the DNS of Wi-Fi or mobile data. Android’s Private DNS setting can send lookups to a DNS over TLS server instead, and apps or browsers can bring their own encrypted DNS.
- On Windows, the system can send a lookup to the DNS servers of several network adapters at once (Smart Multi-Homed Name Resolution), so a name can reach your internet provider’s server even while the VPN is on. VPN clients add firewall rules or switch it off to stop that.
- Everywhere, a lookup that leaves outside the VPN tells that DNS server which site you’re about to visit, even if the connection itself goes through the tunnel.
How to check if your VPN is working shows how DNS leak tests find this.
IPv6
A VPN that tunnels IPv4 but leaves IPv6 available outside the tunnel lets IPv6 connections go around it. On a network with IPv6, that’s every site that has an IPv6 address. Android blocks an address family by default when the VPN app configures nothing for it, though an app can explicitly allow it with allowFamily(). Desktop systems have no such default, so VPN clients there have to tunnel or block IPv6 themselves.
Kill switches and split tunneling
A kill switch blocks traffic that doesn’t use the VPN. Split tunneling sends some traffic outside the VPN on purpose. The two can clash. On Android, Block connections without VPN also blocks the apps a VPN app has left out, unless the VPN app carries their traffic itself. The VPN kill switch guide covers it.
Several exits at once
A normal VPN has one tunnel to one server. Split tunneling usually means “this tunnel or no tunnel”. Giving different apps different exits, say a streaming app in the United States and everything else in the Netherlands, needs several tunnels open at once and something that picks one for each connection.
On Android that has to happen inside one VPN app, since Android runs only one per profile. This is how unbraid does it:
apps -> TUN -> engine -> rules: blocked apps, DNS, home, local network, website rules, app rules, default
|- WireGuard, OpenVPN or Shadowsocks exits
|- Tailscale for your tailnet or an exit node
'- direct
Apps on routes enter one TUN interface. Apps you set to Direct normally stay outside it, left out by Android. Behind the interface, the sing-box engine handles each connection and asks Android which app owns it, with ConnectivityManager.getConnectionOwnerUid() (ConnectivityManager). Blocked apps are refused first; home and local network rules precede website and app exit rules. Everything else goes to the tunnel of that app’s route, and routes on the same server with the same login share one tunnel. Address lookups get synthetic answers and the name is looked up again through the exit the connection uses. For a website rule, unbraid uses the website name from a lookup made through it, then resolves it using the chosen route’s DNS settings. The website rule takes precedence over the app’s route.
App ownership also explains these two behaviours:
- Ping follows the default route. Android’s owner lookup works for TCP and UDP connections, not ping, so unbraid can’t tell which app sent a ping. When Direct is the default and other apps have VPN routes, unbraid blocks internet ping instead, so it can’t leave directly.
- Work handed to another app follows that app’s route. A link opened in a browser tab belongs to the browser. Push messages delivered through Google Play services follow that service’s route. Apps that keep their own connection for notifications follow their own.
On a Mac, unbraid does the same inside one packet tunnel network extension. Each connection is matched to the program that opened it, by its path: helpers inside an app’s bundle count as that app, and so do connections macOS opens for it, such as Safari’s pages through WebKit or a download through nsurlsessiond. The tunnel captures IPv6 too, and an app’s IPv6 traffic follows its route or is refused. Split tunneling on macOS explains the rest.
When split tunneling is a bad idea
On a work VPN, security teams often turn split tunneling off. A device on the company network and the open internet at once is harder to protect, and the traffic outside the VPN isn’t covered by the company’s filtering.
For a personal VPN the risk is plainer. Apps you leave outside use your normal connection. Their servers see your real address, and your internet provider sees which servers they connect to, as it would without a VPN. Keep the apps you want private on the VPN, and leave out only the ones that need your normal connection.
Questions
Does WireGuard do split tunneling? By address, yes: that’s AllowedIPs. By app, it depends on the client. The Android app can include or exclude apps; see WireGuard split tunneling on Android.
Can I split tunnel by app on an iPhone? Not with a VPN app on a personal iPhone. Apple keeps per-app VPN for managed devices, so VPN apps can only split by address range.
Is split tunneling the same as a proxy? No. A proxy you configure serves the apps that use its settings, and a transparent proxy intercepts traffic for them. Split tunneling is the VPN’s decision about which traffic enters the tunnel at all.
Bring your own VPN
unbraid is a VPN client with no servers of its own. You sign in with an account you already have, or add your own server. It has built-in support for AirVPN, ExpressVPN, IVPN, Mullvad, NordVPN (affiliate link), Private Internet Access, Proton VPN (Free included), Surfshark (affiliate link) and Windscribe. For CyberGhost, you import config files from your account, with step-by-step help in the app.
We earn a commission if you subscribe through a link marked (affiliate link). It helps keep unbraid free. If you're about to subscribe to a VPN service, thank you for considering doing it through one of them.