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?
2 Answers
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.
- 19,224
-
So it translates the source port.. and later looks up the translation to get back to the correct private IP and source port. Is this correct? – 700 Software Dec 29 '10 at 16:57
-
It translates the IP address. Some devices might translate the source port as well. The important thing to note is that it has a table of these source ports that it uses to reverse translation on return packets. – Jason Berg Dec 29 '10 at 16:59
Given a NAT where multiple PCs are sharing one IP address, how is NAT able to know where to send the incoming data.
By not being programmed with alheimer as model. Basically it has a memory - about which internal ports / ip addresses map to whiche external target port / ip, so it can do the translation. For TCP that is simple, for UDP the internal program better regularly sends packets outside (so that NAT refreshes the routing table).
Does it translate th SYN-ACK ids?
No, proper NAT is not following the TCP protocol. THis is to make sure that TCP does not work.
Joke aside - NATURALLY it has to do translations when needed, otherwise it would break the implementation. NAT has to be trnasparent, so it has to make all translations necessary.
- 51,864
- 7
- 55
- 136