Skip to content
Omnikalc

IPv4 subnet calculator

Turn a CIDR prefix into a subnet mask and a number of addresses and usable hosts, find the smallest subnet for a number of hosts, and see how many smaller subnets fit inside.

Updated on
Your inputs
/

Value out of range

/

Value out of range

Value out of range

Results

Usable hosts
254
Total addresses
256
Subnet mask, 1st octet
255
Subnet mask, 2nd octet
255
Subnet mask, 3rd octet
255
Subnet mask, 4th octet
0
Smaller subnets that fit inside
4
Usable hosts in each smaller subnet
62
Smallest prefix for the hosts you need
26

CIDR notation

An IPv4 address has 32 bits. A CIDR prefix such as /24 says how many of those bits identify the network; the rest identify hosts inside it. A /24 network leaves 8 host bits, so it contains 2⁸ = 256 addresses.

Usable hosts

In each subnet, the first address is the network address and the last is the broadcast address, so:

Usable hosts = 2^(32 − prefix) − 2

Exceptions: a /31 has 2 usable addresses on point-to-point links (RFC 3021), and a /32 is a single host.

Common prefixes

Prefix Mask Addresses Usable hosts
/8 255.0.0.0 16,777,216 16,777,214
/16 255.255.0.0 65,536 65,534
/22 255.255.252.0 1,024 1,022
/24 255.255.255.0 256 254
/25 255.255.255.128 128 126
/26 255.255.255.192 64 62
/27 255.255.255.224 32 30
/28 255.255.255.240 16 14
/29 255.255.255.248 8 6
/30 255.255.255.252 4 2

Example

A /24 network, such as 192.168.1.0/24:

  • mask 255.255.255.0, 256 addresses, 254 usable hosts;
  • split into /26 subnets, it gives 4 subnets of 62 hosts each (.0, .64, .128 and .192);
  • for 50 hosts, you need at least 52 addresses, so a /26 (64 addresses) is the smallest subnet that fits.

How the mask is built

The mask has the prefix’s number of 1 bits, followed by 0 bits. Each full group of 8 ones gives 255. A partial octet gives 256 − 2^(number of zero bits in that octet): with /26, the last octet has 2 one bits and 6 zero bits, so 256 − 64 = 192.

Private address ranges

Home and office networks use private ranges that are not routed on the internet (RFC 1918):

  • 10.0.0.0/8
  • 172.16.0.0/12
  • 192.168.0.0/16

Planning tips

  • Leave room to grow: if you need 50 hosts today, a /26 leaves only 12 spare addresses.
  • Keep subnets aligned: a /26 must start at a multiple of 64 in its last octet.
  • IPv6 subnets are almost always /64, with an astronomical number of addresses; host counting matters far less there.

Frequently asked questions

How many hosts are in a /24?

256 addresses and 254 usable hosts.

What subnet mask is /26?

255.255.255.192, with 62 usable hosts.

Why subtract 2 from the number of addresses?

The first address identifies the network and the last is the broadcast address.

What prefix do I need for 100 hosts?

A /25, which has 126 usable hosts.

Was this calculator helpful?

Thanks for your feedback!

Results are estimates provided for information purposes. They do not replace professional advice.