Wednesday, February 5, 2020

Basics of CIDR notations in Oracle cloud OCI

Supposedly, my network admin has created a VCN for me with CIDR block  10.10.10.0/24.
Oops, i should have started with the notations for CIDR. Let's get started.

To prevent IPs exhaustion, a new scheme known as Classless Inter-Domain Routing(CIDR) was introduced in 1993. CIDR notation is based on an IPv4 or IPv6 network or routing prefix separated by a slash from a number indicating the prefix length. OCI networking uses IPv4 addressing so the address length is 32 bits. Consider the block of IPv4 addresses specified with the following CIDR notation:10.10.10.0/24

The first part is the network identifier and the second part is host address space.

network identifier/host address space

Decimal values/host address space.


The number of addresses available for host addresses may be derived using the formula 2 , where n is the network prefix. In OCI, the networking service reserves the first IP, known as the network address; the last IP, known as the broadcast address; as well as the first host address in the CIDR range, known as the subnet default gateway address; so the actual usable number of addresses in a VCN is 2 –3

Thus in my case, 10.10.10.0/24 will have 256 hosts(32-24=8. 2 ^8=256). Out of the 256 hosts, as per the explanation above, we can have 253 hosts available.

There is a site https://www.ipaddressguide.com/cidr using which we can find all the relevant details for the CIDR block.






Now, lets us go through one scenario which will help us in putting up the CIDR block for our subnets inside a particular vcn.


My VCN-10.10.10.0/24-total 256 hosts

First Ip-10.10.10.0
Last ip-10.10.10.255


Now if i create a subnet and use the CIDR value-10.10.10.0/26, it will be created. So if we calculate the total number of hosts utilized by this CIDR block, it will be 64 hosts. So inside the VCN, out of the total 256 hosts, 64 has been taken and thus next should start from 64 onwards. If i try to create a subnet with CIDR value below


I will get the above error mentioned in the screenshot because from 0-63, it has already been used by 10.10.10.0/26 and using 10.10.10.0/25 will overlap with 10.10.10.0/26. So i will have to use the CIDR blocks, for which the ip addresses start from 64 onwards.


If i use 10.10.10.64/26, it will reserve another 64 addresses starting from 10.10.10.64 to 10.10.10.127. If we don't want to reserve that much of addresses, it is always better to go for CIDR blocks which will have less number of hosts inside that. So we can use 10.10.10.64/30 which will have 4 IP addresses. Next CIDR can be used from 10.10.10.68/30 and so on. Thus we will be able to accommodate more number of CIDR blocks if we can calculate in a wise manner.

Another aspect is, if my VCN CIDR is 10.10.10.0/24 and if i need to create subnets, then my CIDR range also depends upon host address space. For example, if i decide that my host address space would be 4, then my CIDR can be 10.10.0.40/30 or 10.10.0.44/30 or 10.10.0.48/30 or 10.10.0.52/30. It can't be 10.10.0.50/30. Similarly, if i choose my host address space would be 8, then it would be like 10.10.10.32/29 or 10.10.10.24/29 etc.


Hope this will help someone. Happy learning cloud




No comments:

Post a Comment