Chapter 5

Network Address Translation (NAT)

By Nikhila Sattala
15 mins read

NAT is a technique used in networking to allow multiple devices on a local network to share a single public IP address. It is commonly used in home and office networks to conserve public IP addresses and enhance security. Here's an elaborate example to explain NAT

Scenario
Imagine you have a home network with several devices, including computers, smartphones, and a smart TV. Your Internet Service Provider (ISP) has assigned you a single public IP address (let's say 203.0.113.1). Without NAT, only one device could use this public IP address at a time, severely limiting your network's functionality.

Internal Private Addresses: Inside your home network, each device is assigned a private IP address. These addresses are not routable on the public internet and are typically from reserved address ranges like 192.168.0.0/16 or 10.0.0.0/8. For example, your computer might have the address 192.168.0.2.

Outgoing Request: When a device in your network, such as your computer, wants to access a website like www.example.com, it creates a request packet. This packet includes your private IP address (e.g., 192.168.0.2) as the source address and the website's IP address as the destination (e.g., 198.51.100.1).

NAT Router: Your home router, which has both a private and a public IP address, intercepts the outgoing packet from your computer.

Source Address Translation: The NAT router changes the source IP address of the packet from your computer's private IP address (e.g., 192.168.0.2) to its own public IP address (e.g., 203.0.113.1). It also keeps a record of this translation in a NAT table.

Outgoing to the Internet: The router sends the modified packet out to the internet with the router's public IP address as the source.

Response from the Internet: When the response packet arrives from the internet (e.g., www.example.com responds), it has a destination IP address of your router's public IP (203.0.113.1).

Destination Address Translation: Your router, using its NAT table, knows that the incoming packet is meant for your computer (192.168.0.2). It translates the destination IP address back to the original private IP address (192.168.0.2) and forwards the packet to your computer.

Result

  • Your computer can access websites and services on the internet using the same public IP address.
  • Multiple devices in your home network can share the same public IP address simultaneously.
  • The NAT router keeps track of translations in its NAT table, allowing it to route responses to the correct internal devices.