Skip to content

Publish all interface addresses via global discovery #8453

Description

@bt90

Continuing the (lengthy) discussion from #8443 (comment) here.

As of now Syncthing only publishes temporary IPv6 addresses to the global discovery server as these are enabled and used for outgoing connections on nearly all platforms by default.

The biggest drawback is that other clients are very likely to hit the firewall of the router even if the user properly configured it. The firewall rules only target EUI-64 (aka MAC generated) addresses and maybe DHCPv6 IA_NA addresses if supported by the router vendor. An IPv6 "port forwarding" configured via the router therefore doesn't apply to temporary addresses.

With temporary addresses enabled, neither of those two currently gets published to the discovery server. The result is that global IPv6 connectivity only works if either no firewall is involved or UDP/TCP holepunching succeeds.

Disabling the creation of temporary addresses is not a workaround as it allows for website operators to freely track single devices. The same goes for hardcoding the listening address as the prefix is renewed by the ISP once in a while.

The only option left would be to lookup globally routable IPv6 addresses via interface as we do already for private IPv4 ranges.

The main concern raised by @calmh is about user privacy. As long as the user doesn't disable random identifiers and switches to EUI-64 address generation instead, these addresse still don't leak the device MAC.

If the user manually configures to use a stable MAC based IPv6 and runs Syncthing with global discovery enabled, i'd argue that he wants those IPs published.

