What is Network Address Translation
Network Address Translation (NAT) was born due to the fast depletion of public IP, appliance, and applications.
It was back in 1970’s when the researchers started thinking about how long the IP addresses should be? The reason for its importance is that in every data packet we have to encode the sender IP and the receiver IP.
The point which kept in mind while making the IP address was that if we only reserve a few bits to encode an IP address, we can keep packet size small; however, we will also have few IP addresses to send out to people. On the other hand, if we choose lots of bits to encode IP addresses we will have a lot of IP addresses to hand out to people, but also we will have huge packets which will increase the communication overhead. So it was a choice that had to be made of either having small packets or a lot of IP addresses. They ended up deciding they will go for 32bit IP address that left them with 4.2 Billion IP addresses. That is what today is known as IP version 4 (IPv4).
The problem with IPv4 was that with it we have 4.2 billion IP addresses to a handout, but we have 7 billion people living on the Planet as of 2012, and also each one of those 7 billion people may want to use multiple devices to access the internet.
What is the solution for this problem?
There is a fix for this problem that we can keep using IP version 4 and get more machines onto the internet, and that is why Network Address Translation (NAT) is. What it basically does is it Changes the Private IP address of the machine into the Public IP address. Different machines on the same network are given different IP addresses and when they reach to the router, the router translates these IP addresses into one public IP address and then forwards it to the internet.
To understand it more clearly let’s just take an example.
When the Packet is forwarded from the Computer it will have the source IP address of the computer 192.168.1.3 and destination IP of the Web server 220.127.116.11.
As soon as the packet reaches to the router, the router will change its source IP address to the public IP address as 18.104.22.168, and then it will forward it to the web server over the Cloud.
Moreover, the router will also build a NAT forwarding table in which public IP is assigned against to that private IP of the machine. This NAT table is helpful for forwarding the packet to the concerned machine when it will get a reply from the Web server which is 22.214.171.124.
When the packet will reach back to the router by bringing the information over the cloud this NAT table will again translate that Public IP address to the private IP address of that machine and will forward the information to it. Thus, by this way, multiple users can have multiple numbers of Local IP addresses, and they can get access to the internet against just one Public IP address. This way we can save a lot of public IP addresses, but a little overhead will be there on the router as it will be performing NAT along with the Routing.
To avoid this overhead IP version6 concept was introduced in 1998. This IPv6 can have 3.8x1038 IP addresses which are a lot of IPs. Till now IPv4 version is valid on the internet to all the devices on the service provider level, and customer level support IPv4 and it is a long time taking task to move them to IPv6.