About Network Address Translation (NAT)?

Just be interested in a specific NAT scenario. Suppose we have 4 computers sharing a global IP address under NAT. I understand that the NAT box stores an internal record to find out which computer to forward requests to. But let me say that on computer # 2 I am trying to download a file. And let them speak on computers No. 1, No. 3 and No. 4, I just browse the website in normal mode. When a browser initiates a TCP connection to receive this file, how does it know which computer it will send it to? I mean, do each of the four computers use port 80 to browse the web right? How does a NAT record distinguish which "port 80" belongs to a computer?

+3
source share
2 answers

The concept of "port 80 for http" does not work like that. When a computer browses the Internet, only the server uses port 80, and the client will use a random port number. The server responds with the attached destination port provided by the client. Port 80 is only for knocking on the web server door.

What NAT does is translate all these 4 computers with external packages so that their source ports are not duplicated. When NAT receives the packet, it checks if the connected destination port can be translated and translated to the LAN, if possible.

+5
source

Each unique TCP-connection to the internet is made up of four rooms - {source IP, source port, destination IP, destination port}.

NAT- (GW) {GW public IP, GW-mapped port, destination IP, destination port}, , . IP- {GW-mapped port -> {source IP, source port}}, , .

+8

Source: https://habr.com/ru/post/1746724/


All Articles