DEV Community 👩‍💻👨‍💻

Cover image for CIDR: a brief overview & subnet calculation
Rishita Shaw
Rishita Shaw

Posted on

CIDR: a brief overview & subnet calculation

Learn what IPv4, CIDR, CIDR Block, Subnetting and and how to calculate it...

Overview of IPv4
You must have heard about IP address, which stands for Internet Protocol. One popular version of IP is v4. IP version four addresses are 32-bit integers which will be expressed in decimal notation.
Example- 192.0.2.126 could be an IPv4 address. Now, IPv4 addresses come from a finite pool of numbers, which exactly contains 4,294,967,296 IPv4 addresses.

Why CIDR?
This may seem like a lot(and is a lot) but given the rapid exhaustion of IPv4 addresses, its efficiency was greatly reduced. Hence, in 1993 CIDR was invented.

What Is Subnetting?
You can think of Subnetting as the process of stealing bits from the HOST part of an IP address in order to divide the larger network into smaller sub-networks called subnets. After subnetting, we end up with NETWORK SUBNET HOST fields. We always reserve an IP address to identify the subnet and another one to identify the broadcast subnet address.

What is CIDR?
CIDR(Classless Inter-Domain Routing) also known as subnetting, was designed to improve the efficiency of address distribution. CIDR is based on variable-length subnet masking (VLSM), which enables network engineers to divide an IP address space into a hierarchy of subnets of different sizes, making it possible to create subnetworks with different host counts without wasting large numbers of addresses.

CIDR Notation
CIDR notation compactly indicates the network mask for an address and adds on the total number of bits in the entire address using slash notation. For example, 192.168.129.23/17 indicates a 17-bit network mask.

What is CIDR Block?
You may have come across this term in cloud services. To brief CIDR blocks are groups of addresses that share the same prefix and contain the same number of bits. Now if we put together multiple CIDR blocks together to make a network with a common prefix we call it supernetting. If a router knows routes for different parts of the same supernet, then it will use the most specific one -- or the one with the longest network address.

How to Subset a Class C Address?
Now let's see how to subnet the same Class C address. Let's use the IP address 192.168.10.44 with subnet mask 255.255.255.248 (/29).

The steps to perform this task are the following:

  1. The total number of subnets: Using the subnet mask 255.255.255.248, number value 248 (11111000) indicates that 5 bits are used to identify the subnet. To find the total number of subnets available simply raise 2 to the power of 5 (2^5) and you will find that the result is 32 subnets. Note that if subnet all-zeros is not used then we are left with 31 subnets and if also all-ones subnet is not used then we finally have 30 subnets.
  2. Hosts per subnet: 3 bits are left to identify the host therefore the total number of hosts per subnet is 2 to the power of 3 minus 2 (1 address for the subnet address and another one for the broadcast address)(2^3-2) which equals to 6 hosts per subnet.
  3. Subnets, hosts, and broadcast addresses per subnet: To find the valid subnets for this specific subnet mask you have to subtract 248 from the value 256 (256-248=8), which is the first available subnet address. Actually, the first available one is the subnet-zero which we explicitly note. The next subnet address is 8+8=16, the next one is 16+8=24 and this goes on until we reach value 248.

The following table provides all the subnet cal information. Note that our IP address (192.168.10.44) lies in subnet 192.168.10.40.

table

Thanks to Stelios for the awesome blog on subnet calculation: link

Top comments (2)

Collapse
avinash201199 profile image
Avinash Singh

Thanks for the brief overview !

Collapse
rishitashaw profile image
Rishita Shaw Author

Glad you enjoyed!

🌚 Browsing with dark mode makes you a better developer.

It's a scientific fact.