How to Force All Traffic Through a VPN on Windows Using Docker (When Your Router Can’t)
How to Force All Traffic Through a VPN on Windows Using Docker (When Your Router Can’t)
Windows Architecture Reality
So we need:
-
Windows to forward traffic
-
Windows to NAT into Docker VM
-
Docker VM to forward into VPN tunnel (click here for instructions on installing the VPN Docker container on Windows).
Requirements
-
Windows 10/11 Pro (Home can work, but more painful)
-
Docker Desktop using WSL2 backend
-
NordVPN service account (click here to watch the video on how to generate service account credentials)
-
Admin access on Windows
-
Router that either:
-
Allows changing DHCP gateway OR
-
You are OK setting gateway manually per device
-
The Hard Limits
Know this!
-
If Windows sleeps → internet dies
-
Docker updates can break networking
-
WSL2 networking is NAT’d → adds latency
-
Some devices (Chromecast, consoles) hate non-standard gateways
-
This is not “set and forget”
Click if you need a NordVPN service account
Step 0 – Verify Docker is Using WSL2
In PowerShell:
You should see:
If not, fix that first.
Step 1 – Enable IP Forwarding in Windows
Open PowerShell as Administrator:
Find your main LAN interface (usually Ethernet or Wi-Fi), note the InterfaceIndex.
Then:
Now enable the routing service:
This is important. Without this, Windows often won’t forward packets reliably.
Step 2 – Allow Forwarding Through Windows Firewall
Still in admin PowerShell:
Or, more controlled:
(You can tighten later.)
Step 3 – Run NordVPN in Docker
Example:
Then:
Verify tunnel:
You must see tun0. If not, stop.
Step 4 – Enter the Docker VM (WSL2)
In PowerShell:
Now you are inside the Linux VM that actually hosts the container network.
Step 5 – Enable Forwarding in WSL2
Step 6 – NAT WSL2 Traffic Into the VPN Tunnel
Still inside WSL2:
Allow forwarding:
At this point:
Windows can forward → WSL2 can forward → VPN tunnel exists
The pipeline is now technically functional.
Step 7 – Make Windows the Gateway for Other Devices
This is where router reality kicks in.
Case A – Router Allows DHCP Gateway Override (Rare)
Router LAN settings:
Done.
Case B – Router Does NOT Allow (Most Common)
You must set per device:
Example on a device:
Now that device routes:
Step 8 – Test
On the device:
-
Go to: https://whatismyip.com
-
It should show NordVPN location.
If not:
-
Check Windows firewall
-
Check
ip routein WSL2 -
Check
iptables -t nat -L

