What Is a Subnet Mask? A Beginner's Guide
Learn what a subnet mask is, why it matters, what numbers like /24 mean and how to calculate usable IP addresses for Network+.

On this page 10 sections ▾
TL;DR
- A subnet mask tells a device which part of its IP address identifies its network and which part identifies its own connection.
- A subnet mask of 255.255.255.0 leaves room for 254 usable IP addresses on a typical network.
- An incorrect subnet mask can prevent a device from reaching other networks even when its IP address is valid.
When a computer joins an IP (Internet Protocol) network, it needs an IP address to identify its connection. IPv4, or Internet Protocol version 4, uses addresses written as four numbers separated by dots, such as 192.168.10.70. Alongside that address, the computer needs a subnet mask, a separate value such as 255.255.255.0 that tells it which part of the address identifies the network and which part identifies the individual connection. A subnet is a group of IP addresses that share the same network portion.
#What does a subnet mask do?
Imagine your laptop has an IP address of 192.168.10.70 and your printer has an address of 192.168.10.90. Both use the subnet mask 255.255.255.0. This mask tells them to treat the first three numbers (192.168.10) as the network portion. This beginning part of an address is called the network prefix. The last number is called the host portion and distinguishes the laptop from the printer on that network.
ELI5: explain it simply▾

THE WORDS
- Subnet mask
- A separate value that shows where the network part of an IP address ends.
- Network prefix
- The beginning of the address that identifies the network.
- Host portion
- The remaining part that identifies a connection within that network.
THE IDEA
Think of a street name and a house number. Houses on the same street have the same street name but different house numbers. The subnet mask tells your computer how much of the address is the street name and how much is the house number.
When the laptop wants to print, it looks at its routing table, a list of instructions for sending data to different destinations. Because both devices belong to the same subnet on a typical Ethernet or Wi-Fi network, the laptop can send data directly to the printer. To reach other networks, it usually sends data to its default gateway, the router used when no more specific route applies.
#How to read a subnet mask
Computers work with binary, a system that represents numbers using only 0s and 1s. Each 0 or 1 is a bit. An IPv4 address contains 32 bits, arranged in four groups of eight called octets. We normally write each group as a number from 0 to 255, separated by dots. A subnet mask follows a pattern in binary: a series of 1s marking the network part of the IP address, followed by 0s marking the host part.
The number 255 is 11111111 in binary, while 0 is 00000000. That's why 255.255.255.0 marks the first three octets as the network portion and the last as the host portion. It is called a mask because it selects which bits of the IP address identify the network. A mask can also divide an octet partway through, rather than only at the dots.
ELI5: explain it simply▾

THE WORDS
- Bit
- One binary digit, either 0 or 1.
- Octet
- A group of eight bits, shown as one number in an IPv4 address.
THE IDEA
Imagine placing a stencil over the 32 bits of an IP address. The 1s in the subnet mask reveal the bits that name the network. The 0s cover the remaining bits, which distinguish connections on that network.
#What is CIDR notation?
Instead of writing an IP address and subnet mask separately, network administrators often write them together when configuring servers, routers and cloud networks, such as 192.168.10.70/24. This shorthand is called CIDR notation (Classless Inter-Domain Routing). The number after the slash is the prefix length: the number of bits at the beginning of the IP address that identify the network. A subnet mask of 255.255.255.0 is equivalent to /24 because its first 24 bits are 1s.
Now consider the mask 255.255.255.192. The first three octets contain 24 ones, and the final octet, 192, is 11000000 in binary. That adds two more network bits, giving you a /26 prefix. The remaining six zeros represent the host bits.
A larger prefix length means fewer bits remain for host addresses, so the subnet is smaller.
#How to calculate usable host addresses
Not every IP address in a regular subnet can be assigned to a device. Two addresses are reserved for special purposes: the first identifies the subnet itself and the last is used to send messages to all devices on it. Here is what those addresses are called:
- Network addressThe address in which all host bits are 0. It identifies the subnet, rather than an individual device.
- Broadcast addressThe address in which all host bits are 1. It is used to address every host on that IPv4 subnet.
- Usable host addressesThe addresses between the network and broadcast addresses that can be assigned to devices' network connections.
To calculate a subnet's size, subtract the prefix length from the 32 bits in an IPv4 address. For a /27, that leaves 5 host bits (32 minus 27). Each bit has two possible values, so 2 to the power of 5 gives 32 total addresses. Subtract 2 for the network and broadcast addresses, leaving 30 usable addresses.
ELI5: explain it simply▾

