AWS TCET

Learn/Networking

Networking · 16 min read · August 2026

VPC Sketch: Subnets, Routes, and a Public Web App

A minimal Amazon VPC you can redraw from memory: CIDR, public/private subnets, IGW, NAT, and security groups — from the VPC User Guide.

Source. Amazon VPC User Guide · Security groups vs network ACLs · VPC fundamentals

Abstract & theoretical context

A VPC is your isolated network in a Region. You pick an IPv4 CIDR (often 10.0.0.0/16). Subnets slice that CIDR into AZ-bound ranges. A route table decides where packets go: local, internet gateway (public), or NAT gateway (private egress). Security groups are stateful instance-level firewalls; NACLs are stateless subnet-level filters. AWS's default VPC is convenient and dangerous for learning — you should be able to build a two-AZ public/private layout by hand. This is that layout, as the docs describe it.

Models, formulas & variables

  1. 1. Public subnet test

    public ⇔ route 0.0.0.0/0 → igw-… and instance has a public IPv4 (or EIP)

    • — A subnet is not public because you named it Public. The route table is the truth.
    • — Private subnets reach the internet through NAT in a public subnet, not through an IGW on the instance.
  2. 2. Security group vs NACL

    SG = stateful allow-list on ENI; NACL = stateless numbered rules on subnet

    • — If you allow inbound 443 on a SG, return traffic is allowed automatically.
    • — NACLs need both inbound and outbound rules. Students forget ephemeral ports.

Reference implementation

Copy into a sandbox account. Pin Region ap-south-1 unless the lab says otherwise.

sg-web.json

Security group ingress · JSON

{
  "IpPermissions": [
    {
      "IpProtocol": "tcp",
      "FromPort": 443,
      "ToPort": 443,
      "IpRanges": [{ "CidrIp": "0.0.0.0/0", "Description": "HTTPS from internet (lab only)" }]
    }
  ]
}
# Pair with: SSH 22 only from your IP, never 0.0.0.0/0, in any real account.

Lab procedure

  1. 01Draw 10.0.0.0/16, two public /24s in two AZs, two private /24s, IGW, NAT, and two route tables.
  2. 02Create the VPC in the console or CLI and attach an internet gateway.
  3. 03Place a test instance in a public subnet with a public IP and a tight SSH security group.
  4. 04Place nothing with a database port in a public subnet.
  5. 05Delete NAT gateways after the lab — they bill by hour.

Key insights

  • Default security group + 0.0.0.0/0 SSH is how campus accounts get mined overnight.
  • Interface endpoints (PrivateLink) keep AWS API traffic off the public internet when you outgrow NAT.
  • IPv6 is optional in labs; dual-stack is a later module, not a first-week surprise.

Account & lab requirements

ec2:CreateVpc permissions. NAT Gateway hourly cost — use a single AZ NAT only while the lab is running.

More in Networking