Amazon VPC n ^ 2 -4 IP Addresses? CIDR block

I was going to create a new AWC VPC for my instances. However, I noticed that when I used CIDR Notation to create a VPC and Public Subnet, does AWS indicate that I have n ^ 2 - 4 (where n is the number of bits) available IP addresses? Why is this?

My understanding is that n ^ 2 -2 usually removes the case where the bits are all 0s or all 1s. But I'm not sure why this is - 4 in this case.

AWS VPC Screen

Here / 28 indicates 11 IPs available when I was expecting 15 or 13, and 251 when I was expecting 255 or 253

+4


source to share


3 answers


Attention!

AWS reserves both the first four IP addresses and the last IP address in each subnet CIDR block; they are not available to you. For example, in the subnet with the CIDR block 10.0.0.0/24, the following IP addresses are reserved: 10.0.0.0, 10.0.0.1, 10.0.0.2, 10.0.0.3 and 10.0.0.255.

- http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_Subnets.html



In addition to the network and broadcast addresses, a dedicated default gateway is automatically provided, as well as the IP addresses used to deliver the services automatically provided by the VPC infrastructure on each subnet (such as DNS resolvers and DHCP). They are pretty much transparent to you, but this is where the addresses come in and the reason they are not available for assignment to instances on a subnet.

+7


source


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, on a subnet with a CIDR 10.0.0.0/24 block, the following five IP addresses are reserved:

• 10.0.0.0: Network address.

• 10.0.0.1: Reserved by AWS for the VPC router.

• 10.0.0.2: Reserved by AWS for mapping to the Amazon-provided DNS.

• 10.0.0.3: Reserved by AWS for future use.

• 10.0.0.255: Network broadcast address.

      



Since AWS does not support VPC broadcasts, so they reserve this address.

+3


source


Now that you know what the reserved IP is, you might be wondering. How to calculate the total number of used IP addresses for a given CIDR VPC block ?

Use the formula to calculate the normal CIDR block, then subtract 5 because AWS uses the first 4 and last address.

  1. Subtract 32 from the mask number.
  2. Raise the number 2 to the degree of the answer in step 1.
  3. Subtract 5 because AWS uses 5 of them.

Example: given netmask / 27

Step 1) 32 - 27 = 5
Step 2)  2^5 = 32
Step 3)  32 - 5 = 27  Because VPC uses 5 addresses

      

0


source







All Articles