Every network in AWS needs an addressing system to identify resources like servers, databases, or applications. AWS uses CIDR (Classless Inter-Domain Routing) to manage these addresses efficiently. In this article, we’ll break down what CIDR blocks are, how they work, and how to assign them in AWS, along with an intuitive explanation of binary math for those curious about the details.
A CIDR block defines the range of IP addresses your network can use. It combines:
For example:
10.0.0.0/16
means:
10.0
is the network portion (fixed part)./16
tells you how many addresses can exist in this range.CIDR works by splitting an IP address into two parts:
The number after the slash (/
) in CIDR notation indicates how many bits are allocated to the network portion. The remaining bits are for the host portion.
Binary is the foundation of CIDR. It uses 0s
and 1s
, where each slot (bit) represents a power of 2. Moving from right to left, the powers of 2 grow larger.
0
in a slot, you don’t count that power of 2.1
in a slot, you count that power of 2.Let’s convert the binary number 00001010
to decimal:
Write out the powers of 2:
Slots: 0 0 0 0 1 0 1 0
Powers: 2^7 2^6 2^5 2^4 2^3 2^2 2^1 2^0
Values: 128 64 32 16 8 4 2 1
Check each slot (from the right):
0
, so it contributes 0.1
, so it contributes 2.0
, so it contributes 0.1
, so it contributes 8.0
, so they contribute 0.Add the contributions:
8 + 2 = 10
8
comes from the 4th slot (2^3).2
comes from the 2nd slot (2^1).Tying It All Together:
Therefore, the binary number 00001010
translates to 10 in decimal.
For an IP address, 00001010.00000000.00000000.00000000
is equivalent to 10.0.0.0.
The number of IP addresses in a CIDR block depends on the number of bits allocated to the host portion. It is calculated using the formula:
Total IPs = 2^(Number of Host Bits)
/16
CIDR block reserves the first 16 bits for the network portion.2^16 = 65,536
When you create a VPC in AWS, you assign it a CIDR block. This block defines the IP address range for all resources in the VPC.
10.0.0.0/8
./16
for 65,536 IPs or /24
for 256 IPs.10.0.0.0/16
).10.0.1.0/24
for subnets).Make sure CIDR ranges don’t overlap to avoid routing conflicts:
10.0.0.0/16
192.168.0.0/16
10.0.0.0/16
10.0.0.0/24
(overlaps with the first)./
).Next, we’ll explore Routing Tables — the internal roadmaps that direct traffic within your VPC and to the outside world.