Subnet Calculator
Enter an IPv4 address and prefix to get the network, broadcast, wildcard mask and usable host range, with correct /31 and /32 handling.
The interactive tool loads here when JavaScript runs.
About this toolWhat is the Subnet Calculator?
The Subnet Calculator takes an IPv4 address and a prefix length from /0 to /32 and works out the block that address belongs to: network address, broadcast address, subnet mask, wildcard mask, total and usable host counts, and the first and last usable addresses. It recalculates as you type, and every value has its own copy button.
The maths is plain 32-bit integer arithmetic done in your browser, so nothing is sent anywhere. It handles the edge cases that trip up quick spreadsheets: a /31 point-to-point link has two usable addresses and no broadcast, a /32 is a single host, and /0 covers all 4,294,967,296 addresses.
It is an IPv4 tool. IPv6 subnetting follows the same prefix logic but on 128 bits, and is not supported here.
- Every prefix from /0 to /32, with RFC 3021 /31 and single-host /32
- Network, broadcast, netmask and wildcard mask in one view
- Total and usable host counts and first and last usable address
- Strict input checks for octets above 255, letters and leading zeros
- Copy button for each value; runs entirely in your browser
Updated
How to use the Subnet Calculator
- Type an IPv4 address in the IP Address field. Any address inside the block works; 192.168.1.130 and 192.168.1.0 give the same /24.
- Pick a prefix in the CIDR Notation dropdown. Each option shows its dotted mask, for example /26 (255.255.255.192).
- Read the Subnet Results card. It updates automatically; the Calculate Subnet button reruns it if you want to be sure.
- Use the copy button beside any row to copy that value, such as the wildcard mask for an ACL.
Worked examples
A /26 inside a home network range
Input
10.20.30.77 with /26
Output
Network 10.20.30.64, broadcast 10.20.30.127, mask 255.255.255.192, wildcard 0.0.0.63, usable 10.20.30.65 to 10.20.30.126 (62 hosts)
77 falls in the second block of 64 (64 to 127), so that is the subnet. The 62 usable hosts are 64 minus the network and broadcast addresses.
A /20 that spans several third octets
Input
172.16.37.9 with /20
Output
Network 172.16.32.0, broadcast 172.16.47.255, usable 172.16.32.1 to 172.16.47.254 (4,094 hosts)
A /20 moves in steps of 16 in the third octet, so 37 belongs to the 32 to 47 block.
A /31 router link
Input
10.0.0.1 with /31
Output
Network 10.0.0.0, broadcast None, usable 10.0.0.0 and 10.0.0.1 (2 hosts)
Under RFC 3021 both addresses are usable. Older calculators report zero usable hosts here, which is wrong for modern routers.
Background and insight
Subnetting was added to IPv4 by RFC 950 in 1985, and CIDR (RFC 1519 in 1993, replaced by RFC 4632) removed the fixed class boundaries so any prefix length could be used. A prefix like /26 means the first 26 bits name the network and the remaining 6 bits number the hosts inside it, so the block holds 2^6 = 64 addresses. The network address is the IP with all host bits set to 0 (a bitwise AND with the mask), and the broadcast address is the same with all host bits set to 1.
The usual rule of "subtract two for network and broadcast" stops being true at the small end. RFC 3021 allows /31 on point-to-point links, where both addresses are usable and there is no broadcast, which saves half the addresses on router-to-router links. A /32 identifies one host and is common for loopbacks, VPN peers and cloud firewall rules.
The wildcard mask is the bitwise inverse of the netmask (0.0.0.63 for a /26). Cisco ACLs and OSPF network statements use it instead of the netmask, which is why it is shown separately. The Network Class row is historical: classes A to E were retired by CIDR, but people still say "a class C" when they mean a /24.
Common use cases
Planning a VPC or VLAN
Check how many hosts a /24, /23 or /22 actually gives before carving address space for a cloud network or office floor.
Writing firewall and ACL rules
Get the exact network address and wildcard mask for a Cisco ACL or the CIDR block for a security group.
Debugging "same subnet?" problems
Confirm whether two hosts with a given mask are on the same network or need a router between them.
Studying for CCNA or Network+
Check hand-worked answers for block sizes, broadcast addresses and host ranges.
Tips and limitations
- Block size is 256 minus the last non-255 octet of the mask. For 255.255.255.224 that is 32, so subnets start at .0, .32, .64 and so on.
- Cloud providers reserve extra addresses. AWS keeps five per subnet (network, router, DNS, a future-use address and broadcast), so a /24 VPC subnet leaves 251 assignable addresses instead of the usual 254.
- Leading zeros are rejected on purpose. Some parsers read 010 as octal 8 and others as decimal 10, so 192.168.001.010 is ambiguous.
- The Network Class row is for reference only. Routing has ignored classes since CIDR in 1993.
- For IPv6, the standard LAN size is /64; use the prefix length directly rather than this IPv4 calculator.
Sources and further reading
- RFC 950: Internet Standard Subnetting Procedure, IETF
- RFC 4632: Classless Inter-domain Routing (CIDR): The Internet Address Assignment and Aggregation Plan, IETF. CIDR prefixes, replacing RFC 1519
- RFC 3021: Using 31-Bit Prefixes on IPv4 Point-to-Point Links, IETF. Why both addresses of a /31 are usable
- RFC 1918: Address Allocation for Private Internets, IETF. The private IPv4 ranges
Frequently asked questions
How many usable hosts are in a /24 subnet?
A /24 has 256 addresses and 254 usable hosts, because the first is the network address and the last is the broadcast address. Cloud platforms can reserve more: AWS takes five addresses per subnet, leaving 251.
Why does a /31 show two usable hosts instead of zero?
RFC 3021 lets a /31 be used on point-to-point links, where there is no need for a network or broadcast address. Both addresses become usable, so a router-to-router link needs two addresses instead of the four a /30 would use.
What is a wildcard mask and how is it different from a subnet mask?
A wildcard mask is the subnet mask with every bit flipped, so 255.255.255.0 becomes 0.0.0.255. Cisco ACLs and OSPF use it to say which bits must match (0) and which can be anything (1).
How do I find the network address from an IP and mask?
Do a bitwise AND of the IP and the mask. In practice, find the block size from the interesting octet of the mask, then round the IP down to the nearest multiple of it. For 10.20.30.77/26 the block is 64, so the network is 10.20.30.64.
Does this subnet calculator support IPv6?
No, it is IPv4 only. IPv6 uses the same prefix idea on 128-bit addresses, but has no broadcast address and normally uses /64 for a LAN, so host counts are rarely the question.
Why does the calculator reject 192.168.01.1?
It refuses octets with leading zeros because they are ambiguous. inet_aton and some older libraries treat a leading 0 as octal, so 010 means 8, while others read it as 10. Remove the zero and the address is accepted.
Is a /32 a valid subnet?
Yes. A /32 matches exactly one address. It is used for loopback interfaces, host routes, VPN peer addresses and firewall rules that should allow one machine only.
Is there an in-depth guide to the Subnet Calculator?
Yes. “How Subnetting Works: CIDR Prefixes, Masks and Host Counts” covers the background, how it works, common pitfalls and worked examples. Read the full guide.
Related Tools You May Like
Free, in-browser tools that pair well with this one.