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

Port forwarding listens only on IPv6 when client connects #258

Open
kernelPanic0x opened this issue Aug 26, 2024 · 2 comments
Open

Port forwarding listens only on IPv6 when client connects #258

kernelPanic0x opened this issue Aug 26, 2024 · 2 comments

Comments

@kernelPanic0x
Copy link
Contributor

I have tested the port forwarding feature and it works as it should on Windows and Linux and in between, but I was confused at first because when I connected to a forward session, it told me to use the local port, but I could not connect to the destination through that port. Turns out it listens only on IPv6 ::1 or localhost on Windows. Only then it works. Because I am used to typing 127.0.0.1 for local loopback and not localhost, even though that is apparently the better option, I guess. The only clue is that it uses IPv6 ::ffff:0.0.0.0 style IPv6-IPv4 mixing, and that's what led me to the conclusion. I thought maybe it would be helpful for people to also see the local address that is being listened on?

So this does not appear to be a bug report as I first thought, but rather a feature request maybe? 😄

@himikof
Copy link
Contributor

himikof commented Oct 9, 2024

The fundamental reason would be rust-lang/rust#130668: the TcpListener::bind API has no way of setting IPV6_V6ONLY socket option, so a platform-specific default is used. So the behavior is unfortunately inconsistent: on Windows (and on Linux with net.ipv6.bindv6only sysctl set to 1) the socket will not listen for IPv4 connections. Otherwise it will listen to both IPv6 and IPv4 as intended.

All relevant calls to TcpListener::bind need to be replaced by manual socket2::Socket binding after calling socket.set_only_v6(false).

@felinira
Copy link
Collaborator

All relevant calls to TcpListener::bind need to be replaced by manual socket2::Socket binding after calling socket.set_only_v6(false).

👍 Contributions welcome

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

4 participants
@himikof @felinira @kernelPanic0x and others