AWS Builder Center
How to Master AWS Networking (Even if CIDR Math Makes You Dizzy)

How to Master AWS Networking (Even if CIDR Math Makes You Dizzy)

Stop memorizing AWS jargon and start understanding how your cloud actually works. This no-nonsense guide breaks down VPCs, subnets, and CIDR math into simple mental models for building bulletproof, scalable architectures.

The cloud is just someone else's computer. But a VPC? That is your private fortress in the cloud.
If you don't understand how traffic flows through your Virtual Private Cloud (VPC), you don't understand AWS. It’s that simple. Networking isn't just IT plumbing; it is the foundation of security, scale, and architecture.
Let’s strip away the jargon. No textbooks. No fluff. Just the mental models you need to design AWS architectures like a pro.



1. The Foundation: VPCs and Subnets

Think of a VPC as a massive plot of land you just bought. Think of a Subnet as the smaller, fenced-off lots inside that land where you actually build your houses (servers).
When you create a VPC, you assign it a massive range of IP addresses (e.g.,  10.0.0.0/16 ). But you can't just throw servers in there randomly. You divide that massive network into smaller, logical groups called Subnets (e.g.,  10.0.1.0/24 ).
There are two types of neighborhoods on your land:
  • The Public Subnet: The storefront. It has a direct path to the outside world via an Internet Gateway (IGW). This is where your Web Servers and Load Balancers live.
  • The Private Subnet: The vault. There is no direct access from the internet. This is where your Database Servers live. If you want to keep data safe, you keep it off the public internet.
Rule of Thumb: High availability is non-negotiable. Always spread your subnets across multiple Availability Zones (AZs). If one data center goes dark, your application shouldn't blink.



2. The Map: Route Tables

If subnets are the neighborhoods, the Route Table is Google Maps. It tells your network traffic exactly where it is allowed to go.
  • Public Route Table: Sends local traffic to your VPC, and sends everything else ( 0.0.0.0/0 ) out through the Internet Gateway.
  • Private Route Table: Sends local traffic to your VPC, but sends outbound internet requests ( 0.0.0.0/0 ) to a NAT Gateway.



3. The Math: CIDR Demystified

CIDR (Classless Inter-Domain Routing) makes most people’s heads spin. It doesn't have to. It is simply a way to define how many IP addresses you have.
An IPv4 address is always 32 bits long. The number after the slash (like  /16  or  /24 ) tells you how many bits are locked in for the network. The remaining bits are for your hosts (your actual servers).
The Only Formula You Need: Host bits = 32 − CIDR Total IPs = 2^(Host bits)
Example for a  /28  subnet:
  • Host bits = 32 - 28 = 4
  • Total IPs = 2^4 = 16

The "AWS Tax" on IP Addresses

If your math says you have 16 IPs, AWS says, "Not quite." AWS reserves exactly 5 IP addresses in every single subnet:
  1.  .0  – Network address
  1.  .1  – VPC Router
  1.  .2  – DNS Server
  1.  .3  – Reserved for future AWS use
  1.  .255  – Broadcast address
So, in a  /28  subnet, you don't have 16 IPs. You have 11 usable IPs. Plan accordingly, or you will run out of digital real estate.



4. The Bouncers: Security Groups vs. Network ACLs

Security is about layers. In AWS, you have two main firewalls. , they operate at completely different levels.
Feature
Security Group (SG)
Network ACL (NACL)
Level
Instance (EC2)
Subnet
Stateful?
Yes (Return traffic is auto-allowed)
No (Must define inbound & outbound rules)
Rules
Allow rules only
Allow AND Deny rules
Default
Block all inbound, Allow all outbound
Allow everything
The translation? SGs are the bouncers at the door of the specific club (your EC2 instance). NACLs are the roadblocks at the border of the neighborhood (your subnet).



5. The Secret Exit: NAT Gateway

Your database lives in a Private Subnet. It is safe from hackers because it has no internet access. But wait: how does the database download a software update if it can't reach the internet?
Enter the NAT Gateway (Network Address Translation).
You place a NAT Gateway in your Public Subnet. When your private server needs the internet, it sends the request to the NAT Gateway. The NAT Gateway fetches the update from the internet and passes it back.
The Magic: Traffic can flow out to the internet, but the internet cannot initiate a connection in.



6. The Perfect Mental Model

If you want to pass an AWS interview or build a production-ready application, memorize this traffic flow:
  1. The User clicks a link on the Internet.
  1. The Internet Gateway (IGW) opens the door to the VPC.
  1. The Application Load Balancer (ALB) (sitting in a Public Subnet) receives the request.
  1. The ALB forwards the request to your Web Server (EC2) (sitting in a Private Subnet).
  1. The EC2 instance queries your Database (RDS) (sitting in an even deeper Private Subnet).
  1. The data travels back up the chain to the user.
Nobody touches the servers directly. Everything is routed, filtered, and secure.



The Golden Rule of Cloud Real Estate: Private IP Ranges (RFC 1918)

Not all IP addresses are created equal.
If you are building a private network, you cannot just pick random numbers. You have to use Private IP Ranges (defined by a standard called RFC 1918). These are IP addresses that do not exist on the public internet. Think of them as internal phone extensions for your office; you can dial them from inside the building, but nobody can call them from the outside.
You have three choices for your VPC:
  1. The Giant (10.0.0.0/8):
  • Range:  10.0.0.0  to  10.255.255.255 
  • This is the largest private range available. It is the default choice for almost every serious enterprise architecture.
  1. The Middle Ground (172.16.0.0/12):
  • Range:  172.16.0.0  to  172.31.255.255 
  • Often used by AWS for default VPCs or container networking (like Docker).
  1. The Home Network (192.168.0.0/16):
  • Range:  192.168.0.0  to  192.168.255.255 
  • Familiar? It should be. It’s the range your home Wi-Fi router uses.



