Back to Engineering Notes
100 Days of Cloud (AWS)Engineering Note

Create Subnet

A subnet is a smaller network created inside a VPC (Virtual Private Cloud).

๐ŸŒ What is a Subnet?

A subnet is a smaller network created inside a VPC (Virtual Private Cloud).

A VPC might have CIDR: 172.31.0.0/16
A subnet divides that VPC into smaller network ranges (for example, /20, /24)
Each subnet belongs to one Availability Zone

๐Ÿ“ Example VPC CIDR

VPC CIDR: 172.31.0.0/16

/16 means:
16 bits for network
16 bits for hosts
Total IPs = 2^{16} = 65,536

๐Ÿ“˜ Example Subnet CIDR

Subnet CIDR: 172.31.96.0/20

Breakdown:

/20 โ†’ 20 network bits
Remaining 12 bits for hosts
Total IPs = 2^{12} = 4,096 IP addresses

๐Ÿ“ Address Calculation

For subnet 172.31.96.0/20:

Network address โ†’ 172.31.96.0
Broadcast address โ†’ 172.31.111.255
Total IPs โ†’ 4,096

โš ๏ธ AWS Reserved IPs

AWS reserves 5 IP addresses in each subnet:

1. Network address

1. VPC router

1. DNS

1. Future use

1. Broadcast

So usable IPs:

4096 - 5 = 4091 usable IP addresses

๐Ÿ› ๏ธ Steps to Create a Subnet in AWS Console

1. Go to AWS Management Console

1. Navigate to: VPC โ†’ Subnets

1. Click Create subnet

Fill in details:

VPC ID โ†’ Select your VPC (172.31.0.0/16)
Subnet name โ†’ for example, devops-public-subnet
Availability Zone โ†’ for example, us-east-1a
IPv4 CIDR block โ†’ 172.31.96.0/20

Click Create subnet

๐Ÿ” Public vs Private Subnet

Public subnet
Has route to an Internet Gateway
Used for web servers and bastion hosts
Private subnet
No direct internet access
Used for databases and internal services

๐ŸŽฏ Result

Subnet created inside the VPC
4,091 usable IP addresses
Ready for EC2 instance deployment