Subnet Calculator

Calculate IP subnets, CIDR notation, network addresses, and usable hosts for IPv4 networks

Network Configuration

Enter an IPv4 address (e.g., 192.168.1.0)
CIDR prefix length (0-32, e.g., 24 for /24)

Subnet Information

Network Address
0.0.0.0
First address in the subnet
Broadcast Address
0.0.0.0
Last address in the subnet
Subnet Mask
0.0.0.0
CIDR: /0
Wildcard Mask
0.0.0.0
Inverse of subnet mask
Usable Host Range
0.0.0.0 - 0.0.0.0
First and last usable IP
Number of Usable Hosts
0
Available host addresses
IP Class
-
-

Common Subnet Masks Reference

CIDR Subnet Mask Wildcard Mask Usable Hosts Typical Use
/8 255.0.0.0 0.255.255.255 16,777,214 Class A network
/16 255.255.0.0 0.0.255.255 65,534 Class B network
/24 255.255.255.0 0.0.0.255 254 Class C network, Small LAN
/25 255.255.255.128 0.0.0.127 126 Small office
/26 255.255.255.192 0.0.0.63 62 Department subnet
/27 255.255.255.224 0.0.0.31 30 Small subnet
/28 255.255.255.240 0.0.0.15 14 Point-to-point links
/29 255.255.255.248 0.0.0.7 6 Very small subnet
/30 255.255.255.252 0.0.0.3 2 Point-to-point WAN links
/32 255.255.255.255 0.0.0.0 1 Single host (host route)

Understanding IP Subnetting and CIDR Notation

Subnet calculation is a fundamental skill for network engineers, system administrators, and IT professionals. Our comprehensive subnet calculator helps you quickly calculate network addresses, broadcast addresses, usable IP ranges, and subnet masks for IPv4 networks. Whether you're designing a new network infrastructure, troubleshooting connectivity issues, or preparing for networking certifications, this tool provides accurate subnet calculations with detailed information about your network configuration.

What is Subnetting?

Subnetting is the process of dividing a large network into smaller, more manageable sub-networks (subnets). This practice improves network performance, enhances security by isolating network segments, and optimizes IP address allocation. By creating subnets, network administrators can reduce broadcast traffic, implement security policies at the subnet level, and organize networks logically based on departments, functions, or geographic locations.

Without subnetting, all devices on a network would exist in a single broadcast domain, leading to excessive broadcast traffic and security concerns. Subnetting allows you to create multiple broadcast domains, improving overall network efficiency and providing better control over network traffic flow.

Understanding IP Addresses

An IPv4 address consists of 32 bits divided into four octets, each containing 8 bits. These addresses are typically written in dotted-decimal notation, such as 192.168.1.100. Each octet can range from 0 to 255, and the entire address uniquely identifies a device on a network. IPv4 addresses are divided into two parts: the network portion, which identifies the network, and the host portion, which identifies the specific device on that network.

The network and host portions are determined by the subnet mask. For example, in the address 192.168.1.100 with a subnet mask of 255.255.255.0, the first three octets (192.168.1) represent the network, while the last octet (100) represents the host. This division allows routers to efficiently direct traffic between networks while enabling local network switches to handle traffic within a subnet.

IPv4 Address Structure

IPv4 addresses are organized into a hierarchical structure that consists of:

  • Network Address: The first address in a subnet, used to identify the network itself. This address cannot be assigned to a host and is reserved for routing purposes.
  • Host Addresses: The addresses between the network and broadcast addresses that can be assigned to devices. These are the usable IP addresses in your subnet.
  • Broadcast Address: The last address in a subnet, used to send messages to all hosts on the network simultaneously. This address is reserved and cannot be assigned to individual devices.

Understanding this structure is crucial for proper network design. When calculating subnet requirements, you must account for the network and broadcast addresses, which is why the number of usable hosts is always 2^(32-CIDR) - 2, subtracting two addresses from the total.

Subnet Mask Explained

A subnet mask is a 32-bit number that divides the IP address into network and host portions. It consists of consecutive 1s followed by consecutive 0s in binary. The 1s indicate the network portion, while the 0s indicate the host portion. For example, the subnet mask 255.255.255.0 in binary is 11111111.11111111.11111111.00000000, meaning the first 24 bits are the network portion and the last 8 bits are for hosts.

Subnet masks perform a bitwise AND operation with IP addresses to determine the network address. This mathematical operation allows routers and devices to quickly determine whether a destination IP is on the local network or requires routing to a different network. Understanding subnet masks is essential for troubleshooting routing issues and designing efficient network topologies.

