CIDR to subnet calculation

CIDR (Classless Inter-Domain Routing) notation is a way to specify IP addresses and subnet masks using a format like 192.168.1.0/24, where the /24 indicates the number of bits used for the network part of the address. In this example, 192.168.1.0 is the network address, and 24 is the subnet mask, which can also be represented as 255.255.255.0.

Here’s a simple way to manually calculate subnets from CIDR notation:

Steps:

  1. Identify the CIDR Block: For example, let’s consider 192.168.1.0/24.
  2. Calculate Subnet Mask:
  • Convert the number after the slash (/) to a subnet mask. The number 24 in /24 means that the first 24 bits are set to 1 in the subnet mask. In binary, it looks like 11111111.11111111.11111111.00000000.
  • Convert each octet back to decimal: 255.255.255.0
  1. Find the Network Address: This is usually the IP address before the slash. In this example, it’s 192.168.1.0.
  2. Calculate the Broadcast Address:
  • Invert the subnet mask (turn 1s into 0s and vice versa): 00000000.00000000.00000000.11111111 (in binary) which is 0.0.0.255 (in decimal).
  • Perform a bitwise OR operation between this number and the Network Address:
    • 192.168.1.0 OR 0.0.0.255 = 192.168.1.255
  1. Identify Usable IP Range:
  • The first IP address in the range is the Network Address + 1: 192.168.1.1
  • The last IP address in the range is the Broadcast Address – 1: 192.168.1.254

So, for 192.168.1.0/24:

  • Subnet Mask: 255.255.255.0
  • Network Address: 192.168.1.0
  • Broadcast Address: 192.168.1.255
  • Usable IP Range: 192.168.1.1 to 192.168.1.254

Note: There are many online tools available that can perform these calculations for you, but it’s good to know how to do it manually as well.

Leave a comment