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

Error binding local socket for ssh port forward; seems IPv6 related #674

Closed
kuza55 opened this issue Jul 20, 2016 · 8 comments
Closed

Error binding local socket for ssh port forward; seems IPv6 related #674

kuza55 opened this issue Jul 20, 2016 · 8 comments
Labels

Comments

@kuza55
Copy link

kuza55 commented Jul 20, 2016

  • A brief description
    I get some really weird results when trying to forward ports with ssh.

When I try to run:
ssh -L 3390:localhost:3389 user@host

I get an error saying:
bind: Address already in use

However, if I do
ssh -L 127.0.0.1:3390:localhost:3389 user@host

Everything works fine, it binds the port correctly and I can forward a port.

  • Your Windows build number

Version 10.0.14390 Build 14390

  • Strace of the failing command

This is the strace of the failing command:

socket(PF_INET6, SOCK_STREAM, IPPROTO_TCP) = 4
setsockopt(4, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
setsockopt(4, SOL_IPV6, IPV6_V6ONLY, [1], 4) = 0
bind(4, {sa_family=AF_INET6, sin6_port=htons(3390), inet_pton(AF_INET6, "::1", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, 28) = 0
listen(4, 128) = 0
fcntl(4, F_SETFD, FD_CLOEXEC) = 0
fcntl(4, F_GETFL) = 0x2 (flags O_RDWR)
fcntl(4, F_SETFL, O_RDWR|O_NONBLOCK) = 0
fcntl(4, F_GETFL) = 0x802 (flags O_RDWR|O_NONBLOCK)
socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 5
setsockopt(5, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
bind(5, {sa_family=AF_INET, sin_port=htons(3390), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EADDRINUSE (Address already in use)

This is an strace of the successful command:

socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 4
setsockopt(4, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
bind(4, {sa_family=AF_INET, sin_port=htons(3390), sin_addr=inet_addr("127.0.0.1")}, 16) = 0

Notably there is no attempt to bind on ipv6

@sunilmut
Copy link
Member

@kuza55 - Thanks for reporting this and trying out WSL! Unfortunately, IPV6_V6ONLY is currently not fully supported in WSL (even though the setsockopt passes). Also see #157. We are very well aware of this limitation and are looking into supporting the IPV6_V6ONLY option fully. Meanwhile, you may be able to workaround the issue by using the IPv4 address only.

@sunilmut sunilmut added the bug label Jul 28, 2016
@kuza55
Copy link
Author

kuza55 commented Jul 28, 2016

I have no real desire to use IPv6 here, the real problem is that due to the previous IPv6 calls, the IPv4 bind fails.

@sunilmut
Copy link
Member

Correct, and understood. As indicated earlier, we are looking into resolving the IPV6_V6ONLY problem. Please keep the feedback coming.

@sunilmut
Copy link
Member

With the help of the Windows networking team, we were able to fully implement the IPV6_V6ONLY flag. That should resolve the issue here. The fix is still in our dev branch, but should soon hit the release branch.

@kuza55
Copy link
Author

kuza55 commented Sep 17, 2016

You guys are killing it, keep up the good work! :D

@PetaPetaPeta
Copy link

Another thing that can solve this is using the '-4' flag to enforce the use of IPv4.

@sunilmut
Copy link
Member

Just FYI that the IPV6_V6ONLY issue is fixed in 14936 (see release notes)

@sunilmut sunilmut added fixed and removed fixinbound labels Sep 29, 2016
@sunilmut
Copy link
Member

Closing this out since this should be now resolved in builds 14942+. If it is still broke, please let us know.

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

3 participants