IPv4 Subnet Calculator
Input Parameters
Computed Results
The IPv4 subnet calculator determines network boundaries, broadcast addresses, and usable host ranges based on a given IP address and CIDR prefix. It helps network administrators quickly identify subnet masks, wildcard masks, and total available IP addresses for routing configuration and network planning.
How IPv4 Subnetting Works
Subnetting divides a larger network into smaller, more efficient sub-networks. An IPv4 address consists of 32 bits, divided into four 8-bit octets. The subnet mask (or CIDR prefix) determines how many of those 32 bits represent the network portion, leaving the remaining bits for individual hosts.
To calculate the total number of IP addresses in a subnet, use the following formula based on the CIDR prefix:
In a standard subnet, the first address is reserved for the network identifier, and the last address is reserved for the broadcast address. Therefore, the formula for usable hosts is:
Note: Exceptions apply for /31 subnets (used for point-to-point links, yielding 2 usable hosts) and /32 subnets (used for single host loopbacks, yielding 1 usable host).
Subnet Calculation Examples
Understanding how different CIDR prefixes affect network size is essential for proper IP allocation. Here are three distinct scenarios based on standard networking practices.
Standard Class C Private Network
A common configuration for home and small business networks uses a /24 prefix.
- IP Address: 192.168.1.1
- CIDR Prefix: 24
- Network Address: 192.168.1.0
- Broadcast Address: 192.168.1.255
- Subnet Mask: 255.255.255.0
- Usable Host Range: 192.168.1.1 - 192.168.1.254
- Usable Hosts: 254
Point-to-Point Link Edge Case
Modern router connections often use a /31 prefix to conserve IP addresses on point-to-point links, eliminating the standard network and broadcast address reservations.
- IP Address: 172.16.0.5
- CIDR Prefix: 31
- Network Address: 172.16.0.4
- Broadcast Address: 172.16.0.5
- Subnet Mask: 255.255.255.254
- Usable Host Range: 172.16.0.4 - 172.16.0.5
- Usable Hosts: 2
Single Host Loopback Address
A /32 prefix isolates a single specific IP address, commonly used for loopback interfaces or specific firewall rules.
- IP Address: 127.0.0.1
- CIDR Prefix: 32
- Network Address: 127.0.0.1
- Broadcast Address: 127.0.0.1
- Subnet Mask: 255.255.255.255
- Usable Host Range: 127.0.0.1
- Usable Hosts: 1
Practical Use Cases
Calculating subnet boundaries is a fundamental task in network engineering. Administrators use these calculations to segment large networks into smaller broadcast domains, which improves network performance and security. By determining the exact usable host range, engineers can assign static IP addresses to servers and configure DHCP pools for client devices without causing IP conflicts.
Additionally, knowing the exact network address and wildcard mask is required when configuring routing protocols (like OSPF or EIGRP) and writing Access Control Lists (ACLs) for firewalls. The calculator instantly provides the wildcard mask by inverting the bits of the subnet mask, streamlining router configuration.
Frequently Asked Questions
What is the difference between a subnet mask and a wildcard mask?
A subnet mask identifies the network and host portions of an IP address, using binary 1s for the network and 0s for the hosts. A wildcard mask is the exact inverse, using binary 0s to match the network and 1s to ignore the host bits. Wildcard masks are primarily used in routing protocols and firewall access control lists.
Why does a /31 subnet have 2 usable hosts instead of 0?
Under standard subnetting rules, subtracting 2 from the total addresses of a /31 subnet would leave 0 usable hosts. However, RFC 3021 established /31 subnets specifically for point-to-point links between routers. In this configuration, the network and broadcast addresses are not reserved, allowing both IP addresses to be assigned to the two connected router interfaces.
What does CIDR notation mean?
CIDR (Classless Inter-Domain Routing) notation is a compact way to represent an IP address and its associated routing prefix. It appends a forward slash and a number to the IP address (e.g., 192.168.1.0/24). The number indicates exactly how many bits of the address are used for the network prefix.