What Is a VPN Kill Switch and How Does It Work?
A VPN kill switch is a safeguard that cuts off your device's internet traffic whenever the encrypted VPN tunnel is not up. It prevents that traffic from slipping back onto your regular connection, where it would expose your real IP address and send DNS queries outside the VPN.
The idea fits in one sentence, but building a kill switch that holds on every device and every network is one of the hardest jobs in a VPN app.
What happens when a VPN tunnel drops
A device on a VPN has two routes to the internet: the physical connection itself, whether that is Wi-Fi, Ethernet or mobile data, and the encrypted tunnel running on top of it. As long as the VPN is connected, the routing table directs all traffic into that tunnel.
When the tunnel goes away, the operating system does what it is designed to do and keeps you online. Traffic flows over the remaining path, which is the physical connection. Your browser, mail client and background apps notice nothing. They carry on as before, now using the IP address your internet provider assigned to you.
Tunnels drop for mundane reasons. A server stops responding, a phone leaves Wi-Fi range and moves to mobile data, a laptop wakes from sleep, or the VPN app crashes or updates itself. A kill switch exists for those moments.
Two ways to build a kill switch
An app that reacts after the fact
The simpler design lives inside the VPN app. The app monitors the connection, and when it sees the tunnel go down it blocks traffic or closes selected programs. This works only while the app is running, and only once it has noticed the drop.
Android's developer documentation notes that by the time the system informs a VPN app its connection has been revoked, "an alternative network interface is already routing traffic". An app responding to that message is already too late.
A block in the system firewall
The stronger design places rules in the operating system's own packet filter. The rules state that any packet not leaving through the tunnel interface is dropped. The firewall has nothing to notice and nothing to react to, because the ordinary path is closed for as long as the rules exist.
On Linux, the official WireGuard tooling documents an example: a firewall rule that rejects every outgoing packet not going through the WireGuard interface, to "prevent the flow of unencrypted packets through the non-WireGuard interfaces". On Windows, the same job is handled by the Windows Filtering Platform, the system layer on which the built-in Windows firewall itself runs.
The operating system's own always-on and lockdown modes
Some systems provide the block themselves. Android has had Always-on VPN since Android 7.0, which starts the VPN at boot and keeps it running, along with a second switch called "Block connections without VPN". In Android's words, with it on "the system blocks any network traffic that doesn't use the VPN".
Apple offers no user-facing switch. Instead, VPN apps can set a flag named includeAllNetworks, which Apple describes as instructing the system to send "most network traffic" over the tunnel. On Windows, managed VPN profiles can be configured to connect at sign-in and stay connected, which is aimed more at company devices than home users.
Why a kill switch is hard to get right
Each operating system draws the line in a different place
No operating system guarantees that every packet goes through the tunnel. Each one keeps a set of exceptions, and the blocking rules each one uses last for a different length of time.
| System | How blocking is done | Documented limit |
|---|---|---|
| Android | Always-on VPN with "Block connections without VPN" | A 2022 security research report found connectivity checks leaving outside the tunnel each time the device joins a Wi-Fi network |
| iPhone, iPad, Mac | The includeAllNetworks flag, set by the VPN app | Apple always excludes DHCP, captive-portal sign-in, some mobile-only services such as VoLTE, and traffic to a companion device such as an Apple Watch |
| Windows | Windows Filtering Platform filters | Dynamic filters are deleted when the process that created them ends, unless they are made persistent |
| Linux | Firewall rules that reject non-tunnel traffic | In the standard WireGuard example the rule is removed when the tunnel is brought down normally, and most DHCP traffic passes anyway |
In 2022, security researchers reported that with Always-on VPN and blocking both switched on, DNS lookups and HTTP(S) requests still left outside the tunnel when the phone joined Wi-Fi. Those checks exist to detect captive portals, and no user setting turns them off.
Microsoft's documentation describes several filter lifetimes: dynamic filters vanish when the owning process terminates, while persistent filters survive until they are deleted, even across a reboot. A kill switch built from dynamic filters disappears in a crash, which is the moment it is needed.
The hardest moments
A clean disconnect is rarely what tests a kill switch. The difficult cases are the in-between states:
- Reconnecting, when the old tunnel is gone and the new one is not yet up.
- Moving from Wi-Fi to mobile data, when the system changes its routes underneath the VPN.
- Sleep and wake, when the network comes back before the VPN does.
- Captive portals in hotels and airports, where the sign-in page has to load outside the tunnel before any tunnel can exist.
- App updates and crashes, when the software that manages the tunnel is not running at all.
IPv6 and DNS are the other classic gaps. A 2015 academic study of 14 commercial VPN services found that most of them leaked IPv6 traffic, because the clients changed the IPv4 routing table and ignored IPv6. Its advice still stands: capture IPv6 routes as well, and make the DNS server reachable only through the tunnel.
Attacks that get around a working kill switch
A kill switch protects against drops. Two published attacks showed that traffic can leave the tunnel without any drop taking place.
TunnelVision, published on 6 May 2024 and tracked as CVE-2024-3661, uses a rogue DHCP server on the local network. It hands the device routes that are more specific than the VPN's own, so traffic goes out of the physical interface. The VPN's control channel stays up and the app keeps showing "connected". In the researchers' tests the kill switch never triggered. They reported Windows, Linux, iOS and macOS as affected. Android was not, because it does not implement the DHCP option the attack relies on. Firewall rules that drop non-tunnel traffic on the physical interface are one of the mitigations the researchers list.
TunnelCrack, presented at USENIX Security 2023, abused two exceptions that VPN clients commonly add to their routing: one for the local network and one for the VPN server's own address. Across 248 experiments against 67 VPN providers, a hostile Wi-Fi network could present public IP addresses as "local" and pull traffic to those addresses out of the tunnel. According to the researchers' summary, every VPN app they tested on iOS was vulnerable to that variant, and Android was the most secure platform.
The strictest setting can leave you with no internet
Turning every option to maximum has a cost of its own. Apple's includeAllNetworks flag on iOS is an example. During an app update with the flag on, the old tunnel is gone and the new one cannot start, so the device loses all connectivity and the update itself cannot download. Getting out of that state means cancelling the download, toggling the VPN in Settings or restarting the device.
So a strict kill switch can cut the user off entirely, and a lenient one can leak for a moment during an update. Each app has to choose a point between the two.
Networks that block VPNs
On some networks the tunnel never starts. Researchers were able to identify over 85% of OpenVPN flows on an internet provider with a million users, and detected 34 of the 41 "obfuscated" VPN configurations they tested. Another USENIX paper documented real-time blocking of fully encrypted traffic in China since November 2021.
Where VPN handshakes are blocked, a kill switch that holds means no connection at all. The pressure to switch it off is highest in the places where a leak costs the most. On those networks the protocol has to get through first, and only then does a kill switch have a tunnel to protect.
How Le VPN protects against leaks
Linux: a full firewall leak block
The Le VPN app for Linux takes the firewall approach described earlier. While you are connected, a set of nftables rules rejects any traffic that does not go through the tunnel. The only exceptions are loopback, DHCP and, if you enable Local Connections, your local network.
DNS requests can reach only the tunnel's resolvers, and IPv6 outside the tunnel is refused. Traffic forwarded from containers and virtual machines on the same computer is covered as well. The app re-applies the rules every 5 seconds if something removes them, keeps them in place while you switch servers, and keeps them if the tunnel process itself dies. They stay until you disconnect.
WireGuard and WireGuard Stealth: all traffic goes into the tunnel
Every current Le VPN app that connects with WireGuard or WireGuard Stealth (Windows, Mac, iPhone and iPad, Android, Linux) points the whole default route into the tunnel while connected, for IPv4 and for IPv6. If the server stops answering while the app is running, traffic has nowhere to go but the tunnel, so it waits instead of leaking onto the ordinary connection.
On Windows, the app also captures into the tunnel the routes that network adapters already had, including IPv6 routes and routes pushed by DHCP. On iPhone and Mac, DNS goes through the tunnel as well.
WireGuard Stealth on networks that block VPNs
WireGuard Stealth is Le VPN's protocol for networks that block VPN connections. It gets a tunnel up on networks where standard VPN protocols are stopped at the handshake. That matters for leak protection, because routing everything into the tunnel only helps once there is a tunnel.
Android: Always-on VPN and "Block connections without VPN"
The Le VPN app for Android supports Android's own Always-on VPN. The settings belong to Android, and turning them on takes a minute:
- Open Android Settings and go to Network & internet, then VPN.
- Tap the gear next to Le VPN.
- Turn on Always-on VPN.
- Turn on "Block connections without VPN".
Menu names differ between phone makers. With both switches on, the phone has no internet unless the Le VPN tunnel is up.
Mac, Apple Vision Pro and the legacy apps
On Mac and Apple Vision Pro, Le VPN has an Automatic reconnection setting: if the tunnel goes down while it should be up, the system brings it back. For people still using the legacy Windows and macOS apps with OpenVPN or L2TP, those apps have an option called "Block Internet connection while reconnecting".
Work that continues
Everything in the section on why kill switches are hard applies to Le VPN as much as to anyone. The operating systems change what they exempt, new attacks get published, and networks get better at blocking tunnels. Le VPN keeps improving its kill switch protection for that reason: it is bringing in more secure protocols and working to make the protection hold in every network environment.
How to test a kill switch yourself
Run the test on your own network. Do not test on a network where an unprotected leak could put you at risk.
- Before connecting, open an IP check such as Le VPN's IP address test and write down your real public IPv4 address, your IPv6 address if you have one, and your DNS resolver.
- Connect the VPN and reload the page. The IP address should have changed, and no IPv6 address from your internet provider should appear.
- Start something that sends traffic continuously: a long download, a ping to a public IP address in a terminal, or a page that refreshes itself.
- Force a drop. Turn Wi-Fi off and on, switch from Wi-Fi to mobile data, or put the laptop to sleep and wake it.
- Watch what happens. With working protection the ping or download stops completely until the tunnel is back, and the IP check never shows your real address in between.
- On Android, also confirm that Always-on VPN and "Block connections without VPN" are both on.
A browser test has limits. It does not show what system services such as push notifications, time sync or connectivity checks are doing. To see what really leaves the physical interface, run a packet capture on your router or on a second machine. The Android and Apple findings described earlier were made that way.
What a kill switch can and cannot do
A kill switch closes the gap between a dropped tunnel and a restored one. The most dependable kind is a firewall rule, because it does not have to notice the drop. Even then, the operating system lets some traffic through by design, and a hostile network can still attack the routing. The practical steps are to check which design your app uses, switch on the system's own always-on settings where they exist, and run the test above once on every device you depend on.
Le VPN's apps route all IPv4 and IPv6 traffic into the tunnel over WireGuard and WireGuard Stealth, and the Linux app adds the full firewall block. See Le VPN plans.
About the author
Le VPN Blog Editor
Alan Summers has been writing and editing for the Le VPN blog for years, covering online privacy, cyber security, and the best ways to get the most out of a VPN. He keeps a close eye on the news that affects internet freedom around the world and turns it into practical advice for Le VPN readers.
Articles by Alan Summers →