Subnet masks: a complete guide for infrastructure professionals

Internet: the network of networks

Few things are as fundamental in infrastructure management as subnet masks—and few are understood as superficially. Anyone who has ever configured a network interface has typed 255.255.255.0 almost on autopilot. But when it comes time to design the network architecture for a production environment, segment traffic across VLANs, size subnets for a private cloud deployment, or figure out why a firewall isn’t passing what it should, a real understanding of how subnet masks work is the difference between a well-designed infrastructure and a permanent source of incidents.

This guide covers the concept from the fundamentals through the practical scenarios that come up daily in datacenter and cloud environments, including reference tables, calculation examples, and the most common mistakes.

What is a subnet mask and why does it matter in infrastructure

A subnet mask is a 32-bit value that, when applied to an IP address, separates two things: the portion that identifies the network and the portion that identifies the host (the specific device within that network). It is, in essence, the tool that tells an operating system, a switch, or a router whether a packet should stay on the local network or be forwarded through the default gateway.

In binary, a subnet mask is always a sequence of contiguous ones followed by contiguous zeros. The ones mark the network bits; the zeros mark the host bits. No exceptions—although, as we’ll see later, there was a time when there were.

Two ways to express the same thing:

  • Dotted decimal notation: 255.255.255.0
  • CIDR notation: /24

Both represent exactly the same thing: the first 24 bits are network, the remaining 8 are host.

How it works internally: the AND operation

When a device needs to determine whether a destination IP is on its own network, it doesn’t compare addresses by eye. It performs a logical AND operation between its own IP address and the mask, then does the same with the destination IP. If the results match, the packet goes directly. If not, it’s sent to the gateway.

Practical example with IP 192.168.1.45 and mask 255.255.255.0:

IP:       11000000.10101000.00000001.00101101  (192.168.1.45)
Mask:     11111111.11111111.11111111.00000000  (255.255.255.0)
          ────────────────────────────────────
AND:      11000000.10101000.00000001.00000000  → 192.168.1.0

The result—192.168.1.0—is the network address. If another device produces the same result when applying its mask, both are on the same subnet.

This seemingly simple mechanism is what makes all IP communication work: from the most basic home network to the network architecture of a datacenter with hundreds of VLANs.

Complete subnet mask table: /32 to /0

The following table is a reference worth keeping handy at all times. It includes the CIDR notation, the dotted decimal mask, the total number of IPs, usable hosts (subtracting the network address and broadcast), and the most common use case in real-world infrastructure environments.

CIDRDecimal maskTotal IPsUsable hostsCommon use
/32255.255.255.25511Host route, loopback, firewall rules
/31255.255.255.25422*Point-to-point links (RFC 3021)
/30255.255.255.25242Router-to-router interconnections
/29255.255.255.24886DMZ segment, small public IP blocks
/28255.255.255.2401614Small public IP pool, management
/27255.255.255.2243230Management network, small office
/26255.255.255.1926462Department VLAN, server segment
/25255.255.255.128128126Medium server subnet
/24255.255.255.0256254Standard LAN, typical VLAN
/23255.255.254.0512510Large LAN, campus
/22255.255.252.01,0241,022Campus, corporate WiFi
/21255.255.248.02,0482,046Large campus
/20255.255.240.04,0964,094ISP, cloud provider
/19255.255.224.08,1928,190ISP block
/18255.255.192.016,38416,382ISP block
/17255.255.128.032,76832,766ISP block
/16255.255.0.065,53665,534Large corporate network
/12255.240.0.01,048,5761,048,574Class B private range (172.16.0.0/12)
/8255.0.0.016,777,21616,777,214Class A private range (10.0.0.0/8)
/00.0.0.04,294,967,296Default route

* The /31 mask, defined in RFC 3021, does not reserve a network address or broadcast address. It is widely supported on modern routers and saves one address compared to /30 on every point-to-point link—something that adds up when managing hundreds of interconnections in a datacenter.

Decimal to binary conversion: the values that appear in each octet

