NAT (Network Address Translation)
NAT allows multiple devices on a private network to share a single public IP address when accessing the internet. It was critical in extending IPv4’s lifespan.
How it works:
- Devices behind NAT have private IPs (e.g.,
192.168.1.10) - When they connect to the internet, the NAT router:
- Replaces the private source IP with its own public IP
- Assigns a unique source port for each connection
- Maintains a NAT table mapping
(private IP:port → public IP:port) - When response arrives, looks up the mapping and forwards to the correct internal device
| Type | Description |
|---|---|
| Static NAT | One-to-one mapping between private and public IP |
| Dynamic NAT | Pool of public IPs, assigned on demand |
| PAT (Port Address Translation) | Many private IPs → one public IP (most common) |
Security benefit: External hosts cannot initiate connections to devices behind NAT — the firewall blocks unsolicited inbound traffic.
ICMP (Internet Control Message Protocol)
ICMP is a Layer 3 protocol used for diagnostics and error reporting. It does NOT carry user data.
- Ping — sends ICMP Echo Request, receives Echo Reply. Measures RTT (Round Trip Time), packet loss.
- Traceroute — sends packets with incrementing TTL values. Each router that decrements TTL to 0 sends back an ICMP Time Exceeded message, revealing the path.
Common ICMP Messages
| Type | Code | Meaning |
|---|---|---|
| 0 | 0 | Echo Reply (ping response) |
| 3 | 0 | Destination Network Unreachable |
| 3 | 1 | Destination Host Unreachable |
| 8 | 0 | Echo Request (ping) |
| 11 | 0 | TTL Expired |
Q: How does NAT help with security?
A: Devices behind NAT have private IPs that are not directly reachable from the internet. An external attacker cannot initiate a connection to a NAT’d device — only responses to outbound requests are forwarded.
Q: What’s the difference between Ping and Traceroute?
A: Ping checks reachability by measuring RTT to a destination (ICMP Echo). Traceroute reveals the entire path by exploiting TTL — each router sends back ICMP Time Exceeded, one hop at a time.
Q: Does ICMP use TCP or UDP?
A: Neither. ICMP is a standalone Layer 3 protocol that sits directly on top of IP. It has its own protocol number (1).
Q: What is the difference between SNAT and DNAT?
A: SNAT (Source NAT) changes the source IP of outgoing packets — used for outbound internet access. DNAT (Destination NAT) changes the destination IP of incoming packets — used for port forwarding (e.g., exposing a web server behind NAT).
Premium Content
Unlock NAT & ICMP and all premium lessons with a subscription.
From ₹199.99/year — See plans