IP Subnet Calculator: CIDR, Netmask & Host Range
Calculate IPv4 subnet details from an address and CIDR prefix: network and broadcast address, usable host range, subnet mask, and wildcard mask.
IP Subnet Calculator
Results
Subnet Mask in Binary
Results follow RFC 791 (IPv4 addressing), RFC 4632 (CIDR notation), RFC 950 with RFC 919 and RFC 922 (network and broadcast reservation), and RFC 3021 (/31 point-to-point links).
Documentation
IP Subnet Calculator
An IP subnet calculator works out the network details behind an IPv4 address and a prefix length. From these two inputs it finds the network address, the broadcast address, the range of usable host addresses, the subnet mask, and the wildcard mask.
What the calculator does
The tool takes an IPv4 address written as four numbers separated by dots, such as 192.168.1.10, and a prefix length from 0 to 32. Writing the two together in CIDR form, such as 192.168.1.10/24, also works: the /24 part moves into the prefix field on its own.
The calculator returns:
- CIDR notation: the network in address/prefix form, such as 192.168.1.0/24.
- Network address: the first address in the block. It names the network itself.
- Broadcast address: the last address in the block. A message sent to it reaches every host in the subnet.
- Usable host range: the first and last address a device can actually use.
- Usable hosts and total addresses: how many addresses the block holds, and how many are free for devices.
- Subnet mask and wildcard mask: the mask in dotted form, such as 255.255.255.0, and its inverse, 0.0.0.255.
- The subnet mask drawn out bit by bit, eight bits per octet.
The results follow RFC 791 (IPv4 addressing), RFC 4632 (CIDR notation), RFC 950 with RFC 919 and RFC 922 (the network and broadcast reservations), and RFC 3021 (/31 point-to-point links).
How subnetting works
An IPv4 address is a 32-bit number. People write it as four octets, where each octet is 8 bits and holds a value from 0 to 255. The prefix length splits those 32 bits into two parts. The first bits, as many as the prefix says, name the network. The remaining bits name a host inside that network.
A /24 network keeps 24 bits for the network part and leaves 8 bits for hosts. Eight host bits give 2⁸ = 256 addresses. A /26 network leaves only 6 host bits, so it holds 2⁶ = 64 addresses.
The subnet mask writes the same split as an address: a 1 bit for every network bit and a 0 bit for every host bit. For /24 that is 255.255.255.0. The wildcard mask flips every bit of the subnet mask. Router access lists, notably on Cisco equipment, match addresses with wildcard masks, which is why the tool shows both.
The subnet formula
For a prefix length p between 0 and 30, the calculator applies these rules, defined by RFC 950 and RFC 4632:
- Subnet mask = the top p bits of the 32-bit word set to 1.
- Network address = IP address AND subnet mask (a bitwise AND keeps a bit only where both inputs have a 1).
- Broadcast address = network address OR wildcard mask (every host bit set to 1).
- Total addresses = 2⁽³²⁻ᵖ⁾.
- Usable hosts = 2⁽³²⁻ᵖ⁾ − 2. The subtraction removes the network address and the broadcast address, which RFC 950 and RFC 919 reserve.
- First usable host = network address + 1. Last usable host = broadcast address − 1.
Two prefix lengths follow different rules. A /31 holds exactly 2 addresses and RFC 3021 makes both of them usable hosts on a point-to-point link, with no broadcast address at all. A /32 names a single address: 1 total, 1 usable, no broadcast. For these two cases the tool labels the first address "Prefix Base" instead of "Network Address", since neither block reserves an address to name the network.
Every result comes from arithmetic on one 32-bit number. The tool never lists the addresses one by one, so a /0 covering all 4,294,967,296 IPv4 addresses computes as fast as a /32.
Worked example
For the address 10.128.7.33 with prefix length /26:
- Subnet mask: 26 one-bits followed by 6 zero-bits is 11111111.11111111.11111111.11000000, which reads as 255.255.255.192.
- Network address: AND the address with the mask. The first three octets pass through unchanged. In the last octet, 33 is 00100001 in binary; AND with 11000000 gives 00000000, which is 0. The network address is 10.128.7.0, so the CIDR notation is 10.128.7.0/26.
- Broadcast address: set all 6 host bits to 1. The last octet becomes 00111111, which is 63. The broadcast address is 10.128.7.63.
- Counts: 2⁶ = 64 total addresses, and 64 − 2 = 62 usable hosts.
- Host range: 10.128.7.1 through 10.128.7.62.
- Wildcard mask: the inverse of the subnet mask, 0.0.0.63.
A second example with the tool's default input, 192.168.1.10/24: network 192.168.1.0, broadcast 192.168.1.255, hosts 192.168.1.1 through 192.168.1.254, 254 usable hosts out of 256 total, subnet mask 255.255.255.0, wildcard mask 0.0.0.255.
Conventions the tool follows
Zero-padded octets are rejected. The tool refuses 010.1.1.1 rather than reading it as 10.1.1.1. This is deliberate. The POSIX inet_aton function, which sits behind ping, curl, and most operating-system resolvers, treats an octet with a leading zero as octal, so 010.1.1.1 means 8.1.1.1 to those programs. No decimal or octal guess can agree with every reader, so the tool accepts neither. A prefix written as /08 is refused for the same reason.
The host count subtracts two. Some calculators report the raw block size as the host count. This tool follows RFC 950: in any /0 to /30 block, the all-zeros host part names the network and the all-ones host part is the broadcast, so both are excluded and a /24 has 254 usable hosts, not 256.
A /31 has two usable hosts. Older texts, written before RFC 3021 (published in 2000), call a /31 unusable because subtracting the two reserved addresses leaves zero. RFC 3021 removed both reservations for point-to-point links, and routers have supported this for decades, so the tool reports 2 usable hosts and no broadcast address.
Any prefix from /0 to /32 is accepted. A /0 is a valid block covering the whole IPv4 space, matching how 0.0.0.0/0 appears in routing tables as the default route.
IPv4 only. IPv6 (RFC 4291) uses 128-bit addresses and different notation, and is out of scope for this tool. The tool also does not flag special-purpose ranges such as private or loopback addresses (RFC 6890); it reports the address arithmetic only.
Frequently asked questions
How many usable hosts does a /24 have? 254. A /24 leaves 8 host bits, giving 2⁸ = 256 addresses. Two are reserved: the network address and the broadcast address. That leaves 254 for devices.
What is a wildcard mask? The bit-by-bit inverse of the subnet mask. Where the subnet mask has a 1, the wildcard mask has a 0, and the other way round. For the mask 255.255.255.0 the wildcard is 0.0.0.255. Access control lists on many routers use wildcard masks to describe which addresses a rule matches.
Why does a /31 show no broadcast address? A /31 holds only two addresses. Reserving one for the network and one for broadcast would leave nothing, so RFC 3021 defines the /31 as a point-to-point link where both addresses are hosts and no broadcast address exists. The calculator reports 2 usable hosts and marks the broadcast as not applicable.
Why is 010.1.1.1 rejected instead of read as 10.1.1.1? Because operating systems disagree with a plain decimal reading. POSIX inet_aton reads a leading-zero octet as octal, so 010 means 8 to most systems. Refusing the input is the only answer that cannot quietly differ from what the user's own machine would do.
What is the difference between total addresses and usable hosts? Total addresses is the full size of the block, 2 to the power of (32 minus the prefix length). Usable hosts is that number minus the two reserved addresses, except in a /31 (both usable) and a /32 (the single address is the host).
What does the network address of 192.168.1.10/24 mean? It is 192.168.1.0, found by keeping the first 24 bits of the address and setting the host bits to zero. It identifies the subnet as a whole and cannot be assigned to a device.
References
- Postel, J. "RFC 791: Internet Protocol." IETF, 1981.
- Mogul, J., and J. Postel. "RFC 950: Internet Standard Subnetting Procedure." IETF, 1985.
- Mogul, J. "RFC 919: Broadcasting Internet Datagrams." IETF, 1984.
- Fuller, V., and T. Li. "RFC 4632: Classless Inter-domain Routing (CIDR)." IETF, 2006.
- Retana, A., et al. "RFC 3021: Using 31-Bit Prefixes on IPv4 Point-to-Point Links." IETF, 2000.