Windows VPN kill switch: firewall rules that actually block leaks
A kill switch stops every connection the moment the VPN tunnel drops, so nothing reaches the internet over your real address while the app reconnects. The 404 VPN app for Windows has one built in. If you use another VLESS client that does not, the reliable way is two outbound rules in Windows Defender Firewall: block everything, allow the VPN server. The commands below set that up in a minute and a second pair removes it.
Why you want it
Without a kill switch, a tunnel that drops for two seconds on a Wi-Fi handover lets your browser, torrent client and every background app continue over the plain connection. The apps do not notice; your real IP does the talking for those seconds. A kill switch turns that into a short loss of connectivity instead.
Option 1: the 404 VPN app
Turn on the kill switch in the app's settings. That is all: the app blocks traffic while the tunnel is down and lifts the block when it is back. Setup is in the Windows guide. If you use the 404 VPN app, stop here.
Option 2: Windows Firewall rules
Open PowerShell as administrator. Replace SERVER_IP with the server address from your VLESS key in the dashboard, and TUN_ADAPTER with the name of your client's tunnel adapter from Get-NetAdapter.
New-NetFirewallRule -DisplayName "404VPN allow server" -Direction Outbound -RemoteAddress SERVER_IP -Action Allow
New-NetFirewallRule -DisplayName "404VPN allow DNS via tunnel" -Direction Outbound -InterfaceAlias "TUN_ADAPTER" -Action Allow
Set-NetFirewallProfile -Profile Domain,Private,Public -DefaultOutboundAction Block
The first rule lets the client reach the VPN server. The second allows traffic on the tunnel interface itself. The third makes "block" the default for everything else. From now on, with the tunnel down, nothing leaves the machine.
Switch it off
Set-NetFirewallProfile -Profile Domain,Private,Public -DefaultOutboundAction Allow
Remove-NetFirewallRule -DisplayName "404VPN allow server"
Remove-NetFirewallRule -DisplayName "404VPN allow DNS via tunnel"
Things that break and how to handle them
- Local network printers and NAS. Add an allow rule for your LAN range:
New-NetFirewallRule -DisplayName "404VPN allow LAN" -Direction Outbound -RemoteAddress 192.168.0.0/16 -Action Allow. - Windows Update. Goes through the tunnel; works as long as the VPN is connected.
- Switching servers. Each server address needs its own allow rule. Add one per server you use.
- Captive portals. Switch the default action to Allow, log in to the portal, switch back.
FAQ
My client has a "TUN mode". Is that a kill switch?
No. TUN mode routes everything through the tunnel while connected; it does not block traffic when the tunnel is down. Check your client's settings for a separate "block when disconnected" option, or use the rules above.
Is the firewall method as good as a built-in kill switch?
It is stricter: it blocks at the OS level, independent of whether the app is even running.
Will this block the VPN app's own update check?
Yes, while disconnected. Updates download fine once the tunnel is up.
Does this work on Windows 10 Home?
Yes. Windows Defender Firewall and these PowerShell cmdlets are in every edition.