An overview of the content of the article

Network address translation (NAT) is used because there are not enough IP addresses

  • IPv4 has a maximum of 4 + billion IP addresses (which, if used properly, is generally not enough)
  • Incorrect IP address planning causes IP number waste

As mentioned in the previous article, the edge of the network is the home network, with terminals, routers, gateways, and local ISPs

In fact, many families only have “one” extranet IP address. So, how do many Intranet devices communicate?

Because we know that the network layer needs a unique IP address for communication. At this time, if a family has only one IP address, how can so many terminal devices connect to the Internet? This problem needs to be solved

In addition to the home, there are many times when IP addresses are not enough for companies to support so many terminal devices in the company (mobile phones, laptops, routers, etc. They all need a unique IP address). So how do so many of the company’s devices connect to the Internet?

Internal and external IP addresses

IP addresses can be classified into two types: internal address and External address.

A network address

  • Internal organization use (for example, laptops, mobile phones, ipads, etc., all use Intranet addresses)
  • Avoid the same external address

Outside the web address

  • Used worldwide (only in the world)
  • Unique in global public network

A network address

  • Intranet addresses can also be classified into three types (A, B, and C).
  • 10.0.0.0 to 10.255.255.255(Supporting tens of millions of devices)
  • 172.16.0.0 to 172.31.255.255(millions of devices supported)
  • 192.168.0.0 to 192.168.255.255(support tens of thousands of devices)

Because Intranet addresses are mainly used by internal organizations, the Intranet addresses of company A and company B can be the same. Similarly, for different families, their Intranet addresses can be the same without causing conflicts

For a company, it can use globally unique extranet IP addresses externally, but Intranet addresses internally (the same goes for homes). That would solve the problem,Problems connecting different devices to the Internet

In this way, each device is assigned an IP address, but using an Intranet address raises another problem: “Multiple devices on the Intranet use the same IP address to request services from the Internet. How can the Internet know which device is requesting services from the Internet?”

To do this, you need to use the “Network address translation NAT technology” introduced in this article.

Network address translation (NAT)

  • Network Address Translation (NAT)
  • The NAT technology is used to allow multiple hosts to access the Private network of the Internet through one public IP address
  • NAT slows down the consumption of IP addresses but increases the complexity of network communication

How does NAT technology solve this problem

Suppose you have a computer and a mobile phone connected to an external network through a router. Suppose the external IP address is 173.21.59.10. The IP addresses of the two internal terminals are 192.168.2.10 and 192.168.2.11

Before introducing NAT technology to solve the above problems, you need to understand the concept of “ports”.

A port is a concept when each process makes a network request. “A port can specify which process of a certain device is using the network”. With the concept of ports, you can understand NAT technology

If 192.168.2.11:6666 is using the network, it will send network packets with the following address: 192.168.2.11:6666, but this address will be replaced with a new IP address and port number when it comes to the router. The new IP address is 173.21.59.10, assuming the new port is 16666. Through the router, the data that was just sent is sent to the network with the new address and port number. On the destination computer, it recognizes the new IP address and port number and does not recognize the old IP address and port number because the IP address and port have been replaced in the router. So the outside is actually communicating with 173.21.59.10

When the destination computer finishes processing the data, it will send the result to 173.21.59.10:16666. After receiving the data, the router will conduct an address and port conversion again, so that the internal device will also obtain the requested data

Therefore, NAT technology is actually the network request of Intranet IP address, in theLocal routerAn IP address and port conversion is performed internally, and when the return result is received, the IP address and port are converted back and sent to the requesting device. The table that I’m mapping is calledNA (P) T table

In fact, this technology is very common. For example, when we install virtual machines on the local computer and communicate with them, NAT technology is used for communication

It is the core competitiveness of a technician to seek invariance in the rapidly changing technology. Unity of knowledge and practice, theory and practice