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

Can't access Windows socks5 tunnel from WSL2 #4507

Closed
oliviercwa opened this issue Sep 15, 2019 · 11 comments
Closed

Can't access Windows socks5 tunnel from WSL2 #4507

oliviercwa opened this issue Sep 15, 2019 · 11 comments
Labels

Comments

@oliviercwa
Copy link

Environment

  • Windows build number: 1903 (OS Build 18980.1)
  • Distro: Ubuntu-18.04

Repro steps:
From Windows Powershell: Create a SOCKS 5 tunnel to an SSH Server:

ssh -D 0.0.0.0:20000 USER@IP_ADDRESS

Validate that the proxy is working. For my specific environment, I have a web server that i can query using:

curl --socks5 127.0.0.1:20000 http://10.0.2.5:8081

This returns a response (a Spring Boot configuration JSON payload)

Next go to WSL2 mode

wsl

curl --socks5 127.0.0.1:20000 http://10.0.2.5:8081

Result:
"curl: (7) Failed to connect to 127.0.0.1 port 20000: Connection refused"

curl --socks5 localhost:20000 http://10.0.2.5:8081

Result:
"curl: (7) Failed to connect to localhost port 20000: Connection refused"

Expected:

  • Curl request from WSL to work as well.
@therealkenc
Copy link
Collaborator

ref #4402

@oliviercwa
Copy link
Author

Thank you very much for the quick answer. I have tried the first method from here :

cat /etc/resolv.conf

and copying the IP address following the term nameserver but it did not work.

However the second method did work: Establish the tunnel from WSL

Thanks again

@lackovic
Copy link

lackovic commented Dec 5, 2019

I am running into the same issue, can't establish a connection in the WSL->Windows direction.

@oliviercwa can you elaborate more on how you managed to fix this problem?

@oliviercwa
Copy link
Author

oliviercwa commented Dec 5, 2019

You need to create the tunnel not from a windows command prompt, but from a WSL command prompt. In windows, launch powershell, then type:

wsl

This will enter the wsl mode

Then create your tunnel, for example:

ssh -D 0.0.0.0:20000 USER@IP_ADDRESS

Then curl will work properly

Note that I am running WSL2 from Windows 10 version 19035.1

@lackovic
Copy link

lackovic commented Dec 5, 2019

I have a service running in WSL (listening on 127.0.0.1:3000) which needs to access a service running in Windows on 127.0.0.1:5432.

My WSL resolv.conf file:

# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateResolvConf = false
nameserver 192.168.224.1

When I run ssh -D 127.0.0.1:5432 [email protected] I get the following error:

ssh: connect to host 192.168.224.1 port 22: Connection timed out

Also using WSL2 from Windows 10 version 19035.1

@oliviercwa
Copy link
Author

Are both these services running on the same machine? If so, you don't need a tunnel for this. You should be able to call the Windows service directly.

@lackovic
Copy link

lackovic commented Dec 5, 2019

Yes, they are both running on the same machine.

I am not able to access the service directly, the service in WSL returns the error:

PG::ConnectionBad - could not connect to server: Connection refused
        Is the server running on host "localhost" (127.0.0.1) and accepting
        TCP/IP connections on port 5432?

Also, in WSL:

curl 127.0.0.1:5432
curl: (7) Failed to connect to 127.0.0.1 port 5432: Connection refused

while on Windows it works fine:

curl 127.0.0.1:5432
curl: (52) Empty reply from server

According to ref #4402, this is expected because tunneling 127.0.0.1 does not currently work in the WSL->Windows direction.

@lackovic
Copy link

lackovic commented Dec 5, 2019

I must point out also that everything works perfectly fine in WSL 1.
The issue occurs only with WSL 2.

@therealkenc
Copy link
Collaborator

I must point out also that everything works perfectly fine in WSL 1.

Right #4402, aka #4619 (with a side of #4199, #4210, #4711)

@danksuperuser
Copy link

I have a proxy client running on windows which provides a socks5 proxy. This client has been set to listening 127.0.0.1:9050 .I want to use it in WSL2 Kali Linux terminal.How can I ??

Exactly what I am trying to do is ,to rotate IP's in kali Linux terminal WSL2 via windows client proxy application. The proxy application itself changes/rotate proxy
frequently no need of other application in the WSL2.

So the only need is How can I connect it in WSL.

The proxy client supports socksv5 so I have to set the WSL to socksv5 proxy.

TIA!

@therealkenc

@sanjaychauhan7321
Copy link

@danksuperuser did you get your query answered???

I am facing the same problem, want to access this socks5 client running on windows on my vs-code running on wsl

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

No branches or pull requests

5 participants