Virtual Private Cloud (VPC) Basics

IP Subnetting

Subnetting – Key Concepts
Subnetting Process Step by Step
Designing Business Networks and IP Plans

Building a reliable infrastructure platform depends as much on strong design decisions as it does on technical implementation.

Considerations when Designing Business Networks

VPC Sizing and Structuring – Concepts

VPC Size (CIDR)

VPC Structure (Subnets)

VPC Sizing and Structuring – Example

VPC Sizing & Structuring – Considerations
VPC Design for A4L Scenario

Amazon VPC (Virtual Private Cloud) 101

Amazon VPC – Core Concepts
Default VPC

Custom VPCs

Amazon VPC – Refresher
Amazon VPC – Custom VPCs
Custom VPC IP Addressing (Quotas)

IPv4

IPv6

DNS in VPCs
Demo: Custom VPC Design (Course Scenario)

VPC Subnets & DHCP Options Set

VPC Subnets – Core Concepts
VPC Subnets – IP Addressing
DHCP Options Set

Network Address Translation (NAT)

NAT – Core Concepts
Types of NAT

Static NAT

Dynamic NAT

Port Address Translation (PAT)

(also known as IP masquerading or NAT overload)

VPC Routing, Internet Gateway & Bastion Hosts

VPC Router

VPC Route Table (RT)

Internet Gateway (IGW)

IPv4 Behavior with IGW

IPv6 Behavior

Bastion Host / Jump Box

NAT Gateways & NAT Instances

Common Scenario: Updating Private EC2 Instances
  1. Convert the subnet to public
    • Allows direct internet access for instances
    • Drawback: breaks standard secure multi-tier architecture design, where private subnets are intentionally isolated
  2. Maintain internal update servers
    • Host patch repositories within the VPC
    • Drawback: introduces operational overhead
      • Requires manually downloading updates and distributing them internally
  3. Recommended approach: use NAT (Network Address Translation)
    • Enables private instances to access the internet without becoming publicly accessible
    • Deployment options:
      • NAT Instance (self-managed EC2)
      • NAT Gateway (NATGW) (AWS-managed service)
Refresher: Network Address Translation (NAT)

NAT Types

  1. Static NAT
    • One private IP maps to one public IP
    • Used by Internet Gateway (IGW)
  2. Dynamic NAT
    • Multiple private IPs share a pool of public IPs
  3. Port Address Translation (PAT)
    • Many private IPs share a single public IP
    • Differentiation handled via port numbers
    • Also known as IP masquerading
    • Most commonly used form of NAT in practice
NAT Architecture in a VPC

Traffic Flow

  1. Private subnet sends traffic to NATGW
    • Route table default route (0.0.0.0/0) points to NATGW
    • NATGW records sessions in a translation table
  2. NATGW modifies source IP
    • Replaces private IP with its own private IP
  3. Traffic is forwarded to Internet Gateway (IGW)
    • Via the VPC router
  4. IGW performs final translation
    • Replaces NATGW private IP with a public IP
  5. Return traffic follows reverse path
    • IGW → NATGW → private instance
NAT Gateway (NATGW) – Key Concepts

Characteristics

Limitations

Billing Model

NAT Instances

Special Configuration

NAT Instances vs NAT Gateway

Why NAT Gateway is the default choice

When NAT Instances may be preferred

  1. Cost considerations
    • Lower cost for:
      • Small environments
      • Low traffic workloads
    • Can use small or free-tier instances
    • Predictable pricing (fixed instance size)
  2. Multi-purpose usage
    • Can act as:
      • Bastion host
      • Port forwarding device
    • NATGW cannot be customized
  3. Security flexibility
    • Supports Security Groups and NACLs
    • NATGW supports only NACLs
IPv6 Considerations

Connectivity Options

Stateless vs Stateful Firewalls

TCP Connections, Ports, and Direction
Stateless Firewall
Stateful Firewall

Network Access Control Lists (NACLs)

VPC NACL – Key Concepts
NACL Rules
NACL Types

Default NACL

Custom NACL

Security Groups (SGs)

VPC Security Group (SG) – Key Concepts
VPC SG – Logical References
SG Self-References

Advanced VPC Networking

VPC Flow Logs
Flow Log Records

Egress-Only Internet Gateway (EIGW)

Differences Between IPv4 and IPv6 in AWS

Network Address Translation (NAT) for IPv4

Egress-Only Internet Gateway (EIGW)

VPC Endpoints (VPCEs) – Gateway & Interface Types

VPC Endpoints (VPCEs)
VPC Gateway Endpoints (GWEs)
Comparison: Access to S3 With and Without GWE

Without GWE

With GWE

VPC Interface Endpoints (IEs)
Comparison: Access to SNS With and Without IE

Without IE

Without IE (without private DNS)

With IE (with private DNS)

