Ravindra BagaleCourses & study guides मराठी Track your progress

Ravi Sir's Cards › AWS › VPC networking

AWS Cloud

AWS VPC networking: subnets, route tables, IGW, NAT and security

This page keeps the related VPC cards on one topic page, so you can revise the whole network in one sitting. It has the 13 VPC revision cards (VPC, CIDR, subnets, internet gateway, NAT, route tables, the 3-tier plan, and security groups versus NACLs) plus five close comparison cards.

Each card still has its image and its original text. Under each group you will also find a short Why, What, How example, and an exam tip, in easy English. The names, subnet labels and IP addresses in the stories are made up for learning.

VPC and CIDR basics

Why this matters

When you launch an EC2 instance or a database on AWS, it needs a private network. The VPC is that network. You decide the IP range, and you need to know how many addresses a range really gives you.

What it is

A VPC (Virtual Private Cloud) is your own logically isolated virtual network inside one AWS Region. You choose its IPv4 range, called a CIDR block. A common example, used on these cards, is ThreeTierVpc with CIDR 10.0.0.0/16. The VPC covers all Availability Zones in that Region. Each subnet inside it lives in exactly one AZ.

Every AWS account already has a default VPC in each Region, with CIDR 172.31.0.0/16, a /20 subnet in each AZ, and an internet gateway. A custom VPC is one you create yourself.

CIDR math is a power of two: total IPv4 addresses = 2 to the power of (32 minus the prefix). So /16 = 65,536, /20 = 4,096, and /24 = 256. In an AWS subnet, five of those addresses are reserved, so a /24 does not give you 256 usable IPs.

How it works — a real example

Suppose we are building a small shop website in Mumbai (ap-south-1) with ThreeTierVpc as 10.0.0.0/16. If we cut a subnet 10.0.0.0/20, AWS reserves 10.0.0.0 (network), 10.0.0.1 (VPC router), 10.0.0.2 (DNS), 10.0.0.3 (future use) and 10.0.15.255 (broadcast). The names and IP addresses are made up for learning.

Common mistake / exam tip

A VPC does not span more than one Region. Mumbai and Singapore need two VPCs. Do not delete the default VPC as "cleanup". If you delete it, a new instance may show no subnet. You can recreate it from Your VPCs → Actions → Create default VPC, but it is safer to leave it alone. And when an examiner asks how many IPs a /24 subnet has, subtract the five reserved addresses.

What is a VPC?

What is a VPC: your own private network inside one AWS Region, example ThreeTierVpc 10.0.0.0/16.
Card 1 of 13: What is a VPC? · Download PNG
Read card text

What this card says

What is a VPC: your own private network inside one AWS Region

Example

ThreeTierVpc 10.0.0.0/16

The default VPC

Default VPC: AWS makes one in every Region with CIDR 172.31.0.0/16, a /20 subnet in each AZ and an internet gateway.
Card 2 of 13: The default VPC · Download PNG
Read card text

What this card says

Default VPC: AWS makes one in every Region with CIDR 172.31.0.0/16, a /20 subnet in each AZ and an internet gateway.

CIDR math: how many IPs?

CIDR host count: total IPs = 2 to the power of (32 minus prefix); /16 = 65,536, /20 = 4,096, /24 = 256; AWS subnets lose 5.
Card 3 of 13: CIDR math: how many IPs? · Download PNG
Read card text

What this card says

CIDR host count: total IPs = 2 to the power of (32 minus prefix)

/16 = 65,536, /20 = 4,096, /24 = 256

AWS subnets lose 5.

The 5 reserved IPs in a subnet

AWS reserves 5 IPs in subnet 10.0.0.0/20: .0 network, .1 VPC router, .2 DNS, .3 future use, 10.0.15.255 broadcast.
Card 4 of 13: The 5 reserved IPs in a subnet · Download PNG
Read card text

What this card says

AWS reserves 5 IPs in subnet 10.0.0.0/20: .0 network, .1 VPC router, .2 DNS, .3 future use, 10.0.15.255 broadcast.

