WSLAttachSwitch
WSLAttachSwitch copied to clipboard
Doesn't Work on Win11?
Hi - I have 2 vSwitches and have used .wslconfig to change eth0 to one of them. When I try to run your tool to create/connect eth1 to the 2nd, nothing happens. I've tried running it from within cmd, within Debian WSL2, with WSL2 shutdown, with it running ... nothing happens and no eth1 is created?
@x86txt Can u run ip link
command after u ran attached all the switch u wanted ?
I think I can see the issue. On running the command it silently 'succeeds' but WSL does not see any changes.
Looking at the system event log I see
NIC 8E0C717D-B40B-44FE-8F81-AB8577BA3E7A--DB445E4D-5025-4162-9E85-9C1C333CC3CB (Friendly Name: )
successfully connected to port DB445E4D-5025-4162-9E85-9C1C333CC3CB (Friendly Name: DB445E4D-5025-4162-9E85-9C1C333CC3CB)
on switch B95D0C5E-57D4-412B-B571-18A81A16E005(Friendly Name: WSL).
I ran the following...
./wslAttachSwitch.exe "vEthernet (VS-I-WSL-BR)"
then:
List of VM switches
PS C:\Windows\System32> Get-VMSwitch | select-object -property Name, Id
VS-I-WSL-NAT 1e8885a0-2e81-4dae-abc8-5e45e2b3f916
Default Switch c08cb7b8-9b3c-408e-8e30-5e16a3aeb444
VS-I-WSL-BR a64cf8e4-4d35-43af-aee3-1d3612bf97ef
WSL b95d0c5e-57d4-412b-b571-18a81a16e005
However, for me the initial adapter setting in .wslconfig is VS-I-WSL-NAT, and the one I am trying to add is VS-I-WSL-BR. From the numbers above it seemss it is manipulating the last one (the default/hidden one) called 'WSL'.
I'm not a Windows programmer so I don't know how to compile your code, otherwise I'd try to add more diagnostics.
I tried powershell get-networkswitchnetworkport
but could not work out how to use it. However if I could I expect that would yield the rest of the numbers in the event log. For completeness here is the (failing) command.
$Session = New-CimSession -ComputerName "corp_pc4634"
Get-NetworkSwitchEthernetPort -CimSession $Session [-deviceid b95d0c5e-57d4-412b-b571-18a81a16e005]
# above tried with and without the `-deviceid` qualifier.
I will play a bit more tomorrow, e.g. the other way round (adding the NAT to the BR, BR to WSL, etc.)