Comparison: Gateway Endpoints vs Interface Endpoints
Gateway Endpoint (GWE)Interface Endpoint (IE)
Implemented as a gateway resource within the VPCImplemented as an Elastic Network Interface (ENI) inside a subnet
Used specifically for S3 and DynamoDB servicesUsed for most AWS public services except DynamoDB
Supports both IPv4 and IPv6, along with TCP and UDP protocolsSupports only IPv4 and TCP
Highly available across the region by defaultRequires one endpoint per Availability Zone to achieve high availability
Does not support Security Groups for controlling trafficSupports Security Groups for network access control
Does not rely on PrivateLinkBuilt on AWS PrivateLink technology
Access is controlled via route tables (prefix lists added to routes)Accessed through DNS resolution within the VPC (assigned a private IPv4 address)
No changes needed in application configurationMay require application updates depending on DNS setup (unless Private DNS is used)
Cannot be used for cross-region access to S3 or DynamoDBCan be used to access services across different regions
DEMO: VPCEs (IE, GWE) and EIGW
PART 1: Create a VPC Interface Endpoint (IE) to use Instance Connect on a private EC2 instance
  1. EC2 instance is in private subnet sn-app-A. By default, we cannot connect via Instance Connect since it has no public IP.
  2. Create a VPC IE in sn-app-A via:
    • Instance Connect UI → “EC2 Instance Connect Endpoint”
    • Or directly via VPC → Endpoints
    • Option: Preserve Client IP
      • Enabled → instance sees your machine’s IP
      • Disabled → instance sees the IP of the endpoint’s ENI
  3. Once the endpoint is created, Instance Connect can access the private instance.
    • If client IP is not preserved, the instance shows the endpoint ENI IP in the last login info.
PART 2: Create a VPC Gateway Endpoint (GWE) to access S3 privately
  1. Private instance in sn-app-A cannot access the public internet or S3.
    • ping 1.1.1.1 fails
    • aws s3 ls shows nothing
  2. Create a GWE for S3:
    • VPC → Endpoints → Create Endpoint → Type: AWS Services → filter by s3 → Gateway type
    • Select the main route tables for private subnets (sn-app-A)

3. Once the GWE is created, private instance can access S3:

4. Instance remains private: ping 1.1.1.1 still fails

PART 3: Create an Egress-only Internet Gateway (EIGW) for a private IPv6 instance
  1. EC2 instance in sn-app-A has an IPv6 address but cannot reach the internet
    • ping -6 ipv6.google.com fails
  2. Create an EIGW:
    • VPC → Egress-only Internet Gateway → Create → Attach to A4L-VPC
  3. Update the Route Table for main subnets:

4. Verify IPv6 connectivity:

5. Optional test: confirm another EC2 instance in a different VPC cannot ping this IPv6 instance.

VPC Peering

VPC Peering – Concepts and Features
DEMO: Peering 3 VPCs
  1. Start with three private VPCs, one EC2 instance in each.
    • Connect via Session Manager to EC2 in VPCA
  2. Ping instance in VPCB → no response (private VPCs by default)
  3. Create peering between VPCA and VPCB
    • VPC → Peering connections → Create → VPCA as sender, VPCB as accepter
    • Invitation model: accepter must accept the request
    • Peering remains in Pending state until accepted
  4. Update Route Tables in both VPCA and VPCB
    • Add route → destination = other VPC’s CIDR → target = peering object
  5. Update Security Groups
    • Add inbound rules to allow ICMP/IPv4 traffic from the other VPC’s SG
  6. Ping between VPCA and VPCB instances should now succeed
  7. Repeat steps 3–6 to create peering between VPCB and VPCC
  8. Attempt A → C ping → fails
    • VPC peering is not transitive; a direct peering between VPCA and VPCC is required
  9. Create peering between VPCA and VPCC
    • Ping from VPCA to VPCC now works

Route 53 – Global DNS

Amazon R53 (Route 53) 101

Amazon Route 53 (R53) – Key Concepts
R53 Registered Domains

Domain registration workflow (e.g., animals4life.org):

  1. Check if domain is available
  2. Accept terms and purchase the domain
  3. R53 creates a ZoneFile (database storing DNS info)
  4. R53 allocates four AWS-managed name servers (NSs) for this domain
  5. Creates a hosted zone with the ZoneFile, storing it on the four NSs
  6. R53 communicates with the TLD (e.g., PIR)
    • TLD NS records point to R53’s four servers → these become authoritative
R53 Hosted Zones

Network visibility types:

  1. Public Hosted Zones – accessible from the internet
  2. Private Hosted Zones – linked to one or more VPCs, only accessible from those VPCs

Billing:

R53 Public and Private Hosted Zones

R53 Public Hosted Zone
R53 Private Hosted Zone
Split-View (Split-Horizon) DNS

CNAME Records vs R53 Alias Records

Limitations of CNAME Records
Route 53 Alias Records

Key guideline:

Use CNAME for subdomains. Use Alias records for apex/naked domains or when pointing to AWS-managed services.

R53 Simple Routing Policy

Route 53 Routing Policies Overview
Route 53 Simple Routing

R53 Health Checks

Route 53 Health Checks Overview
Endpoint Health Checks – Configuration

Basic options:

Advanced options:

Health Check Notifications

R53 Failover Routing Policy

Route 53 Failover Routing – Architecture

This architecture ensures minimal downtime and transparent failover at the DNS level.