DecimalBinaryNetwork bits
0000000000
128100000001
192110000002
224111000003
240111100004
248111110005
252111111006
254111111107
255111111118

These are the only valid values that can appear in a subnet mask octet. If someone configures a different value (for example, 255.255.255.200), the configuration is incorrect.

The most commonly used masks in professional environments

Not all masks are used with the same frequency. In datacenter and cloud infrastructure practice, these are the ones that come up again and again:

/24 — The standard mask

The most common in LANs and VLANs. It provides 254 hosts, making it suitable for most enterprise network segments: workstations, servers in a rack, management networks, or storage VLANs.

Example: 10.10.5.0/24 covers from 10.10.5.1 to 10.10.5.254, with broadcast at 10.10.5.255.

/25 — Splitting a /24 in two

When a /24 is too large and you need to separate two environments (for example, production and staging), a /25 divides the block into two subnets of 126 hosts each.

SubnetRangeHosts
10.10.5.0/25.1 – .126126
10.10.5.128/25.129 – .254126

/26 — Four segments per /24

Ideal for separating VLANs within a single block when smaller segments are needed: server network, management network, monitoring network, and user network, each with up to 62 hosts.

SubnetNetwork addressFirst hostLast hostBroadcast
110.10.5.0/2610.10.5.110.10.5.6210.10.5.63
210.10.5.64/2610.10.5.6510.10.5.12610.10.5.127
310.10.5.128/2610.10.5.12910.10.5.19010.10.5.191
410.10.5.192/2610.10.5.19310.10.5.25410.10.5.255

/27 — 30-host segments

Widely used for management networks (iDRAC/IPMI, switches, smart PDUs) where there are only a few dozen devices and a reduced broadcast domain is desirable.

/28 — Small public IP blocks

When a provider assigns a block of public IPs to a customer, /28 (14 hosts) is one of the most common units. Also used for DMZs with few exposed services.

/30 and /31 — Point-to-point links

In any datacenter network with multiple interconnected routers or firewalls, the links between them use /30 (2 hosts) or /31 (2 hosts with no waste). In an infrastructure with 50 interconnections, the difference between /30 and /31 amounts to 50 saved IP addresses—something that matters at scale.

/32 — The individual host

Not a “subnet” in the strict sense: it identifies a single IP address. Used in host routes (static routes to a specific host), specific firewall rules, router loopback interfaces, and IP assignment in point-to-multipoint networks.

Network design with VLSM: a real-world example

In a production infrastructure, subnets rarely all need to be the same size. The VLSM (Variable Length Subnet Mask) technique allows you to assign each segment exactly the mask it needs, optimizing address utilization.

Scenario: A company has the allocated block 172.16.10.0/24 and needs:

  • Production servers: 100 hosts
  • User network: 50 hosts
  • Management/IPMI network: 20 hosts
  • DMZ: 10 hosts
  • Two WAN links: 2 hosts each

The allocation—always starting with the largest subnet—would be:

SegmentHosts neededCIDRMaskAvailable hostsAssigned network
Production100/25255.255.255.128126172.16.10.0/25
Users50/26255.255.255.19262172.16.10.128/26
Management20/27255.255.255.22430172.16.10.192/27
DMZ10/28255.255.255.24014172.16.10.224/28
WAN 12/30255.255.255.2522172.16.10.240/30
WAN 22/30255.255.255.2522172.16.10.244/30

Out of the 256 addresses in the original block, 238 are being used with minimal waste. Without VLSM, you would need to assign a /24 to each segment, requiring six /24 blocks instead of one.

Wildcard mask: the other side of the subnet mask

In ACL (access control list) configurations on routers and switches, and in protocols like OSPF, the subnet mask is not used directly. Instead, its inverse is used: the wildcard mask.

The calculation is straightforward: 255.255.255.255 - subnet mask = wildcard.

Subnet maskWildcard
255.255.255.255 (/32)0.0.0.0
255.255.255.252 (/30)0.0.0.3
255.255.255.240 (/28)0.0.0.15
255.255.255.0 (/24)0.0.0.255
255.255.0.0 (/16)0.0.255.255

