If I listen to multi-port...and the peer is beind the NAT

If I setting Syncthing to listen not only port 22000, but multi port for example 22000-22002 … and my peer is beind the NAT… and My private IP is 192.168.0.1 and my NAT have 3 WAN port , IPs are 61.0.0.1 61.0.0.2 61.0.0.3

I have 2 questions above:

  • If I setting up NAT policy route: 192.168.0.1 port 22000 outgoing with 61.0.0.1 WAN NAT policy route: 192.168.0.1 port 22001 outgoing with 61.0.0.2 WAN NAT policy route: 192.168.0.1 port 22002 outgoing with 61.0.0.3 WAN

Do Syncthing report these three correct incoming port like a. 61.0.0.1:22000 b. 61.0.0.1:22001 c. 61.0.0.1:22002 to dicover server ??

  • and another question is , did the syncthing transfer data with 22000~22002 port ?? or syncthing will create new tcp port other than 22000-22002 to connect to peer ??

(create new random tcp port connect will cuz NAT policy not work…becuz I don’t know what port will syncthing used, I must control the differant port outgoing with differant WAN-internet connection )

The discovery server will probably get on of the 3 IPs (at random). AFAIK Syncthing connects to each discovery server ones to report all available ports. The IP will be determined by the discovery server by using the remote addr of the incoming connection.

On outgoing connections, Syncthing will use other random ports. The port in the settings is only for incoming connections.

For your setup to work as intended, you will probably need to disable global discovery and setup all other nodes, to connect to this node manually by entering the specific IP and port.

When v0.12 will be finished, there will be 3 default discovery servers, so you could try adding static routes or other rules to connect to each of that discovery servers with a specific public IP. E.g. you could tell your NAT router to connect to the IP of the first discovery server with 61.0.0.1, to the IP of the second with 61.0.0.2, …

so If I want to totally use these 3 leaseline (WAN) right now…

There is only 1 solution is run 3 Syncthing instance with differant progile to solve my work ??

If I run my own discover server, could I setting discover server to listen multi IP/port ??

If you want to use discovery, yes.

I think you could run 3 discovery servers and use my suggestion from above (last paragraph).

but even If I create 3 dicover server, How can I set the NAT policy with port range… I mean when syncthing got incoming request , and create new connection is also random port… (I can’t setting NAT policy according to random-port)

So, I think above is total solution

  • 3 dicover server , and manaul point syncthing discover server to these three, and setting up 3 NAT policy outgoing for these 3 dicover-server
  • I should bind 3 private IP: 192.168.0.1,192.168.0.2,192.168.0.3 and syncthing listen these 3 private IP , so that I can set the NAT rule with differ source-address outgoing with differ WAN port ??

Is that all correct ??

The existing old (v0.11) discovery server takes a querystring argument listenaddress, so you can make it bind to different nics if each of your wans is on a different nic.

Also, the problem is not the discovery server, and running it won’t change anything.

The issue is that syncthing will only make one announcement, and only from one address, it doesn’t care that you have 3 listen addresses and it has no way to know that your LAN has 3 gateways.

so If I set thress static dicover server, each discover server will recieve one time announcement ?

Right, to correct myself, it’s not one time, but it opens and uses a single socket, throughout the runtime duration.

So you will get multiple announcements, but from the same random client port.