CIDR Notation (Classless Inter-Domain Routing)

CIDR notation provides a compact way to represent subnet masks using a slash followed by the number of network bits. For instance, /24 indicates that the first 24 bits are the network portion, equivalent to the subnet mask 255.255.255.0. CIDR notation replaced the older classful addressing system, providing more flexibility in network design and more efficient use of IP address space.

CIDR allows for variable-length subnet masking (VLSM), enabling network designers to create subnets of different sizes based on actual requirements rather than fixed class boundaries. This flexibility has been crucial in extending the life of IPv4 addressing and preventing premature exhaustion of available addresses.

Common CIDR Notations:
/8 = 255.0.0.0 (16,777,214 hosts)
/16 = 255.255.0.0 (65,534 hosts)
/24 = 255.255.255.0 (254 hosts)
/30 = 255.255.255.252 (2 hosts)

How to Calculate Subnets

Calculating subnets involves several steps and mathematical operations. Here's the systematic approach used by network engineers:

  1. Determine the Network Address: Perform a bitwise AND operation between the IP address and subnet mask. This identifies the first address in the subnet.
  2. Calculate the Broadcast Address: Perform a bitwise OR operation between the network address and the wildcard mask (inverse of subnet mask). This identifies the last address in the subnet.
  3. Find Usable Hosts: Use the formula 2^(32-CIDR) - 2 to determine the number of assignable host addresses, subtracting the network and broadcast addresses.
  4. Identify the Host Range: The first usable host is the network address + 1, and the last usable host is the broadcast address - 1.

Network Address vs Broadcast Address

The network address is the identifier for the subnet itself and is always the first address in the range. It's used in routing tables to direct traffic to the appropriate subnet. For example, in the 192.168.1.0/24 network, 192.168.1.0 is the network address. Routers use this address to make forwarding decisions and maintain routing tables.

The broadcast address is the last address in the subnet range and is used to send packets to all hosts within that subnet simultaneously. In the same 192.168.1.0/24 network, 192.168.1.255 is the broadcast address. When a host sends a packet to the broadcast address, all devices in the subnet receive it. This is useful for network discovery protocols, DHCP requests, and other network-wide communications.

Usable IP Addresses

Usable IP addresses are those that can be assigned to hosts (computers, servers, printers, etc.) within a subnet. In any subnet, you must subtract two addresses from the total: one for the network address and one for the broadcast address. For example, a /24 subnet (255.255.255.0) has 256 total addresses but only 254 usable host addresses.

When planning network capacity, always consider the number of usable addresses rather than the total address space. A common mistake is forgetting to account for the network and broadcast addresses, leading to insufficient IP address allocation. Additionally, consider growth requirements and leave room for future expansion when selecting subnet sizes.

Wildcard Mask

A wildcard mask is the inverse of a subnet mask, where the 0s and 1s are flipped. It's primarily used in Cisco access control lists (ACLs) and routing protocols like OSPF to specify which IP address bits should be matched and which can be ignored. For example, the wildcard mask for 255.255.255.0 is 0.0.0.255, indicating that the first three octets must match exactly while the last octet can be any value.

Understanding wildcard masks is essential for configuring network security policies and routing protocols. Unlike subnet masks, wildcard masks allow for non-contiguous bits, providing greater flexibility in defining address ranges for access control and route filtering.

IP Address Classes

Although CIDR has largely replaced classful addressing, understanding IP address classes remains important for legacy systems and networking fundamentals:

  • Class A (1.0.0.0 to 126.0.0.0): Designed for very large networks with up to 16,777,214 hosts. The first octet identifies the network, and the remaining three octets identify hosts. Default subnet mask is 255.0.0.0 (/8).
  • Class B (128.0.0.0 to 191.255.0.0): Designed for medium to large networks with up to 65,534 hosts. The first two octets identify the network, and the last two identify hosts. Default subnet mask is 255.255.0.0 (/16).
  • Class C (192.0.0.0 to 223.255.255.0): Designed for small networks with up to 254 hosts. The first three octets identify the network, and the last octet identifies hosts. Default subnet mask is 255.255.255.0 (/24).
  • Class D (224.0.0.0 to 239.255.255.255): Reserved for multicast groups. These addresses allow efficient one-to-many communication without creating multiple unicast streams.
  • Class E (240.0.0.0 to 255.255.255.255): Reserved for experimental purposes and future use. These addresses are not available for general network assignment.

