DEV Community


Posted on

An Introductory Explanation of NAT and NAPT

What is NAT?

NAT stands for Network Address Transition. As the name suggests, NAT was developed to convert an IP address into a different one. NAT is mainly used to change a global IP into a private IP and vice versa. Let's take an example to understand how NAT works. Your PC has a private IP address (e.g., and it is usable only in a local network such as your home network. If you use an Windows PC, you should enter ipconfig on the command prompt to see the private IP assigned to your PC. When your PC attempts to access to the Internet, a global IP (e.g. 34.203.75.ZZZ) has to be assigned to it. This is where the NAT technique comes in. NAT assigns a global IP to your PC so that it can reach the Internet.

What problem does NAT have?

NAT is not a perfect solution to get Internet access. Imagine that your PC ( and tablet (192.168.1.YYY) attempt to get some data from the Internet at the same time. They have the same global IP on the Internet and it will be converted back into their each private IP by the router of your local network. Here is the problem. When the router tries to convert the global IP into a private IP, will the router convert it into the PC's private IP (192.168.1.XXX) or the tablet's private IP (192.168.1.YYY)? Since the global IP doesn't have information to distinguish your PC and table, the question is impossible to answer. Given this factor, NAT can not let multiple devices access the Internet simultaneously.

What is NAPT?

NAPT technique can solve the aforementioned problem. In addition to an IP address, NAPT also converts a port number. As I said above, you can not distinguish your PC and tablet only from the global IP. However, if different port numbers are assigned to your PC and tablet, let's say... 192.168.1.XXX:10000 => 34.203.75.ZZZ:20000 (PC) and 192.168.1.YYY:10000 => 34.203.75.ZZZ:30000 (tablet), the router can clearly distinguish your PC and table, which makes it possible to let multiple devices reach the Internet simultaneously.

Discussion (0)