June 8, 2026
How I Fixed WSL 2 Network Timeouts on a Strict Corporate Network
If you use WSL 2 on a corporate laptop, you have likely run into this frustrating issue:
Souvede Inshuti
1 min read
git cloneor other commands that need network to run timeout.- Your regular Windows terminal (
cmd) works perfectly fine. - WSL works flawlessly at home or on a phone hotspot.
Here is the quick explanation of why this happens and how to fix it permanently using a single configuration file. (This is what worked for me)
The Problem
By default, WSL 2 uses NAT (Network Address Translation) mode [wsl]. It creates a hidden, isolated virtual network inside your machine.
Why Home Networks Work
- Consumer routers are permissive.
- They accept nested traffic coming from WSL's virtual IP addresses.
Why Corporate Networks Block It
- Strict Firewalls: Enterprise firewalls drop unrecognized virtual IP packets to prevent security spoofing.
- DNS Isolation: Offices block public DNS servers like
8.8.8.8. WSL's isolated sandbox cannot see your company's private internal DNS servers.
The Solution
We will use Mirrored Networking Mode (exclusive to Windows 11) [wsl]. This forces WSL to mirror your Windows internet connection exactly [wsl]. To your corporate firewall, WSL traffic looks completely identical to your authorized Windows traffic.
Step 1: Update the Windows WSL Config
- Press
Win + R, type%USERPROFILE%, and hit Enter. - Create or edit a file named exactly
.wslconfig. - Paste this configuration block and save:
[wsl2]
networkingMode=mirrored
dnsTunneling=true[wsl2]
networkingMode=mirrored
dnsTunneling=truenetworkingMode=mirroredclones your Windows connection into Linux [wsl].dnsTunneling=truesecurely routes Linux DNS lookups through Windows corporate DNS servers [wsl].
Step 2: Clear Out Legacy Linux DNS Conflicts
Switching network modes can sometimes leave old, cached networking files stuck inside your Linux environment. We need to tell Linux to let Windows manage the DNS address resolution cleanly.
- Open your WSL Linux terminal.
- Run this command to delete any broken or hardcoded DNS files:
sudo rm -f /etc/resolv.confsudo rm -f /etc/resolv.conf- Open (or create) the core WSL configuration file:
sudo nano /etc/wsl.confsudo nano /etc/wsl.conf- Paste the following lines to ensure WSL automatically regenerates a clean network profile on launch:
[network]
generateResolvConf = true[network]
generateResolvConf = true- Save and exit the file (
Ctrl + O,Enter,Ctrl + X).
Step 3: Flush Network Caches and Restart
Finally, completely reset the environment from your Windows host so the new settings take effect.
- Close your WSL window.
- Open a standard Windows PowerShell or Command Prompt (CMD) window.
- Run the following commands to forcefully shut down the active Linux subsystem and wipe the local network cache:
- wsl — shutdown
- ipconfig /flushdns
The Result
Reopen WSL and test your connection:
curl -Iv https://github.comcurl -Iv https://github.comLinux environment will instantly pull down the data payload. Because your network identity is now perfectly mirrored from Windows [wsl], all your existing Git configurations, and local development scripts will work seamlessly without any manual terminal switching or duplicate setup.
Best of all, this configuration is completely set-and-forget — when you head home or jump on a hotspot, Windows will automatically mirror your new connection profiles straight down to WSL without you ever needing to toggle a setting again.