Following post provide the formulas for calculating CIDR for VPC Subnet.
Considering a VPC with CIDR 172.31.0.0/16.
1) What will be the CIDR notation for subnets inside 172.31.0.0/16 VPC?
The VPC can be divided into subnets with CIDR notation starting from /17 to /28.
2) What will be the CIDR notation for subnets if we have to divide 172.31.0.0/16 VPC into 'X' number of subnets?
If we have to divide 172.31.0.0/16 into 4 subnets, then following if the formula to calculate network bits (CIDR notation) for subnets.
2 ^ (32 minus VPC CIDR Notation) / 2 ^ ( 32 minus SUBNET CIDR Notation) = NUMBER OF SUBNETS
considering 'SUBNET CIDR Notation' which is to be derived as a variable x, the above formula will be:
2 ^ ( 32 - 16) / 2 ^ (32 - x) = 4
Now consider 32 - x as variable y, above equation will be:
2 ^ 16 / 2 ^ y = 4
2 ^ (16 - y) = 4
which derives, y as 14. So 'x' will be 32 - 14 = 18.
That means, the CIDR notation of 4 subnets inside 172.31.0.0/16 will be /18.
3) How many subnets can be created with specific CIDR notation?
To find out how many subnets can be created for a given CIDR notation, same formula can be used:
2 ^ (32 minus VPC CIDR Notation) / 2 ^ ( 32 minus SUBNET CIDR Notation) = NUMBER OF SUBNETS
Considering 'SUBNET CIDR Notation' to be 20, above formula will be :
2 ^ ( 32 - 16) / 2 ^ (32 - 20) = NUMBER OF SUBNETS
2 ^ 16 / 2 ^ 12 = NUMBER OF SUBNETS
2 ^ (16-12) = NUMBER OF SUBNETS
2 ^ 4 = NUMBER OF SUBNETS
that means, 16 subnets can be created with CIDR notation of /20.
4) How many IP Addressed will be available in subnet with CIDR notation /20?
Formula: 2 ^ ( 32 minus SUBNET CIDR Notation)
with /20, above will be 2 ^ ( 32 - 20 ) i.e. 2 ^ 12 i.e. 4096 IP Addresses
5) How to calculate Subnet addresses for each subnet?
Considering that we decided to divide 172.31.0.0/16 into subnets with /20 CIDR notation, following can be used to determine subnet address for each subnet.
First subnet address will be 172.31.0.0/20. Since we know there will be total of 4096 IP addresses in this subnet and the range of IP address is 0 to 255 i.e. 256 values on fourth octet, so 4096 / 256 i.e.16 which mean 0 to 15 third octet value will cover total IP address range.
So next subnet will start from 172.31.(0 + 16).0/20 and so on.
172.31.0.0/20 (IP Range: 172.31.0.0 to 172.31.15.255)
172.31.16.0/20 (IP Range: 172.31.16.0 to 172.31.31.255)
172.31.32.0/20
172.31.48.0/20
........
172.31.240.0/20
Hope this helps ✌
Useful Link: https://www.davidc.net/sites/default/subnets/subnets.html
No comments:
Post a Comment