Developer & Tech
Subnet & CIDR Calculator
Enter your details
Runs in your browser
How to use it
Using the subnet & cidr calculator
- 01
Paste any address in the block
It does not have to be the network address itself; any member lands on the same block.
- 02
Set the prefix length
Use the slash notation from your plan or config, e.g. 24 for a classic class-C-sized block.
- 03
Copy the results
Network, broadcast, host range, wildcard mask and host count are ready for router, firewall or DHCP configuration.
Good to know
Why bit math beats mental arithmetic
Subnetting questions reduce to bitwise AND/OR on 32-bit integers. Doing them by hand means juggling octet boundaries; doing them with shifts makes every boundary; even odd ones like /13 or /27; mechanical and error-free.
Wildcard masks in the wild
Cisco-style ACLs and OSPF network statements take wildcard masks rather than subnet masks. They are the exact complement: a /26 mask of 255.255.255.192 becomes wildcard 0.0.0.63.
Choosing a prefix size
Plan for growth before carving blocks: a /25 holds 126 hosts, a /24 holds 254, a /23 holds 510. Reserving headroom now avoids painful re-addressing later, since usable counts double with each shorter prefix.
How it's calculated
The math behind this calculator
mask = prefix ? (0xFFFFFFFF << (32−p)) : 0
network = ip AND mask broadcast = network OR NOT mask
hosts = 2^(32−p) − 2 (/31 → 2 per RFC 3021, /32 → 1)The prefix length p becomes a bitmask whose first p bits are ones. ANDing it with your address yields the network address; ORing with the inverted mask yields the broadcast address.
For prefixes up to /30 the lowest and highest addresses are reserved for network and broadcast identities, leaving 2^(32−p) − 2 usable hosts. Point-to-point /31 links keep both addresses per RFC 3021, and a /32 is a single-host route.
The wildcard mask used by ACLs and routing configs is simply the bitwise inverse of the subnet mask.
Assumptions & limitations
- Strict IPv4 dotted-decimal only; no IPv6.
- Prefix must be a whole number 0–32.
- Host counts follow the RFC 950 convention with RFC 3021 /31 handling.
Worked example
The address 192.168.1.130 inside a /26 sits on network 192.168.1.128 with broadcast 192.168.1.191, usable hosts .129–.190 (62 total), mask 255.255.255.192 and wildcard 0.0.0.63.
FAQ
Frequently asked questions
- Why does a /24 show only 254 usable hosts?
- Two addresses are reserved: the lowest is the network identifier and the highest is the broadcast address, leaving 2^8 − 2 = 254 for hosts.
- What is special about /31 and /32?
- RFC 3021 allows both addresses of a /31 on point-to-point links (no broadcast needed), and a /32 identifies exactly one host.
- Can I enter IPv6 or shorthand like “10.1”?
- No; this tool validates strict four-octet IPv4 dotted decimal, rejecting out-of-range octets such as 999.1.1.1.
- Does this work for supernetting?
- Yes. Prefixes shorter than /24 aggregate multiple class-C-sized blocks exactly the same way.
Keep exploring