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.
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
-
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.
-
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.
-
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.
-
Work out the usable range
Everything between the network and broadcast addresses. For a /26 that is 62 usable hosts from .65 to .126.
-
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.
-
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?
What is the difference between a subnet mask and a wildcard mask?
Why can a /26 not start at 192.168.1.50?
Which ranges are private?
How do I split a network into smaller subnets?
Tools used in this guide
All tools →- Subnet Calculator Work out the network, broadcast and usable host range for a CIDR block. In your browser
- IP Address Lookup See the network, organisation and approximate location of an IP. Server-side
- IP Address Extractor Find IPv4 and IPv6 addresses in logs and text. In your browser
- Number Base Converter Convert numbers between any bases from 2 to 36. In your browser
- DNS Lookup Query A, AAAA, MX, NS, TXT, CNAME, SOA and SRV records. Server-side
Related guides
All guides →Last reviewed .