WSLAttachSwitch icon indicating copy to clipboard operation
WSLAttachSwitch copied to clipboard

WSL VMs talking to each other with their own attached interface

Open BuhtigithuB opened this issue 3 weeks ago • 1 comments

Hi,

More of a question of faisability here

This is the network topology that I try to achieve

[Internet] ↓ (NAT) [Windows Host] ├─ vSwitch: WSL_Private_Bridge (Internal) → 172.200.x.1 ├─ vSwitch: WSL_VM1_Private (Internal) → 10.10.x.1 └─ vSwitch: WSL_VM2_Private (Internal) → 10.10.x.1

├─ WSL VM1 │ ├─ eth0 → 172.200.x.100 (MGMT + Internet via NAT) │ └─ eth1 → 10.10.x.10 (Private) │ └─ WSL VM2 ├─ eth0 → 172.200.x.101 (MGMT + Internet via NAT) └─ eth1 → 10.10.x.15 (Private)

I been able to configure interfaces in Hyper-V / Windows so I have Windows Host interfaces created with the routing working in windows...

Been able to attach eth1 with WSLAttachSwitch.exe, but if I try to configure eth1 "per" vm it is never work, if I run the attaching script in each vm, I ends out with eth1 and eth2 in both WSL VMs... If I try to configure eth1 for vm1 and eth2 for vm2 communication won't really passing by the gateway (WSL_Private_Bridge) since each VM has eth1 and eth2 configured they just talk to each other...

So my question is WSLAttachSwitch.exe can be used to achieve such topology where we could make multipleS WSL VMs talk to each other going through an internal windows brigde interface...

Since I can't configure individual ip address for each vm with eth0 I come to the conclusion that what I try to achieve is not possible with WSL...

Side note to other as I saw many person struggling with possibly that gotcha :

That command runing /mnt/c/Windows/System32/cmd.exe -c WSLAttachSwitch.exe <SWITCHNAME>

Note the -c as in Linux /c can't be use as it is recognize as if you trying to pass a path...

Thanks

BuhtigithuB avatar Nov 05 '25 16:11 BuhtigithuB

There are no multiple WSL VMs. They are just multiple Linux containers sharing the same network namespace.

I would recommend using real Hyper-V VMs instead if you want such network topology.

dantmnf avatar Nov 05 '25 16:11 dantmnf