Talk to a specialist

BLOG VLSM.io

IPv4 subnets: how to calculate them

Calculate IPv4 prefixes, boundaries, and subnets through worked examples that distinguish address totals, LAN capacity, and service delivery.

IPv4-only egressConnectivity and intelligence
Globe with IPv4-only outbound connections
IPv4-only egress203.0.113.24Illustrative addresses
Estimated reading time: 7 min8 sections
IPv4 subnets: how to calculate them
IPv4 subnets: how to calculate them
01

The prefix defines the block size

A subnet begins with a division between bits that identify the network and bits available inside it. An IPv4 address contains 32 bits. The notation 192.0.2.0/24 means that the first 24 belong to the prefix and the remaining eight can vary. Consequently, this block contains 2 to the power of 8, or 256 addresses. The number after the slash does not indicate a machine count. A longer prefix describes a smaller block because fewer bit positions remain available for variation.

The general formula is 2^(32 − prefix). A /16 therefore contains 65,536 addresses, a /20 contains 4,096, and a /24 contains 256. Before calculating, identify the question: total block size, covered range, possible child subnets, or capacity of a local network. Mixing these questions is a common source of apparently contradictory answers. The same block can be delivered through different architectures, and its mathematical address count does not independently determine how every address becomes available to applications.

PrefixMaskTotal addresses
/16255.255.0.065,536
/20255.255.240.04,096
/22255.255.252.01,024
/24255.255.255.0256
/25255.255.255.128128
/26255.255.255.19264
/27255.255.255.22432
/28255.255.255.24016
CONNECTIONS IN MOTIONThe path of your connection
ApplicationJob or integration
ConnectivityIPv4-only egress
DestinationSystem or service
Example of a service with IPv4-only Internet egress. IPv6 egress belongs to a separate service. The animation does not represent live traffic.
02

Converting the prefix into a subnet mask

A subnet mask expresses the same division as four decimal octets. With a /24, the first three octets are complete, producing 255.255.255.0. A /26 adds two network bits in the last octet: 128 plus 64 equals 192, producing 255.255.255.192. The six remaining bits allow 64 combinations. This explains why valid mask values do not increase one at a time. They follow powers of two and a continuous sequence of network bits filled from left to right.

To find the step between subnets in the relevant octet, subtract the mask value from 256. For /26, 256 minus 192 gives 64. Valid starting points inside 192.0.2.0/24 are therefore .0, .64, .128, and .192. An address such as 192.0.2.70/26 belongs to the network beginning at .64; it does not create a subnet beginning at .70. This distinction matters when entering routes, firewall rules, and inventory records: an interface address and a network address serve different purposes.

03

Finding the complete address range

Consider 192.0.2.64/26, using a block reserved for documentation. Its size is 64, so the final address is 63 positions after the first: 192.0.2.127. On a conventional IPv4 LAN, .64 identifies the network and .127 is the directed broadcast address for that subnet. The range ordinarily available to interfaces runs from .65 through .126, totaling 62 addresses. Host capacity uses 64 minus 2 in this particular context, rather than as a rule applying to every connectivity service.

Checking both boundaries is essential. If a spreadsheet says that the next subnet starts at .127, the ranges overlap; the correct start is .128. If it starts at .129, a boundary address was skipped. Record the prefix, first address, last address, gateway, and purpose in separate columns. A gateway may occupy an available interface address, but that is an implementation choice. Do not automatically subtract an additional address without checking whether the architecture actually places a gateway inside that range.

TRAFFIC AND ADDRESSINGObserve the source and track responses.
Source203.0.113.24
Destination198.51.100.20
Return203.0.113.24
Addresses reserved for examples. Track bidirectional traffic together with latency, failures, and application results.
04

Splitting a block into equal parts

Splitting a /24 into four equal parts requires two additional prefix bits because 2² equals four. The new prefix is /26. The resulting networks are 192.0.2.0/26, 192.0.2.64/26, 192.0.2.128/26, and 192.0.2.192/26. Each contains 64 addresses, and together they occupy exactly the original 256 addresses. The general method uses 2^(new prefix − original prefix) to count equal child subnets. Every child must remain inside its parent and must respect the binary boundaries associated with its own prefix length.

A /22 split into /24s produces four subnets, while a /24 split into /28s produces sixteen. The reverse calculation is useful too: four /26s can form a /24 if they are contiguous, aligned, and cover the correct aggregate completely. Four randomly selected blocks cannot be announced as one /24 merely because they total 256 addresses. Aggregation depends on position and continuity as well as quantity. Before advertising or summarizing routes, verify which destinations the aggregate includes and who is authorized to use them.

05

Applying VLSM to different requirements

VLSM allows different subnet sizes within the same addressing plan. Imagine three LANs requiring 100, 50, and 20 interfaces. One possible division of a /24 assigns a /25 to the first, a /26 to the second, and a /27 to the third. For conventional LANs, these choices provide 126, 62, and 30 host addresses. The allocation consumes 128 plus 64 plus 32 addresses, totaling 224, and leaves one /27 available for growth or another purpose established in the plan.

In the example block, the assignments can be .0/25, .128/26, and .192/27, preserving .224/27. Planning larger blocks first makes alignment easier. Mathematical efficiency does not replace operational headroom, however: a network expected to grow may need extra space. Document expected expansion, the reason for each size, and the renumbering approach if capacity is reached. This prevents a team from selecting a mask solely because it fits the current inventory exactly, without considering additional machines, infrastructure roles, or new services.

06

Understanding /31, /32, and proxy services

The familiar host formula, 2^(32 − prefix) minus 2, has exceptions. On supported point-to-point links, a /31 can use its two addresses for the two endpoints without applying the conventional network and broadcast division. A /32 identifies one address and is commonly used for host routes and logical interfaces. Negative or zero host results should therefore not be accepted mechanically in these cases. Link type and device support must accompany the interpretation of a subnet mask before a configuration is deployed.

With an IP Proxy service, the contracted address count is not necessarily the host capacity of a LAN. A service may expose egress addresses through mappings, routing, or provider-specific configurations. Confirm which addresses are usable, how access is authenticated, and what source destinations will observe. Separating these commercial and technical conditions from arithmetic prevents an incorrect promise about available egress addresses. Prefix size, usable IP availability, bandwidth, and connection concurrency are related dimensions, but each should be specified independently when evaluating a delivery.

FROM CONNECTION TO RESULTTurn requirements into an observable operation.
Plan
Connect
Monitor
Destination planning, connectivity configuration, and result validation are complementary steps. The animation represents this workflow.
07

Checking the result before deployment

Finish with an independent review of the mask, boundaries, containment within the parent, and absence of overlap. A subnet calculator helps, but the result should remain understandable to the team. For scripts and inventory systems, use addressing libraries that validate prefixes and operate on binary values. Comparing addresses as plain text can produce incorrect ordering. Also distinguish private, public, and documentation ranges: a mathematically correct example does not authorize deployment of those addresses on the real Internet or establish ownership of the range.

During deployment, compare inventory records with actual routes and with the source addresses observed when applications connect. This reveals issues that arithmetic alone cannot detect, such as an incorrect gateway, partial delivery, or unexpected source selection. Keep documentation with the change history and update reservations when services are added. When discussing subnet rental with VLSM.io, bring address requirements, the intended delivery method, and growth expectations. Sizing can then account for both the mathematical block and how the application will actually use it.

08

Institutional references

Reference documents on the topics covered in this article.