Search code examples
network-programmingportip-addressnatinternet-connection

How many devices can run behind a Network Address Translation (NAT) device?


I was studying about Network Address Translation devices in a networking course (CS144, Stanford).

They described that a NAT works by mapping local IP address and corresponding application port numbers to the NAT's external IP and assigned (by the NAT) port number for that connection.

Assume that there is only one single external IP address to the NAT. My question is as follows:

Since the bottleneck to the number of connections between the internet and the NAT here is the limit on port numbers (which can go upto 65535), does that limit the number of applications (running on various devices behind the NAT) which can access the Internet, and also the number of devices that can run behind the NAT?

If yes, how can this limit be increased so that there can be unlimited devices behind the NAT?


Solution

  • it's a good question.

    As you said, NAT is limited by the port numbers. But the thing is that the protocol use a tuple like : internal IP, internal Port, external IP, external Port, and protocol.

    So, if we only have one external IP, then port numbers (65536) and protocol (TCP/UDP) will be the limitation. Since we can only map to 65546 * 2 external Port and protocol, that is the limitation of internal connection.

    If you want to break the limitation, maybe it's best to increase the number of external IP addresses.