Cisco ACL example: Allow traffic from the server network 172.16.10.0/25:

access-list 100 permit ip 172.16.10.0 0.0.0.127 any

OSPF example: Advertise the management network 172.16.10.192/27:

router ospf 1
 network 172.16.10.192 0.0.0.31 area 0

Quick calculation formulas

Two formulas worth having committed to memory:

Usable hosts per subnet:

2^(32 - CIDR_prefix) - 2

Number of subnets when dividing a block:

2^(new_prefix - original_prefix)

Quick examples:

  • How many hosts fit in a /27? → 2^(32-27) – 2 = 30
  • How many /28s can I carve from a /24? → 2^(28-24) = 16 subnets
  • I need at least 500 hosts: 2^n ≥ 502 → n = 9 → /23

Route aggregation (supernetting)

CIDR doesn’t just allow dividing networks into smaller subnets—it also allows aggregating multiple networks into a larger announcement. This is critical for keeping routing tables manageable, especially in BGP.

Example: Instead of advertising four separate routes:

192.168.0.0/24
192.168.1.0/24
192.168.2.0/24
192.168.3.0/24

You can advertise a single summary route: 192.168.0.0/22, reducing the load on neighboring routers. This only works if the networks are contiguous and align on a power-of-2 boundary.

Private addresses (RFC 1918) and CGNAT

Three address blocks are reserved for internal use and are not routed on the public Internet:

BlockCIDRTotal hostsCommon use
10.0.0.0 – 10.255.255.25510.0.0.0/816,777,214Large corporate networks, private cloud, datacenters
172.16.0.0 – 172.31.255.255172.16.0.0/121,048,574Mid-size networks, infrastructure segments
192.168.0.0 – 192.168.255.255192.168.0.0/1665,534Home networks, small offices

Additionally, the block 100.64.0.0/10 is reserved for CGNAT (Carrier-Grade NAT, RFC 6598), a technique used by ISPs to share public IPs across multiple customers. It’s important not to use this range in your own internal networks to avoid conflicts.

A brief history: from flat networks to CIDR

IP addressing hasn’t always worked this way:

1970s: IP networks were flat. They always assumed 8 bits for the network and 24 for the host. Only 256 networks were possible across the entire Internet.

1981 (RFC 791): Jon Postel introduces Classes A, B, and C. The mask was implicitly derived from the class. The problem: a mid-size organization needed a Class B (65,534 hosts) because Class C (254 hosts) was too small, wasting thousands of addresses.

1985 (RFC 950): Subnet masks are formalized, allowing networks to be divided into smaller subnets.

1993 (RFC 1519): CIDR (Classless Inter-Domain Routing) is born, eliminating the class concept and adopting VLSM. This is the system in use today and the one that allowed IPv4 to survive far longer than anyone expected.

An interesting historical note: in the early years, masks didn’t require contiguous bits. A mask like 255.255.192.128 was perfectly valid. The practice was abandoned in the early 1990s because it made efficient longest prefix match routing computationally impractical.

Subnet masks in IPv6

In IPv6, dotted decimal mask notation doesn’t exist. Only prefix notation, equivalent to CIDR, is used:

2001:0db8:85a3::1/64

The most common prefix is /64 for local networks (2^64 = 18.4 quintillion addresses per subnet—more than enough for any scenario). ISPs receive /32 or /48 blocks from regional registries (RIPE, ARIN, LACNIC, etc.).

In practice, subnet planning in IPv6 is simpler than in IPv4: the abundance of addresses eliminates the need for the fine-grained subnetting that makes mastering VLSM essential in IPv4.

Checking your subnet mask: quick commands

Linux (the mask appears in CIDR notation):

ip addr show
# Example output: inet 10.10.5.45/24 brd 10.10.5.255 scope global eth0

Windows:

ipconfig
# Look for: Subnet Mask . . . . . . . . . . . : 255.255.255.0

macOS:

