What is the use of NAT and PAT?

Have you ever wondered why the IPV4 address is still in active use today? Even with the multiplicity of devices connected to the internet, the very limited IPV4 address is yet to be exhausted.

IPV4 is said to have an address pool of 4,294,967,296 IP addresses. With 18 million for private networks and 270 million for multicast and other reserved addresses, this makes address availability very insufficient.

The rise of IoT, and the drive to have every electronic device inter-networked, has also made it very difficult to keep up with IPV4 shortages. IPV6 promises to solve this problem with an address pool sufficient enough to give an IP address to every square meter on the earth’s surface. But the implementation of IPV6 has been slow and has left us dependent on IPV4.

Now, another question arises. What is the magic that our hardworking ISPs use to ensure there are enough public IP addresses for the large number of smart devices that need internet connectivity?

PAT and NAT are your magic technology.

What is NAT?

Network Address Translation (NAT) is a technique used by Internet Service Providers (ISPs) to map an IP address to another. This is done by changing the network address information in the header of the packet en-route to its destination. Let’s go through an explanation with the aid of a diagram.

A simple illustration of NAT function in an inter-network          Source: (wikipedia)
A simple illustration of NAT function in an inter-network Source: (wikipedia)

In the above diagram, a host with a private IP address 10.0.0.1 wants to communicate over the internet with a server with the IP address 200.100. 10.1 , possibly to access some documents.

This would not be possible because private IP addresses cannot be used on the internet. But the ISPs now come in, using the NAT technique to map the private IP 10.0.0.1 to the public IP 150.150.0.1, enabling it to communicate with the server on the internet. This is possible because NAT masquerades private IP addresses with public ones.

This is achieved by using a routing table that holds a temporaryit is constantly refreshed record of all available, registered, public IP addresses that they have. It maps the public IPs to each private IP coming from clients who wish to access the internet.

A situation can arise whereby the IP addresses available to the service provider (using the NAT router) are grossly insufficient to accommodate the number of users(hosts) that wish to access the internet through them. In this situation, they will employ the other technique we mentioned earlier, PAT.

What is PAT?

Port Address Translation (PAT) is a way of overloading NAT with port numbers so that with a few public IPs, the hosts on a private network can reach other hosts on the interneti.e., public network.

PAT allows NAT to support more hosts. With PAT, the port numberwhich is a logical address in a computer system, recognized in the Transport layer of the OSI model that indicates where applications communicate to the entire system from is attached to the address that has been translated by the NAT router, making this address very unique.

For example, if an HTTP request is coming from two different hosts, the addresses of these hosts can be managed like this: the private IP of each host can be attached to the same public IP, and the port address of the communicating application can be attached as well.

With this setup, a very unique identifier is created for each host on that network, and the server doesn’t really care if it has multiple connections to the same host or a single connection to different host’s IP addresses. There are about 65,000 port numbers available for use by this PAT technique.

In summary, NAT and PAT do the following:

  • Translate a Private IP to a public one (NAT)
  • Overload NAT with port numbers (PAT)
  • Generally, they increase the number of hosts that can connect to the internet with limited registered public IP addresses