# Subnet (CIDR) Calculator

URL: https://hifreetools.com/developer/subnet-calculator

> Instantly calculate subnet details from any IPv4 CIDR notation — network address, broadcast address, subnet mask, first and last usable host, and total host count.

## Quick answer

A subnet calculator takes an IPv4 address and a CIDR prefix length (e.g., 192.168.1.0/24) and computes the network address, broadcast address, subnet mask, first usable host, last usable host, and total usable host count. The number of usable hosts equals 2^(32−prefix) − 2 for prefixes /1 through /30. For example, a /24 network has 256 total addresses and 254 usable hosts. Subnetting lets network engineers divide a large IP space into smaller, manageable segments for routing and security isolation.

## Formula

- Subnet Mask = 2^32 − 2^(32−prefix) (as a 32-bit integer)
- Network Address = IP & Mask
- Broadcast = Network | (~Mask)
- Usable Hosts = 2^(32 − prefix) − 2

## Examples

- 192.168.1.0/24 — typical home LAN: IP: 192.168.1.0, Prefix: /24 → Network: 192.168.1.0 | Broadcast: 192.168.1.255 | Mask: 255.255.255.0 | Hosts: 192.168.1.1 – 192.168.1.254 | Usable: 254
- 10.0.0.0/8 — Class A private block: IP: 10.0.0.0, Prefix: /8 → Network: 10.0.0.0 | Broadcast: 10.255.255.255 | Mask: 255.0.0.0 | Hosts: 10.0.0.1 – 10.255.255.254 | Usable: 16,777,214
- 172.16.5.100/20 — mid-size office subnet: IP: 172.16.5.100, Prefix: /20 → Network: 172.16.0.0 | Broadcast: 172.16.15.255 | Mask: 255.255.240.0 | Hosts: 172.16.0.1 – 172.16.15.254 | Usable: 4,094
- 203.0.113.64/26 — small office segment: IP: 203.0.113.64, Prefix: /26 → Network: 203.0.113.64 | Broadcast: 203.0.113.127 | Mask: 255.255.255.192 | Hosts: 203.0.113.65 – 203.0.113.126 | Usable: 62

## FAQ

**What does CIDR notation mean?**
CIDR stands for Classless Inter-Domain Routing. The notation 192.168.1.0/24 means the first 24 bits of the address identify the network and the remaining 8 bits identify individual hosts within that network. It replaced the older Class A/B/C system to allow more flexible IP allocation.

**Why are 2 addresses always subtracted for usable hosts?**
The first address in any subnet (all host bits = 0) is the network address used for routing, and the last address (all host bits = 1) is the broadcast address. Neither can be assigned to a device, so usable hosts = total addresses − 2. The exception is /31 (point-to-point links, RFC 3021) and /32 (single host).

**What is a wildcard mask and how does it differ from a subnet mask?**
A wildcard mask is the bitwise complement of the subnet mask. Where the subnet mask has 1s (network bits), the wildcard has 0s, and vice versa. Wildcard masks are used in Cisco ACLs and OSPF network statements to specify which bits must match.

**How many subnets can I create from a /24 network using /26?**
A /26 adds 2 bits beyond the /24 boundary, creating 2^2 = 4 subnets. Each /26 subnet has 64 addresses and 62 usable hosts. The four blocks are .0/26, .64/26, .128/26, and .192/26.

**What are the RFC 1918 private IP ranges?**
RFC 1918 defines three private, non-routable IPv4 ranges: 10.0.0.0/8 (about 16.7 million addresses), 172.16.0.0/12 (about 1 million addresses, covering 172.16.0.0 through 172.31.255.255), and 192.168.0.0/16 (65,536 addresses). These are used inside LANs and are translated to public IPs by NAT at the internet edge.

**What is a /32 subnet used for?**
A /32 prefix identifies exactly one host address — there is no network or broadcast address. It is used for loopback interfaces, host routes in routing tables, and in firewall rules to match a single IP. The 'subnet' contains only that one address with no usable range.


## Sources

- [RFC 4632 — Classless Inter-domain Routing (CIDR): The Internet Address Assignment and Aggregation Plan](https://www.rfc-editor.org/rfc/rfc4632)
- [RFC 1918 — Address Allocation for Private Internets](https://www.rfc-editor.org/rfc/rfc1918)
- [IANA — IPv4 Address Space Registry](https://www.iana.org/assignments/ipv4-address-space/ipv4-address-space.xhtml)

Runs in the browser; nothing is uploaded. Cite as: HIFreeTools, "Subnet (CIDR) Calculator", https://hifreetools.com/developer/subnet-calculator
