-2

The question I'm asking is probably very elementary, but It is about the subject of DNAT in Networking. Imagine we have a LAN with 2 computers that both of them want to connect with a single server, outside of LAN (Internet). My question is how our Home router or NAT Server can differentiate received packets from that Server for two computers if two computers are requesting from the same server when translating IP addresses. What Information Help DNAT to Forward Packets to The Right PC?

DariushStony
  • 153
  • 8

2 Answers2

0

This is because we have a table in the router or NAT device.

A connection is specified by five things: source IP, source Port, protocol, destination IP and destination Port. These two local PCs will have different ip/port which is allocated by the router. So by using the table, we can easily choose the packets to right PC.

tyChen
  • 1,404
  • 8
  • 27
0

NAT devices use layer-4 identifiers to map the answers back to the hosts in the LAN. For TCP/UDP it uses port numbers, although different types of NAT will use these port numbers differently.

Wikipedia has a nice diagram of what a NAT table looks like: NAT translation

Note the port numbers in the NAT translation table.

For protocols other than TCP/UDP (i.e. protocols that have no layer-4 port numbers) other identifiers are used for the mapping. For example, for ICMP pings the identifier field is used.

Malt
  • 28,965
  • 9
  • 65
  • 105