Subnets, gateways and routes

Why this matters

A VPC alone does not put your servers on the internet, and it does not keep a database private. Routes and gateways do that work.

What it is

An internet gateway (IGW) is attached to the VPC, one per VPC. A route table decides where traffic goes next. The local route (for example 10.0.0.0/16) is always there, so subnets in the same VPC can talk to each other. A public subnet is a subnet whose route table has 0.0.0.0/0 pointing to the internet gateway. A private subnet does not have that route.

A NAT gateway sits in a public subnet and uses an Elastic IP. If a private subnet's route table sends 0.0.0.0/0 to the NAT, servers in that subnet can go out to the internet (for updates, for example) but incoming connections from the internet are blocked.

The IGW is two-way for public subnets and is free. The NAT gateway is outbound-only for private subnets and is billed. Check current AWS pricing when you practise, because prices change.

How it works — a real example

In ThreeTierVpc, the web subnet gets the public route: 0.0.0.0/0 → IGW. The app and database subnets stay private. If the app server must download a package, we place a NAT gateway in the public subnet and add 0.0.0.0/0 → NAT in the private route table. The names and IP addresses are made up for learning.

Common mistake / exam tip

Attaching an IGW is not enough. If you forget the route 0.0.0.0/0 to the IGW, the subnet is still private. And putting a NAT gateway in a private subnet will not work: the NAT itself needs a public subnet and an Elastic IP.

Internet gateway (IGW)

Internet gateway: one per VPC, attach it first, then add route 0.0.0.0/0 to the IGW in the public route table.
Card 5 of 13: Internet gateway (IGW) · Download PNG
Read card text

What this card says

Internet gateway: one per VPC, attach it first, then add route 0.0.0.0/0 to the IGW in the public route table.

Route tables

Route tables: the local route 10.0.0.0/16 is always there; the public route table adds 0.0.0.0/0 to the internet gateway.
Card 6 of 13: Route tables · Download PNG
Read card text

What this card says

Route tables: the local route 10.0.0.0/16 is always there

the public route table adds 0.0.0.0/0 to the internet gateway.

Public vs private subnet

Public vs private subnet: a public subnet has a route 0.0.0.0/0 to the internet gateway; a private subnet does not.
Card 7 of 13: Public vs private subnet · Download PNG
Read card text

What this card says

Public vs private subnet: a public subnet has a route 0.0.0.0/0 to the internet gateway

a private subnet does not.

NAT gateway

NAT gateway: sits in a public subnet with an Elastic IP; private route 0.0.0.0/0 to the NAT lets private servers go out but blocks incoming connections.
Card 8 of 13: NAT gateway · Download PNG
Read card text

What this card says

NAT gateway: sits in a public subnet with an Elastic IP

private route 0.0.0.0/0 to the NAT lets private servers go out but blocks incoming connections.

IGW vs NAT gateway

Internet gateway vs NAT gateway: IGW is two-way for public subnets and free; NAT is outbound-only for private subnets and billed hourly.
Card 9 of 13: IGW vs NAT gateway · Download PNG
Read card text

What this card says

Internet gateway vs NAT gateway: IGW is two-way for public subnets and free

NAT is outbound-only for private subnets and billed hourly.

AZ placement, 3-tier plan and security

Why this matters

One subnet lives in exactly one Availability Zone. If you put every tier in a single AZ, one AZ failure can stop the whole app. You also need a simple firewall plan, not just a network plan.

What it is

For high availability, put a copy of each tier in two AZs, for example AZ a and AZ b. A common 3-tier plan on a 10.0.0.0/16 VPC uses eight /20 subnets: public, web, app and database, each in both AZs. The card on this page lists those CIDR blocks.

A security group works on the instance (or network interface). It is stateful and has allow rules only: if you allow a request in, the reply is allowed out automatically. A network ACL (NACL) works on the subnet. It is stateless and can allow or deny. You must allow both the request and the reply, and rules are checked by number.

