Repository navigation
Description
Feature description
Hi,
I'd like to propose syncthing should support using a network's NAT64 (Wikipedia) service as a new connection type along relays and direct connections.
Problem or use case
Currently syncthing is not able to establish connections between devices in IPv4-only and IPv6-only networks. My research and testing suggests this is due to the project's technically correct attitude that relay servers should not operate on IPv6.
Thanks to IPv6-mostly (IETF draft) there is renewed interest in v6-only and moving away from dualstack networks in general, but synthing could be a blocker to deployment for organizations relying on it.
IPv6-only/-mostly networks generally deploy a NAT64 service which allows v6-only hosts to connect to legacy v4-only hosts by way of IP layer packet translation. Think: to reach v4 address 1.2.3.4 connect to the v6 address 64:ff9b::[1.2.3.4] instead.
Today, we get devices to use a network's NAT64 in one of two ways:
-
DNS64 (RFC 6147) is a universally supported hack but only works for DNS names. Works great for the web, but since syncthing makes extensive use of address literals in its operation this doesn't help.
-
OS provided on-device translation "CLAT (Wikipedia)". Some devices (Android and Apple) support bringing up a virtual network device with a fake IPv4 address that bends traffic towards the network's NAT64 to allow legacy applications to keep using IPv4 address literals. Linux and Windows do not support this as of yet.
Do you see any blockers or challenges for adding NAT64 support to syncthing?
Alternatives or workarounds
-
Rely on device's system CLAT. Problematic:
- Not available on all platforms. (May improve in the future)
- CLATs have inconsistent performance across platforms since they're only a last resort fallback. All important high bandwidth services support native IPv6 now, right? ;-) Or so the implementer's thinking seems to go anyway.
-
Operate relays on IPv6 too. Has problems:
- NAT64 performs better since it's closer to users
- project pays for bandwidth network operators could be covering
- disincentives IPv6 deployment due to inconsistent performance until all devices are on v6
-
Use v6 VPN on devices that may be in v4-only environments.
Works but is extra effort for users and sync performance suffers due to VPN backhaul over WAN instead of using fast LAN connection. The latter could be mitigated by syncthing actively switching away from WAN connections when LAN is available, however we seem to stick to active connections in my testing.
Thanks,
--Daniel
Activity
calmh commentedon Jan 12, 2025
What does "support NAT64" mean, practically speaking? Is it just to try and dial resolved v4 addresses as v6 in 64:ff9b::/96?
DanielG commentedon Jan 12, 2025
We'd have to first discover the NAT64 prefix used by the network by resolving
ipv4only.arpa(RFC8880) (64:ff9b::/96was just an example) and keep that up-to-date as the device moves around. Should be easy to piggyback on the existing discovery process.Then I'd imagine using the NAT64 would be as easy as synthesising a v6 addresses whenever a v4 endpoint is discovered and adding it to the candidate list. To prevent blowup of the list we may only do this when the device has no v4 addrs.
I haven't looked at the impl. details yet but am happy to work on a finer grained design if there's consensus that this would be a welcome feature.
bt90 commentedon Jan 12, 2025
Apart from a few enthusiasts turning off IPv4 themselves, IPv6-only isn't really a thing. It's either IPv4-only or dual stack with a public IPv4 or a CGNATed one.
But relays being IPv6-enabled may still have some merit. While it's true that we don't have to deal with NAT in the IPv6 world, firewalls are still a thing that block direct connections. If we're able to dial the relay over IPv6, the connection might be a bit faster over native IPv6 than over CGNAT IPv4.
DanielG commentedon Jan 12, 2025
Hi bitpirate,
Have you seen this be a problem in the wild or are you speculating?
During real-world testing I was very surprised to find that syncthing can connect directly over IPv6 even through a restrictive stateful firewall (with relays turned off). This appeared to be the case because ports are not remapped by IPv6 conntrack (Linux's stateful firewall impl.) and so "holepunching" just works.
I belive this is because the default sysctl
net.netfilter.nf_conntrack_tcp_loose=1allows connections to pass even if the SYN flag isn't expected in the REPLY direction. However I bet some vendor is sellingnf_conntrack_tcp_loose=0as a "security" feature so ymmv ;-)Every technology transition starts with a few enthusiastic first movers who tends to reap the benefits if the bet pays off. Considering that CGNAT costs money — money penny pinchers will want to save a couple of network product cycles from now —turning off IPv4 is simply the inevitable next step in the IPv6 transition if it works.
Most recently Jen Linkova demonstrated turning off IPv4 works for "regular" users at large scale in Google's enterprise network and (earlier) Microsoft did something similar at smaller scale. It's just a matter of time now until the right people see the potential to save money here.
Why shouldn't syncthing be the most performant and reliable P2P synchronizer when that happens if all it takes is a periodic DNS request and a tiny bit of address munging?
--Daniel
bt90 commentedon Jan 13, 2025
Let's say I'm having an educated guess 😉 But you're right that this is mostly an enterprise network thing.
lemmi commentedon Jan 13, 2025
I think it's a good idea. Since a few hosters started to charge extra for IPv4 addresses, I have a few machines that are happily running IPv6-only. They also happen to have access to an external DNS64/NAT64. On one workplace, people are still reluctant to roll out v6 and that can be very annoying, if the device you carry along cannot sync data at that location.
Syncthing otherwise works so reliably I do not have to think about it, but in this case it doesn't and I have to make extra provisions. (I can't really blame syncthing for that, but if a simple solutions exists, I'm all for it).
marbens-arch commentedon Feb 25, 2025
There are plenty of personal networks with an IPv6 firewall in the router that blocks all incoming connections to itself and its clients. It's not just a corporate network thing.
bt90 commentedon Feb 25, 2025
That's pretty much the norm nowadays. But these devices don't really make an effort to block holepunching attempts.
marbens-arch commentedon May 19, 2025
If the device has no v4 addrs, then how would synthesizing a v6 address from a v4 endpoint be possible (as there are none)?
Unless, by "the device" you mean the self device, the one that would be doing the synthesizing.
Gunni commentedon Aug 14, 2025