How to calculate CIDR notation for IP ranges

· Category: Networking

Short answer

CIDR (Classless Inter-Domain Routing) notation represents IP ranges by appending a slash and a number to an IP address, such as 192.168.1.0/24. The number indicates how many bits are used for the network portion.

Steps

  1. Understand the bitmask: The CIDR number ranges from 0 to 32 for IPv4. A /24 means the first 24 bits are the network, leaving 8 bits for hosts.

  2. Calculate host count: Use the formula 2^(32 - CIDR) for total addresses, then subtract 2 for network and broadcast addresses if needed.

  3. Determine the subnet mask: Convert the CIDR to dotted-decimal. /24 equals 255.255.255.0, /16 equals 255.255.0.0.

  4. Find the range: The network address is the starting IP. Add the host count to find the broadcast address. Usable hosts lie in between.

  5. Use tools: Practice with calculators until manual calculation becomes natural.

Tips

  • Memorize common CIDR values: /8, /16, /24, /30, /32.
  • /30 is commonly used for point-to-point links.
  • /32 represents a single host.

Common issues

  • Miscounting bits when converting to decimal.
  • Forgetting that some cloud providers reserve additional IPs.
  • Using the wrong CIDR when merging or splitting networks.