Private vs Public IP Addresses

IP addresses are categorized as either private or public. Private IP addresses are reserved for use within private networks and cannot be routed on the public Internet. These ranges are defined by RFC 1918 and can be used by anyone without registration:

  • 10.0.0.0/8: Class A private range (10.0.0.0 to 10.255.255.255) - 16,777,216 addresses
  • 172.16.0.0/12: Class B private range (172.16.0.0 to 172.31.255.255) - 1,048,576 addresses
  • 192.168.0.0/16: Class C private range (192.168.0.0 to 192.168.255.255) - 65,536 addresses

Public IP addresses are globally unique and routable on the Internet. They must be obtained from Internet Service Providers (ISPs) or Regional Internet Registries (RIRs). Organizations use Network Address Translation (NAT) to allow devices with private IP addresses to communicate with the Internet using a limited number of public IP addresses, conserving the scarce IPv4 address space.

VLSM (Variable Length Subnet Masking)

VLSM is a subnetting technique that allows you to use different subnet masks for different subnets within the same network, optimizing IP address utilization. Instead of using the same subnet size for all networks regardless of their host requirements, VLSM enables you to allocate appropriately sized subnets based on actual needs.

For example, if you have a 192.168.1.0/24 network and need subnets for 100 hosts, 50 hosts, and 10 hosts, VLSM allows you to create a /25 subnet (126 hosts), a /26 subnet (62 hosts), and a /28 subnet (14 hosts), efficiently using the available address space without waste. This approach is essential for modern network design and is supported by all current routing protocols.

Supernetting

Supernetting, also called route aggregation or route summarization, is the opposite of subnetting. It combines multiple contiguous networks into a single larger network, reducing the size of routing tables and improving routing efficiency. This is accomplished by using a shorter prefix length (smaller CIDR number) that encompasses multiple smaller networks.

For example, if you have four consecutive /24 networks (192.168.0.0/24, 192.168.1.0/24, 192.168.2.0/24, 192.168.3.0/24), they can be superneted into a single /22 network (192.168.0.0/22). This reduces four routing table entries to one, improving router performance and scalifying network management in large-scale networks and Internet backbone routers.

Example Subnet Calculations

Example 1: Small Office Network (/24)

Scenario: You need a network for a small office with 50 computers.
IP Address: 192.168.10.0/24
Subnet Mask: 255.255.255.0
Network Address: 192.168.10.0
Broadcast Address: 192.168.10.255
Usable Host Range: 192.168.10.1 - 192.168.10.254
Number of Usable Hosts: 254
Result: This subnet provides more than enough addresses for 50 computers with room for growth.

Example 2: Point-to-Point Link (/30)

Scenario: You need to connect two routers with a WAN link.
IP Address: 10.1.1.0/30
Subnet Mask: 255.255.255.252
Network Address: 10.1.1.0
Broadcast Address: 10.1.1.3
Usable Host Range: 10.1.1.1 - 10.1.1.2
Number of Usable Hosts: 2
Result: Perfect for a point-to-point connection with no wasted IP addresses.

Example 3: Medium Network with VLSM (/26)

Scenario: You need to divide a /24 network into four equal subnets.
Original Network: 172.16.50.0/24
New Subnet Size: /26 (255.255.255.192)
Subnet 1: 172.16.50.0/26 (172.16.50.1 - 172.16.50.62) - 62 hosts
Subnet 2: 172.16.50.64/26 (172.16.50.65 - 172.16.50.126) - 62 hosts
Subnet 3: 172.16.50.128/26 (172.16.50.129 - 172.16.50.190) - 62 hosts
Subnet 4: 172.16.50.192/26 (172.16.50.193 - 172.16.50.254) - 62 hosts
Result: Four equal subnets, each supporting up to 62 hosts.

Example 4: Large Corporate Network (/16)

Scenario: A large corporation needs a private network for multiple departments.
IP Address: 10.20.0.0/16
Subnet Mask: 255.255.0.0
Network Address: 10.20.0.0
Broadcast Address: 10.20.255.255
Usable Host Range: 10.20.0.1 - 10.20.255.254
Number of Usable Hosts: 65,534
Result: Provides over 65,000 addresses that can be further subnetted for departments.

Example 5: Calculating Required Subnet Size

