Sunday, February 25, 2024

WSL - Windows Subsystem for Linux networking issue - cannot connect to network when windows is connected to VPN

 I have this issue on WSL on windows 11, when enabling this feature, by default the NetworkingMode is equal to NAT. No issue when connecting to internet from the bash CLI, but when you are connected to a VPN, like on a corporate VPN, the net setup will not allow you to connect to the internal resources. This is not a problem with WSL on Windows 10 though.

So to fix this, I need to set the NetworkingMode to mirrored. This way, what ever the IP you windows get, will have the same IP on your WSL or Linux Terminal.


To make your WSL networkingmode to mirrored, create a config file under your windows user profile.


If my username is windows.user01, then put the config under C:\Users\windows.user01\

File: .wslconfig

Content of file below:


[wsl2]

networkingMode=mirrored


Or if you are on your bash command line, you can just do


vim /mnt/c/Users/oliver.jagape/.wslconfig

and enter below: then save.

[wsl2]

networkingMode=mirrored


Shutdown WSL

--shutdown


Then open back bash, or if you have windows terminal installed, just type bash, and it will open to Linux bash terminal.