IP Subnet Calculator -- CIDR & Subnet Mask

Calculate subnet masks, network addresses, broadcast addresses, and host ranges for IPv4

Calculate Subnet

Enter an IPv4 address and select a CIDR prefix length (or subnet mask) to calculate network details, usable host range, and binary representations.

Quick Select CIDR
Network Address
--
Usable Host Range
--
Broadcast Address
--
IP Address
--
Subnet Mask
--
Wildcard Mask
--
CIDR Notation
--
Total Addresses
--
Usable Hosts
--
IP Class
--
IP Type
--
Binary Representation
IP Address
--
Subnet Mask
--
Network Address
--
Broadcast Address
--
Wildcard Mask
--

CIDR Reference Table

Complete reference of all CIDR prefix lengths with their subnet masks, wildcard masks, total addresses, and usable hosts.

CIDR Subnet Mask Wildcard Mask Total Addresses Usable Hosts Typical Use

How Subnetting Works

Subnetting is the process of dividing a large network into smaller, more manageable sub-networks (subnets). Every IPv4 address is a 32-bit number, typically written in dotted-decimal notation (e.g., 192.168.1.100). A subnet mask determines which portion of the address identifies the network and which portion identifies individual hosts.

The Subnet Mask

A subnet mask is a 32-bit value where the leading bits are set to 1 (the network portion) and the trailing bits are set to 0 (the host portion). For example, a /24 subnet mask has 24 ones followed by 8 zeros:

11111111.11111111.11111111.00000000 = 255.255.255.0

Calculating the Network Address

The network address is found by performing a bitwise AND between the IP address and the subnet mask. This zeros out the host bits, leaving only the network identifier.

Example: 192.168.1.100/24

IP Address:    11000000.10101000.00000001.01100100 (192.168.1.100)
Subnet Mask:  11111111.11111111.11111111.00000000 (255.255.255.0)
AND Result:   11000000.10101000.00000001.00000000 (192.168.1.0) = Network Address

Calculating the Broadcast Address

The broadcast address is found by setting all host bits to 1. You can compute it by performing a bitwise OR between the network address and the wildcard mask (the inverse of the subnet mask).

Example: 192.168.1.0/24

Network:      11000000.10101000.00000001.00000000 (192.168.1.0)
Wildcard:     00000000.00000000.00000000.11111111 (0.0.0.255)
OR Result:    11000000.10101000.00000001.11111111 (192.168.1.255) = Broadcast Address

Usable Host Range

The usable hosts in a subnet are all addresses between the network address and the broadcast address, exclusive. The first usable host is the network address + 1, and the last usable host is the broadcast address - 1. The total number of usable hosts is:

Usable Hosts = 2^(32 - CIDR prefix) - 2

The subtraction of 2 accounts for the network address and the broadcast address. For a /31, there are 2 addresses and 0 usable hosts by traditional rules, though RFC 3021 allows /31 for point-to-point links. A /32 represents a single host address.

CIDR and Classful Networking

Before CIDR (Classless Inter-Domain Routing) was introduced in 1993, IPv4 addresses were divided into fixed classes:

ClassFirst Octet RangeDefault MaskNetworksHosts per Network
A1 -- 126/8 (255.0.0.0)12616,777,214
B128 -- 191/16 (255.255.0.0)16,38465,534
C192 -- 223/24 (255.255.255.0)2,097,152254
D224 -- 239N/A (Multicast)Reserved for multicast
E240 -- 255N/A (Reserved)Reserved for future use

Classful addressing was wasteful -- a Class A network allocated over 16 million addresses, far more than most organizations needed. CIDR replaced this system with variable-length subnet masking (VLSM), allowing any prefix length from /1 to /32. This flexibility dramatically improved address space efficiency.

Private Address Ranges (RFC 1918)

Certain address ranges are reserved for private networks and are not routable on the public internet:

RangeCIDR BlockClassTotal Addresses
10.0.0.0 -- 10.255.255.25510.0.0.0/8A16,777,216
172.16.0.0 -- 172.31.255.255172.16.0.0/12B1,048,576
192.168.0.0 -- 192.168.255.255192.168.0.0/16C65,536

Common Subnetting Scenarios

Home Network (/24)

Most home routers use 192.168.1.0/24, providing 254 usable addresses. This is more than enough for typical household devices.

Small Office (/25 or /26)

A /25 gives 126 hosts and a /26 gives 62 hosts, which suits small businesses that need to segment their network without wasting address space.

Point-to-Point Link (/30)

A /30 provides exactly 2 usable hosts -- perfect for a link between two routers. Each router gets one address, with no waste.

Server VLAN (/27 or /28)

A /27 gives 30 hosts and a /28 gives 14 hosts, ideal for server subnets where you want tight control and minimal broadcast domains.

Frequently Asked Questions

What is a subnet mask?

A subnet mask is a 32-bit number that divides an IP address into a network portion and a host portion. The network bits are set to 1 and the host bits are set to 0. For example, a /24 subnet mask is 255.255.255.0, meaning the first 24 bits identify the network and the remaining 8 bits identify hosts within that network.

What is CIDR notation?

CIDR (Classless Inter-Domain Routing) notation is a compact way to specify an IP address and its associated subnet mask. It is written as an IP address followed by a slash and a number (e.g., 192.168.1.0/24). The number after the slash indicates how many bits of the address are used for the network portion.

How do I calculate the number of usable hosts in a subnet?

The formula is 2^(32 - CIDR prefix) - 2. You subtract 2 because the first address is the network address and the last address is the broadcast address, neither of which can be assigned to hosts. For example, a /24 network has 2^8 - 2 = 254 usable hosts.

What is the difference between a network address and a broadcast address?

The network address is the first address in a subnet and identifies the network itself (all host bits set to 0). The broadcast address is the last address in the subnet and is used to send data to all hosts on the network (all host bits set to 1). Neither can be assigned to a device.

What is a wildcard mask?

A wildcard mask is the inverse of a subnet mask. Where the subnet mask has 1s, the wildcard mask has 0s, and vice versa. Wildcard masks are commonly used in access control lists (ACLs) on Cisco routers and firewalls to match ranges of IP addresses. For a /24 network, the wildcard mask is 0.0.0.255.

What are IP address classes?

IPv4 addresses were historically divided into classes: Class A (1.0.0.0 to 126.255.255.255, default /8), Class B (128.0.0.0 to 191.255.255.255, default /16), and Class C (192.0.0.0 to 223.255.255.255, default /24). While classful addressing has been largely replaced by CIDR, understanding classes remains useful for networking fundamentals and exam preparation.

Does this calculator store my data?

No. All calculations run entirely in your browser. No data is sent to any server, and nothing is stored.

Privacy

This calculator runs entirely in your browser using client-side JavaScript. No IP addresses or subnet data are transmitted to any server. Nothing is logged or stored.

Related Tools

Related Tools

View all tools

IP Subnet Calculator FAQ

What is a subnet mask?

A subnet mask is a 32-bit number that divides an IP address into a network portion and a host portion. The network bits are set to 1 and the host bits are set to 0. For example, a /24 subnet mask is 255.255.255.0, meaning the first 24 bits identify the network and the remaining 8 bits identify hosts within that network.

What is CIDR notation?

CIDR (Classless Inter-Domain Routing) notation is a compact way to specify an IP address and its associated subnet mask. It is written as an IP address followed by a slash and a number (e.g., 192.168.1.0/24). The number after the slash indicates how many bits of the address are used for the network portion.

How do I calculate the number of usable hosts in a subnet?

The number of usable hosts is 2^(32 - CIDR prefix) - 2. You subtract 2 because the first address is the network address and the last address is the broadcast address, neither of which can be assigned to hosts. For example, a /24 network has 2^8 - 2 = 254 usable hosts.

What is the difference between a network address and a broadcast address?

The network address is the first address in a subnet and identifies the network itself. It is obtained by performing a bitwise AND between the IP address and subnet mask. The broadcast address is the last address in the subnet and is used to send data to all hosts on the network. It is obtained by setting all host bits to 1.

What is a wildcard mask?

A wildcard mask is the inverse of a subnet mask. Where the subnet mask has 1s, the wildcard mask has 0s, and vice versa. Wildcard masks are commonly used in access control lists (ACLs) on routers and firewalls to match ranges of IP addresses. For a /24 network, the wildcard mask is 0.0.0.255.

What are IP address classes?

IPv4 addresses were historically divided into classes: Class A (1.0.0.0 to 126.255.255.255, default /8), Class B (128.0.0.0 to 191.255.255.255, default /16), and Class C (192.0.0.0 to 223.255.255.255, default /24). While classful addressing has been replaced by CIDR, understanding classes remains useful for networking fundamentals.

Does this calculator store my data?

No. All calculations run entirely in your browser. No data is sent to any server, and nothing is stored.

Request a New Tool
Improve This Tool