How to Figure Out a Subnet Mask from an IP Address
Understanding subnet masks is one of those networking fundamentals that sounds intimidating until you see how the logic actually works. Whether you're configuring a router, troubleshooting a connection, or studying for a networking cert, knowing how to determine a subnet mask from an IP address is a genuinely useful skill.
What a Subnet Mask Actually Does
A subnet mask is a 32-bit number that works alongside an IP address to define two things: which part of the address identifies the network, and which part identifies the host (a specific device on that network).
Think of an IP address like a postal address. The subnet mask acts like the rule that separates the city from the street address. Without it, a device has no way of knowing whether another IP is on the same local network or somewhere else on the internet.
Subnet masks are written in the same dotted-decimal format as IP addresses — for example, 255.255.255.0 — or in CIDR notation, which is a slash followed by a number, like /24.
The Relationship Between IP Address Classes and Default Subnet Masks 🌐
Historically, IP addresses were divided into classes, and each class had a default subnet mask. These defaults are still relevant when working with classful networks or older equipment.
| IP Address Class | First Octet Range | Default Subnet Mask | CIDR |
|---|---|---|---|
| Class A | 1 – 126 | 255.0.0.0 | /8 |
| Class B | 128 – 191 | 255.255.0.0 | /16 |
| Class C | 192 – 223 | 255.255.255.0 | /24 |
So if you have an IP address like 10.0.0.1, the first octet (10) falls in the Class A range, and the default subnet mask would be 255.0.0.0. For 192.168.1.50, the first octet (192) puts it in Class C, pointing to a default mask of 255.255.255.0.
Important caveat: These are defaults, not guarantees. Modern networks use classless inter-domain routing (CIDR), which means the actual subnet mask in use could differ from the class default. The IP address alone doesn't tell you the mask with certainty — you need to check the network configuration.
How to Find the Subnet Mask on Your Device
Rather than guessing, you can check the subnet mask currently assigned to your device directly.
On Windows: Open Command Prompt and run:
Look for Subnet Mask under your active network adapter. It will appear as something like 255.255.255.0.
On macOS or Linux: Open Terminal and run:
or on newer Linux systems:
Look for the netmask value next to your IP address, or the CIDR prefix attached directly to the IP (e.g., 192.168.1.50/24).
On a router admin page: Log into your router's interface (typically via 192.168.0.1 or 192.168.1.1) and check the LAN settings. The subnet mask is usually listed alongside the gateway IP.
Reading CIDR Notation to Determine the Mask
If you see an IP written as 192.168.1.50/24, the /24 is the prefix length — it tells you how many bits are used for the network portion. From that number, you can derive the subnet mask.
Here's how common prefix lengths map to subnet masks:
| CIDR Prefix | Subnet Mask | Usable Hosts |
|---|---|---|
| /8 | 255.0.0.0 | ~16.7 million |
| /16 | 255.255.0.0 | ~65,000 |
| /24 | 255.255.255.0 | 254 |
| /25 | 255.255.255.128 | 126 |
| /26 | 255.255.255.192 | 62 |
| /30 | 255.255.255.252 | 2 |
Each bit added to the prefix length halves the number of available host addresses and tightens the subnet.
Calculating a Subnet Mask Manually
If you want to work it out from a CIDR prefix: a /24 means 24 bits are set to 1 in the mask. In binary, that looks like:
Converting each octet from binary to decimal gives you 255.255.255.0. A /26 sets 26 bits to 1:
That converts to 255.255.255.192. 🔢
This binary-to-decimal conversion is the core mechanic behind all subnet mask calculation. Online subnet calculators automate this, but understanding the binary logic helps when you're diagnosing unexpected network behavior or manually setting up static IPs.
What Determines the Right Subnet Mask for a Network
The subnet mask used on any given network depends on several factors:
- Network size — how many devices need IP addresses on the same subnet
- Segmentation goals — whether the network is intentionally split into smaller subnets for security or traffic management
- Router and ISP configuration — your ISP assigns the mask for your WAN connection; your router sets it for your LAN
- Static vs. dynamic addressing — DHCP servers automatically hand out subnet masks; static setups require manual entry
- Enterprise vs. home use — home networks almost universally use /24 with a 255.255.255.0 mask; enterprise environments often use custom subnetting
A home network with a handful of devices has very different subnetting needs than a corporate network with hundreds of VLANs and segmented departments. The IP address gives you a starting point, but the appropriate mask depends on what the network is actually trying to accomplish.