AWS VPC and Subnet CIDR calculation and allocation
Its hard to understand CIDR calculation and allocation when we create our first virtual private cloud and subnets. I hope this article would be helpful for beginners.
Let’s first understand why CIDR allocation is so important while creating VPCs. When we have a single VPC then CIDR allocation may not be that important. However, when we need interconnectivity between multiple VPCs in same account or across different accounts, then its very important to plan ahead and define our CIDR blocks accordingly. When we have same CIDR blocks or overlapping CIDR blocks in two different VPCs, then we can’t use features like VPC peering.
So, now we understand that allocating CIDR blocks correctly is a critical task, let’s understand what CIDR is. CIDR, which stands for Classless Inter-Domain Routing, is an IP addressing scheme that improves the allocation of IP addresses. I had written an answer to a stackoverflow question (https://stackoverflow.com/questions/51734945/cidr-address-is-not-within-cidr-address-from-vpc/56051282#56051282), where I have explained how CIDR address range works. I hope this will provide more clarity in CIDR allocation.
An IPv4 address consists of 32 bits.