Skip to content

Please support NAT64 connections to ease IPv6-only deployment #9917

Description

@DanielG

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:

  1. 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.

  2. 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:

    1. Not available on all platforms. (May improve in the future)
    2. 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:

    1. NAT64 performs better since it's closer to users
    2. project pays for bandwidth network operators could be covering
    3. 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

  1. added
    enhancementNew features or improvements of some kind, as opposed to a problem (bug)
    needs-triageNew issues needed to be validated
    on Jan 12, 2025
  2. calmh commented on Jan 12, 2025

    @calmh
    Member

    What does "support NAT64" mean, practically speaking? Is it just to try and dial resolved v4 addresses as v6 in 64:ff9b::/96?

  3. DanielG commented on Jan 12, 2025

    @DanielG
    Author

    We'd have to first discover the NAT64 prefix used by the network by resolving ipv4only.arpa (RFC8880) (64:ff9b::/96 was 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.

  4. bt90 commented on Jan 12, 2025

    @bt90
    Contributor

    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.

  5. DanielG commented on Jan 12, 2025

    @DanielG
    Author

    Hi bitpirate,

    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.

    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=1 allows connections to pass even if the SYN flag isn't expected in the REPLY direction. However I bet some vendor is selling nf_conntrack_tcp_loose=0 as a "security" feature so ymmv ;-)

    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.

    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

  6. bt90 commented on Jan 13, 2025

    @bt90
    Contributor

    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.

    Have you seen this be a problem in the wild or are you speculating?

    Let's say I'm having an educated guess 😉 But you're right that this is mostly an enterprise network thing.

  7. lemmi commented on Jan 13, 2025

    @lemmi

    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).

  8. marbens-arch commented on Feb 25, 2025

    @marbens-arch
    Member

    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.

    Have you seen this be a problem in the wild or are you speculating?

    Let's say I'm having an educated guess 😉 But you're right that this is mostly an enterprise network thing.

    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.

  9. bt90 commented on Feb 25, 2025

    @bt90
    Contributor

    That's pretty much the norm nowadays. But these devices don't really make an effort to block holepunching attempts.

  10. marbens-arch commented on May 19, 2025

    @marbens-arch
    Member

    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.

    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.

  11. added theissue type on May 30, 2025
  12. Gunni commented on Aug 14, 2025

    @Gunni

    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.

    • if no ipv4 address on device, or only IPv4 link-local addresses:
      1. Discover the nat64 prefix, f.ex by using ipv4only.arpa (RFC8880)
      2. foreach remote ipv4 address received, add it in hex and with the nat64 prefix prepended
        • example: if the nat64 prefix is 2001:db8::/96 then 192.0.2.42 becomes 2001:db8::c000:22a
        • adding the ipv4 address to the remote ip list on an ipv6-only client will only lead to no route found errors for it, consider not adding addresses that don't have a route/default route for them
      3. The nat64 client needs to discover the nat64 public ip it has and advertise it to discovery, just like how it's done today for standard ipv4 nat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew features or improvements of some kind, as opposed to a problem (bug)needs-triageNew issues needed to be validated

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions