Use our free tool — no sign-up required.

IP Subnet Calculator — Free Online Tool

How IPv4 addressing works

An IPv4 address is a 32-bit number written as four decimal octets separated by dots — for example 192.168.1.10. Each octet represents 8 bits, giving values from 0 to 255. In binary, 192.168.1.10 is 11000000.10101000.00000001.00001010.

Every IPv4 address has two parts: the network portion (shared by all hosts in the subnet) and the host portion (unique to each device). The subnet mask defines where that boundary falls.

What is a subnet mask?

A subnet mask is a 32-bit number where all network bits are set to 1 and all host bits are set to 0. When written in dotted decimal, the most common subnet masks look like this:

CIDR PrefixSubnet MaskNetwork BitsHost BitsTotal Addresses
/8255.0.0.082416,777,216
/16255.255.0.0161665,536
/24255.255.255.0248256
/25255.255.255.128257128
/28255.255.255.24028416
/30255.255.255.2523024

CIDR notation

CIDR (Classless Inter-Domain Routing) expresses the network prefix length as a suffix after the IP address: 192.168.1.0/24. The number after the slash tells you how many bits are in the network portion. /24 means the first 24 bits are fixed (the network) and the remaining 8 bits vary (the hosts).

CIDR replaced the older classful addressing system — Class A (/8), Class B (/16), Class C (/24) — in 1993. It allows far more flexible allocation because any prefix length from /0 to /32 is valid, not just multiples of 8.

How to calculate subnet values from a CIDR prefix

Given an IP address and prefix — for example 192.168.10.50/26 — here is how to derive all subnet values:

Step 1: Calculate the subnet mask

A /26 prefix means the first 26 bits are 1s. In binary: 11111111.11111111.11111111.11000000. In dotted decimal: 255.255.255.192.

Step 2: Find the network address

Apply a bitwise AND between the IP address and the subnet mask. In binary:

Step 3: Calculate total addresses and usable hosts

Host bits = 32 − prefix = 32 − 26 = 6. Total addresses = 2^6 = 64. Usable hosts = 64 − 2 = 62 (subtract network and broadcast addresses).

Step 4: Find the broadcast address

Set all host bits to 1. The last octet of the network address is 0 (00000000). Setting 6 host bits to 1: 00111111 = 63. Broadcast address: 192.168.10.63.

Step 5: First and last usable host

Wildcard masks

The wildcard mask is the bitwise complement of the subnet mask — it has 0s where the subnet mask has 1s, and 1s where the subnet mask has 0s. For a /26 mask (255.255.255.192), the wildcard mask is 0.0.0.63.

Wildcard masks are used in Cisco IOS access control lists (ACLs) and OSPF network statements. A 0 bit means "must match", a 1 bit means "ignore". This allows patterns like "match any host in 10.0.0.0/8" or "match this specific host".

Private IP address ranges (RFC 1918)

Three address ranges are reserved for private use and are not routable on the public internet:

RangeCIDRClassUsable Hosts
10.0.0.0 – 10.255.255.25510.0.0.0/8A~16.7 million
172.16.0.0 – 172.31.255.255172.16.0.0/12B~1 million
192.168.0.0 – 192.168.255.255192.168.0.0/16C~65,534

Devices on private networks access the internet through Network Address Translation (NAT), which maps private addresses to a single public IP address at the router.

Special prefix lengths: /31 and /32

The formula "usable hosts = 2^(32−prefix) − 2" breaks down at the extremes:

Frequently asked questions

What is CIDR notation?

CIDR (Classless Inter-Domain Routing) expresses an IP address and its network prefix as a single string — for example 192.168.1.0/24. The number after the slash tells you how many bits belong to the network portion. CIDR replaced the older classful system (Class A/B/C) in 1993, allowing far more flexible address allocation.

How many usable hosts does a /24 subnet have?

A /24 subnet contains 256 total addresses (2^8). Two are reserved — the network address and the broadcast address — leaving 254 usable hosts. In general, usable hosts = 2^(32 − prefix) − 2 for prefixes from /1 to /30.

What is the difference between subnet mask and wildcard mask?

The subnet mask uses 1s to mark network bits (e.g. 255.255.255.0). The wildcard mask is its bitwise complement — 0s for network bits and 1s for host bits (e.g. 0.0.0.255). Wildcard masks are standard in Cisco IOS access control lists and OSPF network statements.

What are the private IP address ranges?

RFC 1918 defines three private ranges not routable on the public internet: 10.0.0.0/8 (Class A — up to 16M hosts), 172.16.0.0/12 (Class B — up to 1M hosts), and 192.168.0.0/16 (Class C — up to 65K hosts). Devices on private networks access the internet through NAT.

Conclusion

Subnetting is built on straightforward binary arithmetic. Once you understand that the prefix length defines how many bits are fixed (network) versus variable (host), you can derive every other value — subnet mask, network address, broadcast address, first and last usable host, and wildcard mask — from first principles. Use our free IP Subnet Calculator to get all these values instantly for any IP address and prefix, with a full binary breakdown included.

Ready to calculate your subnet? Try our free tool — works instantly in your browser.

IP Subnet Calculator — Try it Free

Related tools