How does NAT keep track of connections

Given a NAT where multiple PCs are sharing one IP address, how is NAT able to know where to send the incoming data to. Does it translate th SYN-ACK ids?


When a device connects to a server on the other side of the router, it uses a source port in its ephemeral port range. This is typically a port between 49152 and 65535 and it is randomly assigned. The NAT router records this port number as well as the destination IP address in a NAT translation table. When data starts coming back in from the server, it looks up where it goes from this table.