Network Address Translation (NAT) Preview
What you'll learn: How private subnets connect to the internet without exposing their internal IP addresses.
The Private Subnet Problem
Remember from earlier lessons that private subnets contain resources with RFC 1918 IP addresses (like 10.0.1.5 or 192.168.1.10). These addresses aren't routable on the public internet—they're only valid within your virtual network. So how do instances in private subnets download updates, call external APIs, or access internet resources without being directly accessible from the outside world?
What is NAT?
Network Address Translation (NAT) acts as a middleman between your private resources and the internet. Think of it like a corporate mail room: employees (private instances) send outgoing letters with their desk number (private IP), but the mail room replaces that with the company's street address (public IP) before sending. Replies come back to the company address, and the mail room routes them to the correct desk.
How NAT Enables Internet Access
When an instance in a private subnet needs to reach the internet:
- It sends traffic to a NAT device (like a NAT Gateway)
- The NAT device translates the source private IP to its own public IP
- The internet destination sees only the NAT device's public IP
- Return traffic flows back through the NAT device to the original instance
The key benefit: your private instances can initiate outbound connections, but the internet cannot initiate inbound connections to them—they remain protected.
Key Takeaway: NAT allows resources in private subnets to access the internet for outbound traffic while keeping their private IP addresses hidden and preventing unsolicited inbound connections.