Using the calculator
Type an address with its prefix, like 192.168.1.10/24, or with its mask, like 192.168.1.10 255.255.255.0. The calculator gives the network address, the broadcast address, the range of usable host addresses, the subnet and wildcard masks, how many addresses there are, and whether the address is in a private or other special-purpose range.
Show the steps writes the address and mask in binary and ANDs them, the way it's done by hand, and the drawing marks which of the 32 bits are network and which are host. To split a range of addresses into CIDR blocks, use the CIDR calculator.
How subnetting works
An IPv4 address is 32 bits. The prefix says how many of them, from the left, name the network; the rest pick a host on it. In 192.168.1.10/24, the first 24 bits, 192.168.1, are the network and the last 8 are the host.
To find the network address, AND the address with the mask: every host bit becomes 0. To find the broadcast address, set every host bit to 1. With h host bits there are 2ʰ addresses, and two of them, the network and the broadcast, can't be given to a host. A /24 has 8 host bits: 256 addresses and 254 hosts.
Private ranges and the small prefixes
RFC 1918, from February 1996, set aside three blocks for private networks: 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. Addresses in them aren't routed on the public internet, which is why home networks are usually numbered from one. The calculator also names the other special-purpose ranges in IANA's registry, like 127.0.0.0/8 for loopback. Multicast addresses, 224.0.0.0 to 239.255.255.255, are named too.
A /31 has only two addresses. RFC 3021, from December 2000, lets both be used as hosts on a point-to-point link, with no network or broadcast address. A /32 is a single host.
A worked example: 172.16.5.4/20
/20 means 20 network bits and 12 host bits. In binary the address is 10101100.00010000.00000101.00000100 and the mask is 11111111.11111111.11110000.00000000. ANDing them clears the last 12 bits and leaves 10101100.00010000.00000000.00000000, which is 172.16.0.0, the network.
Setting those 12 bits to 1 instead gives 172.16.15.255, the broadcast. Everything in between is a host, from 172.16.0.1 to 172.16.15.254, which makes 2¹² − 2 = 4,094 usable hosts. The third octet is where the work happens, because that's where the mask stops being 255: 5 AND 240 is 0, and 0 plus the 15 free values gives the 15 in the broadcast.
Splitting a network into subnets
Each bit added to the prefix halves the block and doubles the number of blocks. 192.168.1.0/24 split into /26 subnets gives four, at 192.168.1.0, 192.168.1.64, 192.168.1.128 and 192.168.1.192, each with 64 addresses and 62 hosts. Split into /27 it gives eight blocks of 32, starting every 32 addresses.
To pick a prefix from the number of hosts you need, find the smallest power of two that's at least two more than that number. 50 hosts need 64 addresses, so 6 host bits, which is a /26 with the mask 255.255.255.192.
Questions
What's a wildcard mask?
The subnet mask with every bit flipped: 255.255.255.0 becomes 0.0.0.255. Router access lists use it to say which bits of an address are allowed to vary.
How many hosts in a /24?
254. The 8 host bits give 256 addresses, minus the network and broadcast addresses.
Does it work for IPv6?
Not yet. It handles IPv4 addresses, which are the ones subnetting is usually taught with.
Sources
- RFC 1918: Address Allocation for Private Internets
- RFC 3021: Using 31-Bit Prefixes on IPv4 Point-to-Point Links
- IANA IPv4 Special-Purpose Address Registry
Added . Last updated and reviewed . What's new






