Discovery Server + Node at Same IP


First of all, allow me to thank the developers and all contributors of the Syncthing for the great work they have been doing. I’ve been using it for a long time flawlessly to sync all my machines.

I’ve been using the public discovery server in order to connect my machines, however, I recently decided to roll my own Discovery Server. I picked up a VPS, installed the server and fired everything with:

stdiscosrv -cert=/root/syncthing-server/fullchain.pem -key=/root/syncthing-server/key.pem -listen=:8443 -db-dir=/root/syncthing-server/discovery.db

After configuring my clients to do discovery using that VPS hostname I was able to sync everything without any issues.

Now the complicated part: I decided that I also want to run the client on the same VPS. The idea here is to have a copy of all my data on the VPS so any device can get the latest data without having to wait for other devices to get online.

Here is is what happens:

  1. I add my computers device ids to the client running on the VPS;
  2. The client on the VPS gets the correct public IPs (from the discovery server hosted by itself, same public IP) for the computers (everything looks fine)
  3. Then I add the VPS device ID on my computers, all the computer say that the address of the VPS node is [::1]:port

Why is this happening? Is it impossible to run a node and a discovery server on the same public IP? I believe that the VPS client is actually telling the discovery server that its IP is [::1] and then the other computers pick this. How can I avoid this issue?

Thank you.

I think it’s already mentioned in the docs, you cannot run discovery server and a syncthing node on the same machie (or even the saman if you expect someone from outside the lan to be able to connect), as the recorded address os either loopback address or lan address which makes no sense to external clients.

1 Like

I didn’t find anything relevant in the docs regarding this issue. But as I described before I was under the impression that the VPS client was feeding the local IP to the discovery. Is there a way to force the client to advertise its static external IP instead of the local one?

Yes, set the Syncthing listen address to that IP and that will be announced – tcp:// for example. With the default unspecified address the discovery server has to guess based on the source of the announcement.

1 Like

Hi! I tried that suggestion and this is the result:

The VPS client is publishing both the public IP and the local IPv6 to the discovery.

Unfortunately, the machine I used to take the screenshot still doesn’t sync. It is picking the IPv6, failing to connect to it and then ignoring the IPv4?

No it will be trying both. Verify firewalls etc.

1 Like

The computer keeps saying:

2018-08-30 16:07:48 Connected to myself (xxxxx) at [::1]:64837-[::1]:33287/tcp-client - should not happen

So it isn’t trying the real IPv4.

It is. It just doesn’t log connection failures at info level as that would be hilarious amounts of logspam. ‘Connected to myself’ is more unusual and noteworthy.

Yes, but it never connects to the IPv4 / starts syncing.

Again, verify firewalls etc, see if you can connect yourself using nc or telnet. To see all that’s going on with connection attempts, run STTRACE=connections syncthing (or enable the corresponding debug stuff in the GUI log thing).

1 Like

No firewall enabled on the VPS, and… If I edit the device on the computer and change Addresses from dynamic to the real VPS IP the sync starts and everything works fine.

Then no idea, sorry. The above debugging might tell you though.

Oh, actually I do know, and it’s a bug and not your fault.

We dial candidate addresses in parallel and proceed with the first to connect. In your case that’s (of course) the localhost address. That connection then gets rejected at a later stage because it’s to the wrong device.

Honestly, it’s also a bug that the discovery server accepts the localhost address at all. That should be filtered out from the announcement as it has no chance in being valid…

At least the latter of these should be solved.

1 Like

Thank you for all the help. So I’m sticking with setting the Addresses field to the VPS hostname, this way I don’t need to remember the IP and the sync still works. Should I open an issue on Github about this?

Thanks, I already did, #5151 and #5152.

Using the hostname to connect to is perfectly fine.

1 Like

Theoretically, this discosrv should filter out the badness and things hopefully “just work” as I expected earlier;

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.