How the IP Subnet Calculator Works
An IPv4 address, such as 192.168.1.10, is a 32-bit number written as four parts. A subnet is a block of addresses that share the same first part, called the network part. The prefix length (CIDR) says how many of the 32 bits belong to the network. The rest are for the devices, called hosts. The IP Subnet Calculator uses the prefix to find the mask, the range and the number of hosts.
What you enter
- The IPv4 address, four numbers from 0 to 255 separated by dots.
- The prefix length, a number from 0 to 32, written after a slash. For example, /24.
The steps
mask = the first (prefix) bits set to 1, the rest set to 0 wildcard = the opposite of the mask network = address AND mask broadcast = network OR wildcard total = 2 ^ (32 - prefix) usable = total - 2
The first usable host is the network address plus 1. The last usable host is the broadcast address minus 1. Two addresses in each subnet are kept: the network address (the first) names the subnet, and the broadcast address (the last) reaches every device in it.
Worked example: 192.168.1.10/24
| Result | Value |
|---|---|
| Subnet mask | 255.255.255.0 |
| Wildcard mask | 0.0.0.255 |
| Network address | 192.168.1.0 |
| Broadcast address | 192.168.1.255 |
| First and last usable host | 192.168.1.1 and 192.168.1.254 |
| Total addresses | 256 |
| Usable hosts | 254 |
A second example: 192.168.1.130/26
A /26 has 6 host bits, so each subnet has 64 addresses. The address 192.168.1.130 is in the subnet that starts at 192.168.1.128.
| Result | Value |
|---|---|
| Subnet mask | 255.255.255.192 |
| Network address | 192.168.1.128 |
| Broadcast address | 192.168.1.191 |
| Usable hosts | 62 (192.168.1.129 to 192.168.1.190) |
Chart: the 32 bits of an address
Green bits are the network part, and amber bits are the host part. Each block is one bit.
/8 ████████████████████████████████ /16 ████████████████████████████████ /20 ████████████████████████████████ /24 ████████████████████████████████ /26 ████████████████████████████████ /30 ████████████████████████████████
Every extra network bit halves the size of the subnet.
Common prefixes
| Prefix | Subnet mask | Total addresses | Usable hosts |
|---|---|---|---|
| /8 | 255.0.0.0 | 16,777,216 | 16,777,214 |
| /16 | 255.255.0.0 | 65,536 | 65,534 |
| /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 |
| /31 | 255.255.255.254 | 2 | 2 (point-to-point) |
| /32 | 255.255.255.255 | 1 | 1 (a single host) |
Chart: usable hosts from /24 to /30
Each block is about 6.4 hosts. A bar of at least one block is always drawn.
/24 ████████████████████████████████████████ 254 /25 ████████████████████ 126 /26 ██████████ 62 /27 █████ 30 /28 ██ 14 /29 █ 6 /30 █ 2
Special cases: /31 and /32
- /31 has only 2 addresses. By the rule "total minus 2" it would have none, but a standard called RFC 3021 allows both addresses to be used on a link between two devices. The calculator shows 2 usable hosts.
- /32 is a single address, used for one device such as a loopback or a route to one host. The calculator shows 1 host.
The type of address
The calculator also tells you what kind of address you entered:
| Range | Type |
|---|---|
| 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 | Private, for use inside a home or an office |
| 127.0.0.0/8 | Loopback, this computer |
| 169.254.0.0/16 | Link-local, self-assigned when no server answers |
| 100.64.0.0/10 | Shared space used by internet providers (carrier-grade NAT) |
| 224.0.0.0 to 239.255.255.255 | Multicast |
| 240.0.0.0 and above | Reserved |
| Everything else | Public |
The class (A, B, C, D or E) comes from the first number of the address. It is the old way of sizing networks, and today the prefix length is what counts.
Tips
- Choose the prefix from the hosts you need. Add 2 to the number of devices, then take the smallest block that is big enough. For 50 devices, 52 addresses need a /26 (64 addresses).
- Leave room to grow. Changing a subnet later is more work than choosing a bigger one now.
- Type the address as four plain numbers. Numbers with a leading zero, such as 010, are not accepted, because some systems read them as octal.
What this calculator does not include
- IPv6 addresses.
- Splitting a network into several smaller subnets (VLSM), or joining networks into a summary route.
- Checking whether an address is free or in use on your network.
This tool is for planning and learning. Always check the design of a real network before you change equipment.