Subnet Calculator (IPv4 CIDR)

A /24 network leaves 8 bits for devices, so it holds 256 addresses with 254 usable: the all-0s network address and the all-1s broadcast address can’t be given to a device. Type an IPv4 address and its prefix (the /24 in 192.168.1.10/24) or its subnet mask (255.255.255.0) to see the network it belongs to, the first and last usable addresses, the broadcast address and how many devices fit. This is Classless Inter-Domain Routing (CIDR) notation, the way networks have been written since the 1990s.

Prefix as 24 or /24, or a mask like 255.255.255.0. You can also type 10.0.0.0/8 in the address box.

Network
192.168.1.0/24 Private (RFC 1918)

192.168.1.10/24 is in the network 192.168.1.0/24 with 254 usable host addresses: 192.168.1.1 – 192.168.1.254.

Usable hosts 254
Subnet mask 255.255.255.0
Addresses 256
Network address
192.168.1.0
Broadcast address
192.168.1.255
First usable
192.168.1.1
Last usable
192.168.1.254
Wildcard mask
0.0.0.255
Mask in binary
11111111.11111111.11111111.00000000

How to calculate a subnet

An IPv4 address is 32 bits, written as four numbers from 0 to 255. The prefix says how many of those bits, from the left, are the network; the rest number the devices. Line the address up with the mask in binary and three things follow:

Network = address AND mask · Broadcast = network OR wildcard · Usable hosts = 2^(32 − prefix) − 2

Here it is with your numbers:

  1. /24 means the first 24 of the 32 bits are the network, so the mask is 11111111.11111111.11111111.00000000, which is 255.255.255.0.
  2. Keep the address’s bits where the mask has a 1 (a bitwise AND): 192.168.1.10 gives the network address 192.168.1.0.
  3. Turn the other 8 bits on (OR with the wildcard 0.0.0.255) for the broadcast address, 192.168.1.255.
  4. 2⁸ is 256 addresses; take away the network and broadcast addresses: 256 − 2 = 254 usable hosts.

It means devices on 192.168.1.0/24 can use the addresses 192.168.1.1 – 192.168.1.254.

The host part may not be all 0s or all 1s: all 0s is the network’s own address and all 1s is its broadcast address, so they can’t be given to a device. That is where the “minus 2” comes from. A /31 is the exception: on a link between two routers both addresses are used.

Source RFC 4632 · Classless Inter-domain Routing (CIDR), §3.1 prefix notation ↗RFC 1122 · Requirements for Internet Hosts, §3.2.1.3 addressing ↗RFC 3021 · Using 31-Bit Prefixes on IPv4 Point-to-Point Links ↗

CIDR to subnet mask chart

Tap a prefix to see it worked out for 192.168.1.10.

PrefixSubnet maskUsable hosts
/8255.0.0.016,777,214
/9255.128.0.08,388,606
/10255.192.0.04,194,302
/11255.224.0.02,097,150
/12255.240.0.01,048,574
/13255.248.0.0524,286
/14255.252.0.0262,142
/15255.254.0.0131,070
/16255.255.0.065,534
/17255.255.128.032,766
/18255.255.192.016,382
/19255.255.224.08,190
/20255.255.240.04,094
/21255.255.248.02,046
/22255.255.252.01,022
/23255.255.254.0510
/24255.255.255.0254
/25255.255.255.128126
/26255.255.255.19262
/27255.255.255.22430
/28255.255.255.24014
/29255.255.255.2486
/30255.255.255.2522
/31255.255.255.2542
/32255.255.255.2551

Each block has 2 more addresses than usable hosts, for the network and broadcast addresses (except /31 and /32). Each step down the chart halves the network. The chart starts at /8, the size of block the Internet Assigned Numbers Authority (IANA) hands to the regional internet registries.

Private IP address ranges

Three blocks are set aside for private networks, such as the one behind your home router. They are never routed on the public internet, so every home can use the same ones:

BlockRangeAddresses
10.0.0.0/810.0.0.0 – 10.255.255.25516,777,216
172.16.0.0/12172.16.0.0 – 172.31.255.2551,048,576
192.168.0.0/16192.168.0.0 – 192.168.255.25565,536

Addresses starting 127 are loopback: they always mean “this computer” and never leave it.

Source RFC 1918 · Address Allocation for Private Internets, §3 ↗

FAQs

What is a subnet mask and why is it used?

A subnet mask marks which bits of an IPv4 address are the network and which are the device: 1s for the network, then 0s. 255.255.255.0 is 24 ones, so in 192.168.1.10 the network is 192.168.1 and the device is 10. Devices on the same network talk directly; anything else goes through a router.

Source RFC 4632 · Classless Inter-domain Routing (CIDR), §3.1 prefix notation ↗

Is CIDR the same as subnet mask?

They say the same thing two ways. The CIDR prefix counts the 1 bits (/24), and the mask writes them out as four numbers (255.255.255.0). /16 is 255.255.0.0, /20 is 255.255.240.0.

What is the subnet mask if the CIDR is 22?

/22 is 255.255.252.0: 22 ones, then 10 zeros. It holds 1,024 addresses, 1,022 of them usable by devices.

What is the subnet mask for a 30 CIDR?

/30 is 255.255.255.252: 4 addresses, 2 of them usable, the usual size for a link between two routers. A /31 (255.255.255.254) can do the same with 2 addresses and no waste.

Source RFC 3021 · Using 31-Bit Prefixes on IPv4 Point-to-Point Links ↗

How many hosts are in a 27 subnet?

A /27 has 32 addresses, so 30 usable hosts: the first is the network address and the last is the broadcast address.

Source RFC 1122 · Requirements for Internet Hosts, §3.2.1.3 addressing ↗

How many IP addresses are in a 25?

A /25 has 128 addresses (2 to the power of 7), and 126 of them can be given to devices.

How big is a 24 CIDR?

A /24 has 256 addresses and 254 usable hosts, such as 192.168.1.1 to 192.168.1.254, with 192.168.1.0 as the network and 192.168.1.255 as the broadcast address.

Is 255.255.0.0 a subnet mask?

Yes: it is /16, 16 ones then 16 zeros, for 65,536 addresses (65,534 usable). It was the mask of the old “Class B” networks.

Source RFC 4632 · Classless Inter-domain Routing (CIDR), §3.1 prefix notation ↗

Is 29 subnet 248?

Yes. /29 is 255.255.255.248: 29 ones leaves 3 zero bits, and 256 − 8 is 248. It has 8 addresses and 6 usable hosts.

Sources

Related calculators