0

I run a service that needs more than 65535 ports and I use an AWS VPS

I was thinking what if i attach more static IP's to that VPS, would each of those IP's get 65535 ports whilst being connected to the main server or would they all just be aliases for eachother

1 Answers1

1

TCP tuples are identified by destination IP and port and source IP and port.

So in theory, 2001:db8:2943:a::1 and 2001:db8:2943:a::2 can each connect to 2001:db8:2943:b::3 on one destination port 443, 64K times. In reality, fewer ephemeral ports are available, and it takes a large and well tuned host to do 64K connections of anything non-trivial.

Say another server IP was added, 2001:db8:2943:b::4. Each source IP can connect another 64K times to this other destination IP, all on destination port 443.

Very unlikely you will exhaust ports in practice. You could have have a million different source IP addresses, and the 64K limit doesn't apply.

Perhaps a load balancer with one IP doing 64K connections to one IP and port. This already is quite large, but if necessary you can add another IP to the backend host and use that as well.

Or, 64K independent instances of a thing each listening on a unique destination port. This is an enormous number of processes to run. Could run fewer listening ports, and move the complexity into the application layer. For example, HTTP name based virtual hosting.

John Mahowald
  • 30,009
  • 1
  • 17
  • 32
  • I have noticed that this appers to be IPv6 Does this work with IPv4? – user14118720 Dec 11 '20 at 20:05
  • Yes, the same TCP tuple concept applies to IPv4. Actually, address family is yet another dimension, as it is a different address space. v6 examples should not feel alien in the era of v4 address exhaustion, I use them where I can. – John Mahowald Dec 11 '20 at 20:24
  • Even though @JohnMahowald’s answer explains the *TCP Tuple* concept also note that you will face many other problems if you try opening too many connections at once. From sockets and buffers limits, tcp overhead, etc. Dare to explain what are you actually trying to do? I’m pretty sure that there may be a better and less resource intensive way to do that. – MLu Dec 12 '20 at 00:10