Subnet Calculator

Calculate an IPv4 network, subnet mask, broadcast address and usable host range from a CIDR prefix.

Your calculation

bits

Enter the address and prefix separately. /31 assumes a point-to-point link; /32 describes a single host route.

Result

Network / prefix

192.168.1.0/24

Subnet mask
255.255.255.0
Wildcard mask
0.0.0.255
Broadcast
192.168.1.255
First usable address
192.168.1.1
Last usable address
192.168.1.254
Usable addresses
254
Total addresses
256

Address-space arithmetic only. Reserved ranges, cloud-provider reservations, gateways and network policies may reduce assignable addresses.

Calculated in your browser. Your inputs are not sent to a server.

How to use this calculator

Enter a dotted IPv4 address and a separate prefix length from 0 to 32. For example, enter 192.168.1.42 and 24. The address can be anywhere inside the subnet; the result identifies the network boundary.

The math behind it

Address count = 2^(32 − prefix)
Network = floor(address / count) × count
Last address = network + count − 1
Usable hosts = count − 2 for prefixes 0–30
/31: two point-to-point endpoints; /32: one host route

A worked example

192.168.1.42/24 belongs to 192.168.1.0/24 with mask 255.255.255.0, broadcast 192.168.1.255 and 254 conventional host addresses from .1 through .254.

Assumptions & precision

IPv4 only. Leading-zero octets are rejected to avoid ambiguous notation. /31 uses RFC 3021 point-to-point semantics; /32 represents one address. Neither has a subnet broadcast here. Counts describe mathematical address space, not actual reachability or assignability. Reserved blocks, cloud providers and gateways may reserve more addresses.

A common question

Why does /31 have two usable addresses?

On a point-to-point link, RFC 3021 allows both addresses as endpoints instead of reserving network and broadcast addresses. Do not assume this behavior on other link types.