Scenario: You need to support 500 hosts in a single subnet.
Calculation: 2^n - 2 >= 500, where n is the number of host bits
Solution: 2^9 - 2 = 510 hosts, so you need 9 host bits
CIDR: 32 - 9 = /23
Subnet Mask: 255.255.254.0
Example Network: 192.168.0.0/23
Usable Host Range: 192.168.0.1 - 192.168.1.254
Number of Usable Hosts: 510
Result: This subnet size meets the requirement with minimal waste.

Common Subnet Masks and Their Uses

Different subnet masks serve different purposes in network design. Understanding when to use each is crucial for efficient network architecture:

  • /32 (255.255.255.255): Single host or host route, used for static routes to specific devices or loopback interfaces.
  • /31 (255.255.255.254): Point-to-point links (RFC 3021), optimized for router-to-router connections without wasting addresses.
  • /30 (255.255.255.252): Traditional point-to-point WAN links, provides 2 usable addresses for device interfaces.
  • /29 (255.255.255.248): Very small LANs or server clusters, supports 6 hosts.
  • /28 (255.255.255.240): Small workgroups or server segments, supports 14 hosts.
  • /27 (255.255.255.224): Department or floor networks, supports 30 hosts.
  • /26 (255.255.255.192): Small to medium office networks, supports 62 hosts.
  • /25 (255.255.255.128): Medium office or building networks, supports 126 hosts.
  • /24 (255.255.255.0): Standard small network, the most common subnet size for LANs, supports 254 hosts.
  • /16 (255.255.0.0): Large campus or enterprise networks, supports 65,534 hosts.
  • /8 (255.0.0.0): Very large organizational networks, supports over 16 million hosts.

Subnetting Best Practices

Effective network design requires following established best practices for subnetting:

  • Plan for Growth: Always allocate more addresses than currently needed to accommodate future expansion without redesigning the network.
  • Use VLSM: Allocate subnet sizes based on actual requirements to minimize IP address waste and maximize efficient utilization.
  • Document Everything: Maintain detailed documentation of subnet allocations, including purpose, location, and contact information for each subnet.
  • Use Private Addresses: Implement RFC 1918 private addresses for internal networks and use NAT for Internet connectivity to conserve public IP addresses.
  • Hierarchical Design: Organize subnets hierarchically to enable efficient route summarization and simplified routing table management.
  • Reserve Address Blocks: Set aside specific ranges for servers, network devices, DHCP pools, and static assignments to maintain organization.
  • Standardize Assignments: Use consistent patterns for network and host addressing across your organization for easier troubleshooting and management.
  • Consider Security: Design subnet boundaries to align with security zones and policy requirements, enabling effective firewall and access control implementation.

When to Use Different Subnet Sizes

Selecting the appropriate subnet size depends on various factors including the number of required hosts, network type, growth projections, and organizational structure:

  • Enterprise Campus Networks: Use /16 or /20 networks with VLSM to create department and building subnets, allowing for hierarchical design and growth.
  • Branch Office Networks: Typically use /24 networks, providing adequate address space for small to medium offices while maintaining simplicity.
  • Data Center Networks: Use /26 or /27 for server segments, separating different tiers (web, application, database) for security and management.
  • WiFi Networks: Often use /22 or /23 to accommodate large numbers of mobile devices with high turnover rates.
  • WAN Links: Use /30 or /31 for point-to-point connections between routers, minimizing address waste on links with only two endpoints.
  • Management Networks: Use /28 or /29 for out-of-band management interfaces, keeping management traffic isolated from production.
  • DMZ Segments: Size based on the number of public-facing servers, typically /28 or /27, balancing security isolation with address availability.

Using the Subnet Calculator

Our subnet calculator supports three input methods to accommodate different scenarios:

  • IP / CIDR: Enter an IP address and CIDR notation (e.g., 192.168.1.0/24) - the most common and efficient method.
  • IP / Subnet Mask: Enter an IP address and subnet mask in dotted decimal notation (e.g., 192.168.1.0 and 255.255.255.0) - useful when working with legacy systems.
  • IP / Hosts: Enter an IP address and the number of required hosts - the calculator automatically determines the smallest suitable subnet size.

The calculator provides comprehensive information including network address, broadcast address, subnet mask in multiple formats, wildcard mask, usable IP range, number of hosts, IP class classification, and whether the address is private or public. Optional features include binary representation for understanding the underlying mathematics and a complete list of all usable IP addresses for smaller subnets.

Whether you're a network engineer designing enterprise infrastructure, a student learning networking fundamentals, or an IT professional troubleshooting connectivity issues, our subnet calculator provides the accurate information you need to work with IPv4 networks efficiently and effectively.