Understanding NAT and IPv4 Limitations

Aug 8, 2024

Lecture Notes: Network Address Translation (NAT) and IPv4 Limitations

Introduction to IPv4 Limitations

  • 20 billion+ devices on the internet.
  • IPv4 supports only 4.29 billion addresses.
  • IPv4 address space is exhausted; obtaining a new public IPv4 address is difficult.

Network Address Translation (NAT)

  • NAT is used to increase the number of available devices using limited IP addresses.
  • Private IP addresses are used within local networks.

RFC 1918: Private IP Address Ranges

  • Defines specific private IP address ranges:
    • 10.0.0.0 - 10.255.255.255
    • 172.16.0.0 - 172.31.255.255
    • 192.168.0.0 - 192.168.255.255
  • Devices within these ranges use private IP addresses (RFC 1918 IP addresses).

How NAT Works

  • Translation of IP addresses occurs as devices communicate through the network.
  • Routers commonly perform this translation.

Example Scenario

  • Private network: 10.10.20.0/24 (Example: Vala's device at 10.10.20.50).
  • Public IP address: Used for communication with an external server (e.g., professormesser.com at 104.20.19.63).
  • Translation Process:
    • Vala sends a packet with source IP 10.10.20.50 to public IP 104.20.19.63.
    • Router recognizes and translates private IP to a configured public IP.
    • Destination server reverses the IP addresses for return communication.
    • Router translates back to the internal private IP before sending to Vala.

NAT for Multiple Devices

  • Source Network Address Translation (Source NAT), NAT Overload, or Port Address Translation (PAT) used for multiple devices.

Scenario with Multiple Devices

  • Port numbers are included in the IP address translation.
  • Example: Vala's device uses source port 3233 to communicate with port 80 on the server.
  • Router's Role:
    • Changes both IP address and port number.
    • Maintains a table mapping private IP and port to public IP and port.
    • Example: Translates to public IP 94.1.1.1 with port 1055.
    • Returns traffic by looking up the port and translating it back to the internal private IP and port.

Conclusion

  • Millions of NAT operations occur daily across routers on the internet.
  • Home and business routers commonly perform NAT overload or PAT for network communication.