How it works — a real example

The shop website puts public and web subnets in ap-south-1a and ap-south-1b, and does the same for app and database. A security group on the web server allows port 443 from the internet. A security group on the database allows the database port only from the app security group, not from 0.0.0.0/0. The names and IP addresses are made up for learning.

Common mistake / exam tip

Interviewers often ask how many subnets a 3-tier design needs. The short answer is at least three — one per tier. For high availability in two AZs, that becomes six, and this card's plan uses eight because it also keeps a public tier in both AZs. An RDS subnet group also needs subnets in at least two AZs.

AZs and subnet placement

AZs and subnets: one subnet lives in exactly one AZ; put a copy of each tier in AZ 2a and AZ 2b so one AZ failure does not stop the app.
Card 10 of 13: AZs and subnet placement · Download PNG
Read card text

What this card says

AZs and subnets: one subnet lives in exactly one AZ

put a copy of each tier in AZ 2a and AZ 2b so one AZ failure does not stop the app.

3-tier subnet plan

3-tier subnet plan for 10.0.0.0/16: eight /20 subnets, Public 10.0.0.0 and 10.0.16.0, Web 10.0.32.0 and 10.0.48.0, App 10.0.64.0 and 10.0.80.0, DB 10.0.96.0 and 10.0.112.0, across AZs a and b.
Card 11 of 13: 3-tier subnet plan · Download PNG
Read card text

What this card says

3-tier subnet plan for 10.0.0.0/16: eight /20 subnets, Public 10.0.0.0 and 10.0.16.0, Web 10.0.32.0 and 10.0.48.0, App 10.0.64.0 and 10.0.80.0, DB 10.0.96.0 and 10.0.112.0, across AZs a and b.

Security group vs NACL

Security group vs NACL: SG works on the instance, is stateful and has allow rules only; NACL works on the subnet, is stateless and has allow and deny rules checked by number.
Card 12 of 13: Security group vs NACL · Download PNG
Read card text

What this card says

Security group vs NACL: SG works on the instance, is stateful and has allow rules only

NACL works on the subnet, is stateless and has allow and deny rules checked by number.

VPC cheat sheet

VPC cheat sheet: VPC, subnet, IGW, route table, NAT gateway, /16 = 65,536 IPs, /20 = 4,096 IPs, 5 reserved IPs per subnet.
Card 13 of 13: VPC cheat sheet · Download PNG
Read card text

What this card says

VPC cheat sheet: VPC, subnet, IGW, route table, NAT gateway, /16 = 65,536 IPs, /20 = 4,096 IPs, 5 reserved IPs per subnet.

VPC comparison cards

Why this matters

Exam and interview questions often come as a pair: default versus custom, public versus private, stateful versus stateless. These five cards sit next to the revision pack because they answer those pairs.

What it is

Default VPC versus custom VPC, and public versus private route tables, repeat the ideas from the first two sections. Stateful versus stateless is the difference behind security groups and NACLs: a stateful firewall remembers the request, a stateless firewall checks every packet on its own.

A zonal NAT gateway is the classic NAT, living in one AZ, in a public subnet. The comparison card also describes a newer regional NAT gateway mode (from November 2025): one NAT gateway for the whole VPC, across AZs.

In a security group rule, 0.0.0.0/0 means every IPv4 address. "My IP" means only your current public IP.

How it works — a real example

When you open SSH (port 22) to a bastion or jump server, use "My IP" rather than 0.0.0.0/0. If you use anywhere, the whole internet can try that port.

Common mistake / exam tip

Students often open port 22 or 3389 from 0.0.0.0/0 "just for a lab" and leave it. For SSH and RDP, prefer "My IP", and remove the rule when you finish. Also remember: a zonal NAT in AZ a does not cover an AZ b outage. If you use zonal NAT and need two AZs, you typically need a NAT in each AZ.

Comparison: Default VPC vs Custom VPC

