## Saturday, June 01, 2019

### How To Tell The Count of IP Numbers In a CIDR Notation

This post about how to get the count of IP numbers a CIDR notation depicts, is in the series of posts on Tips to Quickly Perform Binary and CIDR Operations. It is borne out of my experience working on ip-num, a typescript library for working with ASN, IPv4, and IPv6 numbers.

### How to tell the count of IP number in a CIDR notation

You have a CIDR notation and you want to quickly calculate how many ip numbers present in the range represented by the CIDR notation.

• Subtract the CIDR prefix from 32. If it is an IPv6 address, subtract from 128
• Raise 2 to the power of the result of the above subtraction
Example:
How many IP addresses are in a /17, /25, /30 assuming IPv4?
/17 = 2 (32-17) = 2 15 = 32768 IP addresses
/25 = 2 (32-25) = 2 7 = 128 IP addresses
/30 = 2 (32-30) = 2 2 = 4 IP addresses

Previous post: How to tell the size of IP number in a CIDR notation
Next post: How to tell which CIDR notation is bigger