Port Conflict Between Multiple WSL2 Systems in Bridged Networking Mode
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 33.7k
- Forks
- 1.8k
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 116
Description
**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:
```yaml
[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:
```bash
$ 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the shared .wslconfig networkingMode and vmSwitch settings, then compare the netplan configuration for Ubuntu-22.04 and Ubuntu-24.04. Reproduce the conflict by starting ssh on both systems and inspect systemctl status ssh and journalctl -xeu ssh for each. Done means both systems retain independent addresses and can run SSH on port 22 simultaneously.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- linux, ubuntu
- Domain
- networking, operating-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100