Checking an IPv4 range across an octet boundary
Consecutive IPv4 addresses can differ in more than their last octet. This guide uses 198.51.100.255 and 198.51.101.0 to show why consecutive addresses may need two CIDR entries.
Address order follows the full 32-bit value
The address 198.51.100.255 is followed immediately by 198.51.101.0. In the last octet the values go from 255 to 0, so comparing last octets alone would say the second address comes first. The ordering that matters is the 32-bit number. 198.51.100.255 equals 3,325,256,959 and 198.51.101.0 equals 3,325,256,960, which is one more. The last octet wraps and the third octet increases by one, much like a car odometer rolling from 199 to 200. Each octet is a base-256 digit, with the first octet carrying the weight 16,777,216, the second 65,536, the third 256 and the fourth 1. Seen that way, 198.51.100.255 plus one carries into the third digit, exactly as 199 plus one carries into the tens place in everyday counting. All four octets form one number, and every comparison, count and range calculation should use that number.
Why two neighbors can need two entries
A CIDR block of two addresses must start at an even address, because its last bit is the free one. The first address here, 3,325,256,959, is odd. A two-address block starting there would have to cover 3,325,256,959 and 3,325,256,960, but the block that contains the odd address starts one lower, at 3,325,256,958. So the pair straddles an alignment boundary. The exact cover is two single-address entries, 198.51.100.255/32 and 198.51.101.0/32. Being consecutive is not the same as sharing a block, and the converter reports the exact cover rather than a larger block.
Spans that line up across the boundary
Crossing an octet boundary does not always force extra blocks. The range 198.51.100.0 through 198.51.101.255 holds 512 addresses and starts at a multiple of 512, since 100 is even in the third octet. The converter returns the single block 198.51.100.0/23. The difference lies in alignment, not in the octet change. A block that spans a boundary is fine when its start is a multiple of its size, and a pair that merely touches the boundary is not.
A four-address range across the boundary
Take 198.51.100.254 through 198.51.101.1. It has four addresses, which is the size of a /30. A /30 must start at a multiple of 4, and 254 is not one, since 252 is. The cover therefore uses two blocks of two: 198.51.100.254/31, covering .254 and .255, and 198.51.101.0/31, covering .0 and .1. If the range ran from 198.51.100.252 through 198.51.101.3, it would hold eight addresses and still need two /30 blocks, 252 to 255 and 0 to 3, because eight addresses starting at 252 do not align to a multiple of eight. Counting addresses and counting blocks are separate tasks.
The greedy cover and why it is exact
The converter starts at the first address and picks the largest block that begins there, fits the alignment of the start and stays within the end. It then moves to the address after that block and repeats. For the pair here it picks a single address at .255, because no larger aligned block fits, then a single address at 101.0, because the range ends there. The method produces the smallest number of blocks that cover the range exactly, with no address added or missed. Covering the same range with one larger block would silently include addresses you did not request.
Reversed endpoints are rejected
If you enter 198.51.101.0 as the start and 198.51.100.255 as the end, the tool rejects the range and says the start must not precede the end. A text comparison might read the zero in the first address and conclude it is smaller, but as a 32-bit number 198.51.101.0 is the larger of the two. The rejection comes from comparing complete addresses. If you see it, swap the endpoints. If the swap seems wrong, recheck both addresses, because a typo in the third octet changes the order as well. Importing ranges from another system is a common source of this problem, since exports sometimes list the end first or sort rows as text. Fix the order at the source, then rerun the cover so that the blocks and the inclusive count are produced from the corrected pair.
Documentation addresses and no live network
This guide concerns ordering and coverage only. The addresses come from the 198.51.100.0/24 and 198.51.101.0/24 neighborhood, where the first is reserved for documentation by RFC 5737, so the example points to no live network. Nothing here recommends a block size, a routing entry or a filter. Real allocations follow policy from a registry or network owner, and a range that covers addresses exactly is only one input to such decisions. The worked pairs also show a general pattern: the more a range straddles a power-of-two boundary, the more entries an exact cover needs, so a short range placed awkwardly can need more entries than a long range placed neatly. For example, the two addresses here need two entries, while 512 addresses starting at 198.51.100.0 need one. Use the arithmetic to check that a list of blocks matches a stated range, then take the policy question to whoever manages the addresses.
Testing your own boundary formula
If you write a spreadsheet or script that handles ranges, run it on a few boundary cases before trusting it. The pair 198.51.100.255 and 198.51.101.0 should give an inclusive count of 2 and two /32 entries. The range 192.0.2.255 through 192.0.3.0 behaves the same way, and 10.0.0.255 through 10.0.1.0 does too. A formula that subtracts last octets will return -255 for these, and one that sorts addresses as text may put 198.51.100.255 after 198.51.100.100 in a way that looks right only by luck. Converting to integers first, then comparing, subtracting and adding one, passes every case here.
Odd and even starts
A quick rule helps with small cases. An odd start address can only begin a single-address entry, because every larger block starts at an even number. A start that is a multiple of 4 can begin a four-address block, a multiple of 8 an eight-address block, and so on, as long as the end allows it. In the pair here, the first address ends in 255, which is odd, so the cover starts with a /32, and the range then ends at 101.0 after one more address. In the four-address example, 254 is even but not a multiple of 4, so it starts a two-address block at most. Checking the last bits tells you the largest block available.
Reproduce the checks
Cross-boundary exact cover
Open the Ipv4 Range To Cidr Calculator and enter:
- Start
198.51.100.255- End
198.51.101.0
Expected output:
Blocks
198.51.100.255/32
198.51.101.0/32Consecutiveness alone does not establish block alignment.
Reversed endpoints
Open the Ipv4 Range To Cidr Calculator and enter:
- Start
198.51.101.0- End
198.51.100.255
Expected rejection:
must not precedeThe implementation rejects reversed complete-address order.
References and implementation scope
The examples describe the behavior of the linked Computandum tools. A successful local check does not establish that another application accepts the same format or applies the same limits.
Sources
- Primary definition and convention reference ↗ · 2026-10-08