Basic VPC CIDR

Nivas DevSecOps
3 min readAug 15, 2024

--

What is CIDR?

  • CIDR stands for Classless Inter-Domain Routing.
  • It is a method for allocating IP addresses and for IP routing.
  • CIDR IP addresses are composed of two sets of numbers — Prefix and Suffix.
  • The network address is written as a prefix like you would see a normal IP address (e.g. 10.0.0.0). The second part is the suffix which indicates how many bits are in the entire address (e.g. /24). Putting it together, a CIDR IP address would look like the following.
10.0.0.0/24

Let’s calculate how many IP addresses are available for the above CIDR range.

Since IP addresses are made of 32 bit. The suffix of the CIDR will decide how many IPs it can have.

The total no. of IPs for this CIDR (10.0.0.0/24) is 32–24=8 and ²⁸ = 256.

So the IP addresses will be something like this — 10.0.0.0, 10.0.0.1, 10.0.0.2, 10.0.0.3, 10.0.0.4, 10.0.0.5…, 10.0.0.255

There will be a total of 256 IP addresses for 10.0.0.0/24.

We can calculate like this.

  • /32 allows for 1 IP = ²⁰
  • /31 allows for 2 IP = ²¹
  • /30 allows for 4 IP = ²²
  • /29 allows for 8 IP = ²³
  • /28 allows for 16 IP = ²⁴
  • /27 allows for 32 IP = ²⁵
  • /26 allows for 64 IP = ²⁶
  • /25 allows for 128 IP = ²⁷
  • /24 allows for 256 IP = ²⁸
  • /16 allows for 65,536 IP = ²¹⁶
  • /0 allows for all IPs = ²³²

Small exercise

Ques. 192.168.0.0/24 = … ?

Ans. 192.168.0.0–192.168.0.255 (256 IP)

Ques. 192.168.0.0/16 = … ?

Ans. 192.168.0.0–192.168.255.255 (65,536 IP)

Ques. 134.56.78.123/32 = … ?

Ans. only 134.56.78.123

0.0.0.0/0 — All IP

Calculate the CIDR here

IP range of AWS VPC and Subnet

  • When you create a VPC, you must specify a range of IPv4 addresses for the VPC in the form of a Classless Inter-Domain Routing (CIDR) block.
  • AWS recommends that you specify a CIDR block (of /16 or smaller) from the private IPv4 address ranges as specified in RFC 1918.
  • Here are the address blocks you can get started with:

Example 1:

  • If you create a VPC with CIDR block 10.0.0.0/27, it supports 32–27=5 and ²⁵ =32 IP addresses (for addresses 10.0.0.0–10.0.0.31)
  • You can break this CIDR block into two subnets, each supporting 16 IP addresses. One subnet has CIDR 10.0.0.0/28 (for addresses 10.0.0.0–10.0.0.15) and second subnet 10.0.0.16/28 (for addresses 10.0.0.16–10.0.0.31).

Example 2:

  • If you create a VPC with CIDR block 10.0.0.0/24, it supports 32–24=8 and ²⁸= 256 IP addresses (for addresses 10.10.0.0–10.10.0.255)
  • You can break this CIDR block into four subnets, each supporting 64 IP addresses.
  • First subnet has CIDR 10.10.0.0/26 (for addresses 10.10.0.0–10.10.0.63)
  • Second subnet has CIDR 10.10.0.64/26 (for addresses 10.10.0.64–10.10.0.127).
  • Third subnet has CIDR 10.10.0.128/26 (for addresses 10.10.0.128–10.10.0.191).
  • Forth subnet has CIDR 10.10.0.192/26 (for addresses 10.10.0.192–10.10.0.255).

Example 3:

  • If you create a VPC with CIDR block 10.100.0.0/22, it supports 32–22=10 and ²¹⁰=1024 IP addresses (for addresses 10.100.0.0–10.100.3.255)
  • You can break this CIDR block into four subnets, each supporting 256 IP addresses.
  • First subnet has CIDR 10.100.0.0/24 (for addresses 10.100.0.0–10.100.0.255).
  • Second subnet has 10.100.1.0/24 (for addresses 10.100.1.0–10.100.1.255).
  • The third subnet has 10.100.2.0/24(for addresses 10.100.2.0–10.100.2.255).
  • Forth subnet 10.100.3.0/24 (for address 10.100.3.0–10.100.3.255).

Example 4:

  • If you create a VPC with CIDR block 10.10.0.0/16, it supports 32–16=16 and ²¹⁶=65536 IP addresses (for addresses 10.10.0.0–10.10.255.255)
  • You can break this CIDR block according to the requirement.
  • If you break this CIDR block into 16 subnets, each supporting 4096 IP addresses.

Click here to calculate CIDR Online.

--

--

Nivas DevSecOps
Nivas DevSecOps

Written by Nivas DevSecOps

Cloud | DevSecOps| AWS ⭐Passionate Cloud and DevOps . 🎯 Like to stay up-to-date with the latest trends and insights.

No responses yet