ShowIP.net
Menu

Network tool

Range to CIDR

Convert an IPv4 or IPv6 start and end address into the smallest set of CIDR blocks that covers the exact range. Use this when a vendor supplies address ranges but your firewall or API expects CIDR notation.

Start address
8.8.8.0
End address
8.8.8.255
IP version
IPv4
Total addresses
256
CIDR blocks
1
8.8.8.0/24

Reference

Range boundaries and CIDR blocks

Start and end address
The inclusive range that must be covered by the returned CIDR blocks.
IP version
The start and end values must both be IPv4 or both be IPv6.
CIDR blocks
Use all returned blocks together. Dropping a block leaves part of the submitted range uncovered.
Block count
Several blocks may be needed when a range is not aligned to one larger CIDR boundary.

Advertisement

Examples

Example ranges

Single CIDR block

8.8.8.0 - 8.8.8.255 Converts cleanly to one /24 block. Convert /24 range

Uneven range

8.8.8.1 - 8.8.8.3 Returns 8.8.8.1/32 and 8.8.8.2/31, covering all three addresses without adding any others. Convert uneven range

Boundaries

Limits

Start and end addresses must use the same IP version, and the start address must be lower than or equal to the end address. The result optimizes for the fewest CIDR blocks, not for provider ownership or routing policy.

To divide an existing network into equal-sized ranges, use the subnet splitter.

IP and CIDR libraries

Build the same kind of checks into your code using these documented libraries.

Python: ipaddress

Standard-library IPv4 and IPv6 parsing, networks and membership checks.

Go: net/netip

Standard-library address and prefix types with Contains and Overlaps methods.

ShowIP endpoint documentation

Next steps

Advertisement