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.
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:
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:
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:
| Class | First Octet Range | Default Mask | Networks | Hosts per Network |
|---|---|---|---|---|
| A | 1 -- 126 | /8 (255.0.0.0) | 126 | 16,777,214 |
| B | 128 -- 191 | /16 (255.255.0.0) | 16,384 | 65,534 |
| C | 192 -- 223 | /24 (255.255.255.0) | 2,097,152 | 254 |
| D | 224 -- 239 | N/A (Multicast) | Reserved for multicast | |
| E | 240 -- 255 | N/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:
| Range | CIDR Block | Class | Total Addresses |
|---|---|---|---|
| 10.0.0.0 -- 10.255.255.255 | 10.0.0.0/8 | A | 16,777,216 |
| 172.16.0.0 -- 172.31.255.255 | 172.16.0.0/12 | B | 1,048,576 |
| 192.168.0.0 -- 192.168.255.255 | 192.168.0.0/16 | C | 65,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
- RGB to HSL Converter -- Convert RGB colors to HSL format
- JavaScript Formatter -- Format and beautify JavaScript code with customizable indentation
- Bcrypt Generator -- Generate bcrypt password hashes with configurable rounds
- Unix Permissions Calculator -- Convert between symbolic (rwx) and octal unix permissions
Related Tools
View all toolsBig-O Notation Visualizer
Interactive plot of O(1) through O(n!) complexity curves with operation count comparison
JSON Formatter
Format and beautify JSON with proper indentation
JSON Validator
Validate JSON syntax and show errors
CSV to JSON Converter
Convert CSV data to JSON format with auto-detection
JSON to CSV Converter
Convert JSON arrays to CSV format with nested object handling
JWT Decoder
Decode JWT tokens and display header and payload
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.