Comparison card: Default VPC vs Custom VPC. Default VPC: A VPC AWS makes for you in every Region. Custom VPC: A VPC you create yourself.
Comparison: Default VPC vs Custom VPC · Download PNG
Read card text

What this card says

Comparison card: Default VPC vs Custom VPC. Default VPC: A VPC AWS makes for you in every Region. Custom VPC: A VPC you create yourself.

Comparison: Public route table vs Private route table

Comparison card: Public route table vs Private route table. Public route table: Route table used by public subnets. Private route table: Route table used by private subnets.
Comparison: Public route table vs Private route table · Download PNG
Read card text

What this card says

Comparison card: Public route table vs Private route table. Public route table: Route table used by public subnets. Private route table: Route table used by private subnets.

Comparison: Zonal NAT gateway vs Regional NAT gateway

Comparison card: Zonal NAT gateway vs Regional NAT gateway. Zonal NAT gateway: The classic NAT gateway, living in one AZ, in a public subnet. Regional NAT gateway: A newer mode (Nov 2025): one NAT gateway for the whole VPC, across AZs.
Comparison: Zonal NAT gateway vs Regional NAT gateway · Download PNG
Read card text

What this card says

Comparison card: Zonal NAT gateway vs Regional NAT gateway. Zonal NAT gateway: The classic NAT gateway, living in one AZ, in a public subnet. Regional NAT gateway: A newer mode (Nov 2025): one NAT gateway for the whole VPC, across AZs.

Comparison: Stateful vs Stateless

Comparison card: Stateful vs Stateless. Stateful: A firewall that remembers each request. Stateless: A firewall that checks every packet on its own.
Comparison: Stateful vs Stateless · Download PNG
Read card text

What this card says

Comparison card: Stateful vs Stateless. Stateful: A firewall that remembers each request. Stateless: A firewall that checks every packet on its own.

Comparison: Anywhere (0.0.0.0/0) vs My IP

Comparison card: Anywhere (0.0.0.0/0) vs My IP. Anywhere (0.0.0.0/0): Security group source that allows every IP. My IP: Security group source that allows only your current IP.
Comparison: Anywhere (0.0.0.0/0) vs My IP · Download PNG
Read card text

What this card says

Comparison card: Anywhere (0.0.0.0/0) vs My IP. Anywhere (0.0.0.0/0): Security group source that allows every IP. My IP: Security group source that allows only your current IP.

FAQ

Does a VPC span more than one Region?

No. A VPC lives in one AWS Region. If you need resources in Mumbai and in Singapore, you need two VPCs.

What is the CIDR of the default VPC?

172.31.0.0/16, with a /20 subnet in each Availability Zone of that Region, and an internet gateway already attached.

Why is a /24 subnet not 256 usable IPs on AWS?

The total is 256, but AWS reserves five addresses in every subnet (network, VPC router, DNS, future use, and broadcast). So a /24 has 251 usable IPs.

What makes a subnet public?

A route of 0.0.0.0/0 to an internet gateway in that subnet's route table. Attaching an IGW to the VPC, or giving an instance a public IP, is not enough on its own.

How can a private instance reach the internet?

Place a NAT gateway in a public subnet (with an Elastic IP) and add 0.0.0.0/0 to that NAT in the private subnet's route table. Outbound traffic can go out; incoming connections from the internet stay blocked.

Is the internet gateway free? Is NAT billed?

These cards say the IGW is free and the NAT gateway is billed (hourly for the classic NAT). Always check current AWS pricing when you practise, because prices change.

What is the difference between a security group and a NACL?

A security group works on the instance, is stateful, and has allow rules only. A NACL works on the subnet, is stateless, and has allow and deny rules checked by number.

Should I allow SSH from 0.0.0.0/0?

Prefer "My IP" for SSH (port 22) or RDP (port 3389). 0.0.0.0/0 allows every IPv4 address to try that port.

These chapter pages and guides are already on the site (checked live, HTTP 200, on 19 Nov 2026):

See all AWS revision cards