Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to access WSL2 Ubuntu ports from other LAN connected PCs #5798

Closed
dsjm1 opened this issue Aug 24, 2020 · 4 comments
Closed

Unable to access WSL2 Ubuntu ports from other LAN connected PCs #5798

dsjm1 opened this issue Aug 24, 2020 · 4 comments

Comments

@dsjm1
Copy link

dsjm1 commented Aug 24, 2020

Environment

Windows [Version 10.0.19042.450]
Ubuntu 20.04 LTS
The issue is on WSL 2


# Steps to reproduce
1) Set up ssh on WSL2-Ubuntu-20.04 (I use port 9561)
2) From Win10, use ssh to access the ssh port 9561 using localhost (this works - see grab)
3) Then try ssh to access using the Win10 PC ip addr (10.0.0.19). This fails - see grab).
4) Same problem when trying to access 10.0.0.19:9561 from remote PCs.  A screen grab
   shows attempt to access 10.0.0.19 from 10.0.0.17 (fails) but ssh to 10.0.0.1 (a Ubuntu
   server 18.04 running on an Odroid micro PC works fine.

![in-bound-rules-1](https://user-images.githubusercontent.com/399801/91004103-9a436b00-e616-11ea-86bf-1315607de61d.jpg)
![ipconfig-on10 0 0 19-1](https://user-images.githubusercontent.com/399801/91004104-9b749800-e616-11ea-8805-4e290a8c60df.jpg)
![ssh-from-10 0 0 17-to-10 0 0 19-a](https://user-images.githubusercontent.com/399801/91004105-9c0d2e80-e616-11ea-8269-31551aa8042a.jpg)
![ssh-from-win10-to-wsl2-a](https://user-images.githubusercontent.com/399801/91004106-9ca5c500-e616-11ea-8e70-02b07ee3d5e8.jpg)
![Win10-netstat-1](https://user-images.githubusercontent.com/399801/91004108-9d3e5b80-e616-11ea-8067-a27fcfd9a16a.jpg)

#  Expected behavior
On my Win 10 PC 10.0.0.19, I expected ssh [email protected] -p 9561 to work the same as ssh doug@localhost -p 9561.

<!-- A description of what you're expecting, possibly containing screenshots or reference material. -->

# Actual behavior
See grabs

In essence I am expecting the WSL2 Ubuntu Server to act just like a Virtual Host under Hyper V.
I have other PCs that run Hyper V and I can access them and their ports ok.



@dsjm1
Copy link
Author

dsjm1 commented Aug 24, 2020

On thinking further about this problem. As mentioned I can access other Hyper-V virtual computers on my LAN.

What it seems is that the WSL2-Ubuntu-20.04 is a virtual machine but while I can access that virtual machine from its host
WSL2 PC running Win 10, I can only do so using 'localhost' as the ip-address. i.e. ssh doug@localhost -p9561 works from Win10 host PC.

In effect, I don't know what hostname or ip address (apart from 'localhost' will allow me access to the Ubuntu-20.04 running under WSL2. Especially from other PCs on the LAN. Clearly the virtual machine that is WSL2 Ubuntu-20,04 needs some gateway / routing to access it from my LAN.

The WSL2 Ubuntu-20.04 system can see all my other LAN attached PCs and I can SSH to any of them from WSL2 Ubuntu-20.04.

The answer to this problem seems to be just knowing what hostname / ip address the WSL2 server makes available for each server it hosts, on the LAN.

NOTE: If I start WSL2 Ubuntu-20.04 and run cmd 'sudo hostname' I get the same name as my Win 10 hosting PC (i.e. IAWSX-1)
If I run 'netstat -a' on Win10, none of the Ubuntu-20.04 ports show.
If I run ''sudo netstat -a' on Ubuntu-20.04, as expected it only shows port 9561 and 3308 (that I use for MySql).
If I go to another LAN PC (win10) and run cmd 'ping IAWSX-1' I get the normal response.

So how do I ping the my WSL2 Ubuntu-20.04 Server if it shares the same name as its Win10 host but hides its ports from Win 10 ?

JUST DID another test where I installed a clean WSL2 + only One WSL2 Linux (Ubuntu-20.04) - when I only have one WSL2 Linux installed, I can access to ports ok and this WSL2-Ubuntu-20.04 reports the same dotted ip address as the Win10 host PC.
On my other PCs I had 2 WSL2 Linux distros, 18.04 and 20.04 (I was upgrading). When I have 2 distros the Linux server fails to identify the Win10 host dotted ip addr. With this new test where I have only installed 1 Linux distro (Ubuntu-20.04) I can both see the dotted ip addr (same as the Win10 host) and can access the Ubuntu-20.04 ssh from other PPCs on the LAN.

So the problem appears to be that when more than one Linux distro is installed, the distros no longer share the Win10 hosts dotted ip address but allocate an internal one that is not visible to other PCs.

@therealkenc
Copy link
Collaborator

/dupe #4150

@ghost
Copy link

ghost commented Aug 24, 2020

Hi! We've identified this issue as a duplicate of another one that already exists in this repository. This specific instance is being closed in favor of tracking the concern over on the referenced thread.

Thanks for your report!

@ghost ghost closed this as completed Aug 24, 2020
@ghost ghost added the duplicate label Aug 24, 2020
@dsjm1
Copy link
Author

dsjm1 commented Aug 25, 2020

Hi! We've identified this issue as a duplicate of another one that already exists in this repository. This specific instance is being closed in favor of tracking the concern over on the referenced thread.

Thanks for your report!

I just did a further test that showed my problem is due to having more than one Linux distro installed (I had previously had Ubuntu 18.04 & added Ubuntu 20.04 whil upgrading). The moment I added the 20.04 distro, I was no longer able to access either 18.04 or 20.04 remotely other than via 'localhost' on the hosting Win10 PC.

My short term fix is to remove the 18.04 distro.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants