Random Ports without Upnp

Hi

I just setup two computers to sync between each other I disable the Upnp in booth machines and in booth routers and open the respective ports of course.

My question is why even Upnp is disable one of the address always comes with a random port and not the assigned one 22000

In booth machines i have the Addresses:22000

But one they connect one always uses a random port and not the designated one.

Thanks for your advice

Are you getting confused between source and destination ports? Where exactly do you see port numbers that aren’t 22000? Copy/pasting log messages / whatever you’re seeing would be very helpful.

You see the Synology has ip:55360 Why ???

The thecus has ip:22000 this is fine.

Thanks

One is a listening port (incoming), the other is a connecting port (outgoing).

The listening port is defined by the listen address, the connecting port is randomly chosen by the OS at the point we try and connect (if we fail, it gets closed and OS uses a different one).

In this case Synology (random port) connected to Thecus (listening port), this is how TCP works.

Thank you very much for the explanation !!!

Hi

But is there a way to force use only determinate ports ?

I have a firewall and whenever I enable it I loose the connection with the other machines.

[WZGWC] 05:29:14 INFO: Connection to xxxxxx closed: write tcp xxxxxxxxxx:22000: connection reset by peer

[WZGWC] 05:29:38 INFO: Established secure connection to xxxxxxxxxx at 192.168.1.100:22000-xxxxxxxxxx:48968

[WZGWC] 05:29:38 INFO: Device xxxxxxxxxxxx client is “syncthing v0.11.26”

[WZGWC] 05:29:38 INFO: Device xxxxxxxxxxxx name is “RackStation”

[WZGWC] 05:29:39 INFO: Connection to xxxxxxxxxxxx closed: write tcp xxxxxxxxxxxxxx:48968: connection reset by peer

I want to know if its possible only use certain ports like 2200 - 21025 - 22026 not random ones.

Thanks

Usually no, atleast without effort, because that is controlled by the OS. Why does it matter?

The problem is that because of the firewall , I can’t establish a connection with the remote server

They connect for seconds and immediately disconnect

I open all the respective ports in booth ends but they disconnect all the time , I am assuming because this random ports…

Thanks

It’s perfectly valid for applications to open outward connections on a random port. Did you instruct your Chrome browser to open ports only in a certain range? If you explicitly forbid opening ports in a random range, then I guess you are on your own, as most applications rely on this being allowed.

Hi AudriusButkevicius

I did not instruct nothing to the browser I have a firewall and I need to open ports to allow connections to the network Most of the applications have respective ports that work on for example FTP port 21 But with Syncthing I can’t do this because ports are open random …

Thanks

FTP listens on port 21. FTP clients connect to port 21 from a RANDOM port. Same like webservers listen on ports 80 and 443, and Chrome connects to the webservers from a RANDOM port.

Same way syncthing listens on port 22000, other syncthing clients listen on 22000, but use a random port for connecting to port 22000.

Every connection has 2 ports, the listen port and the connect port.

Please read up about connections in work, as you seem to be missing the very basic fundamentals, and are obviously misunderstanding something.

Also, if you are making the effort of addressing a message to someone, make sure you get the name right, or don’t use a name at all.