Subnet Calculator
Enter an IPv4 address and the prefix length (the number after the slash, such as 24). You get the network address, broadcast address, subnet and wildcard masks, the first and last usable host, and the number of hosts.
Your numbers
How we calculate it
An IPv4 address is a 32-bit number. The prefix length says how many of the leading bits name the network. The rest name the host. The subnet has 2^(32 − prefix) addresses, and the network address is your address with all the host bits set to zero. The broadcast address is the same with all the host bits set to one.
Normally the first and last address of the subnet are the network and broadcast addresses, so the usable hosts are 2^(32 − prefix) − 2. For example 192.168.1.10/24 has 256 addresses, the network 192.168.1.0, the broadcast 192.168.1.255 and 254 usable hosts from .1 to .254. The two exceptions are /31, which has two usable hosts and no broadcast (RFC 3021, for point-to-point links), and /32, which is a single host.
Assumptions and limits
- Only IPv4 is supported. IPv6 addresses are not accepted.
- Write the address with no leading zeros, such as 192.168.1.5 and not 192.168.001.005, because some systems read a leading zero as octal.
- The address type is shown for the address you typed. The main special ranges are labelled (private, loopback, link-local, carrier-grade NAT, documentation, multicast, reserved). Anything else is shown as Public.
- The network address is shown for the whole subnet even when you type a host address inside it.
Frequently asked questions
How many hosts are in a /24?
A /24 has 256 addresses and 254 usable hosts, because the first (network) and last (broadcast) addresses are not given to devices. A /25 has 126, a /26 has 62 and a /30 has 2.
What are the private IP ranges?
The private ranges in RFC 1918 are 10.0.0.0 to 10.255.255.255 (10.0.0.0/8), 172.16.0.0 to 172.31.255.255 (172.16.0.0/12) and 192.168.0.0 to 192.168.255.255 (192.168.0.0/16). They are not routed on the public internet.
What is a wildcard mask?
A wildcard mask is the subnet mask turned upside down, so 255.255.255.0 becomes 0.0.0.255. It is used in access lists on some network devices, where a 0 bit means the bit must match.
Related calculators
- Binary and Hex ConverterType a whole number, say which base it is in and which base you want.
- Download Time CalculatorEnter the file size, your connection speed and how much of that speed you actually get.
- Data Storage ConverterEnter an amount of data, choose the unit it is in and the unit you want.
- Ohm's Law CalculatorChoose which two values you know and type them in.
Worked example (a fixed example using the starting numbers, it does not change as you type)
Inputs: IPv4 address = 192.168.1.10; Prefix length (the number after the slash) = 24.
- Network address 192.168.1.0
- CIDR notation 192.168.1.0/24
- Broadcast address 192.168.1.255
- Subnet mask 255.255.255.0
- Wildcard mask 0.0.0.255
- First usable host 192.168.1.1
- Last usable host 192.168.1.254
- Usable hosts 254
- Total addresses 256
- Address type Private (RFC 1918)
Embed this calculator
Add this calculator to your own page. Paste the code where you want it. The small link keeps credit to the source.