-
Notifications
You must be signed in to change notification settings - Fork 174
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
Fix connection failure on iOS when connecting to a Tailscale IPv4 address from an IPv6-only mobile network such as T-Mobile #98
base: master
Are you sure you want to change the base?
Conversation
464XLAT works fine on T-Mobile with the current code. For IPv4-only hosts, it will either synthesize an IPv6 address and communicate via NAT64 or use 464XLAT to appear as an end-to-end IPv4 connection over IPv6. I've used a number of T-Mobile devices over the years to connect to IPv4-only and dual-stack hosts through their network without issue, both using hostnames and IPv4 literals. This sounds more like a routing or address translation compatibility issue with 464XLAT and Tailscale than an application bug. Are you getting a synthesized NAT64 IPv6 address rather than a 100.x.x.x Tailscale address and that's being routed onto T-Mobile's network instead of through Tailscale? That seems like an obvious device bug, since the OS should not synthesize IPv6 addresses for on-link IPv4 prefixes.
IPv6 does work for both dual-stack and IPv6-only/NAT64 networks, and this will break it. Even if we just preferred IPv4 over IPv6 if both are available, that's degrading our performance on devices/networks with correctly working NAT64+464XLAT configurations (by requiring a trip through 464XLAT for an otherwise totally IPv6-capable application) to fix a niche scenario with a buggy one. We could explicitly prioritize IPv4 addresses when provided with an 100.64.0.0/10 subnet, but I'd need to think about that more to determine if that's actually the correct thing to do for conventional Carrier-Grade NATs. I suspect it may not be. |
I neglected to save all my logs from debugging this, I will obtain some more data and we can come up with a better fix. |
Here's what happens, when the system only has IPv6 interfaces. RemoteAddr will resolve to this:
This is the 464XLAT address for the Tailscale CGNAT IPv4 address (6457:ce50 in hex). It is able to make some v4 HTTP requests to do pairing and to display the host's list of apps. But It dies during RTSP even though it wants to use I'm thinking that a better fix is to write a |
Aha yep, My guess is that the only reason web requests work is that the HTTP client is using Happy Eyeballs and establishing both IPv4 and IPv6 connections. Without that, it would be very obvious to the device vendor that this scenario was badly broken. What's so confusing to me is that we explicitly use I'd be curious to see if you remove
In a 464XLAT environment, you'd rather not go through 464XLAT. Well-behaved IPv6-supporting applications should never need to interact with 464XLAT since they will use |
…cale IPv4 address from an IPv6-only mobile network such as T-Mobile. T-Mobile handles IPv4 addresses, including the special 100.x.x.x Tailscale addresses, using 464xlat and NAT64. This patch detects the 464XLAT situation and forces the address into AF_INET IPv4 mode, allowing the connection to reach Tailscale.
bc67221
to
cd0e47e
Compare
That was a good idea but it doesn't work, probably because AF_UNSPEC is just AF_INET6 when there is no v4 interface. I did manage to hack together a working patch that should only run in this very specific case. I feel like there's gotta be a way to do this with less code, but that's BSD sockets for you... The output from the patch looks like this now, err, well it did before I removed some extra debug. This would be a perfect thing to write a unit test for, I will look into that later.
|
T-Mobile handles IPv4 addresses, including the special 100.x.x.x Tailscale addresses, using 464xlat and NAT64. We need to force resolve the address using AF_INET instead of AF_UNSPEC in order to get a usable address to connect to. More info: https://en.wikipedia.org/wiki/IPv6_transition_mechanism#464XLAT
I am unsure if true native IPv6 currently works properly and I'm also not sure if this patch would break it if so.