1

This question already has an answer here:

I seem to get different answers from different people depending on the topic at hand. I'd like to actually understand how routers forward traffic to external networks using a single IP Address. I'm asking the following question: How does a router with a single IP Address forward requests from the multitude of clients behind it and when those request arrive back to itself, how does it know who requested it? I often get the contradictory answers of either NAT or PAT. But which is correct? Are they used in conjunction and why is that conjunction required?

Let's say I have a small network. Single router with IP Address of 10.0.0.1. Behind that I have 2 clients using the 192.168 address space. Client 1 attempts to connect to Google. When this happens, the packet reaches the router. The router substitutes it's public IP Address for the source IP, replacing the local 192 Address of the local packet. When that packet returns from Google, how does the router know which client requested the packet? At this point, is PAT being used?

It would seem to me that the router would have a memory of which packets it's forwarded and where they originally came from. It would then use this memory to forward the packet from Google back to the original requesting client. Does this happen at all? Or is this so called "memory" non existent?

Are PAT and NAT used in conjunction on every modern router?

How does this process truly work?

marked as duplicate by Zac67, Community Oct 14 '17 at 18:59

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1

A simple router is stateless, ie. it just looks at the current packet and decides where it should go.

A NAT router translates the source IP address, the destination IP address (aka port forwarding), or both. Usually, it also translates the according port number (PAT). In order to translate the addresses/ports back for the reverse direction, it needs to be remember what connections it is currently translating.

0

Understand that NAT really has nothing to do with routing; it is a kludge to extend the life of IPv4 addressing until IPv6, with its large addressing, is ubiquitous.

Routers receive packets, and they use the destination address on the packets to decide where to forward the packets for the next hop. This is done by looking up the destination in a routing table. If no destination is found for a packet, then the packet is dropped. Routers often have a default route (0.0.0.0/0) in the routing table that matches every destination, but that is not a requirement.

On the other hand, NAT simply replaces either the source, destination, or both addresses on packets. It doesn't actually route anything, and it can be use on devices other than routers. What some people call PAT is actually NAPT (see RFC 2663, IP Network Address Translator (NAT) Terminology and Considerations). NAPT is one form of NAT that translates both the layer-3 and layer-4 addressing in order to allow multiple devices to be translated to the same address.

A router or firewall is often a convenient place to do NAT, but it is not a requirement for routing or firewalls. IPv6 has enough addresses for the foreseeable future, so there are no NAT standards for it the way there are for IPv4.

  • NAT/PATing isn't simply about extending the life of IPv4, that is a very narrow view of the NAT/PAT purpose. It also allows you to quickly manipulate where traffic is directed without changing IPs or ports on end devices, like pointing your websites to a separate set of servers running a newer version of code. (Whether in an LB, FW, or router) Or move services expecting Port A onto port B to prevent conflicts. It also Allows you to pose remote networks on alternative paths as local IPs in a given network so local hosts can respond to them without needing to have any route updates. – Ben Personick Oct 11 '18 at 21:49

Not the answer you're looking for? Browse other questions tagged or ask your own question.