Subnet Calculator
Computes the network address, broadcast address, usable host range, subnet mask and wildcard mask for an IPv4 address and CIDR prefix length. The mask is prefix-length one bits followed by zeros, the network is the IP ANDed with the mask, the broadcast is the network ORed with the wildcard, and usable hosts equal 2^(32 − prefix) − 2 through /30. /31 and /32 follow RFC 3021 and host-route conventions, and the address is labeled private, loopback or public.
Type an IPv4 address, pick a prefix length, and the calculator unpacks everything the CIDR notation implies: the network address that names the subnet, the broadcast address at its top, the range of addresses a host can actually take, how many such hosts fit, the subnet mask, its wildcard complement, and whether the address sits in private, loopback or public space. The network address is the primary result because it is the answer most lookups are really after — two machines are on the same subnet exactly when this line matches for both. With the default of 192.168.1.130/24 it reads 192.168.1.0, with usable hosts 192.168.1.1 through 192.168.1.254.
How the calculation works
An IPv4 address is a 32-bit number written as four decimal octets, and the prefix length after the slash says how many of those bits, counted from the left, identify the network. The rest identify a host inside it. The subnet mask is just the prefix drawn as bits:
mask = prefix ones followed by (32 − prefix) zeros
network = address AND mask
broadcast = network OR wildcard
usable hosts = 232 − prefix − 2
The wildcard mask is the bitwise complement of the subnet mask, so it has ones exactly where the host bits are. ANDing with the mask clears every host bit, which pins the address to the bottom of its block; ORing with the wildcard sets every host bit, which pins it to the top. The subtraction of 2 removes the two reserved endpoints — the all-zeros network identifier and the all-ones broadcast, a convention set out in RFC 919 in October 1984 and made binding by RFC 1122 in 1989, which forbids assigning either value to a host. That rule holds from /8 down to /30. A /31 has only two addresses, and RFC 3021, published in December 2000, lets point-to-point links use both with no broadcast at all — the point of the change was that every such link then consumes two addresses instead of four. A /32 has zero host bits and therefore exactly one address, a route to a single host, so those two prefixes get their own wording in the results.
Reading a CIDR by hand
The default input makes the mechanics visible. In 192.168.1.130/24 the prefix covers the first three octets exactly, so they carry through untouched and only the last octet needs binary. 130 is 10000010. The mask's last octet is 00000000, and 10000010 AND 00000000 is 00000000, so the network address is 192.168.1.0. The wildcard's last octet is 11111111, and 00000000 OR 11111111 is 11111111, or 255, so the broadcast is 192.168.1.255. Between those endpoints sit 28 − 2 = 254 usable hosts, from 192.168.1.1 to 192.168.1.254.
Prefixes that cut through the middle of an octet are where a calculator earns its keep. Take 10.0.0.200/26. The mask is 26 ones, which fills three octets and leaves 11000000, or 192, in the fourth: 255.255.255.192. Now 200 in binary is 11001000, and 11001000 AND 11000000 is 11000000, which is 192 again — the network address is 10.0.0.192, not 10.0.0.0 as a glance at the dotted decimal might suggest. The wildcard is 0.0.0.63, so the broadcast is 192 OR 63 = 255, giving 10.0.0.255, and the 26 − 2 = 62 usable hosts run from 10.0.0.193 to 10.0.0.254. The same arithmetic on 172.16.0.1/12 splits the second octet instead: the mask is 255.240.0.0, the network is 172.16.0.0, and the broadcast is 172.31.255.255, because 16 OR 15 is 31.
The classful internet of 1981
The internet protocol specification published in September 1981 as RFC 791 did not have prefix lengths. The network portion of an address was fixed by its first few bits. An address starting with a 0 bit was class A, the rest of the first octet naming the network and twenty-four bits the host: 128 possible networks, each holding 16,777,216 addresses. Addresses starting 10 were class B, split sixteen and sixteen: 16,384 networks of 65,536 addresses. Addresses starting 110 were class C, twenty-four and eight: 2,097,152 networks of 256 addresses, 254 of them usable. The design was elegant to route — a router read the leading bits and knew where the network field ended — and spectacularly wasteful to allocate. An organization with 300 machines outgrew a class C, so it received a class B and left more than 65,000 addresses idle. There was nothing in between, and the roughly 4.3 billion addresses that a 32-bit number allows were being consumed in blocks far larger than anyone needed.
The first patch came in August 1985, when Jeffrey Mogul and Jon Postel published RFC 950. It let a site carve its one classful network into internal subnets by extending the network field with a subnet mask — the same mask this calculator prints. Subnetting fixed the inside of an organization, but from the outside each site still occupied a full class A, B or C block, and the mismatch between block sizes and real networks kept burning address space.
The CIDR rescue of 1993
By the early 1990s the arithmetic was closing in from two directions: class B networks, the only comfortable middle size, were being handed out at a pace projected — in the figures RFC 4632 recounts — to exhaust their space between 1993 and 1995, and every class C given out instead added a separate route that core routers had to carry. Classless Inter-Domain Routing was the response. Specified in September 1993 in RFC 1519 by Vince Fuller, Tony Li and their co-authors, and reissued by Fuller and Li in August 2006 as RFC 4632, the version still in force, CIDR abolished the classes outright. A network became an arbitrary-length prefix written with the now-familiar slash, so a provider could hold a large block and delegate exactly sized pieces of it, and a router could summarize hundreds of customer routes as one aggregate announcement. Every prefix from /8 to /32 that this calculator accepts is CIDR notation at work.
CIDR bought time rather than abundance. On 31 January 2011 IANA allocated two blocks to APNIC, which triggered a global policy of dividing whatever remained equally, and on 3 February 2011 it handed out its last five /8 blocks, one to each regional internet registry. That date marks the depletion of the central pool, not of IPv4 itself — the five registries went on allocating from their remaining stocks — but no new space would ever reach them, which is why the arithmetic of squeezing subnets to fit still matters.
Private space and the address on your router
The other lever was conservation — stop giving every machine a globally unique address. RFC 1918, published in February 1996, reserved three blocks that would never be routed on the public internet: 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. Its stated purpose was to conserve the globally unique address space by not spending it where global uniqueness is not required. Any network may reuse the three blocks internally, which is why the calculator's default address looks familiar — home routers almost universally hand out 192.168.x.x addresses. Network address translation, described in RFC 1631 in May 1994 and framed even there as a short-term measure, rewrites those private addresses to a shared public one at the network edge, letting an entire household or office ride on a single allocation. The address type line reports when an input falls inside one of the three RFC 1918 blocks, labels 127.0.0.0/8 as loopback — traffic to those addresses never leaves the machine — and calls everything else public.
Assumptions and edge cases
All arithmetic here is unsigned 32-bit binary, and the address must be four dot-separated decimal octets between 0 and 255; anything else produces a named error rather than a guess. Octets written with leading zeros are read as decimal, whereas some older tools treat them as octal, so 010 means ten here and not eight. The usable-host figure subtracts exactly two addresses on /8 through /30, reports both addresses of a /31 as usable per RFC 3021, and reports a /32 as one host route. Gateways, reserved pools and other conventions inside a subnet are not modeled — the range shown is what the protocol permits, not what a given network assigns. The address type check covers only the three RFC 1918 blocks and loopback; special-purpose ranges such as link-local or documentation space report as public. Prefixes shorter than /8 and IPv6 are out of scope.
Frequently asked questions
How do you calculate a network address from an IP and subnet mask?
AND the address and the mask together bit by bit. Every bit that is 1 in the mask keeps the address bit, and every 0 clears it. For 192.168.1.130 with mask 255.255.255.0 the first three octets pass through unchanged and the last is cleared to zero, giving the network address 192.168.1.0. The broadcast address goes the other way: OR the network with the wildcard mask, which sets every host bit to 1.
How many usable hosts are in a /24 subnet?
254. A /24 leaves 8 host bits, which is 2 to the power of 8, or 256 addresses, and two of them are reserved: the all-zeros address names the network itself and the all-ones address is the broadcast. The same rule gives 62 usable hosts in a /26 and 2 in a /30. The exceptions are /31, which uses both of its addresses on point-to-point links under RFC 3021, and /32, a single host route.
What is a wildcard mask?
The bitwise complement of the subnet mask, so each pair of octets sums to 255. Mask 255.255.255.0 has wildcard 0.0.0.255, and mask 255.240.0.0 has wildcard 0.15.255.255. Where the subnet mask marks the network bits with ones, the wildcard marks the host bits, and some router configuration syntax expresses address ranges using the wildcard form rather than the mask.
Why are the first and last addresses of a subnet unusable?
The first address, with all host bits at zero, is the identifier of the network itself, and the last, with all host bits at one, is the broadcast address that reaches every host on the subnet. Neither can be assigned to a machine on prefixes from /8 through /30. RFC 3021 makes /31 an exception for point-to-point links, where both addresses are usable and no broadcast exists, and a /32 is a route to one specific host.
Which IP address ranges are private?
RFC 1918 reserves three blocks for private use: 10.0.0.0/8 with 16,777,216 addresses, 172.16.0.0/12 with 1,048,576, and 192.168.0.0/16 with 65,536. Addresses in these ranges are not routed on the public internet, so any network can reuse them internally, translating to a public address at its edge. The 127.0.0.0/8 block is separate again, reserved for loopback traffic that never leaves the machine.
What does the /26 in an IP address mean?
The 26 counts network bits, so the subnet mask is 26 ones followed by 6 zeros, which is 255.255.255.192 in decimal. That leaves 6 host bits, giving 64 addresses per subnet of which 62 are usable. For 10.0.0.200/26 the network address works out to 10.0.0.192 and the broadcast to 10.0.0.255, so hosts can use 10.0.0.193 through 10.0.0.254.