Is it possible to make "WSL" virtual switch external in Windows 20H2 (WSL2.0) and how to configure it?

Viewed 10239

It's not enough for me to bind WSL ports to localhost because I need to run applications in WSL which must be run in and from my local network. Attempt to switch WSL virtual switch to external in Hyper-V manager leads to Access-denied error (when wsl instance is running) with following big problems with host's and/or WSL's network as a result until I reboot the host. When WSL distro is not running WSL virtual switch is invisible in Hyper-V manager (Virtual switch manager).

I have 2 question and will be very appreciated if someone could help me with that:

  1. Is it a normal behavior - having got problem with network attempting to configure WSL virtual switch directly? As I recall there were no such problems with Hyper-V virtual machines - maybe just short losing of connectivity, not more.
  2. Is there a way to configure WSL such way so it starts with WSL external switch any time I run it? Files .wslconfig and /etc/wsl.conf look to be useless for this - I haven't managed to find the solution in google.
3 Answers

Yes you can convert it to external from Hyper-v Manager. Just start the Hyper-v Manager as Administrator

Yes you can, but it seems to work only in IPv6 in my situation:

IP Address of WSL 2

When I ran wsl --shutdown and opened Hyper-V Manager, the WSL switch appeared in Virtual Switch Manager, and can be successfully changed to external.

Hyper-V Virtual Switch Manager

However, the IPv4 address could not be changed, and it's unable to access the Internet via IPv4 either. So I have to assign a NAT IPv6 network (fd68::/64 in my case) to make it work.

Maybe you should do some repair to your system if you can't reproduce this.


Note: if switch WSL is changed to external, your main adapter will become vEthernet (WSL) or something similar.

No we cant use it. I tried the the same Its not showed on hyper-v management .. and when you re trying to do wsl -l you find a list of your distribution still there ,and if you run do wsl.exe => it will run your default distribution and wsl will show up again on hyper-v and parameter will be reset to default which NOT the external virtual switch .. I dont think we can use that now for now , many issues have been raised on github .

Related