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

**URL:** https://forum.syncthing.net/t/if-i-listen-to-multi-port-and-the-peer-is-beind-the-nat/5829
**Category:** General
**Created:** [October 5, 2015, 8:12am UTC](https://forum.syncthing.net/t/if-i-listen-to-multi-port-and-the-peer-is-beind-the-nat/5829 "2015-10-05T08:12:48Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![netenken1](https://forum.syncthing.net/letter_avatar_proxy/v4/letter/n/b9e5f3/32.png) [@netenken1](https://forum.syncthing.net/u/netenken1)
#### Post date: [October 5, 2015, 8:12am UTC](https://forum.syncthing.net/t/if-i-listen-to-multi-port-and-the-peer-is-beind-the-nat/5829/1 "2015-10-05T08:12:48Z")

</div>

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

---

<div class="post-metadata">

### Author: ![wweich](https://forum.syncthing.net/user_avatar/forum.syncthing.net/wweich/32/1063_2.png) [@wweich](https://forum.syncthing.net/u/wweich)
#### Post date: [October 5, 2015, 8:26am UTC](https://forum.syncthing.net/t/if-i-listen-to-multi-port-and-the-peer-is-beind-the-nat/5829/2 "2015-10-05T08:26:47Z")

</div>

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, …

---

<div class="post-metadata">

### Author: ![netenken1](https://forum.syncthing.net/letter_avatar_proxy/v4/letter/n/b9e5f3/32.png) [@netenken1](https://forum.syncthing.net/u/netenken1)
#### Post date: [October 5, 2015, 8:32am UTC](https://forum.syncthing.net/t/if-i-listen-to-multi-port-and-the-peer-is-beind-the-nat/5829/3 "2015-10-05T08:32:09Z")

</div>

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 ??

---

<div class="post-metadata">

### Author: ![netenken1](https://forum.syncthing.net/letter_avatar_proxy/v4/letter/n/b9e5f3/32.png) [@netenken1](https://forum.syncthing.net/u/netenken1)
#### Post date: [October 5, 2015, 8:33am UTC](https://forum.syncthing.net/t/if-i-listen-to-multi-port-and-the-peer-is-beind-the-nat/5829/4 "2015-10-05T08:33:50Z")

</div>

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

---

<div class="post-metadata">

### Author: ![wweich](https://forum.syncthing.net/user_avatar/forum.syncthing.net/wweich/32/1063_2.png) [@wweich](https://forum.syncthing.net/u/wweich)
#### Post date: [October 5, 2015, 8:44am UTC](https://forum.syncthing.net/t/if-i-listen-to-multi-port-and-the-peer-is-beind-the-nat/5829/5 "2015-10-05T08:44:29Z")

</div>

> [@netenken1](#):
>
> There is only 1 solution is run 3 Syncthing instance with differant progile to solve my work ??

If you want to use discovery, yes.

> [@netenken1](#):
>
> If I run my own discover server, could I setting discover server to listen multi IP/port ??

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

---

<div class="post-metadata">

### Author: ![netenken1](https://forum.syncthing.net/letter_avatar_proxy/v4/letter/n/b9e5f3/32.png) [@netenken1](https://forum.syncthing.net/u/netenken1)
#### Post date: [October 5, 2015, 8:55am UTC](https://forum.syncthing.net/t/if-i-listen-to-multi-port-and-the-peer-is-beind-the-nat/5829/6 "2015-10-05T08:55:15Z")

</div>

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 ??

---

<div class="post-metadata">

### Author: ![AudriusButkevicius](https://forum.syncthing.net/user_avatar/forum.syncthing.net/audriusbutkevicius/32/277_2.png) [@AudriusButkevicius](https://forum.syncthing.net/u/AudriusButkevicius)
#### Post date: [October 5, 2015, 10:23am UTC](https://forum.syncthing.net/t/if-i-listen-to-multi-port-and-the-peer-is-beind-the-nat/5829/7 "2015-10-05T10:23:36Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![netenken1](https://forum.syncthing.net/letter_avatar_proxy/v4/letter/n/b9e5f3/32.png) [@netenken1](https://forum.syncthing.net/u/netenken1)
#### Post date: [October 5, 2015, 11:30am UTC](https://forum.syncthing.net/t/if-i-listen-to-multi-port-and-the-peer-is-beind-the-nat/5829/8 "2015-10-05T11:30:18Z")

</div>

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

---

<div class="post-metadata">

### Author: ![AudriusButkevicius](https://forum.syncthing.net/user_avatar/forum.syncthing.net/audriusbutkevicius/32/277_2.png) [@AudriusButkevicius](https://forum.syncthing.net/u/AudriusButkevicius)
#### Post date: [October 5, 2015, 11:34am UTC](https://forum.syncthing.net/t/if-i-listen-to-multi-port-and-the-peer-is-beind-the-nat/5829/9 "2015-10-05T11:34:14Z")

</div>

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.
