[Day 12] 3. NAT (Network Address Translation)
- Definition: NAT is the method where the source or destination IP address and/or port number of a packet is modified as it travels through a router or firewall.
- Purpose:
- To hide internal private IP addresses behind a public IP.
- To allow multiple devices to share a single public IP address for accessing the internet.
- To redirect traffic for specific services.
Types of NAT
SNAT vs. DNAT
-
Source NAT (SNAT):
- Function: Modifies the source IP address in the packet.
- Use Case: Common for outbound traffic from private networks to the internet.
- Example: Changing a private IP () to a public IP (
192.168.1.10).203.0.113.1
-
Destination NAT (DNAT):
- Function: Modifies the destination IP address in the packet.
- Use Case: Redirects inbound traffic to specific servers within a private network.
- Example: Redirecting traffic from a public IP () on port
203.0.113.1to a private IP (80).192.168.1.20
Static NAT vs. Dynamic NAT
-
Static NAT:
- Function: Maps a single private IP to a single public IP.
- Characteristics: The mapping is constant.
- Use Case: Hosting servers or services that need consistent access.
- Example: Server () always mapped to public IP (
192.168.1.10).203.0.113.10
-
Dynamic NAT:
- Function: Maps multiple private IPs to a pool of public IPs.
- Characteristics: The mapping is dynamic.
- Use Case: Situations with limited public IP addresses.
- Example: Devices (,
192.168.1.10) dynamically assigned public IPs (192.168.1.11,203.0.113.10).203.0.113.11
Clarifications
-
SNAT vs. Static NAT:
- SNAT: Modifies the source address in packets.
- Static NAT: One-to-one, permanent mapping of internal to external IP.
-
DNAT vs. Dynamic NAT:
- DNAT: Modifies the destination address in packets.
- Dynamic NAT: Dynamically maps private IPs to a pool of public IPs, not necessarily involving destination address changes.
Key Differences
|Feature|SNAT (Source NAT)|DNAT (Destination NAT)|Static NAT|Dynamic NAT| |---|---|---|---|---| |Focus|Changes the source IP|Changes the destination IP|Maps private to public IP|Dynamically maps private IPs| |Type|One-to-many or many-to-one|Many-to-one or one-to-one|One-to-one|Many-to-many or many-to-one| |Use Case|Outbound traffic|Inbound traffic|Hosting servers|Internet access sharing| |Consistency|Can be dynamic|Can be dynamic|Fixed mapping|Dynamic mapping|
Read Next
[Day 12] Extra
### **Cryptocurrency** - **Definition**: Cryptocurrency is a digital or virtual currency secured by cryptography, making it nearly impossible to co...
[Day 1] 1. Overview and Revision
### **Purpose of the Lab** - **Goal:** Improve troubleshooting skills. No spoon-feeding will be entertained. - **Important Guidelines:** 1. U...