English version
A VPC is the network boundary where many AWS resources live. If IAM answers “who can do what,” VPC answers “where does the resource live and how can traffic move?”
The Velog note describes VPC as a virtual data center in AWS. That is a useful beginner model, as long as we remember that a VPC is specifically a logically isolated virtual network, not a complete data center replacement by itself.
VPC and CIDR
When you create a VPC, you choose an IP address range. For IPv4 VPC CIDR blocks, AWS allows ranges such as /16 through /28, depending on the configuration. A /16 range is larger, while a /28 range is much smaller.
The CIDR decision matters because it affects how many private IP addresses the VPC can hold and how easily the network can be split into subnets later.
A common design mistake is choosing a range that overlaps with an on-premises network or another VPC that later needs peering or VPN connectivity. Plan the address space before creating production networks.
Subnets and Availability Zones
A subnet is a slice of a VPC CIDR range. In AWS, each subnet exists in one Availability Zone. A subnet does not span multiple Availability Zones.
This is important for high availability. If an application should survive an Availability Zone failure, place resources across multiple subnets in multiple zones.
A public subnet and a private subnet are not different resource types. They are usually distinguished by routing:
- Public subnet: has a route to an Internet Gateway.
- Private subnet: does not have a direct route to an Internet Gateway.
Resources in a private subnet can still reach the internet for updates or external APIs through a NAT gateway or NAT instance, depending on the design.
Route tables
A route table controls where network traffic goes. Subnets are associated with route tables, and those route tables decide the next hop for destination ranges.
For example:
10.0.0.0/16 local
0.0.0.0/0 internet-gateway
The local route lets resources inside the VPC communicate with each other. A default route to an Internet Gateway allows internet-bound traffic to leave through that gateway.
Internet Gateway
An Internet Gateway connects a VPC to the internet. To make an EC2 instance publicly reachable, several conditions usually need to line up:
- The VPC has an attached Internet Gateway.
- The subnet route table sends internet traffic to that gateway.
- The instance has a public IPv4 address or reachable IPv6 address.
- Security groups and network ACLs allow the traffic.
- The operating system firewall allows the traffic.
That is why “I put an instance in a public subnet” is not always enough. Routing, addressing, and security rules must all agree.
NAT Gateway
A NAT Gateway lets resources in a private subnet initiate outbound internet connections without exposing those resources directly to inbound internet traffic.
For availability, it is common to deploy NAT gateways per Availability Zone and route each private subnet to a NAT gateway in the same zone. This avoids sending all outbound traffic through one zone and reduces the blast radius if a zone has a problem.
NAT gateways cost money and process traffic, so they should be designed intentionally. For AWS service traffic, VPC endpoints can sometimes reduce the need to route through NAT.
VPN, Direct Connect, and Route 53
VPC can connect to other networks in several ways. A Site-to-Site VPN can connect an on-premises network to a VPC through encrypted tunnels. Direct Connect provides private dedicated connectivity into AWS. Route 53 provides managed DNS and can be part of public or private name resolution design.
These are separate services, but they often show up together when a VPC is used as the network foundation for production infrastructure.
Korean notes
VPC는 AWS resource가 놓이는 network boundary다. IAM이 “누가 무엇을 할 수 있는가”를 다룬다면, VPC는 “resource가 어디에 있고 traffic이 어떻게 이동하는가”를 다룬다.
Velog 원본에서는 VPC를 AWS cloud 위에 만드는 virtual data center라고 정리했다. 입문용으로는 괜찮은 표현이지만, 더 정확히는 AWS 안의 logically isolated virtual network라고 보는 게 맞다.
VPC와 CIDR
VPC를 만들 때 IP address range를 선택한다. IPv4 VPC CIDR block은 설정에 따라 /16부터 /28 같은 범위를 사용할 수 있다. /16은 큰 network이고, /28은 작은 network다.
CIDR 선택은 private IP 수와 subnet 분리 방식에 영향을 준다. Production에서는 나중에 VPC peering, VPN, Direct Connect로 다른 network와 연결할 수 있으므로 address range가 겹치지 않게 설계해야 한다.
Subnet과 Availability Zone
Subnet은 VPC CIDR range를 나눈 것이다. AWS에서 subnet은 하나의 Availability Zone 안에 존재한다. 하나의 subnet이 여러 AZ에 걸쳐 존재하지 않는다.
그래서 고가용성이 필요하면 여러 AZ에 subnet을 만들고 resource를 분산해야 한다.
Public subnet과 private subnet은 별도의 resource type이라기보다 route table 차이로 나뉜다.
- Public subnet: Internet Gateway로 향하는 route가 있다.
- Private subnet: Internet Gateway로 직접 나가는 route가 없다.
Private subnet 안의 resource도 NAT Gateway나 NAT instance를 통해 outbound internet access를 가질 수 있다.
Route table
Route table은 network traffic이 어디로 갈지 정한다. Subnet은 route table과 연결되고, route table은 destination range에 대한 next hop을 결정한다.
예를 들어 이런 구조다.
10.0.0.0/16 local
0.0.0.0/0 internet-gateway
local route는 VPC 내부 통신을 의미하고, 0.0.0.0/0 route는 모든 IPv4 destination에 대한 default route다.
Internet Gateway
Internet Gateway는 VPC와 internet을 연결한다. EC2 instance를 public하게 접근 가능하게 만들려면 보통 여러 조건이 같이 맞아야 한다.
- VPC에 Internet Gateway가 attached 되어 있다.
- Subnet route table이 internet traffic을 Internet Gateway로 보낸다.
- Instance에 public IPv4 또는 접근 가능한 IPv6 주소가 있다.
- Security group과 network ACL이 traffic을 허용한다.
- OS firewall도 traffic을 허용한다.
그래서 public subnet에 instance를 넣었다고 해서 항상 바로 접근되는 것은 아니다. Routing, addressing, security rule이 모두 맞아야 한다.
NAT Gateway
NAT Gateway는 private subnet의 resource가 outbound internet connection을 시작할 수 있게 해준다. 하지만 inbound internet traffic이 private resource로 직접 들어오는 구조는 아니다.
Availability를 고려하면 AZ별로 NAT Gateway를 만들고, 각 private subnet이 같은 AZ의 NAT Gateway를 사용하도록 routing하는 설계가 흔하다. 이렇게 하면 한 AZ 문제로 전체 outbound traffic이 영향을 받는 범위를 줄일 수 있다.
NAT Gateway는 비용과 traffic 처리량을 고려해야 한다. AWS service로 향하는 traffic은 VPC endpoint로 대체할 수 있는 경우도 있다.
VPN, Direct Connect, Route 53
VPC는 다른 network와 연결될 수 있다. Site-to-Site VPN은 on-premises network와 VPC를 encrypted tunnel로 연결한다. Direct Connect는 AWS로 private dedicated connectivity를 제공한다. Route 53은 managed DNS 서비스로 public/private name resolution 설계에 쓰인다.
Summary
VPC를 이해하려면 CIDR, subnet, route table, Internet Gateway, NAT Gateway를 같이 봐야 한다. Public/private subnet은 이름보다 route가 중요하고, production에서는 address overlap과 AZ별 routing까지 고려해야 한다.