Work out the first and last address of a CIDR block, and how many addresses the range contains.
Masking the address clears every host bit, which lands on the first address of the block. ORing that with the inverted mask sets every host bit, giving the last address. The count is simply two raised to the number of host bits. Firewall rules, DHCP exclusions and cloud security groups are written as ranges, so translating a prefix into explicit bounds prevents rules that overlap or leave gaps.
IP Range
first = IP AND mask, last = first OR NOT(mask), total = 2^(32 − p).
first = IP AND mask, last = first OR NOT(mask), total = 2^(32 − p). Masking the address clears every host bit, which lands on the first address of the block. ORing that with the inverted mask sets every host bit, giving the last address. The count is simply two raised to the number of host bits.
Firewall rules, DHCP exclusions and cloud security groups are written as ranges, so translating a prefix into explicit bounds prevents rules that overlap or leave gaps.
This calculator takes 2 inputs: IPv4 address, Prefix length (CIDR). The pre-filled defaults are a realistic starting point — replace them with figures from your own environment for a result you can act on.