Subnet Mask Calculator

Calculate subnet masks from CIDR notation, find the optimal mask for your required number of hosts, and convert between different subnet mask formats.

/
255.255.255.0
255.255.255.128
/25
Recommended: A /25 network provides 126 usable hosts, which accommodates your requirement of 100 hosts.
/24
0.0.0.255

Complete Subnet Mask Reference Table

CIDR Subnet Mask Wildcard Mask Total IPs Usable Hosts

What is a Subnet Mask?

A subnet mask is a 32-bit number that divides an IP address into network and host portions. It works by masking (hiding) the network portion of an IP address, leaving only the host portion visible for local network operations. The subnet mask determines which part of an IP address identifies the network and which part identifies the specific device (host) on that network.

Subnet masks are written in the same dotted-decimal notation as IP addresses, such as 255.255.255.0. In binary, a subnet mask consists of consecutive 1s followed by consecutive 0s. The 1s represent network bits, and the 0s represent host bits. For example, 255.255.255.0 in binary is 11111111.11111111.11111111.00000000, indicating 24 network bits and 8 host bits. For complete subnet calculations, use our comprehensive subnet calculator.

Key Concept

The subnet mask determines network size: more 1s (longer prefix) means smaller networks with fewer hosts; fewer 1s (shorter prefix) means larger networks with more hosts. A /24 mask allows 254 hosts, while a /28 mask allows only 14 hosts.

How to Use the Subnet Mask Calculator

Our subnet mask calculator offers three different calculation modes to handle various scenarios:

Mode 1: CIDR to Subnet Mask

Enter a CIDR prefix length (0-32) to instantly see the corresponding subnet mask in dotted-decimal notation. This is useful when you have a network specification like /24 and need to configure a device that requires the full subnet mask format. The calculator shows 255.255.255.0 for /24, 255.255.255.128 for /25, and so on.

Mode 2: Required Hosts to Subnet Mask

Enter the number of hosts you need to support, and the calculator determines the smallest subnet mask that accommodates that requirement. This mode is essential for network planning when you know how many devices need IP addresses but aren't sure which mask to use. The calculator recommends the optimal mask while showing exactly how many usable addresses it provides.

Mode 3: Subnet Mask Converter

Enter a subnet mask in dotted-decimal format to convert it to CIDR notation and see the corresponding wildcard mask. This is particularly helpful when working with different network devices that use different notation formats. For additional conversion options, try our netmask to CIDR converter.

Understanding Subnet Mask Formats

Dotted Decimal Notation

The most common format displays the subnet mask as four decimal numbers separated by dots (e.g., 255.255.255.0). Each number represents 8 bits and ranges from 0 to 255. Valid subnet masks in this format always have values that represent consecutive 1s in binary: 0, 128, 192, 224, 240, 248, 252, 254, and 255.

CIDR Notation

CIDR (Classless Inter-Domain Routing) notation represents the subnet mask as a prefix length following a forward slash (e.g., /24). The number indicates how many leading bits are set to 1 in the subnet mask. This compact notation is widely used in modern networking and is equivalent to the dotted-decimal format. Our CIDR calculator provides detailed CIDR calculations.

Binary Format

In binary, subnet masks appear as consecutive 1s followed by consecutive 0s. For example, /24 is 11111111.11111111.11111111.00000000. Understanding the binary representation helps visualize how the mask separates network and host portions. Use our IP binary converter to explore binary representations.

Wildcard Mask

The wildcard mask is the bitwise inverse of the subnet mask, used primarily in Cisco ACLs and OSPF configuration. Where the subnet mask has 1s, the wildcard has 0s, and vice versa. For 255.255.255.0, the wildcard mask is 0.0.0.255. Calculate wildcard masks directly with our wildcard mask calculator.

Choosing the Right Subnet Mask

Selecting the appropriate subnet mask depends on your network requirements:

Based on Number of Hosts

If you know how many devices need IP addresses, choose a mask that provides enough addresses plus room for growth. Remember that each subnet loses 2 addresses (network and broadcast), so a network needing 50 hosts requires at least 52 addresses. The "Hosts to Mask" calculator mode handles this automatically.

Hosts Needed Minimum CIDR Subnet Mask Provides
1-2/30255.255.255.2522 hosts
3-6/29255.255.255.2486 hosts
7-14/28255.255.255.24014 hosts
15-30/27255.255.255.22430 hosts
31-62/26255.255.255.19262 hosts
63-126/25255.255.255.128126 hosts
127-254/24255.255.255.0254 hosts
255-510/23255.255.254.0510 hosts

Based on Network Architecture

Different network segments typically use different mask sizes based on their role:

  • Point-to-point WAN links: /30 or /31 (2 addresses)
  • Server VLANs: /27 to /25 (30-126 hosts)
  • User VLANs: /24 to /22 (254-1,022 hosts)
  • Management networks: /28 to /26 (14-62 hosts)
  • Loopback interfaces: /32 (1 address)

