How Does a Layer 3 Router Translate Port Address in PAT?

layer3layer4nat;router

While I was reading about PAT i.e Port Address Translation.The router was configured to translate all the private IP addresses to one single public IP.Since router is a layer-3 device, it can do that translation by changing the source IP in the IP header. But how does it change the port number in the Transport Layer Header.Can a router do such kind of translation and on what basis does it translates those ports.

Kindly help me with this.Please do let me know If am missing something or I am going in wrong direction.

Thanks!

Best Answer

What you are missing is that there is a difference between the functionality of a router as concieved by the people who designed the Internet protocol and the functionality of a modern device that says "router" on the box.

A router as originally invisaged by the creators of the Internet only cared about layer 3 and below. It would strip off the link type specific headers (layers 1/2), perform IP routing (layer 3) and then build a new set of link type specific headers for the next hop.

But modern devices that say "router" on the box often do far more than that. They can and do implement functionality that involves inspecting and modifying the layer 4 headers.

Related Topic