THE WORDS
- Network address
- The first address, which names the entire subnet.
- Broadcast address
- The last address, used to send data to the entire subnet.
- Usable address
- An address that can be assigned to a device's network connection.
THE IDEA
Imagine a row of 32 numbered lockers. Two are reserved for special purposes, so only 30 are available for people to use. A normal IPv4 subnet reserves its first and last addresses in much the same way.
For your information
There are exceptions to the subtract-2 rule. A /31 can use both addresses on a point-to-point link, a direct connection between two devices. A /32 identifies a single address. Don't apply the formula to these two prefixes.
#Subnet mask reference table
Use this table to look up common IPv4 subnet masks and their usable host counts without performing the calculation each time.
| ● Subnet mask | ● Usable hosts | |
|---|---|---|
| /16 | 255.255.0.0 | 65,534 |
| /23 | 255.255.254.0 | 510 |
| /24 | 255.255.255.0 | 254 |
| /25 | 255.255.255.128 | 126 |
| /26 | 255.255.255.192 | 62 |
| /27 | 255.255.255.224 | 30 |
| /28 | 255.255.255.240 | 14 |
| /29 | 255.255.255.248 | 6 |
| /30 | 255.255.255.252 | 2 |
These counts include addresses needed by routers and other network equipment. Dynamic Host Configuration Protocol (DHCP) automatically assigns network settings to devices, but its pool of assignable addresses may be smaller than the subnet's usable range because administrators can reserve or exclude addresses.
Get opnF in your inbox
Tech news for IT professionals that actually teaches you something.
Our promise to you: we'll be conscious about email quality/frequency, and your address will never be shared/sold.
#How does subnetting work?
Subnetting means dividing a larger IP network into smaller networks. Suppose a small company has the address block 192.168.10.0/24 and wants separate networks for office computers, phones, servers and guests. It could divide the existing block into four equal /26 subnets.
If the company assigns each subnet to its own virtual local area network (VLAN), a logically separate local network, traffic between them must pass through a router or another routing device. Firewall rules or access control lists can restrict which networks communicate. You can use the same design at home to keep guests from accessing your file server if your equipment supports it. A subnet mask alone does not provide security isolation.
#Subnetting practice: find the network address
Let's return to the laptop from earlier. Its IP address is still 192.168.10.70, but this time the company has configured it with a /26 prefix. You need to work out the subnet it belongs to, the broadcast address and its usable host range. Here's a shortcut that avoids converting the entire IP address to binary.
- Find the block sizeA /26 leaves six host bits, giving 2 to the power of 6, or 64 addresses per subnet. You can also find this block size using its mask, 255.255.255.192. The fourth octet has 256 possible values (0 through 255), and subtracting its mask value of 192 from 256 leaves 64. This works because the remaining six bits can represent 64 different values.
- Find the subnetThe address blocks begin at 0, 64, 128 and 192 in the final octet. Because 70 is between 64 and 127, the network address is 192.168.10.64.
- Identify the broadcast addressThe last address before the next block begins is 192.168.10.127.
- Find the usable rangeExclude those two endpoints. Assignable addresses range from 192.168.10.65 to 192.168.10.126.
If the printer still has the address 192.168.10.90 and uses the same /26 mask, it remains within the laptop's subnet. A server with address 192.168.10.140/26 is in the next subnet, even though the first three octets match. This is why you cannot determine whether two IPv4 addresses are on the same subnet by looking at their numbers alone.
You can use the same shortcut for other subnet sizes. When the mask divides an octet into network and host bits, use that octet for the calculation. For a /20 mask (255.255.240.0), subtract 240 from 256 to get an increment of 16 in the third octet. Within the 192.168.0.0/16 network, for example, the first /20 subnet spans 192.168.0.0 to 192.168.15.255, and the next spans 192.168.16.0 to 192.168.31.255. The fourth octet ranges from 0 to 255 within each third-octet value.
For more subnetting practice, try our free Subnet Match game. You'll match CIDR prefixes to subnet masks and host counts, then work out network and broadcast addresses yourself. It's designed to help you build the recall you'll need for Network+ without relying on a subnet calculator.
#How to find your subnet mask
On Windows, open Command Prompt or PowerShell and enter ipconfig. Look for Subnet Mask under your active Ethernet or Wi-Fi adapter. The command also displays the IPv4 address and default gateway without changing your settings.
On Linux, open a terminal and enter ip -4 addr show. Find the line beginning with inet under your active network interface. Linux displays the IPv4 address with its prefix length, so an address ending in /24 corresponds to a mask of 255.255.255.0.
On a Mac, open System Settings, select Network, choose your active connection and select Details, then TCP/IP. In addition to the mask, you can find your IPv4 address and router settings there.
#What happens if you use the wrong subnet mask?
A mask that doesn't match the network can cause unusual connectivity problems. Consider the company we divided into /26 subnets. If its laptop was accidentally configured with a /24 mask, its routing table would normally treat the server in the next subnet as directly reachable. Rather than sending traffic to the gateway, the laptop would try to find the server on its own local network. That can fail even if both devices have valid IP addresses.
When troubleshooting, compare the device's address, subnet mask and default gateway against the intended network configuration. Don't simply copy a mask from another device, since that device might belong to a different VLAN or subnet. If a host uses DHCP, check whether the DHCP configuration for its network is supplying the correct settings.
In our Active Directory setup guide, a Windows computer and a domain controller, the server that manages user accounts and sign-ins, share an isolated virtual network and a /24 subnet. If the computer has the wrong subnet mask and treats the server as being on another network, it may be unable to join the domain because the lab has no router.
#Frequently asked questions
What subnet mask should I use for my home network?
Can my subnet mask be 255.255.255.255?
Does changing the subnet mask increase internet speed?
Can I subnet a network into different-sized blocks?
Does IPv6 use subnet masks?
SourcesCisco: IPv4 addressing and subnettingMicrosoft: TCP/IP addressing and subnettingIETF: Classless addressing (RFC 4632)IETF: Point-to-point links (RFC 3021)IETF: IPv6 addressing (RFC 4291)Cisco: Routing and access between VLANsApple: TCP/IP settingsMicrosoft: ipconfigLinux: ip address manualopnF.sh: Subnet Match
Get opnF in your inbox
Tech news for IT professionals that actually teaches you something.
Our promise to you: we'll be conscious about email quality/frequency, and your address will never be shared/sold.