microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
17.4k stars 819 forks source link

WSL2 share IP address with host #6114

Open mdzhigarov opened 4 years ago

mdzhigarov commented 4 years ago

Is your feature request related to a problem? Please describe.

In WSL 1 the IP addresses of the host and the distro were shared, meaning that both the Windows host and the Ubuntu could bind TCP sockets on the same IP using different ports.

This allowed us developers to start some http servers on the WSL distro but others on the Windows host and they'd share they'd be bound to the same IP.

This is not possible in WSL 2 today. Instead, what we end up is WSL distro with its own IP. The Windows host cannot bind sockets to it. And vice-versa - the Ubuntu cannot bind sockets on the Windows host IP.

sepbot commented 4 years ago

When I bind things to 0.0.0.0 in wsl2, they become available on the host from 127.0.0.1.

For the other direction, I have the following export, but I have not had to use it besides for X and pulse: export HOST_MACHINE="$(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}')"

OS Version: 10.0.19041 N/A Build 19041