IPv4 · Local calculator

IP Range Calculator

An allocation request can name arbitrary first and last addresses. Those endpoints may cut across CIDR boundaries. Compare the exact CIDR list with the single covering block before describing the range in an inventory.

Inputs

Result

Address count
6
Smallest covering prefix
192.0.2.0/28
Extra addresses in covering prefix
10
Calculated or matching entries
Exact CIDR blocksAddresses
192.0.2.5/321
192.0.2.6/312
192.0.2.8/312
192.0.2.10/321
In this guide12 sections

Introduction

An allocation request can name arbitrary first and last addresses. Those endpoints may cut across CIDR boundaries. Compare the exact CIDR list with the single covering block before describing the range in an inventory.

Formula and calculation

Inclusive IPv4 range size
count = last − first + 1

Both endpoints are included. The tool also partitions the range into aligned CIDR blocks and reports the smallest single prefix that covers it.

first, last · address value
ordered IPv4 endpoints interpreted as unsigned 32-bit integers

Method and concepts

For an inclusive interval, count = last − first + 1 using the unsigned integer addresses. A single CIDR needs a power-of-two size and an aligned start. For an exact list, begin at the first address, take the largest aligned block that fits, and repeat at the next address.

  1. Enter the lower IPv4 endpoint first and the higher endpoint second. Enter the same value twice for a one-address interval.
  2. Read the inclusive count. Check the first and last addresses of the single covering block against the requested endpoints.
  3. Use the exact component prefixes when addresses outside the original interval must be excluded.

IPv4 addresses and packet headers diagram

  1. IP packet · 1,500 bytes
  2. IPv4 header · 20 bytes
  3. IP payload · 1,480 bytes
  4. TCP data · 1,460 bytes
Read the sizes as a decomposition. After removing a 20-byte IPv4 header, a further 20-byte TCP header leaves 1,460 bytes for TCP data.

Worked examples

Express 192.0.2.5 through 192.0.2.10 exactly

  1. The interval contains 10 − 5 + 1 = 6 addresses. The smallest single covering block is 192.0.2.0/28, spanning .0 through .15.
  2. Start with 192.0.2.5/32 because .5 is odd. Take 192.0.2.6/31 for .6–.7, then 192.0.2.8/31 for .8–.9. A /30 starting at .8 would pass the endpoint.
  3. Finish at 192.0.2.10/32. The four sizes sum to 1 + 2 + 2 + 1 = 6, with no gaps or overlap.

IPv4 addresses and packet headers: Read the first IPv4 byte 0x45

  1. Split 0x45 into the high hex digit 4 and low digit 5. The upper four bits identify version 4. The lower four encode an IHL of five words.
  2. Multiply 5 by 4 bytes to obtain the 20-byte header. With Total Length 1,500, the IP payload contains 1,480 bytes.
  3. If Protocol is 6 and the TCP header also occupies 20 bytes, the segment carries 1,460 application bytes. Adding IPv4 or TCP options reduces that amount at the same packet size.

Reference table

IP Range Calculator reference
Exact componentFinal octetsAddress count
192.0.2.5/3251
192.0.2.6/316–72
192.0.2.8/318–92
192.0.2.10/32101

Reading the result

The exact list describes membership, so /31 and /32 entries can appear regardless of link type. The cover is convenient for summarization, but this example's single /28 contains ten additional addresses.

Common mistakes

  • Dropping the inclusive +1 and obtaining zero for a one-address interval.
  • Assuming any range of eight addresses forms a /29. Its first integer address must also be a multiple of eight.

Frequently asked questions

What happens when the range crosses an octet boundary?

Carry into the preceding octet. The range 192.0.2.254 through 192.0.3.1 contains .2.254, .2.255, .3.0 and .3.1, four consecutive values.

Why can two nearby endpoints have a large cover?

Addresses on opposite sides of a major binary boundary can differ in an early bit. The single cover can keep only the bits shared before that first difference.

What does /32 mean on a route?

All 32 address bits must match. The route represents exactly one IPv4 value and can identify a loopback or another specific destination.

Is the IPv4 Protocol number the service port?

No. The protocol number selects a payload format, for example UDP 17. A UDP header then carries source and destination port numbers.

How many bytes are in the minimum IPv4 header?

The minimum header is 20 bytes. The IHL field counts 32-bit words, so a value of five represents 20 bytes; options can make it longer.

Does IPv4 Total Length include Ethernet framing?

No. It counts the IPv4 header and IPv4 payload. Link-layer framing is outside that length field.

What happens when an IPv4 packet is larger than an outgoing MTU?

Depending on the Don't Fragment setting and path behavior, it may be fragmented or dropped with an ICMP message. Path MTU discovery uses this feedback to find a usable packet size.

Does an IPv4 Protocol number identify a TCP or UDP port?

No. The Protocol field identifies the payload protocol, such as TCP or UDP. A TCP or UDP header then contains the service ports.

What does TTL protect against?

IPv4 Time To Live bounds how many forwarding hops a packet can survive. Routers decrement it so a packet cannot circulate forever in a forwarding loop.

Is the IPv4 header checksum an end-to-end payload checksum?

No. It covers the IPv4 header only and is recomputed when mutable header fields such as TTL change. Transport protocols have separate integrity fields.

Can IPv4 fragmentation be reassembled at every router?

No. Fragmentation can occur during forwarding when permitted, but fragments are normally reassembled by the destination host, not each intermediate router.

Why use documentation IPv4 ranges in examples?

The designated documentation blocks avoid using a real organization's address in examples. They should not be treated as ordinary public service addresses.

What is the difference between limited broadcast and directed broadcast?

The limited broadcast address is 255.255.255.255 and is confined to the local link. A directed broadcast targets the all-ones host part of a particular IPv4 subnet and is commonly filtered by routers.

Can two routers advertise the same IPv4 prefix?

They can provide alternative routes to the same prefix. Routing policy and metrics determine whether one is preferred or both are installed for load sharing.

Why is classful addressing considered historical?

The original A, B, and C boundaries fixed network sizes at coarse octet edges. CIDR allows a prefix boundary at any bit and is used for modern allocation and routing.

What is the IPv4 header checksum recalculated over?

It covers the IPv4 header, not the payload. Because forwarding changes TTL, a router updates the checksum as the packet traverses the path.

When can a /31 IPv4 prefix be useful?

On a point-to-point link, RFC 3021 allows both addresses to be assigned to the two endpoints. It avoids reserving separate network and broadcast values where those functions are not needed.

Further learning and references