How to Design Subnets Without Hating Yourself Later

Good architectural design is simply about eliminating future headaches. When mapping out your subnets, you have two non-negotiable goals.

Goal 1: Never, Ever Overlap IPs

Imagine your company’s physical, on-premise data center uses the  10.0.0.0/16  network.
You go into AWS and create a shiny new VPC using that exact same  10.0.0.0/16  CIDR block. Everything works perfectly... until six months later when your boss asks you to connect the office to AWS via a VPN.
The moment you connect them, the network panics.
If a request goes out to  10.0.1.50 , the router is completely blind. Is that the database sitting in the physical office? Or is it the EC2 instance in the cloud? The traffic crashes. The VPN fails. You have to tear down your entire AWS network and rebuild it from scratch.
The Fix: Always map your networks globally. If your office is  10.0.0.0/16 , make your AWS VPC  10.1.0.0/16 .

Goal 2: Give Yourself Room to Grow

IP addresses are cheap until you run out of them.
If you have 1,000 servers to deploy, do not create a tiny  /28  subnet. A  /28  gives you 16 total IPs. Subtract the 5 IPs AWS reserves for its own plumbing, and you only have 11 usable IPs left. You will run out of space before you even finish deploying your first application tier.
Calculate your hosts, double that number for future growth, and pick your CIDR block accordingly.



The Matrix: Seeing CIDR in Binary (And Why It Matters)

Most people run away from binary math. The best cloud engineers lean into it.
If you want to understand how a VPC actually works, you have to look under the hood. An IPv4 address is always exactly 32 bits long. It is a constant tug-of-war between two sides: the Network (the neighborhood) and the Host (the specific house).
Let’s tear apart a  /28  subnet to see how this works.

How to Read a /28 Subnet

The subnet mask for a  /28  is  255.255.255.240 . If you look at the last section (octet) in pure binary, it looks like this:
 11110000 
Notice the split?
  • The first 4 bits ( 1111 ) belong to the Network.
  • The last 4 bits ( 0000 ) belong to the Host.
Those 4 host bits are your digital real estate. How many combinations can you make with 4 binary bits?
  •  0000  = 0
  •  0001  = 1
  •  0010  = 2
  • ...all the way down to  1111  = 15.
That is exactly 16 possible combinations. Therefore, if your subnet is  192.168.1.0/28 , your IP range is strictly mapped:
  •  192.168.1.0 
  •  192.168.1.1 
  •  192.168.1.2 
  • ...down to  192.168.1.15 
Total IPs: 16. (And remember the AWS tax: subtract 5, leaving you with 11 usable IPs).



The Universal Cloud Shortcut

You don’t have to do binary math in your head every time. There is a universal rule that applies across AWS, Azure, GCP, and even the dusty servers in your on-premise data center.
The Rule:
  1. Host bits = 32 − CIDR
  1. Total IPs = 2^(Host bits)
The Mental Cheat Sheet:
CIDR
Host Bits (32 - CIDR)
Formula
Total IPs
/16
16
2^16
65,536
/24
8
2^8
256
/25
7
2^7
128
/26
6
2^6
64
/27
5
2^5
32
/28
4
2^4
16



Translating CIDR to a Subnet Mask

The CIDR number simply tells you how many  1 s (network bits) you have in your 32-bit string. The rest are  0 s (host bits).
Let’s convert them manually so you never have to guess. You take the 32 bits, chop them into four groups of 8 (octets), and convert them to decimals.
Example 1: The /24 Translation
  • Meaning: 24 ones, 8 zeros.
  • Binary:  11111111.11111111.11111111.00000000 
  • Decimal Conversion:
  •  11111111  = 255
  •  11111111  = 255
  •  11111111  = 255
  •  00000000  = 0
  • Result:  255.255.255.0 
Example 2: The /16 Translation
  • Meaning: 16 ones, 16 zeros.
  • Binary:  11111111.11111111.00000000.00000000 
  • Decimal Conversion:  255.255.0.0 
  • Result:  10.0.0.0/16  uses a subnet mask of  255.255.0.0 
Example 3: The /28 Translation
  • Meaning: 28 ones, 4 zeros.
  • Binary:  11111111.11111111.11111111.11110000 
  • Decimal Conversion of that last octet ( 11110000 ) = 240.
  • Result:  255.255.255.240 

The Ultimate Subnet Mask Table

Bookmark this.
CIDR
Full Binary Breakdown
Subnet Mask
/8
 11111111.00000000.00000000.00000000 
255.0.0.0
/16
 11111111.11111111.00000000.00000000 
255.255.0.0
/24
 11111111.11111111.11111111.00000000 
255.255.255.0
/25
 11111111.11111111.11111111.10000000 
255.255.255.128
/26
 11111111.11111111.11111111.11000000 
255.255.255.192
/27
 11111111.11111111.11111111.11100000 
255.255.255.224
/28
 11111111.11111111.11111111.11110000 
255.255.255.240
Takeaway: Whenever you log into AWS and see a VPC with a CIDR block, the very first, most useful step you can take is to instantly calculate its host bits and its subnet mask. Once you understand the boundaries of your digital land, you control everything built on top of it.

Summary:

  • VPC: The big network.
  • Subnet: The small network.
  • Route Table: The traffic map.
  • IGW: The front door to the internet.
  • NAT Gateway: The private subnet's secure exit.
  • Security Group: The server's personal bodyguard.
Build your network on these simple truths, and the rest of the cloud will fall effortlessly into place.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article