Skip to content
YAS.SH
Network & DNS🌐 YAS server-sideAPI availableintermediate

IP Subnet Calculator

Computes network, broadcast, mask and usable host range for a CIDR block.

Processed by YAS · not stored
Ready to runInstant execution
All tools →
Result

What does this tool do?

Computes network, broadcast, mask and usable host range for a CIDR block.

Why would I use it?

  • You are planning a VPC or VLAN and need the address math.
  • You want to know how many usable IPs a subnet has.
  • You are writing firewall rules and need network boundaries.

Real-life example

Input
192.168.1.0/24
Output
Network 192.168.1.0 · Broadcast 192.168.1.255 · Mask 255.255.255.0 · Usable hosts 254

The /24 prefix gives 256 addresses, 254 usable.

Input → Process → Output → Next

Input
Enter an IP with CIDR prefix.
Process
YAS computes bitwise network/broadcast addresses.
Output
Full subnet details.
Next action
Use the network address for routing and the broadcast for DHCP.

Common mistakes

  • Forgetting to subtract network and broadcast addresses for usable hosts.
  • Using the wrong prefix (a /23 is 512 addresses, not 256).
  • Mixing host bits into the network address.

What the result means

Usable hosts = 2^(32-prefix) − 2 (for IPv4).

Privacy & security

Your input is sent to YAS infrastructure because the tool requires server-side processing or public network queries. Input is not stored.

API

Endpoint
POST https://yas.sh/api/v1/tools/ip-subnet-calculator
Request Header
Content-Type: application/json
cURL
curl -X POST "https://yas.sh/api/v1/tools/ip-subnet-calculator" \
  -H "Content-Type: application/json" \
  -d '{"input":"192.168.1.0/24"}'
JavaScript
const res = await fetch("https://yas.sh/api/v1/tools/ip-subnet-calculator", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
  "input": "192.168.1.0/24"
}),
});
const data = await res.json();
Python
import requests

r = requests.post("https://yas.sh/api/v1/tools/ip-subnet-calculator", json={"input":"192.168.1.0/24"})
data = r.json()
FieldTypeRequiredDescription
inputstringYesCIDR, e.g. 192.168.1.0/24
Success response
{ "result": { "valid": true, "network": "192.168.1.0", "broadcast": "192.168.1.255", "mask": "255.255.255.0", "hosts": 254, "prefix": 24 } }

IPv4 CIDR math: network, broadcast, netmask, usable hosts.

Error responses
  • 400 VALIDATION_ERROR — invalid input or unsupported option.
  • 413 PAYLOAD_TOO_LARGE — input exceeds the 64 KB limit.
  • 429 RATE_LIMIT_EXCEEDED — rate limit exceeded (60 req/min).
Limits
  • Maximum input: 64 KB per request.
  • Rate limit: 60 requests/min per IP address.
  • Authenticated accounts benefit from higher tier quotas.

IP Subnet Calculator: technical reference, use cases and FAQ

How IP Subnet Calculator works

A CIDR prefix such as /26 says how many leading bits of the address identify the network. The tool converts the address and prefix to binary, applies the mask to derive the network address, sets the host bits to derive the broadcast address, and counts the range between them. Usable hosts are 2^(32−prefix) − 2 for IPv4, subtracting the network and broadcast addresses.

Two conventions break that formula. A /31 has no usable hosts under the general rule, but RFC 3021 defines it as a valid two-address point-to-point link, and a /32 is a single host route. IPv6 does not reserve a broadcast address at all — there is no broadcast in IPv6 — so all addresses in a prefix are usable, and /64 is the standard subnet size because SLAAC requires it.

When to use it: real-world scenarios

Planning VPC and subnet layout

Cloud providers reserve additional addresses per subnet (AWS reserves five), so the usable count is lower than the arithmetic. Plan the split before creating resources that cannot be renumbered.

Writing firewall and security-group rules

Confirming that a CIDR covers exactly the hosts you intend prevents a rule that is one bit too broad — the difference between /24 and /23 is 254 unintended hosts.

Splitting an allocation into equal subnets

Dividing a /24 into four /26 blocks needs the boundaries right; off-by-one subnet math causes overlapping ranges that fail only under load.

Checking whether an address falls inside a range

Log analysis and access rules constantly need this, and doing it by eye on non-octet boundaries is unreliable.

Pro tips

  • Prefixes that are not multiples of 8 do not align to dots. A /26 splits the last octet into blocks of 64: .0, .64, .128, .192 — memorise those boundaries.
  • Leave room to grow. Renumbering a production network is far more expensive than allocating a larger prefix now.
  • Use /31 for point-to-point links (RFC 3021) rather than wasting a /30 where two of four addresses are unusable.
  • In IPv6, always use /64 for a LAN. Smaller prefixes break SLAAC and are not worth the addresses they save from an effectively unlimited pool.

Limitations and edge cases

What this tool deliberately does not do, and where it will disagree with other implementations.

  • Arithmetic only — no reachability testing, route validation or overlap detection against your existing allocations.
  • Cloud provider address reservations are not modelled and reduce the usable count further.
  • Variable-length subnet masking across a hierarchy must be checked prefix by prefix.
  • IPv6 host counts are astronomically large and reported as prefix sizes rather than exact figures.

Frequently asked questions

Why does a /24 have 254 usable hosts and not 256?
The first address identifies the network and the last is the broadcast address, so both are unusable for hosts. The formula is 2^(32−prefix) − 2 for IPv4.
Can I use a /31?
Yes, for point-to-point links. RFC 3021 defines both addresses as usable in that case, which is why the general minus-two rule does not apply.
Why is /64 recommended for IPv6 subnets?
Stateless address autoconfiguration requires 64 host bits. Using a longer prefix breaks SLAAC, and address conservation is not a meaningful concern in IPv6.
How many usable addresses will my cloud subnet have?
Fewer than the arithmetic suggests — AWS reserves five addresses per subnet, and other providers reserve their own. Subtract the provider's reservation from the CIDR count.
Ask YAS AI
🍪 Cookies & privacy. Essential cookies keep you signed in and remember language and theme. Google AdSense and reCAPTCHA are Google technologies: AdSense runs only after Accept All; reCAPTCHA loads on sign-in and contact forms. See how Google uses data: https://policies.google.com/technologies/partner-sites cookie policy · privacy policy.
Settings