ifconfig en0
# Look for: netmask 0xffffff00  (hex for 255.255.255.0)

On a Cisco switch or router:

show ip interface brief
show running-config interface Vlan10

Common configuration mistakes

These are the most frequent problems found in network audits—worth knowing so you can avoid them:

Inconsistent masks on the same VLAN. If one server has /24 and another has /25 on the same physical network, part of the range will be unreachable for one of them. This is a classic source of “it works sometimes” issues that are notoriously difficult to diagnose.

Overlapping subnets. When manually assigning blocks with VLSM without a clear plan, it’s easy for two subnets to overlap. The result: packets arriving at the wrong destination or ambiguous routes.

Defaulting to /24 when it’s not needed. A WAN link between two routers doesn’t need 254 addresses. A /30 or /31 is the right choice; using /24 wastes 252 IPs on every link.

Forgetting to subtract 2 when calculating hosts. The network address (all host bits set to 0) and the broadcast address (all set to 1) are not assignable. A /24 has 254 hosts, not 256. A /30 has 2, not 4.

Forgetting to update the gateway and DNS. When changing a mask, the default gateway and firewall rules must reflect the new scheme. Changing a mask without reviewing the gateway is a guaranteed outage.

Subnet masks in the context of private cloud

In private cloud and bare metal environments, subnet design is one of the first architectural decisions. The choice of masks directly affects scalability, traffic isolation, and operational complexity.

A typical datacenter infrastructure design uses separate VLANs with masks tailored to each function:

VLANFunctionTypical maskWhy
VLAN 10Production/24 or /23Enough room for servers and growth
VLAN 20Management/IPMI/27 or /28Few devices, critical isolation
VLAN 30Storage (iSCSI/NFS)/24Dedicated traffic, jumbo MTU, no gateway
VLAN 40Backup/24Separated from production traffic
VLAN 50DMZ/28 or /27Only exposed services, strict firewall
VLAN 100Router interconnections/31 per linkMaximum IP utilization

This type of design, combined with inter-VLAN firewall rules and thorough IP addressing documentation, is what separates a professional infrastructure from an improvised deployment.


At Stackscale, network management is designed so that each customer has properly sized and isolated segments, with network-level redundancy and connectivity to multiple carriers. If you’re planning a deployment that requires custom network design, our team can help you size the subnets, VLANs, and segmentation rules that best fit your use case.

Share it on Social Media!

Cookies customization
Stackscale, Grupo Aire logo

By allowing cookies, you voluntarily agree to the processing of your data. This also includes, for a limited period of time, your consent in accordance with the Article 49 (1) (a) GDPR in regard to the processing of data outside the EEA, for instead, in the USA. In these countries, despite the careful selection and obligation of service providers, the European high level of data protection cannot be guaranteed.

In case of the data being transferred to the USA, there is, for instance, the risk of USA authorities processing that data for control and supervision purposes without having effective legal resources available or without being able to enforce all the rights of the interested party. You can revoke your consent at any moment.

Necessary Cookies

Necessary cookies help make a web page usable by activating basic functions such as the page navigation and the access to secure areas in the web page. The web page will not be able to work properly without these cookies. We inform you about the possibility to set up your browser in order to block or alert about these cookies, however, it is possible that certain areas of the web page do not work. These cookies do not store any personal data.

- moove_gdpr_popup

 

Analytical cookies

Analytical cookies allow its Editor to track and analyze the websites’ users behavior. The information collected through this type of cookie is used for measuring the activity on websites, applications or platforms, as well as for building user navigation profiles for said websites, application or platform, in order to implement improvements based on the analysis of data on the usage of the service by users.

Google Analytics: It registers a single identification used to generate statistical data about how the visitor uses the website. The data generated by the cookie about the usage of this website is generally transferred to a Google server in the USA and stored there by Google LLC, 1600 Amphitheatre Parkway Mountain View, CA 94043, USA.

- _dc_gtm_UA-XXXXXXXX-X

- _gat_gtag_UA_XXXXXXXX_X

- _ga

- _gcl_au

- _gid