‫So the private addressing scheme works really well for computers that only have you access resources
‫inside the network, like workstations needing access to file servers and printers and so forth.
‫Routers inside the private network and route traffic between private addresses with no trouble whatsoever,
‫however, to access resources outside the network like the internet, for example.
‫These computers need to have a public address so that responses to their requests were returned to them.
‫Now this is where Nat comes into play.
‫A workstation inside a private network makes a request to a computer on the internet.
‫The switches or the routers within the network recognized that the request is not for a resource inside
‫the network, so they send the request to the router.
‫Let's say the backbone router.
‫Now, the Backbone routers sees the request from the computer with the internal IP.
‫It then makes the same request to the internet using its own public address and returns, a response
‫from the internet resource to the computer inside the private network.
‫From the perspective of the resource on the internet, it's sending information to the address of the
‫router.
‫From the perspective of the workstation, it appears that the communication is directly with the site
‫on the internet.
‫So when that is used like this, all users inside the private network that access the internet have
‫the same public IP address.
‫So that means only one public address is needed for hundreds or even thousands of users.
‫So let's have a look and see how it works.
‫Here's a typical home network.
‫There's a laptop, desktop PC smartphone all connected to our home router, and a home router is, of
‫course, connected to the internet.
‫So when we register with our ISP, the internet service provider, we get an IP address that is accessible
‫throughout the internet and that's pretty much assigned to that home router.
‫We refer to it as real IP or public IP.
‫Now suppose that the IP address to 0.2 0.2 zero two zero is assigned to our home router.
‫Our devices inside the home network also have IP addresses, right?
‫But in this case, they get private IP addresses, which are assigned by the home router and are not
‫accessible from the internet.
‫So as you can see here, the public IP addresses are red and the private IP addresses are green.
‫So let's consider a connection request from the smartphone, which requests the home page of ABC.com.
‫So to reach the page, the smartphone has to go through the home router.
‫The packet as the source IP address and the source port address, as well as the destination IP address
‫and the destination port.
‫If it arrives at the Web server with these values, it processes the request and tries to send the reply
‫packet to the IP address one nine two two eight one six eight, not 1.5 but that's unreachable for the
‫web server because it's a private IP address.
‫So when the package arrives at the home router, instead of sending the packet right over the internet,
‫the home router changes this source IP address with its very own public IP address.
‫It also creates a record in the net forwarding table.
‫This table allows us to know which packets will be redirected to the smartphone when they come in.
‫So moving right along the packet travels over the internet and arrives at the web server.
‫The Web server creates a reply packet where the source IP address is itself and the destination IP address
‫is the public IP address of the home router.
‫When our home router receives a response, it looks at the net forwarding table and replaces the destination
‫IP and the port, according to the mapping inside the table.
‫And finally, the smartphone receives the packet.
‫Pretty cool, huh?