Activity

  1. added
    enhancement
    needs-triage
    on Jul 28, 2022
  2. changed the title [-]Publish interface IPv6 addresses via global discovery[/-] [+]Publish all interface addresses via global discovery[/+] on Mar 10, 2023
  3. removed
    needs-triage
    on Mar 10, 2023
  4. mdekstrand commented on Sep 15, 2023

    @mdekstrand

    Another use case for this is when SyncThing is running on a Tailscale node. Right now, my Tailscale nodes are announcing their local LAN ipv4 addresses (behind NAT), and their Tailscale IPv6 addresses, but not their Tailscale 100.x CGNAT ipv4 addresses. In practice this seems to be ok — the nodes will happily connect to each other over ipv6 — but the inconsistency of only publishing the ipv6 and not ipv4 TS addresses is odd.

  5. bt90 commented on Sep 15, 2023

    @bt90
    ContributorAuthor

    We discussed adding CGNAT addresses in the past and decided against it. But as you already noticed, we're publishing ULA IPs now.

  6. rdiez commented on Jun 11, 2024

    @rdiez

    My current residential Internet provider uses DS Lite (IPv4 tunneled over IPv6), and does not provide a public IPv4 address, so I am being forced to learn more about IPv6 than I ever wanted to know.

    There are 2 usage scenarios for incoming connections at home:

    (1) Reverse VNC connections, for remote control / desktop sharing purposes, in order to help acquaintances with their PC problems.

    I have written scripts to find out my current public IPv4 address, and help start a remove VNC connection, they are here: https://github.com/rdiez/Tools/tree/master/VNC . It is all rather manual, for occasional usage, but it used to work pretty well for IPv4.

    (2) Syncthing.

    I would rather not use relay servers. There is no need to be burden to any relay volunteers, and a direct connection should be faster anyway.


    The usual VNC software for Windows does not work well with IPv6 yet, but Vinagre, Remmina and x11vnc on Linux work fine. I wrote a new script called vnc-ipv6-addr-to-clipboard.sh in order to find out the computer's global IPv6 address, and I was hoping to reuse the logic for SyncThing, but I am hitting a fundamental issue (apparently).
    I have set the following options in my NetworkManager WLAN connection:
    802-11-wireless.cloned-mac-address: stable
    ipv6.addr-gen-mode: stable-privacy
    

    The MAC address is then pseudo-random but stable for that particular WLAN connection, so even if any IPv6 address were later derived with EUI64, the hardware MAC address would not leak. The "stable-privacy" IPv6 address makes sure that the global IPv6 address for incoming connections is pseudo-random but always the same on that particular WLAN connection. In short: publishing such an IPv6 address would be fine by me.

    I am using a FRITZ!Box router (a popular brand in Germany). You can allow a TCP port through the IPv6 firewall fairly easily, you just have to make sure you select the generated "stable-privacy" IPv6 address, so that the router will remember the target computer reliably. It would be better to generate a truly random IPv6 address upon connecting to the WLAN, and let the router associate the port forward based on the DHCP hostname, but we are not there yet.

    I was expecting SyncThing to publish the global IPv6 address, perhaps by enabling some option, but it doesn't. The current behaviour is described in some GitHub issue and forum posts I have seen. As a result, my SyncThing instance is not directly reachable from outside.

    The next thing I investigated is how to tell SyncThing to register a particular IPv6 address at the discovery servers. That would be a manual process, but I only use SyncThing occasionally. Allegedly, you can achieve that by specifying the IPv6 address in the "Listen Addresses" configuration setting, like:

    tcp6://[my:slaac:stable:privacy:address]:22000

    The trouble is, my residential Internet provider changes the IPv6 address prefix every now and then. I have a few questions now:

    a) Is there a way to tell SyncThing to register/publish only the global and/or non-temporary IPv6 addresses?

    Publishing temporary IPv6 addresses does not really make sense, as the OS will probably not use them for listening purposes, or at least the OS or the application shouldn't.

    Judging from the comments in this bug, this feature is still missing.

    b) How does SyncThing generally react to an IPv6 address prefix change? Will it re-register/re-publish the new IPv6 addresses at the discovery servers? Or will it just stop working, because it would still bind to the old IPv6 addresses with the old prefix? That will probably be the case if I specify a particular IPv6 address to bind to, as mentioned above. I couldn't find any documentation about SyncThing's behaviour regarding IPv6 prefix changes.

    c) Is there a way to tell SyncThing to register/publish an IPv6 address based only on its IPv6 suffix? That would be equivalent to the IPv4 subnetwork mask.

    At the moment, I am getting a /59 IPv6 prefix from my ISP. NetworkManager on Linux knows that, so that the stable-privacy setting only affects the low 69 bits of the IPv6 address. The router knows it too, so it only matches the low 69 bits to set up the firewall rule for TCP forwarding purposes. But SyncThing seems to lack such a feature. Or I am missing something here?

    If so, that would probably be the key feature to implement, instead of just publishing all IPv6 addresses which SyncThing happens to think they could work. This way, you can manually select the IPv6 address to publish without worring about IPv6 prefix changes.

  7. bt90 commented on Jun 12, 2024

    @bt90
    ContributorAuthor

    I think privacy is the only real concern that's currently blocking this feature.

    Couldn't we just filter simple MAC-based IPv6 addresses? These are the biggest offenders IMHO. All other IPv6 addresses are either generated with privacy extensions or have been either statically or dynamically assigned to the device.

    My idea:

    1. iterate over all interfaces
    2. calculate the MAC-based EUI-64 for each interface
    3. publish all global IPv6 addresses that don't have this suffix
  8. bt90 commented on Jul 29, 2024

    @bt90
    ContributorAuthor

    @syncthing/maintainers any objections? I may have some time to invest in this in the near future and wanted to make sure we have a consensus before I start.

  9. calmh commented on Jul 29, 2024

    @calmh
    Member

    We don't publish public v4, and I don't think we should do it with v6 either, at least not by default.

  10. rdiez commented on Jul 29, 2024

    @rdiez

    I do not think that is true, but maybe I do not understand yet how Syncthing's discovery registration works.

    I just started my Syncthing, which is outdated version 1.18.0~ds1-3ubuntu0.2 which comes with Ubuntu 22.04. It automatically registered with the discovery server all my private IPs: 172.17.x.x (docker), 192.168.100.x (libvirt bridge or whatever), 192.168.116.x (LAN), 192.168.122.x (another libvirt bridge), and a 2.212.x.x (a public IPv4 address, which will not work because of DS Lite).

    It also automatically registered a temporary, outgoing-only IPv6 address which is not going to work either.

    If anything, I would say that Syncthing should only register my public IPv4 address (even though it is not going to work in my case). But maybe it's not Syncthing actively registering it, but the discovery server seeing the connection coming from that address. Can you confirm this?

    I would rather tell Syncthing explicitly what IP addresses it should register: no IPv4, and a particular IPv6, because that is the only one which will work for me.

    I do not really like Syncthing leaking so many internal IP addresses anyway.

    As mentioned in a previous comment, specifying the whole IPv6 address will not work either, as the IPv6 prefix is going to change overnight, so I would rather tell Syncthing only the suffix of the IPv6 address to publish.

    And I still would like to know whether Syncthing will tolerate a change of the IPv6 prefix and re-register the new IPv6 address (new prefix + my fixed suffix) as needed.

  11. bt90 commented on Jul 30, 2024

    @bt90
    ContributorAuthor

    The comparison is a bit like apples to oranges. We do publish the public IPv4 address, albeit indirectly as @rdiez mentioned.

    While it's true that we don't announce public IPv4 addresses discovered via interface, the IPv4 world is mostly NAT'ed. So this restriction only really affects servers with multiple public IPv4 addresses. Broadly speaking, there's not much to be gained even if we did announce them, since the number of users affected is tiny and in almost all cases it wouldn't improve connectivity for them.

    We apply the same strategy for IPv6, but with diminishing returns. While NAT66 is frowned upon in the IPv6 world, temporary IPs are used for outgoing connections from devices without a static IP. So we end up with a temporary IPv6 on the global discovery server.

    While this address has a reasonable lifetime of about 24h and is dialable from other clients, we're going to run into the firewall of your average ISP-issued router. The problem is that the user can only configure IPv6 firewall rules (aka "port forwardings") for the main IPv6 address of their device. Without being able to properly configure firewall rules, we're down to the odds of holepunching.

  12. rdiez commented on Jul 30, 2024

    @rdiez

    While this address has a reasonable lifetime of about 24h and is dialable from other clients, we're going to run into the firewall of your average ISP-issued router.

    Temporary IPv6 addresses is an interesting subject. Should Syncthing listen on temporary IPv6 addresses at all? After all, temporary addresses are meant for outgoing connections. What happens if a temporary address expires while Syncthing is listening on it? Or is Syncthing just listening on all addresses on all interfaces, so it will just not care? Will the OS stop incoming connections on temporary addresses? Will Syncthing automatically realise that the temporary IPv6 address it has (indirectly?) published/announced no longer exists?

    If I tell Syncthing to listen to a particular IPv6 address, will it publish/announce that IPv6 address? Or does it publish/announce only based on some heuristic?

    I wonder whether I could disable the discovery server in Syncthing and write a script to publish/announce the global IPv6 at regular intervals. After all, I already have a script to find out the global IPv6 address, it is here: https://github.com/rdiez/Tools/tree/master/VNC

  13. bt90 commented on Jul 30, 2024

    @bt90
    ContributorAuthor

    To us, this is done transparently, with the operating system managing the IP allocation and lifetime. It's not that different from IPv4, as your DHCP-assigned IPv4 also tends to have a limited lifetime and may change from time to time.

    Or is Syncthing just listening on all addresses on all interfaces, so it will just not care?

    In essence: this

    Will Syncthing automatically realise that the temporary IPv6 address it has (indirectly?) published/announced no longer exists?

    The global discovery entry will become stale and disappear. Dialing is designed to be a trial-and-error process, so this doesn't really break things. The OS is also very likely to keep old temporary IPs around a bit longer than it's actively using them, which also mitigates this.

    If I tell Syncthing to listen to a particular IPv6 address, will it publish/announce that IPv6 address?

    Manually configured listening addresses are always published AFAIK.

  14. bt90 commented on Jul 30, 2024

    @bt90
    ContributorAuthor

    Without being able to properly configure firewall rules, we're down to the odds of holepunching.

    to explain this point a little further: Of course, holepunching only works if the clients use the same source address for dialing with which the global discovery server has registered them. It is sufficient for one party to use a different temporary IP address for dialing for all holepunching attempts to fail.

    Combine this with the inability to create firewall rules as explained above, and we end up with the measly 5% IPv6 transport usage we observe today.

  15. calmh commented on Jul 30, 2024

    @calmh
    Member

    About 25% of devices have an ipv6 address in the discovery server. The odds of any given pair of devices both having ipv6 should be about 6%, just statistically. 5% connectivity sounds about right.

  16. rdiez commented on Jul 30, 2024

    @rdiez

    About 25% of devices have an ipv6 address in the discovery server. The odds of any given pair of devices both having ipv6 should be about 6%, just statistically. 5% connectivity sounds about right.

    The problem I described with DS Lite is real, and such IPv6 trouble is only going to increase with time as IPv4 scarcity keeps growing. I wouldn't waste time looking at statistics, and I wouldn't unnecessarily increase the load on the (probably volunteering) relay servers due to this issue. At the very least, I would document the issue for the end user, and perhaps offer some scripting workaround, if a proper solution cannot be implemented yet.

  17. bt90 commented on Jul 30, 2024

    @bt90
    ContributorAuthor

    About 25% of devices have an ipv6 address in the discovery server. The odds of any given pair of devices both having ipv6 should be about 6%, just statistically. 5% connectivity sounds about right.

    IPv6 adoption is very ISP/country dependent. A German user (73% adoption) is much more likely to have IPv6 connectivity between his devices than an Australian user (31% adoption).

    https://www.google.com/intl/en/ipv6/statistics.html#tab=per-country-ipv6-adoption

  18. imsodin commented on Jul 30, 2024

    @imsodin
    Member

    I think there are a two questions here:

    1. Announcing stable public ipv6 addresses opt-in or opt out.
    2. Announcing stable public addresses explicitly by finding them locally or by announcing a magic empty address that the discovery server resolves.

    For 1 I am on the fence: It means knowing the device ID allows device level public IP tracking regardless of privacy measures on ipv6 addresses to avoid that (interface ID changing when prefix changes). That points towards opt-in. However realistically compared to ipv4 where you have that tracking per subnet, that doesn't seem so much worse. I feel like users caring about that are users that shouldn't use global discovery.

    For 2 I think there's no reason to explicitly announce locally discovered public addresses. We should instead announce over the stable address. While NAT in v6 isn't a de facto standard as in v4 (quite the contrary), it still exists and thus people might not want their non-NAT-ed address be announced. Also it would likely be useless. I don't see any downside to using the server side address discovery. That's doable by using a custom transport for the http connection to the discovery server, selecting the stable IP as the local address. For dual stack we might even want to announce twice over both v4 and v6.

  19. bt90 commented on Jul 30, 2024

    @bt90
    ContributorAuthor

    However realistically compared to ipv4 where you have that tracking per subnet, that doesn't seem so much worse. I feel like users caring about that are users that shouldn't use global discovery.

    This is in line with my inner reasoning.

    I'm still not sure what the potential impact of an IPv6 "leak" would be. Let's say I am able to get the Syncthing ID of a foreign device, e.g. via LAN announcement. What can you realistically do with this information?

    • last online -> not bound to IPv4 / IPv6
    • Location -> GeoIP will give roughly the same results for IPv4 / IPv6
    • MAC address -> IPv6 related, but preventable by filtering. (Bold claim, but I think MAC generated IPs are mostly irrelevant/non-existing nowadays)

    The standard use case for temporary IPs is to prevent advertising giants from tying metadata to individual hosts. But there isn't much metadata available to gather interesting insights based on global discovery?

    I think there's no reason to explicitly announce locally discovered public addresses. We should instead announce over the stable address. While NAT in v6 isn't a de facto standard as in v4 (quite the contrary), it still exists and thus people might not want their non-NAT-ed address be announced.

    This is probably the smartest solution. Kudos

    That's doable by using a custom transport for the http connection to the discovery server, selecting the stable IP as the local address.

    I think this can be done via socket options following RFC5014 like IPV6_ADDR_PREFERENCES on Linux. The tricky part is that our BEP connections also should prefer these in order to get better holepunching results.

  20. acolomb commented on Jul 30, 2024

    @acolomb
    Member

    How about our announcement of local IPs to help discovery when the local broadcast doesn't get through? That's a useful default, but excluding the "non-NATed" IPs also takes away this advantage. Local LAN IPv6 addresses may very well be globally routable, even when behind a NAT router. It's not quite as easy to distinguish whether NAT is involved as it is in the usual IPv4 case.

  21. bt90 commented on Jul 30, 2024

    @bt90
    ContributorAuthor

    I think most NAT66 or NPTv6 deployments use addresses from the ULA range(fc00::/7). We already publish these as LAN IPs, but they are inherently not globally routable.

  22. added theissue type on May 30, 2025
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

    enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions