Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port Conflict Between Multiple WSL2 Systems in Bridged Networking Mode #12331

Open
try-agaaain opened this issue Dec 2, 2024 · 4 comments
Open
Labels

Comments

@try-agaaain
Copy link

Is your feature request related to a problem? Please describe.
I have installed two WSL2 systems: Ubuntu-22.04 and Ubuntu-24.04. I want to configure independent networking for both systems, so I switched to a bridged networking mode with the .wslconfig file:

[wsl2]
networkingMode=bridged # Bridged mode
vmSwitch=my-wsl-switch # Name of the virtual switch created in Hyper-V
ipv6=true # Enable IPv6

The my-wsl-switch is a virtual switch I created in Hyper-V, and it works correctly.

I assigned static IP addresses to the two WSL2 systems using netplan (e.g., 192.168.123.100 and 192.168.123.101).

However, when I start the SSH service on both systems, only one system's SSH service can run successfully. If I try to start the SSH service on the other system, it fails with the following error:

$ sudo systemctl start ssh
Job for ssh.service failed because the control process exited with error code.
See "systemctl status ssh.service" and "journalctl -xeu ssh.service" for details.

I suspect that even in bridged mode, the two WSL2 systems might be sharing the same IP stack or network resources, causing a conflict where only one system can use port 22 at a time.

Describe the solution you'd like
I would like each WSL2 system to have truly independent IP addresses and networking, such that services like SSH running on standard port 22 can coexist without conflicts.

Describe alternatives you've considered
I considered using Docker to create separate containers for each environment, but Docker is too cumbersome for me. I prefer working with WSL due to the simplicity of the file system and ease of access compared to Docker. Therefore, I am looking for a way to achieve network isolation for each WSL2 system without switching to Docker.

Additional context
The Windows version I use is Windows 11 23H2.

Copy link

github-actions bot commented Dec 2, 2024

Logs are required for review from WSL team

If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'.
Otherwise please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.

How to collect WSL logs

Download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:

Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
Set-ExecutionPolicy Bypass -Scope Process -Force
.\collect-wsl-logs.ps1

The script will output the path of the log file once done.

If this is a networking issue, please use collect-networking-logs.ps1, following the instructions here

Once completed please upload the output files to this Github issue.

Click here for more info on logging
If you choose to email these logs instead of attaching to the bug, please send them to [email protected] with the number of the github issue in the subject, and in the message a link to your comment in the github issue and reply with '/emailed-logs'.

View similar issues

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@zcobol
Copy link

zcobol commented Dec 2, 2024

@try-agaaain you just hit one of the WSL2 limits! All WSL instances are sharing the same network namespace. It's by design.

@try-agaaain
Copy link
Author

@try-agaaain you just hit one of the WSL2 limits! All WSL instances are sharing the same network namespace. It's by design.您刚刚达到了 WSL2 限制之一!所有 WSL 实例共享相同的网络命名空间。这是设计使然。

Are there any related posts that explain why this design was chosen? Is there a possibility of adding a feature in the future where different WSL instances have independent networks?

@4-FLOSS-Free-Libre-Open-Source-Software

Sad news:

From just released v2.4.5 changelog
Add user warning letting users know bridged networking will be deprecated

Bridged mode works very well as it is now in WSL-Version: 2.4.5.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants