Here’s a detailed explanation of how NAT (Network Address Translation) works. It processes the translation between private and public IP addresses. This includes a step-by-step transformation of the data packet. The explanation also shows how routers handle this communication. Visit the diagram of NAT from Private IP to Public IP.
Table of Contents
🔁 NAT Translation Process: Private to Public IP
Scenario:
- A device on a private network (e.g.,
192.168.1.100
) wants to access a website on the internet (e.g.,www.example.com
with IP93.184.216.34
). - The router has a public IP address (e.g.,
203.0.113.5
).
📦 Step-by-Step NAT Translation (Outbound Request)
✅ 1. Device Sends a Request
- Source IP:
192.168.1.100
(Private IP of device) - Destination IP:
93.184.216.34
(Public IP of website) - Source Port: e.g.,
45000
- Destination Port:
80
(HTTP)
Packet Before NAT (LAN side):
SRC IP: 192.168.1.100:45000
DST IP: 93.184.216.34:80
🔁 2. Router Performs NAT Translation
- The router looks at its NAT table or creates a new entry.
- It replaces the source IP and port with its public IP and a unique port number (e.g.,
203.0.113.5:62001
).
Packet After NAT (WAN side):
SRC IP: 203.0.113.5:62001
DST IP: 93.184.216.34:80
➡ NAT Table Entry Created:
192.168.1.100:45000 → 203.0.113.5:62001
📥 Step-by-Step NAT Translation (Inbound Response)
✅ 3. Web Server Sends a Reply
- The server responds to
203.0.113.5:62001
Packet Received on Router:
SRC IP: 93.184.216.34:80
DST IP: 203.0.113.5:62001
🔁 4. Router Looks Up NAT Table
- Router checks the destination port (
62001
) and finds the corresponding internal IP and port.
➡ NAT Table Lookup:
203.0.113.5:62001 → 192.168.1.100:45000
📦 5. Router Rewrites the Packet
- The router changes the destination IP and port back to the internal device’s IP and original source port.
Final Packet Delivered to LAN:
SRC IP: 93.184.216.34:80
DST IP: 192.168.1.100:45000
🧠 Summary of the NAT Process:
Phase | Source IP:Port | Destination IP:Port | What Happens |
---|---|---|---|
Outbound (Before) | 192.168.1.100:45000 | 93.184.216.34:80 | Device sends request |
NAT Translation | 203.0.113.5:62001 | 93.184.216.34:80 | Router modifies source IP/port |
Inbound (Reply) | 93.184.216.34:80 | 203.0.113.5:62001 | Server replies to translated IP |
Reverse NAT | 93.184.216.34:80 | 192.168.1.100:45000 | Router rewrites and delivers packet |
NAT translation is a seamless process that allows private devices to communicate with the public internet by rewriting IP address and port information in real time. The router maintains a NAT table to track active connections and correctly routes return traffic. Whether using MikroTik, Cisco, or any other router, this translation process ensures efficient and secure use of public IP resources. You can also see the diagram or example commands for MikroTik or Cisco routers showing this process
Discover more from How To Kh
Subscribe to get the latest posts sent to your email.