Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cidr blocks AWS explanation

Tags:

cidr

aws-vpc

Can someone explain exactly how CIDR blocks work and how it translates into 0.0.0.0/32 for example? Please use laymen’s terms or perhaps even an analogy to something not network related. Can’t seems to find an explanation that clicks with me. Thanks!!

like image 916
Billy Avatar asked Oct 07 '17 02:10

Billy


People also ask

What is a CIDR block in AWS?

A subnet CIDR reservation is a range of IPv4 or IPv6 addresses that you set aside so that AWS can't assign them to your network interfaces. This enables you to specify IPv4 or IPv6 prefixes for use with your network interfaces.

What is CIDR block and what do you use it for?

CIDR, which stands for Classless Inter-Domain Routing, is an IP addressing scheme that improves the allocation of IP addresses. It replaces the old system based on classes A, B, and C. This scheme also helped greatly extend the life of IPv4 as well as slow the growth of routing tables.

What is CIDR block in subnet?

In the case of an IPv4 CIDR, this means entering a network prefix and a subnet mask. The subnet mask determines how many IP addresses can be created from the CIDR block. Amazon requires that a CIDR block include a subnet mask ranging from 16 to 28. The two most commonly used subnet sizes are 16 bits and 24 bits.


Video Answer


1 Answers

Classless Inter-Domain Routing (CIDR) blocks are for specifying a range to IP addresses in format of IPv4 or IPv6. For the sake of simplicity I will explain rest of this in format of IPv4 however it is applicable to IPv6.

General format for CIDR Blocks: x.y.z.t/p

x, y, z and t are numbers from 0 to 255. Basically, each represents an 8 bit binary number. That's why it is range is up to 255. Combination of this numbers becomes an IPv4 IP address that must be unique to be able to identify a specific instance.

In case of AWS, p is a number from 16 to 28. It represents the number of bits that are inherited from given IP address. For example: 10.0.0.0/16 represents an IP address in following format: 10.0.x.y where x and y are any number from 0 to 255. So, actually it represents a range of IP addresses, starting from 10.0.0.0 to 10.0.255.255.

However for each CIDR block, AWS prohibits 5 possible IP addresses. Those are the first 4 available addresses and the last available address. In this case:

  1. 10.0.0.0: Network address
  2. 10.0.0.1: Reserved for VPC router
  3. 10.0.0.2: DNS server
  4. 10.0.0.3: Reserved for future use
  5. 10.0.255.255: Network broadcast

See here for official doc.

Actually this is one of the main reasons why AWS permits numeric value of p up to /28. Because for p=30, there will be 4 available values however AWS needs 5 IP address to use. In my opinion for p=29, they might found it inefficient to occupy 5 addresses to provide 3 possible IP address.

Number of possible IP addresses can be calculated by using this formula:

NumberOfPossibleIPs = 2^(32-p) - 5

like image 166
Safak Ozdek Avatar answered Sep 22 '22 18:09

Safak Ozdek