# What is my subnet range?

Computes an IPv4 subnet from an address and a prefix length: network and broadcast addresses, usable host range and count, subnet and wildcard masks, class, and address type.

- Page: https://www.acalculator.org/logic/subnet-calculator
- JSON spec: https://www.acalculator.org/logic/subnet-calculator.json
- Version: 7ede2acc509d

## Default answer

Example with the default inputs (IP address 192.168.1.10, Subnet mask /24 (255.255.255.0)): 192.168.1.0/24 has 254 usable hosts: 192.168.1.1 – 192.168.1.254.

## Inputs

| Key | Label | Description |
| --- | --- | --- |
| ip | IP address | An IPv4 address such as 192.168.1.10, optionally with its prefix after a slash (192.168.1.10/24). |
| prefix | Subnet mask | The prefix length (how many leading bits are the network part) and its subnet mask. |

## Outputs

| Key | Label | Description |
| --- | --- | --- |
| range | Usable host range | The first and last addresses that can be given to hosts on this subnet. |
| hosts | Usable hosts | How many addresses can be given to hosts: 2^(32 − prefix) − 2, except 2 for a /31 (RFC 3021) and 1 for a /32. |
| network | Network address | The address with every host bit set to 0. |
| broadcast | Broadcast address | The address with every host bit set to 1. A /31 or /32 has none. |
| cidr | CIDR notation | The network address and prefix length. |
| total | Total addresses | Every address in the subnet, including the network and broadcast addresses: 2^(32 − prefix). |
| mask | Subnet mask | The prefix as a dotted mask. |
| wildcard | Wildcard mask | The subnet mask with every bit flipped, as used in router access lists. |
| maskBinary | Subnet mask in binary | The mask as 32 bits, in four groups of 8 separated by spaces. |
| addressClass | Address class | The historical classful class of the address (A to E), from its first number. |
| addressType | Address type | Public, or the special-purpose block the address is in (private, loopback, link-local, and others). |

## Method

network = address AND mask; broadcast = network OR NOT mask; hosts = 2^(32 − prefix) − 2 (2 for /31, 1 for /32).

## Assumptions

- IPv4 only. Each part of the address is a whole number from 0 to 255, written without leading zeros.
- The network and broadcast addresses are not usable hosts, except in a /31 (RFC 3021) and a /32.
- The address class is historical (classful addressing, replaced by CIDR in 1993) and shown for reference.

## Worked examples

1. ip = 192.168.1.10, prefix = 24 gives range = 192.168.1.1 – 192.168.1.254, hosts = 254, network = 192.168.1.0, broadcast = 192.168.1.255, cidr = 192.168.1.0/24, total = 256, mask = 255.255.255.0, wildcard = 0.0.0.255, maskBinary = 11111111 11111111 11111111 00000000, addressClass = C, addressType = Private. Source: hand calculation in content.mdx (RFC 4632 prefix, RFC 950 all-zeros and all-ones host numbers, RFC 1918 private block); Python ipaddress module (ip_network, strict off).
2. ip = 10.20.30.40/13 gives range = 10.16.0.1 – 10.23.255.254, hosts = 524,286, network = 10.16.0.0, broadcast = 10.23.255.255, mask = 255.248.0.0, wildcard = 0.7.255.255, addressClass = A, addressType = Private. Source: hand calculation in content.mdx: second number 20 = 00010100, keep 5 bits → 16; 2^19 − 2 = 524,286; Python ipaddress module (ip_network, strict off).
3. ip = 172.16.5.4, prefix = 31 gives range = 172.16.5.4 – 172.16.5.5, hosts = 2, network = 172.16.5.4, total = 2. Source: RFC 3021: both addresses of a /31 are host addresses; the hosts of 172.16.5.4/31 in the Python ipaddress module.
4. ip = 203.0.113.77, prefix = 32 gives range = 203.0.113.77, hosts = 1, cidr = 203.0.113.77/32, addressType = Documentation. Source: hand calculation in content.mdx: a /32 is a single host; RFC 5737 TEST-NET-3 is 203.0.113.0/24.
5. ip = 192.168.1.200, prefix = 26 gives range = 192.168.1.193 – 192.168.1.254, hosts = 62, total = 64, network = 192.168.1.192, mask = 255.255.255.192, wildcard = 0.0.0.63. Source: hand calculation in content.mdx: 2^(32 − 26) = 64 addresses, 64 − 2 = 62 hosts; 200 = 11001000, keep 2 bits → 192.

## FAQ

### How do I find the network address of a subnet?

Write the address and the subnet mask in binary and keep only the bits where the mask has a 1 (a bitwise AND). For 192.168.1.10 with mask 255.255.255.0, the first three numbers stay and the last becomes 0, so the network address is 192.168.1.0.

### How many usable hosts are in a /24?

A /24 leaves 32 − 24 = 8 host bits, so it has 2⁸ = 256 addresses. The first is the network address and the last is the broadcast address, which leaves 256 − 2 = 254 usable host addresses.

### What does the number after the slash mean?

It is the prefix length in CIDR notation: how many of the 32 bits of the address belong to the network. /24 means the first 24 bits, which is the mask 255.255.255.0. The remaining bits number the hosts inside the subnet.

### What is a wildcard mask?

It is the subnet mask with every bit flipped, so each part is 255 minus the matching part of the mask. The /24 mask 255.255.255.0 has the wildcard mask 0.0.0.255. Cisco access lists and OSPF use wildcard masks to say which bits must match.

### Why does a /31 have 2 usable hosts?

A /31 has only 2 addresses. Under the old rule it would have 0 usable hosts, which wastes both. RFC 3021 lets point-to-point links use both addresses as hosts, with no network or broadcast address, so the calculator counts 2.

### Which IP addresses are private?

RFC 1918 sets aside 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16 for private networks. These addresses are not routed on the public internet. The calculator also names other special blocks, such as loopback (127.0.0.0/8) and link-local (169.254.0.0/16).

### Are IP address classes still used?

Not for routing. Classes A, B, and C fixed the network size by the first number of the address. CIDR replaced them in 1993 so networks could be any prefix length. The class is still taught and shown here for reference.

## Sources

- RFC 4632, Classless Inter-domain Routing (CIDR): The Internet Address Assignment and Aggregation Plan. https://www.rfc-editor.org/rfc/rfc4632
- RFC 950, Internet Standard Subnetting Procedure (all-zeros and all-ones host numbers). https://www.rfc-editor.org/rfc/rfc950
- RFC 3021, Using 31-Bit Prefixes on IPv4 Point-to-Point Links. https://www.rfc-editor.org/rfc/rfc3021
- RFC 1918, Address Allocation for Private Internets. https://www.rfc-editor.org/rfc/rfc1918
- IANA IPv4 Special-Purpose Address Registry (RFC 6890). https://www.iana.org/assignments/iana-ipv4-special-registry/
- RFC 791, Internet Protocol, section 3.2 (address classes A, B, C). https://www.rfc-editor.org/rfc/rfc791
