Using the Same Network in WSL and Windows
I recently ran into the problem that WSL (Windows Subsystem for Linux) uses a different network than Windows. This problem can be easily fixed by following these steps, so we ignore WSL's own network and make WSL use the Windows network. For example, the rules used in the Windows hosts file will apply to Linux running in WSL.
If you have not yet installed WSL, you can do so:
The Easiest Guide to Running Linux Scripts on Windows 10
Let's get started!
- Create a .wslconfig file in C:\Users\<UserName> with the following content:
[wsl2]
localhostforwarding=true
- Turn off the WSL in Powershell (run as admin):
wsl --shutdown
- Wait 10 seconds before starting WSL
Tested, it works. No more steps! :)
Comments