For complex networks with varying subnet sizes, our VLSM calculator can help design efficient address allocation.

Subnet Mask and Network Boundaries

The subnet mask determines where networks begin and end. When combined with an IP address using a bitwise AND operation, it produces the network address. Understanding this relationship is crucial for proper network configuration.

Example: How Subnet Mask Defines Network

Consider IP 192.168.1.150 with mask 255.255.255.192 (/26):

  • Network address: 192.168.1.128
  • Broadcast address: 192.168.1.191
  • Valid host range: 192.168.1.129 - 192.168.1.190
  • Usable hosts: 62

The same IP with mask 255.255.255.0 (/24) would be in network 192.168.1.0 with 254 usable hosts.

To visualize how different masks divide a network, try our visual subnet calculator. For calculating specific network and broadcast addresses, use our dedicated network address and broadcast address calculators.

Common Subnet Mask Mistakes

Avoid these frequent errors when working with subnet masks:

Invalid Subnet Masks

A valid subnet mask must have consecutive 1s followed by consecutive 0s in binary. Values like 255.255.255.100 or 255.0.255.0 are invalid because they don't follow this pattern. Each octet can only be: 0, 128, 192, 224, 240, 248, 252, 254, or 255.

Forgetting Reserved Addresses

When planning host capacity, remember that each subnet reserves 2 addresses (network and broadcast). A /28 has 16 total addresses but only 14 usable hosts. Always account for this when sizing networks.

Mismatched Masks

All devices on the same network segment must use the same subnet mask. A device with 255.255.255.0 cannot properly communicate with a device using 255.255.255.128 on the same segment, as they'll calculate different network boundaries.

Subnet Mask in Different Contexts

Windows Configuration

Windows displays subnet masks in dotted-decimal format in network adapter settings. When configuring static IP addresses, you'll enter the full mask (e.g., 255.255.255.0) alongside the IP address and default gateway.

Linux/Unix Systems

Linux typically uses CIDR notation in configuration files and commands (e.g., 192.168.1.100/24). The netmask command and older configurations may use dotted-decimal format.

Network Equipment

Cisco routers use both subnet masks (for interface configuration) and wildcard masks (for ACLs and OSPF). Other vendors may prefer one format over another, making conversion skills essential.

Cloud Platforms

AWS, Azure, and GCP use CIDR notation for VPC and subnet definitions. Understanding how to convert between formats helps when moving between different platforms and tools.

Quick Reference

Valid subnet mask octets:

0 128 192 224 240 248 252 254 255

Frequently Asked Questions

The most common subnet mask is 255.255.255.0 (or /24 in CIDR notation). This mask is the default for Class C networks and provides 254 usable host addresses, which is suitable for most small to medium-sized LANs. It's widely used in home networks, small offices, and as a standard subnet size within larger enterprise networks.

A valid subnet mask must have all 1s on the left followed by all 0s on the right when written in binary. This means each octet in dotted-decimal notation can only be one of these values: 255, 254, 252, 248, 240, 224, 192, 128, or 0. Additionally, once an octet is less than 255, all subsequent octets must be 0. For example, 255.255.240.0 is valid, but 255.240.255.0 is not.

A wildcard mask is the bitwise inverse of a subnet mask. Where the subnet mask has 1s, the wildcard mask has 0s, and vice versa. For subnet mask 255.255.255.0, the wildcard mask is 0.0.0.255. Subnet masks are used in IP configuration to define network boundaries, while wildcard masks are primarily used in Cisco IOS for access control lists (ACLs) and OSPF routing protocol configuration. Use our wildcard mask calculator for conversions.

Every subnet reserves two addresses that cannot be assigned to hosts: the network address (first address, where all host bits are 0) and the broadcast address (last address, where all host bits are 1). The network address identifies the subnet itself in routing tables, while the broadcast address is used to send data to all hosts on the subnet simultaneously. This is why a /24 subnet with 256 total addresses only has 254 usable for devices.

Yes, with CIDR (Classless Inter-Domain Routing), you can use any valid subnet mask with any IP address. This is different from the older classful system where Class A, B, and C addresses had fixed default masks. However, all devices on the same network segment must use the same subnet mask to communicate properly. When planning networks, ensure your chosen mask provides enough addresses and aligns with your organization's IP allocation scheme.

Related Network Tools

Looking to calculate subnets for your network? You can also enter subnet masks in decimal format. For detailed analysis, convert masks to CIDR format. Network administrators often need to convert masks to slash notation. Additionally, see binary forms of IP addresses. Many users find it helpful to use variable subnet masks effectively. For comprehensive planning, understand subnets with visual diagrams.