It is known that public IPs (IPv4) are a limited and currently scarce resource, NAT aims to save public addressing space, using private IPs.
Public addresses are managed by a regulatory entity, are paid for, and allow a machine (PC, routers, etc.) to be uniquely identified on the Internet.
On the other hand, private addresses only make sense in a local domain and are not known (routable) on the Internet, meaning that a machine configured with a private IP will have to go out to the Internet through a public IP.
The translation of a private address into a public address is defined as NAT and is documented in RFC 1631.
There are 3 types of NAT
- Static NAT– A private address is translated into a public address.
- Dynamic NAT –There is a set of public addresses (pool), which machines using private addresses can use.
- NAT Overload (PAT) –This is certainly the most used technique. An example of PAT is when we have a public address and through it we can send several machines (1:N). This process is achieved since the equipment that performs PAT uses ports that uniquely identify each request from local machines (e.g.: 217.1.10.1:53221, 217.1.10.1:53220, etc) to the outside.
PAT is the technique present in most of the network equipment we use. Considering, for example, a Wi-Fi router, it is possible to connect/associate several clients to that equipment and they are configured (or acquired) a private address. However, they can all access the Internet through a single public address. As already mentioned, this is possible because the NAT technique uses logical ports to distinguish requests from internal machines. In practice, there are 65536 ports, however, as a rule, only dynamic ports are used (from 49152 to 65535).