How-to guide

How to Calculate a Subnet

To calculate a subnet, take the address and prefix length — 192.168.1.0/24 — and split the 32 bits into a network part and a host part. The prefix says how many leading bits are the network. The first address in the block identifies the network and the last is the broadcast, so a /24 holds 256 addresses but 254 usable ones.

Subnet Calculator

Work out the network, broadcast and usable host range for a CIDR block.

Open the tool

CIDR notation looks cryptic and is actually simple: the number after the slash is how many of the address's 32 bits belong to the network. Everything left over addresses hosts inside it. A /24 gives 24 network bits and 8 host bits, so 2⁸ = 256 addresses.

The part that trips people is the two reserved addresses. The lowest address in a block names the network itself and the highest is the broadcast address, so neither can be assigned to a machine — which is why a /24 holds 254 usable hosts rather than 256.

Step by step

  1. Read the prefix length

    The number after the slash is the count of network bits. Subtract it from 32 to get the host bits: a /26 has 6 host bits, so 2⁶ = 64 addresses in the block.

  2. Find the network address

    Set every host bit to zero. Blocks always start on a multiple of their size, so a /26 can begin at .0, .64, .128 or .192 and nowhere else. That is why 192.168.1.100/26 sits in the network 192.168.1.64/26.

  3. Find the broadcast address

    Set every host bit to one — the last address in the block. For 192.168.1.64/26 that is 192.168.1.127, and the next block begins at .128.

  4. Work out the usable range

    Everything between the network and broadcast addresses. For a /26 that is 62 usable hosts from .65 to .126.

  5. Convert the mask if you need it

    A prefix length and a dotted subnet mask say the same thing: /24 is 255.255.255.0, /26 is 255.255.255.192. Router interfaces usually want the dotted form; access control lists often want the wildcard mask, which is its inverse.

  6. Watch for the two exceptions

    A /31 has only two addresses and no room for a network or broadcast address, so both are usable — that is RFC 3021, for point-to-point links. A /32 is a single host, used for loopbacks and host routes.

Example

A host address rather than a network address, which is the common case when reading a configuration.

Input

10.20.30.40/22

Result

Network:    10.20.28.0/22
Mask:       255.255.252.0
Wildcard:   0.0.3.255
Broadcast:  10.20.31.255
Usable:     10.20.28.1 – 10.20.31.254
Hosts:      1,022

Frequently asked questions

Why does a /24 have 254 usable hosts and not 256?
The first address identifies the network itself and the last is the broadcast address for it, so neither can be assigned to a machine. That reservation applies to every block larger than a /31.
What is the difference between a subnet mask and a wildcard mask?
They are bitwise inverses. The subnet mask for a /24 is 255.255.255.0; its wildcard mask is 0.0.0.255. Cisco access control lists use the wildcard form, and mixing the two up produces rules that quietly match nothing.
Why can a /26 not start at 192.168.1.50?
Blocks always begin on a multiple of their own size, because the network address is what you get with every host bit set to zero. A /26 spans 64 addresses, so it can only start at .0, .64, .128 or .192.
Which ranges are private?
10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16, defined by RFC 1918. They are not routable on the public internet, which is why they can be reused inside every organisation.
How do I split a network into smaller subnets?
Increase the prefix length by one to halve the block: a /24 becomes two /25s, four /26s, and so on. Each step doubles the number of subnets and halves the hosts in each, and each one loses two addresses to its own network and broadcast.

Tools used in this guide

All tools →
All guides →

Last reviewed .