[WSL 2] Multi WSL2 distributions use the same network namespace #4304
Multi WSL2 distributions use the same network namespace, no network isolation
The text was updated successfully, but these errors were encountered:
Thanks for your response. I think WSL/WSL2 is a great feature for microsoft product. I'd like to try it in our work environment.
thanks for reminding me,
ip netns exec net1 ip addr add 192.168.99.10/24 dev sit0
ip netns exec net1 exec bash
Yes that's exactly correct!
And to check my understanding, you're asking that you'd prefer each distro was in its own networking namespace rather than creating your own network namespaces, because it would be a more direct way? Or easier to setup? I'm sorry as I'm still confused on the feature request, or what you're asking.
English is not my native language, sorry for my imprecision description to make you confuse.
No problem at all! Thank you for clarifying.
All of the WSL 2 distros run on the same virtual machine, which has a singular virtualized networking interface controller. You can create different IP addresses and different networking namespaces just like you would on a Linux machine to create network isolation for multi-node development.
When using multiple WSL2 distros in parallel, it would have been useful to be able to SSH into any one of them by using different IP numbers. (Personally I use this to manage git repos from Emacs magit running on WSL1 or on Windows native, via TRAMP over ssh.)
As it stands, one either has to run the ssh daemons on different ports, or, IIUC, setup namespaces within each WSL2 distro and have the relevant daemon processes (e.g. ssh) attaching to those.
See e.g. https://blogs.igalia.com/dpino/2016/04/10/network-namespaces/ -- setup looks like it could cost some time.
Bottom-line: A more straight-forward, out-of-the-box mechanism whereby different WSL2 distros could be approached via network would be valuable.
If you want to run an SSH server on each WSL distro, could you follow the steps in the link posted by @craigloewen-msft to assign additional IP addresses to the network interface card? Then configure the SSH server to bind to only the one IP address (not sure how to do this but I'm sure this is doable). On your 2nd WSL distro you do the same, but configure the SSH server to bind to a different IP address. Then probably you want to add entries into your host file for the IP addresses and then you can SSH into these distros using the hostname you've given in your hosts file. I haven't tried this myself but if it work, it is better way to go than using CGROUPS (networking namespaces) to run an SSH server on each distro. The network namespaces approach seems a better for problems where you want the same IP address but want to isolate more than just use a new IP address or port number.
i want to scp files to one of my wsl instances but that isn't possible because they have all the same ip address and the address isn't reachable over network... if wsl cant have its own reachable ip its a bit useless sometimes :(
debian -> 172.27.246.30
and "wsl hostname -i" gives for both 127.0.1.1 ...
is it possible to have a reachable ipaddress?
I think an option for assigning a different IP address to a distro is an interesting area of discussion its a shame that it was closed though I understand why a single network for all distro's is the default it would be good to have this as a configuration option. It would be good if someone has the actual link posted by craigloewen-msft on assigning additional IP addresses to the network interface card.
by our friend way i can make new ip for my machine but this ip will work for all distro(s) :///
making new ip for eth0 interface will not isolate the network.
yes it will work but cannot fix my problem
i want to full isolate network