An overview of the
Network Address Translation (NAT) : Installs the NAT software on the router that connects to the Internet on a private Network. The router that installs the NAT software is called a NAT router and has at least one valid external global IP Address. When forwarding data, the NAT router views and translates the port number of the transport layer
How NAT works
In the following figure, 172.38.1.5 is the external global IP address of the NAT
Now suppose A wants to send data to B so
Source IP address: 192.168.0.3, Destination IP address :213.18.2.4, port number :30000(Destination IP address resolved by the DNS server) When data is sent from A to the NAT router, the NAT router changes the source IP address to 172.38.1.5 and port number to: 40001, the NAT router forwards the data, because private IP addresses cannot appear on the public network
In turn, B is going to send data to A so
Source IP address: 213.18.2.4, destination IP address: 172.38.1.5, port number: 40002 When data is sent from B to THE NAT router, the NAT router changes the destination IP address to 192.168.0.3 and port number to 30000 according to the forwarding table. Then the NAT router sends the data to A
Pay attention to
A common router does not change the source AND destination IP addresses when forwarding IP packets, while a NAT router must change its IP address (translating the source or destination IP address) when forwarding IP packets.