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

WSL 2 does not recognize machine names on my network #6198

Closed
p-maybank opened this issue Nov 5, 2020 · 3 comments
Closed

WSL 2 does not recognize machine names on my network #6198

p-maybank opened this issue Nov 5, 2020 · 3 comments

Comments

@p-maybank
Copy link

p-maybank commented Nov 5, 2020

The basic problem I am trying to solve is that I would like to use git within my WSL 2 environment. When I try pushing to my remote repository I get the following message,

$ git push
ssh: connect to host [...] port 22: Connection timed out

After a bit of searching I now understand that the issue is with my ssh cconection. In Issue 5224 a list of 4 things to try is given,

  1. Check if you can ssh using IP
  2. Do a debug with ssh -vvv
  3. Check if you can resolve the DNS name with nslookup
  4. Make sure the nssswitch.conf is good.

I found that my ssh does work when I use an IP address rather than the machine name, i.e., I can ssh when I apply suggestion (1).

However I cannot see how this approach could be applied within the context of git. And in any case I would prefer to be able to use machine names rather than IP addresses when I am logging in to other machines on my network.

A couple of other remarks that may be relevant.

  1. I am connecting to machines on my network using a VPN. Not sure if this could also be part of the issue.
  2. I do not have this issue at all when I am in my WSL 1 environment. I.e. in WSL 1 I can ssh using machine names and git works as expected.
@p-maybank
Copy link
Author

p-maybank commented Nov 5, 2020

I have resolved this now. At some point I disabled automatic generation of /etc/resolv.conf. I have changed my WSL 2 environment so that /etc/resolv.conf is now automatically generated (as it should be by default). This resolved the git / ssh issue that I was having.

@JRHeaton
Copy link

JRHeaton commented Mar 3, 2022

So you're able to resolve local mDNS host names from WSL2 somehow? If so please share as the referenced issue needs a solution.

@vikaspachisia
Copy link

I see that WSL2 FQDN hostname and the windows hostname is same. This is probably causing the hostname to IP resolution to pickup the IP of the localmachine (Windows Machine) and thus not allowing to connect to a port opened in WSL2.

I am not sure if enabling mirroring instead of NAT will resolve this as it will merge the 2 (WSL and Windows) interfaces into 1 and thus make all ports available to each OS. Can somebody shed light on this?

Changing hostname can be tried out but what implications will it have (Mirrored vs NAT setup)?

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

No branches or pull requests

3 participants