IP Subnet Calculator (CIDR)
Enter an IPv4 address and a CIDR prefix to get the network address, broadcast address, usable host range, subnet mask and RFC 6890 address scope.
IP Subnet Calculator (CIDR)
Background.
Subnetting is address arithmetic, and address arithmetic is where careful engineers still make careless mistakes. Give this calculator any IPv4 address that sits inside the subnet you care about, plus the CIDR prefix length, and it returns the six facts you actually need to configure something: the network address, the broadcast address, the first and last assignable host addresses, the dotted-decimal subnet mask, and how many hosts the block will hold. It also tells you which block of the IANA special-purpose registry your address falls into, so you can see at a glance whether you are working in RFC 1918 private space, the RFC 6598 carrier-grade NAT range, link-local space, or genuinely routable public address space.
The reason you supply a host address rather than the network address is that most of the time you do not know the network address yet — that is precisely the thing you are trying to find out. If a device reports 192.168.10.37/26, the subnet boundary is not obvious by inspection, because a /26 splits each /24 into four blocks that begin at .0, .64, .128 and .192. The address .37 falls in the first of those, so the network is 192.168.10.0/26 and the broadcast is 192.168.10.63 — but change the prefix to /27 and the same address lands in the 192.168.10.32 block instead. Masking the host bits off is exactly what this tool does for you, and it does it for every prefix from /0 to /32.
CIDR replaced the old Class A, B and C system in 1993. RFC 4632, the current CIDR specification, describes a prefix as a four-octet quantity followed by a slash and "a decimal value between 0 and 32 that describes the number of significant bits", and states the goal plainly: to deprecate the Class A/B/C network address assignment system in favour of classless, hierarchical blocks. Classful reasoning still lingers in habits and in older documentation — people say "a Class C" when they mean a /24 — but no modern router, firewall or cloud VPC infers a mask from the first octet. The prefix is always explicit, which is why every field on this page asks for it explicitly too.
Two rules trip people up often enough to be worth stating up front. The first is the host count. For a prefix of /30 or shorter you lose two addresses per subnet: the all-zeros network address and the all-ones broadcast address are reserved, so a /24 gives 256 total addresses but only 254 usable ones. The second is that this rule stops applying at /31 and /32. RFC 3021 permits 31-bit prefixes on point-to-point links, where "only two possible addresses may result" and both "MUST be interpreted as host addresses" — there is no network or broadcast address to reserve, so a /31 gives 2 usable hosts, not zero. A /32 is a single-host route with exactly one usable address. Calculators that blindly apply the minus-two rule report 0 and -1 usable hosts for these two prefixes, which is not merely unhelpful but wrong; this one implements the standards instead.
A note on scope: this calculator handles IPv4 only. IPv6 uses the same slash notation but a 128-bit address space with no broadcast address at all, and the host-counting rules and special-purpose registry are entirely different, so folding both into one page would mean two sets of rules fighting over the same output labels. If you need the prefix-to-mask translation on its own — including the reverse direction, mask to prefix, and the binary and hexadecimal forms of the mask — use the companion CIDR to netmask converter, which deliberately does not ask for an address.
What is ip subnet calculator (cidr)?
An IP subnet is a contiguous, power-of-two-sized block of IPv4 addresses identified by a network address and a prefix length. The prefix length says how many of the address's 32 bits are fixed across the whole block (the network portion); the remaining bits vary from address to address (the host portion). Written in CIDR notation, 192.168.10.0/26 means the first 26 bits are the network and the last 6 bits — 64 combinations — enumerate the addresses inside it.
The subnet mask is the same information in a different costume: a 32-bit value whose leading bits are ones wherever the prefix covers and zeros elsewhere. RFC 4632 describes the /16 case as a mask "where the most significant 16 bits are ones and the least significant 16 bits are zeros", which in dotted decimal is 255.255.0.0. A router derives the network address by taking the bitwise AND of a host address with the mask — a step this calculator performs as exact integer arithmetic rather than with JavaScript's bitwise operators, which coerce to signed 32-bit values and would render every mask above /0 as a negative number.
Three addresses in a normal subnet have special meanings. The network address (all host bits zero) names the subnet in routing tables. The broadcast address (all host bits one) reaches every host on the link. Everything in between is assignable. The two exceptions are /31, which under RFC 3021 carries two host addresses and no broadcast, and /32, which is a single-host route used for loopback interfaces, anycast service addresses and host routes injected into a routing protocol.
How to use this calculator.
- Type any IPv4 address that belongs to the subnet — the address of a server, a router interface, or a DHCP lease you are looking at. You do not need to know the network address; deriving it is the point.
- Enter the prefix length: the number after the slash in CIDR notation, or the count of 1-bits in the dotted-decimal mask (255.255.255.0 is /24, 255.255.255.192 is /26).
- Read the network address and CIDR notation line — this is the string you paste into a route statement, a firewall object, or a cloud VPC subnet definition.
- Use the first and last usable host figures to plan static assignments and DHCP pool boundaries; keep the pool strictly inside that range.
- Check the total-versus-usable address counts before committing to a prefix. A /29 sounds like eight addresses but only holds six devices, and gateways, printers and management interfaces eat into that fast.
- Read the address-scope line to confirm you are in the space you meant to be in. Discovering that a 'private' range is actually 100.64.0.0/10 carrier-grade NAT space, or that an address is in the 192.0.2.0/24 documentation range, saves hours of confused troubleshooting.
- For point-to-point links between routers, try /31: it gives you two host addresses out of two, instead of the two-out-of-four a /30 gives you.
- If you only need the mask that corresponds to a prefix (or the prefix that corresponds to a mask), use the CIDR to netmask converter instead — it does not ask for an address and it works in both directions.
The formula.
Every step happens on the address's 32-bit unsigned integer value. The dotted-decimal address o0.o1.o2.o3 becomes ((o0 × 256 + o1) × 256 + o2) × 256 + o3, a value from 0 to 4,294,967,295.
The block size is 2^(32 − p), where p is the prefix length: a /26 has 2^6 = 64 addresses, a /24 has 2^8 = 256, a /0 has all 2^32 = 4,294,967,296. The subnet mask as an integer is 2^32 − blockSize, which is the same thing as p leading 1-bits followed by (32 − p) zeros; converting that integer back to dotted decimal gives 255.255.255.192 for a /26.
The network address is the address rounded down to the nearest multiple of the block size: floor(ip ÷ blockSize) × blockSize. That is arithmetically identical to the bitwise AND of the address with the mask, but it avoids JavaScript's signed 32-bit bitwise coercion, under which 0xFFFFFFC0 | 0 evaluates to −64. The broadcast address is network + blockSize − 1.
Host counting then branches on the prefix. For p ≤ 30, both the network and broadcast addresses are reserved, so usable hosts = blockSize − 2 and the assignable range runs from network + 1 to broadcast − 1. For p = 31, RFC 3021 defines the two addresses as host addresses on a point-to-point link, so usable hosts = 2 and the range is the two addresses themselves; the calculator reports no broadcast address rather than mislabelling the second host. For p = 32 there is one address, one usable host, and again no broadcast.
The address-scope output is a lookup, not a computation: the entered address is tested against the IANA IPv4 Special-Purpose Address Registry as published in RFC 6890, from the most specific block to the least specific, and the registry's own block name is reported. If nothing matches, the address is globally routable public unicast.
A worked example.
A switch reports a server at 192.168.10.37/26 and you need to know the subnet boundaries before adding a second server beside it. The block size is 2^(32−26) = 2^6 = 64 addresses, so each /24 is carved into four /26 blocks starting at .0, .64, .128 and .192. As an integer the address is 192 × 2^24 + 168 × 2^16 + 10 × 256 + 37 = 3,232,238,117; rounding that down to the nearest multiple of 64 gives floor(3,232,238,117 ÷ 64) × 64 = 50,503,720 × 64 = 3,232,238,080, which converts back to 192.168.10.0. The network is therefore 192.168.10.0/26 and the broadcast is 3,232,238,080 + 63 = 3,232,238,143 = 192.168.10.63. The assignable range runs 192.168.10.1 through 192.168.10.62 — 62 usable hosts out of 64 total addresses. The mask is 26 ones followed by 6 zeros, 11111111.11111111.11111111.11000000, which is 255.255.255.192. Finally, 192.168.10.37 sits inside 192.168.0.0/16, so the scope line reads Private-Use (RFC 1918): this address is not globally routable and needs NAT to reach the internet. Change nothing but the prefix and the answer moves: at /27 the block size halves to 32, the same .37 address lands in the 192.168.10.32 block, and the usable range becomes .33 to .62 with 30 hosts.
Frequently asked questions.
How many usable hosts are in a /24, /26 or /29?
Why does a /31 show 2 usable hosts instead of 0?
What is the difference between a subnet mask and a CIDR prefix?
Is my address private or public?
Why did you ask for a host address instead of the network address?
What does /0 mean?
Why are leading zeros rejected in the address field?
How do I split a /24 into smaller subnets?
Does this calculator handle IPv6?
What is a /32 used for if it holds one address?
References& sources.
- [1]Fuller, V. & Li, T. (2006). RFC 4632, "Classless Inter-domain Routing (CIDR): The Internet Address Assignment and Aggregation Plan". IETF Best Current Practice 122. Defines slash notation as a four-octet quantity followed by "a decimal value between 0 and 32 that describes the number of significant bits", the equivalence between a prefix and a mask of leading 1-bits, and the deprecation of the Class A/B/C assignment system.
- [2]Rekhter, Y. et al. (1996). RFC 1918, "Address Allocation for Private Internets". IETF Best Current Practice 5. Section 3 reserves 10.0.0.0–10.255.255.255 (10/8), 172.16.0.0–172.31.255.255 (172.16/12) and 192.168.0.0–192.168.255.255 (192.168/16) for private use — the three blocks reported by this calculator's address-scope output.
- [3]Retana, A., White, R., Fuller, V. & McPherson, D. (2000). RFC 3021, "Using 31-Bit Prefixes on IPv4 Point-to-Point Links". States that with a 31-bit prefix "only two possible addresses may result" and that they "MUST be interpreted as host addresses", and quantifies the saving as two addresses per link instead of four — the basis for this calculator's /31 host count.
- [4]Cotton, M., Vegoda, L., Bonica, R. & Haberman, B. (2013). RFC 6890, "Special-Purpose IP Address Registries". Section 2.2.2 is the IANA IPv4 Special-Purpose Address Registry, source of every block name used by the address-scope output: "This host on this network", "Private-Use", "Shared Address Space", "Loopback", "Link Local", "Documentation (TEST-NET-1)", "Benchmarking", "Reserved" and "Limited Broadcast".
- [5]Pummill, T. & Manning, B. (1995). RFC 1878, "Variable Length Subnet Table For IPv4". Tabulates every prefix against its dotted-decimal mask and address count — /24 = 255.255.255.0 = 256 addresses, /30 = 255.255.255.252 = 4, /31 = 255.255.255.254 = 2, /32 a single host route — and notes the counts include the network and broadcast addresses.
- [6]Postel, J. (1981). RFC 791, "Internet Protocol", DARPA Internet Program Protocol Specification. The base IPv4 specification: 32-bit addresses, an internet header whose "minimum value for a correct header is 5" 32-bit words (20 octets), and a Total Length field allowing datagrams up to 65,535 octets.
In this category
Embed
Quanta Pro
Paid features are coming later.
- All 590 calculators remain free
- No billing is enabled