Skip to content

IP Range Calculator

Dotted IPv4 form, four parts from 0 to 255.

Included in the range.

Addresses in the range —
CIDR blocks needed
—
CIDR notation
—
First address as integer
—
Last address as integer
—

An IP range calculator turns a first and last IPv4 address into an address count and the CIDR blocks that cover it exactly. Each address is read as a 32-bit integer, so the count is last − first + 1. For example, 192.168.0.0 to 192.168.0.255 holds 256 addresses and is exactly one block, 192.168.0.0/24.

About this tool

Network engineers, hosting admins and anyone writing firewall, VPN or allow-list rules often receive an address range as two endpoints, while routers and cloud security groups want CIDR prefixes. Enter the first and last IPv4 address and the tool reports how many addresses the range contains, the integer value of each endpoint, and the shortest list of CIDR blocks that covers the range with no gaps and no extra addresses. A table lists every block with its own first address, last address and size, and the working shows the integer subtraction. One limit: it handles IPv4 only; IPv6 ranges use 128-bit addresses and are not parsed here.

How to use it

  1. Enter the first address

    Type the lowest IPv4 address of the range in dotted form, such as 10.0.0.5.

  2. Enter the last address

    Type the highest address; it is counted as part of the range.

  3. Read the count and prefixes

    The headline is the number of addresses; the CIDR line is ready to paste into a rule.

  4. Check each block in the table

    Every prefix is listed with its own first and last address and size.

Examples

192.168.0.0 to 192.168.0.255

First IP address
192.168.0.0
Last IP address
192.168.0.255

Result Addresses in the range: 256
CIDR blocks needed: 1
CIDR notation: 192.168.0.0/24
First address as integer: 3,232,235,520
Last address as integer: 3,232,235,775

  1. First address as an integer: 192.168.0.0 = 3232235520
  2. Last address as an integer: 192.168.0.255 = 3232235775
  3. Addresses = 3232235775 − 3232235520 + 1 = 256
  4. Split into the largest aligned power-of-two blocks: 1 CIDR block

A range that starts on a 256-address boundary and ends at its last address collapses into one /24 block.

10.0.0.5 to 10.0.0.20

First IP address
10.0.0.5
Last IP address
10.0.0.20

Result Addresses in the range: 16
CIDR blocks needed: 5
CIDR notation: 10.0.0.5/32, 10.0.0.6/31, 10.0.0.8/29, 10.0.0.16/30, 10.0.0.20/32
First address as integer: 167,772,165
Last address as integer: 167,772,180

  1. First address as an integer: 10.0.0.5 = 167772165
  2. Last address as an integer: 10.0.0.20 = 167772180
  3. Addresses = 167772180 − 167772165 + 1 = 16
  4. Split into the largest aligned power-of-two blocks: 5 CIDR blocks

Sixteen addresses, but because the range does not start on a block boundary it takes five CIDR entries to describe it exactly in a firewall rule.

172.16.0.0 to 172.16.3.255

First IP address
172.16.0.0
Last IP address
172.16.3.255

Result Addresses in the range: 1,024
CIDR blocks needed: 1
CIDR notation: 172.16.0.0/22
First address as integer: 2,886,729,728
Last address as integer: 2,886,730,751

  1. First address as an integer: 172.16.0.0 = 2886729728
  2. Last address as an integer: 172.16.3.255 = 2886730751
  3. Addresses = 2886730751 − 2886729728 + 1 = 1024
  4. Split into the largest aligned power-of-two blocks: 1 CIDR block

Four consecutive /24 networks that start on a multiple of four merge into a single /22 of 1,024 addresses.

How it is calculated

N = int(last) − int(first) + 1, where int(a.b.c.d) = a×16,777,216 + b×65,536 + c×256 + d

N
number of addresses in the range, both endpoints included
int()
the address read as an unsigned 32-bit number
/p
prefix length; a block of prefix p holds 2^(32 − p) addresses

Both endpoints are converted to integers and subtracted. To build the CIDR list, the tool starts at the first address and takes the largest power-of-two block that both starts on a multiple of its own size and does not pass the last address, then repeats from the next address. This greedy split gives the minimum number of prefixes, as described for CIDR aggregation in RFC 4632.

When not to use it

  • IPv6 ranges are not supported.
  • It does not look up who owns a range or where it is located.
  • For a known subnet mask, a subnet calculator shows hosts and broadcast more directly.

Common mistakes

  • Treating the count as usable hosts; a single subnet loses its network and broadcast addresses.
  • Writing 10.0.0.5/28 for an unaligned range; the router silently widens it to 10.0.0.0/28.
  • Typing the end address first, which reverses the range.

Frequently asked questions

Why does my range need several CIDR blocks?

A CIDR block must start on a multiple of its own size. A range like 10.0.0.5 to 10.0.0.20 starts on an odd address, so it is pieced together from blocks of 1, 2, 8, 4 and 1 addresses. Ranges starting and ending on a boundary collapse into one prefix.

How many usable hosts are in a /24?

A /24 contains 256 addresses. When it is used as one ordinary subnet, the first is the network address and the last is broadcast, leaving 254 for hosts. Point-to-point /31 links and single /32 routes are exceptions to that rule.

What does the integer value of an IP mean?

An IPv4 address is a 32-bit number written as four bytes. 10.0.0.5 equals 10 × 16,777,216 + 5 = 167,772,165. Databases and geolocation files often store addresses this way because ranges become simple numeric comparisons.

Is the last address included in the count?

Yes. Both endpoints are counted, so 8.8.8.8 to 8.8.8.8 is one address and 192.168.0.0 to 192.168.0.255 is 256.

What is the largest range it accepts?

Everything from 0.0.0.0 to 255.255.255.255, which is 4,294,967,296 addresses and the single block 0.0.0.0/0. Any IPv4 range splits into at most 62 CIDR blocks.

Can I paste the CIDR list into a firewall?

The comma-separated list is standard notation accepted by most firewalls, cloud security groups and web server allow rules. Some systems want one prefix per line, so check the syntax your platform expects.