What is a subnet calculator?
A subnet calculator is a tool that does subnet maths for you. You give it an IPv4 address and a subnet mask (or a CIDR number like /24). It tells you everything about the subnet that address belongs to.
It shows you:
- The network address (the start of the subnet)
- The broadcast address (the end of the subnet)
- The first and last usable IP you can give to devices
- The number of hosts the subnet can hold
- The wildcard mask used in router and firewall rules
You can use it to plan a network, set up routers and firewalls, write access lists, study for a networking exam, or check if two devices are in the same subnet.
How to use this calculator
Using the calculator takes only a few seconds. Follow these steps.
Type an IPv4 address in the IP Address box, for example 192.168.0.1. An IPv4 address has four numbers separated by dots. Each number must be from 0 to 255.
- You can only type numbers and dots. Other characters are removed for you.
- Numbers like
256or01are not allowed. The box turns red and shows a short message if something is wrong. - IPv6 addresses are not supported.
You can set the size in two ways. Both ways always stay in sync, so use the one you like.
- Type a subnet mask in the Subnet Mask box, for example
255.255.255.0. - Move the CIDR slider from 0 to 32. The mask updates by itself. A bigger number means a smaller subnet.
10.0.5.17/22, into the IP Address box. The calculator will fill in the IP, the CIDR and the mask for you.The Subnet Details table updates as you type. Here is what each row means:
- Network Address – the first address of the subnet. It names the subnet and is not given to a device.
- First Usable IP – the first address you can give to a device.
- Last Usable IP – the last address you can give to a device.
- Broadcast Address – the last address of the subnet. It is used to reach all devices at once and is not given to a device.
- Total Usable Hosts – how many devices you can connect.
- Total Available Hosts – all addresses in the subnet, including the network and broadcast addresses.
- Subnet Mask – the mask in dotted form, for example
255.255.255.0. - Wildcard Mask – the opposite of the subnet mask. Cisco access lists and OSPF use it.
- Binary Subnet Mask – the same mask written in 1s and 0s.
- IP Type – tells you if your address is private, public, loopback, multicast and so on, and its class (A to E).
- Click Copy to copy all results as plain text. You can paste it into a document or a chat.
- Click Download to save all results as a CSV file. You can open it in Excel or Google Sheets.
- Both buttons are turned off while the IP address or mask has an error.
Common mistakes
- "Not a valid subnet mask" – a mask must be a row of 1s followed by a row of 0s.
255.255.255.0is valid.255.0.255.0is not. - Wrong number of hosts – remember that two addresses (network and broadcast) are not usable. A
/24has 256 addresses but only 254 usable hosts. - Results look empty – check the IP Address and Subnet Mask boxes for a red message.
How the subnet maths works
An IPv4 address is a 32-bit number. The subnet mask splits those 32 bits into two parts: the network part (the 1s in the mask) and the host part (the 0s in the mask). All the results come from these simple rules:
Two ways to find the broadcast address. Both give the same answer. The first way sets every host bit to 1 (that is what OR with the wildcard mask does). The second way adds the number of addresses, minus 1, to the network address. For 192.168.0.0/24: 192.168.0.0 + 255 = 192.168.0.255.
Worked example: 192.168.0.1/24
Step 1. Write the IP address and the mask in binary (/24 means the first 24 bits are 1s):
Step 2. Network address: AND the two lines. A bit stays 1 only if both bits are 1.
Step 3. Wildcard mask: flip every bit of the subnet mask.
Step 4. Broadcast address: OR the network address with the wildcard mask. This turns all host bits into 1s.
Step 5. Count the hosts. There are 8 host bits (32 − 24 = 8), so the subnet has 28 = 256 addresses. Remove the network and broadcast addresses and 254 are usable. The first usable IP is 192.168.0.1 and the last is 192.168.0.254.
This is the result you get from the calculator. The table below is built live with the same code, so it always matches the calculator:
Why subtract 2?
The first address names the network. The last address is the broadcast address. A normal device cannot use either of them, so usable hosts = total addresses − 2.
There are two special cases:
/31– used for links between two routers (RFC 3021). Both addresses are usable, so there are 2 hosts and no broadcast address./32– a single host. The subnet has only 1 address.
IPv4 CIDR chart (/0 to /32)
This chart lists every prefix length with its subnet mask, wildcard mask and host counts. Usable hosts are the total addresses minus 2, except for /31 (2 usable) and /32 (1 usable).
| CIDR | Subnet mask | Wildcard | Total addresses | Usable hosts |
|---|
Standard IPv4 classes
In the old classful system, the first number of an IPv4 address decides its class. Each class has a default subnet mask. Today, networks use CIDR instead, so you can pick any prefix length. The classes are still useful for learning and for exams.
| Class | First number | IP range | Default mask | CIDR | Networks | Hosts per network | Used for |
|---|---|---|---|---|---|---|---|
| A | 1 – 126 | 1.0.0.0 – 126.255.255.255 | 255.0.0.0 | /8 | 126 | 16,777,214 | Very large networks |
| – | 127 | 127.0.0.0 – 127.255.255.255 | Not used | – | – | – | Loopback (reserved) |
| B | 128 – 191 | 128.0.0.0 – 191.255.255.255 | 255.255.0.0 | /16 | 16,384 | 65,534 | Medium networks |
| C | 192 – 223 | 192.0.0.0 – 223.255.255.255 | 255.255.255.0 | /24 | 2,097,152 | 254 | Small networks |
| D | 224 – 239 | 224.0.0.0 – 239.255.255.255 | Not used | – | – | – | Multicast |
| E | 240 – 255 | 240.0.0.0 – 255.255.255.255 | Not used | – | – | – | Reserved for research |
Class A starts at 1 and ends at 126. The blocks 0.0.0.0/8 ("this network") and 127.0.0.0/8 (loopback) are reserved. They are not normal Class A networks, so Class A has 126 networks.
Private and special IPv4 ranges
These ranges are set aside for special uses. The IP range column shows the first and last address of each block.
| Range | IP range | Total addresses | Purpose |
|---|---|---|---|
| 10.0.0.0/8 | 10.0.0.0 – 10.255.255.255 | 16,777,216 | Private (RFC 1918) |
| 172.16.0.0/12 | 172.16.0.0 – 172.31.255.255 | 1,048,576 | Private (RFC 1918) |
| 192.168.0.0/16 | 192.168.0.0 – 192.168.255.255 | 65,536 | Private (RFC 1918) |
| 100.64.0.0/10 | 100.64.0.0 – 100.127.255.255 | 4,194,304 | Shared address space (carrier-grade NAT) |
| 127.0.0.0/8 | 127.0.0.0 – 127.255.255.255 | 16,777,216 | Loopback |
| 169.254.0.0/16 | 169.254.0.0 – 169.254.255.255 | 65,536 | Link-local (APIPA) |
| 224.0.0.0/4 | 224.0.0.0 – 239.255.255.255 | 268,435,456 | Multicast |