IP Subnet Calculator: IPv4 CIDR & Network Tool
Short answer
The IP Subnet Calculator determines IPv4 network boundaries, valid host ranges, subnet masks, and total capacity using an IP address and CIDR prefix. For example, entering 192.168.1.130 with a /26 prefix yields a network address of 192.168.1.128/26, 62 usable hosts spanning 192.168.1.129 to 192.168.1.190, and a broadcast address of 192.168.1.191.
Formula
Mask = 2³² − 2^(32−prefix); Network = IP AND mask; Hosts = 2^(32−prefix) − 2
Subnetting divides a 32-bit IPv4 address into network and host bits. The Subnet Mask is computed by setting the first n prefix bits to 1 and the remaining bits (32 − prefix) to 0, which translates algebraically to Mask = 2³² − 2^(32−prefix). The Network Address is determined by taking the bitwise logical AND between the binary IP address and the Subnet Mask (Network = IP AND Mask). Usable Hosts are calculated as 2^(32−prefix) − 2, deducting two addresses because the all-zeros host identifier represents the network itself and the all-ones host identifier represents the broadcast address.
Worked example
- IP address
- 192.168.1.130
- Prefix length (/CIDR)
- 26
- Network address: 192.168.1.128/26
- Broadcast address: 192.168.1.191
- Usable host range: 192.168.1.129 – 192.168.1.190
- Usable hosts: 62
- Subnet mask: 255.255.255.192
- Wildcard mask: 0.0.0.63
- Address type: Private (RFC 1918)
How the IP Subnet Calculator Works
Every device connected to an Internet Protocol version 4 (IPv4) network relies on an IP address to send and receive data packets. An IPv4 address is a 32-bit binary number traditionally displayed in dotted-decimal format—four numbers ranging from 0 to 255 separated by periods (for example, 192.168.1.130). For a network to function, routing equipment must discern which portion of those 32 bits identifies the broader network (the routing prefix) and which portion identifies the unique device on that local segment (the host identifier).
The IP Subnet Calculator automates this separation using Classless Inter-Domain Routing (CIDR) logic and bitwise boolean mathematics. By entering an IPv4 address alongside its CIDR prefix length (the number of leading bits assigned to the network portion), the calculator generates the complete boundaries of the network block. This includes the canonical network address, the broadcast address, the range of valid client IP addresses, the decimal subnet mask, the wildcard mask, and the total usable capacity.
The Anatomy of an IPv4 Subnet Mask
A subnet mask is also a 32-bit sequence. Unlike an IP address, however, a standard subnet mask always consists of a contiguous run of binary 1s followed by a contiguous run of binary 0s.
- Network Bits (Binary
1): Indicate the unchanging network prefix. - Host Bits (Binary
0): Indicate address space available for host assignment.
When you specify a prefix length such as /26, it dictates that the first 26 bits of the 32-bit address are binary 1s, leaving the remaining $32 - 26 = 6$ bits as binary 0s. In dotted-decimal form, 26 consecutive ones followed by 6 zeros translates to 255.255.255.192.
Mathematical Formulation of Subnetting
Subnetting relies on core binary arithmetic. The equations behind each value produced by the calculator are straightforward:
-
Subnet Mask: $$\text{Mask} = 2^{32} - 2^{32 - \text{prefix}}$$ This integer calculation converts directly into the four 8-bit octets of the subnet mask.
-
Network Address: $$\text{Network} = \text{IP} \text{ AND } \text{Mask}$$ Each bit of the IP address is evaluated against the corresponding bit of the subnet mask using a logical bitwise AND operation (where
1 AND 1 = 1, and all other combinations equal0). -
Broadcast Address: $$\text{Broadcast} = \text{Network} \text{ OR } (\text{NOT } \text{Mask})$$ The bitwise NOT of the mask (also known as the wildcard mask) sets all host bits to
1. Combining this with the network address via a bitwise OR operation produces the highest possible address in the block. -
Usable Host Capacity: $$\text{Usable Hosts} = 2^{32 - \text{prefix}} - 2$$ The exponent $(32 - \text{prefix})$ represents the number of host bits $h$. Total addresses equal $2^h$. Because the first address represents the network identifier and the final address is reserved for broadcast traffic, standard subnets subtract 2.
Step-by-Step Worked Example
To see these mathematical principles in action, consider the exact input parameters:
- IP address:
192.168.1.130 - Prefix length (/CIDR):
26
Step 1: Convert IP and Prefix to Binary
First, convert the dotted-decimal IP address into 32 binary bits across four 8-bit octets:
192=11000000168=101010001=00000001130=10000010- Full IP in Binary:
11000000.10101000.00000001.10000010
A prefix of /26 means the first 26 bits are 1, and the final 6 bits are 0:
- Mask in Binary:
11111111.11111111.11111111.11000000 - Converting back to decimal octets gives the Subnet mask:
255.255.255.192.
Step 2: Compute the Network Address
Apply the bitwise AND operation between the binary IP and the binary mask:
IP: 11000000.10101000.00000001.10000010 (192.168.1.130)
Mask: 11111111.11111111.11111111.11000000 (255.255.255.192)
--------------------------------------------------------------
Net: 11000000.10101000.00000001.10000000 (192.168.1.128)
The resulting Network address is 192.168.1.128/26.
Step 3: Compute the Wildcard Mask and Broadcast Address
Invert the subnet mask bits to derive the Wildcard mask:
- Binary:
00000000.00000000.00000000.00111111 - Decimal:
0.0.0.63
Apply the bitwise OR between the Network Address and the Wildcard Mask:
Net: 11000000.10101000.00000001.10000000 (192.168.1.128)
Wildcard: 00000000.00000000.00000000.00111111 (0.0.0.63)
--------------------------------------------------------------
Bcast: 11000000.10101000.00000001.10111111 (192.168.1.191)
The resulting Broadcast address is 192.168.1.191.
Step 4: Determine Usable Host Range and Capacity
- Host Bits ($h$): $32 - 26 = 6$
- Total Addresses: $2^6 = 64$
- Usable Hosts: $2^6 - 2 = 62$
- First Usable Host: Network Address + 1 =
192.168.1.129 - Last Usable Host: Broadcast Address − 1 =
192.168.1.190 - Usable host range:
192.168.1.129 – 192.168.1.190
Step 5: Classify Address Scope
The IP address 192.168.1.130 falls squarely within the 192.168.0.0/16 boundary established by the Internet Engineering Task Force (IETF) in RFC 1918. Therefore, the calculator classifies the Address type as Private (RFC 1918).
How to Interpret Your Results
When reviewing outputs from the calculator, each metric serves a distinct administrative role:
- Network Address: The formal base address representing the entire subnet in routing tables. You cannot assign this value to a network interface card (NIC), printer, or server.
- Broadcast Address: A specialized address that relays incoming traffic to every device on that local subnet. Operating systems drop packets targeting this address if broadcast handling is restricted.
- Usable Host Range: The exact inclusive window of IP addresses that can be statically assigned or distributed via Dynamic Host Configuration Protocol (DHCP) to host machines.
- Usable Hosts: The total quantity of unique endpoints this subnet can support concurrently. If your physical equipment count exceeds this figure, you must expand the prefix (e.g., from
/26to/25). - Subnet Mask: The standard dotted-decimal representation required by network operating systems (such as Windows, Linux, and macOS) during static IP configuration.
- Wildcard Mask: The inverse value required primarily when configuring packet filters, firewalls, and routing protocols like Open Shortest Path First (OSPF) on commercial routing platforms.
- Address Type: Indicates whether the address is globally routable across the public internet or private within internal corporate and residential local area networks (LANs).
Modern Subnetting and VLSM Considerations
In modern network architecture, network administrators rarely allocate fixed subnet sizes across an entire organization. Instead, they use Variable Length Subnet Masking (VLSM). VLSM enables engineers to divide an assigned address block into subnets of varying sizes to match specific departmental needs.
For example, an office floor with 50 workstations requires a /26 subnet (providing 62 usable addresses), whereas a point-to-point router uplink connecting two buildings requires only a /30 (providing 2 usable addresses) or a /31 under RFC 3021. Implementing VLSM prevents address exhaustion and keeps routing tables streamlined.
Practical Tips
- Use the "Magic Number" for Quick Mental Math: In the octet where the mask changes (the interesting octet), subtract the mask value from 256. For a
/26mask (255.255.255.192), compute $256 - 192 = 64$. The number 64 is your block size. Subnets in that octet will always start at multiples of 64:0,64,128,192. Because130falls between128and191, the network address must be128. - Standardize Default Gateway Placement: Establish a consistent organizational policy for gateway assignment. Most network engineers assign either the very first usable IP (
192.168.1.129) or the very last usable IP (192.168.1.190) as the router's virtual interface address (HSRP/VRRP). - Plan for 30% Growth: When selecting a CIDR prefix, ensure the usable host count accommodates at least 20% to 30% overhead for new endpoints, smart phones, guest systems, and printers to avoid re-addressing segments later.
- Separate Management and User Planes: Keep network infrastructure interfaces (switches, power distribution units, out-of-band management cards) on isolated subnets separate from general employee workstations to maintain security compliance.
Comparison
| Scenario | Input | Result |
|---|---|---|
| Base example | Default inputs | Network address: 192.168.1.128/26 |
Common mistakes
- Confusing total address capacity with usable host capacity by forgetting to subtract the network and broadcast addresses.
- Assigning the network address or broadcast address directly to a physical host interface.
- Incorrectly converting octets into binary, leading to off-by-one errors in block boundaries.
- Assuming outdated classful network rules (Class A, B, C) apply when designing modern Classless Inter-Domain Routing (CIDR) networks.
- Inverting bits improperly when calculating wildcard masks for router access control lists (ACLs).
Checklist
- Verify the IPv4 address follows standard dotted-decimal notation (four octets between 0 and 255).
- Select an appropriate CIDR prefix length between /0 and /32 based on host requirements.
- Confirm whether the subnet uses RFC 1918 private space or publicly routable IP space.
- Ensure total required devices do not exceed the calculated usable host capacity.
- Reserve the first or last usable IP address for the default gateway router interface.
- Document the calculated network, broadcast, and mask values in an IP Address Management (IPAM) system.

Michael Torres
Co-Founder & Chief Editor, Calculators PercentageCo-Founder & Chief EditorMichael Torres writes about personal finance, loans, and savings for the financial blog The Money Leads.
This tool provides mathematical calculations based on standard IPv4 specifications published by the Internet Engineering Task Force (IETF). Always verify your subnet allocations against your internal IP address management plan before deploying configuration changes to live production networks.
