Simply Calculate AWS Subnet's CIDR Blocks For VPC

aws-subnets-cidr-blocks-simply-calculate

Don't want to read? Watch Video:



VPC and Subnet Basics (AWS Definition):

A virtual private cloud (VPC) is a virtual network dedicated to your AWS account. It is logically isolated from other virtual networks in the AWS Cloud. You can launch your AWS resources, such as Amazon EC2 instances, into your VPC.

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; for example, 10.0.0.0/16. This is the primary CIDR block for your VPC.

vpc-subnets-structure


What is CIDR Blocks ?

It is a Classless Inter-Domain Routing.

ip-address-structure


How to decide IPv4 address range ?

While creating a VPC, AWS recommend that you specify a CIDR block (of /16 or smaller network prefix) from the iana (Internet Assigned Numbers Authority) standard private IPv4 address ranges:

  • 10.0.0.0 - 10.255.255.255 (/8 prefix)

  • 172.16.0.0 - 172.31.255.255 (/12 prefix)

  • 192.168.0.0 - 192.168.255.255 (/16 prefix)

Available IPs Depends On N/W Prefix:

Example: 192.168.0.0 /16 (n/w prefix)

Formula: 
Total Available Host Bits = Total Bits – n/w Prefix
Total Available IPs = 2^ Total Available Host Bits
Total Available Host Bits =  32 bits – 16bits = 16
Total Available IPs = 2^16 = 65536 Ips

How to choose CIDR block for VPC?


vpc-cidr-blocks-subnets


It’s totally depends on your IP addresses requirement and numbers of subnets you want to create.

For example, we have requirement of 200 Ips and want to allocate 100 Ips in subnet-1 and remaining 100 ips in subnet-2

Lets find out total available Ips using different n/w prefix.

  • Example-1: 192.168.0.0 /16 (n/w prefix) => 65536 Ips
  • Example-2: 192.168.0.0 /20 (n/w prefix) => 4096 Ips
  • Example-3: 192.168.0.0 /23 (n/w prefix) => 512 Ips
  • Example-4: 192.168.0.0 /24 (n/w prefix) => 256 Ips (Most suitable)
  • Example-5: 192.168.0.0 /25 (n/w prefix) => 128 Ips

Lets calculate CIDR block for subnets:

Example-1:
192.168.0.0 /25 (n/w prefix) => 32-25 = 7 = 2^7 = 128 Ips (Most suitable)

Example-2:
192.168.0.0 /26 (n/w prefix) => 32-26 = 6 = 2^6 = 64 Ips (less, as we need 100 Ips)

Example-3:
192.168.0.0 /27 (n/w prefix) => 32-27 = 5 = 2^5 = 32 Ips (less, as we need 100 Ips)

Example-4: 
192.168.0.0 /28 (n/w prefix) => 32-28 = 4 = 2^4 = 16 Ip (less, as we need 100 Ips)

start-end-ip-range


AWS Reserved 5 IP Addresses:

The first four IP addresses and the last IP address in each subnet CIDR block are not available for you to use, and cannot be assigned to an instance. For example, in a subnet with CIDR block 192.168.0.0/25, the following five IP addresses are reserved:

  • 192.168.0.0: Network address.
  • 192.168.0.1: Reserved by AWS for the VPC router.
  • 192.168.0.2: Reserved by AWS for future use.
  • 192.168.0.3: Reserved by AWS for future use.
  • 192.168.0.127: Reserved for Network broadcast address.
usable-ip-range



For More Details: https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Subnets.html

Calculate Subnet CIDR Blocks Tool:

There are many tools available to help you calculate subnet CIDR blocks.

My favorite one is :  
http://www.davidc.net/sites/default/subnets/subnets.html


Happy Learning AWS Services!!!! :) Still Doubts? lets put your questions in below comment box! Thanks! 

Please like and subscribe this channel. Your 1 subscription is very important to grow channel!




Simply Calculate AWS Subnet's CIDR Blocks For VPC Simply Calculate AWS Subnet's CIDR Blocks For VPC Reviewed by Web Technology Funda on 9:40:00 AM Rating: 5

No comments

Free! Free!Free! Subscribe to Get Free PHP (Magento) tutorial Update in Your Inbox!!! Hurry Up!!!