A subnet mask is not hidden in the IP address itself
You cannot figure out a subnet mask just by looking at an IP address. The IP address and subnet mask are separate pieces of information — knowing one does not tell you the other. A single IP address like 192.168.1.50 could belong to a network with a /24 subnet mask (255.255.255.0), a /25 subnet mask (255.255.255.128), or dozens of other possibilities. The subnet mask is assigned separately, either by a DHCP server when you connect to a network, or manually if you are setting up a static IP.
What you can do is recognize the class an IP address belongs to based on its first octet (the first number), which gives you a default subnet mask that was historically used. However, modern networks almost never use these defaults anymore. Understanding the relationship between IP addresses and subnet masks requires knowing where the information actually comes from on your network.
Key Takeaways
- The subnet mask is not derived from the IP address — it is assigned separately by your network or DHCP server.
- You can find your current subnet mask by checking your network settings on Windows, macOS, or Linux, or by running the ipconfig or ifconfig command.
- Historical IP classes (A, B, C) had default subnet masks, but modern networks use CIDR notation and custom masks instead.
- If you need to calculate subnets, you work with the mask you already have, not the other way around.
Finding the subnet mask your device is actually using
The fastest way to find out what subnet mask is assigned to your device right now is to check your network settings. On Windows, open Settings, go to Network & Internet, then Status. Click "View your network properties" and look for the "IPv4 subnet mask" field. Alternatively, open Command Prompt and type ipconfig — the subnet mask appears next to "Subnet Mask" for each network adapter.
On macOS, open System Settings, click Network, select your active connection, then click Details. The subnet mask is listed as "Subnet Mask" in the TCP/IP tab. On Linux, open a terminal and type ifconfig or ip addr show. The subnet mask appears as "Netmask" in the output, sometimes shown in CIDR notation (like /24) instead of dotted decimal (like 255.255.255.0).
If you are troubleshooting a network problem or setting up a static IP, you need the subnet mask that is actually in use on that network. Your device received it from the DHCP server, or it was manually entered during setup. The IP address alone cannot tell you what it is.
What historical IP classes tell you (and why they do not matter anymore)
Before the 1990s, IP addresses were divided into classes based on their first octet. A Class A address (1–126) had a default subnet mask of 255.0.0.0. A Class B address (128–191) had a default of 255.255.0.0. A Class C address (192–223) had a default of 255.255.255.0. If you see an IP address like 10.0.0.5, you might guess it is Class A and assume the subnet mask is 255.0.0.0.
This approach is almost never correct in practice. Modern networks use CIDR notation (Classless Inter-Domain Routing), which allows any subnet mask to be paired with any IP address. A Class C address like 192.168.1.50 might have a /25 subnet mask (255.255.255.128) instead of the historical /24 default. A Class A address like 10.0.0.5 might have a /16 mask (255.255.0.0) or a /8 mask (255.0.0.0), depending on how the network was designed.
Knowing the historical class is useful only for understanding old documentation or legacy systems. For any real network you are working with, you need to look up the actual subnet mask in your device settings or ask your network administrator.
Understanding what a subnet mask actually does
A subnet mask tells your device which part of an IP address refers to the network and which part refers to the individual host (your device). In the mask 255.255.255.0, the three 255s mean "these octets are the network part" and the 0 means "this octet is the host part." For the IP 192.168.1.50 with that mask, 192.168.1 is the network address and 50 is the host address on that network.
The mask is written in binary under the hood. 255 in decimal is 11111111 in binary, and 0 is 00000000. When your device needs to send data to another IP address, it uses the subnet mask to figure out whether that address is on the same local network or somewhere else. If it is on the same network, the device sends the data directly. If it is on a different network, the device sends it to the gateway (usually your router).
This is why you cannot work backwards from the IP address to the mask. The mask is a separate rule that the network administrator (or DHCP server) decides. Two devices with the same IP address could theoretically have different subnet masks if they were on different networks, though this would be a configuration error.
CIDR notation as a shorthand for subnet masks
Modern networks often express subnet masks using CIDR notation instead of writing out all four octets. The notation looks like 192.168.1.0/24, where the /24 means "the first 24 bits of the IP address are the network part." Since each octet is 8 bits, /24 equals three full octets, which is the same as the mask 255.255.255.0.
A /25 mask means the first 25 bits are the network part, so the mask is 255.255.255.128. A /16 mask means the first 16 bits are the network part, so the mask is 255.255.0.0. CIDR notation is shorter to write and easier to read, especially when you are working with unusual subnet sizes. If you see a network described as 10.0.0.0/8, you know immediately that the subnet mask is 255.0.0.0.
When you see CIDR notation in your network settings or documentation, you can convert it to a traditional subnet mask if you need to. The number after the slash tells you how many bits are "on" (set to 1) in the mask. Everything after that is "off" (set to 0). Online CIDR calculators can do this conversion for you if you need it, but most modern tools accept CIDR notation directly.
Why you might need to know the subnet mask
You need the subnet mask when you are setting up a static IP address on a device instead of letting DHCP assign one automatically. When you manually configure a network connection, you enter the IP address, the subnet mask, the gateway address, and usually a DNS server. Your device uses the subnet mask to determine which other devices are on the same local network.
You also need it if you are troubleshooting network connectivity. If two devices cannot communicate and you suspect a network configuration problem, checking that they have the correct subnet mask is one of the first steps. A device with the wrong mask might think another device is on a different network and try to route traffic through the gateway instead of sending it directly.
Network administrators use subnet masks to divide large networks into smaller segments, control traffic flow, and organize devices by function or location. If you are designing a network or documenting one, you need to know what mask is in use so that you can calculate how many devices fit on each subnet and plan for growth.
Common subnet masks and what they mean
| Subnet Mask | CIDR Notation | Number of Usable Hosts | Common Use |
|---|---|---|---|
| 255.255.255.0 | /24 | 254 | Small office or home network |
| 255.255.255.128 | /25 | 126 | Dividing a /24 network in half |
| 255.255.255.192 | /26 | 62 | Dividing a /24 network into quarters |
| 255.255.0.0 | /16 | 65,534 | Medium to large organization |
| 255.0.0.0 | /8 | 16,777,214 | Very large organization or ISP |
The most common subnet mask in home and small office networks is 255.255.255.0 (/24). This mask allows for 254 usable host addresses on a single network (the first and last addresses are reserved for the network and broadcast addresses). If you see a network using 255.255.255.128 (/25), it means someone has split a /24 network into two smaller subnets, each with 126 usable addresses.
Frequently Asked Questions
Can I tell the subnet mask just by looking at an IP address?
No. The IP address and subnet mask are independent pieces of information. You can make an educated guess based on historical IP classes, but modern networks do not follow those rules. You must check your network settings or ask your network administrator for the actual subnet mask.
What if my device shows the subnet mask in CIDR notation instead of dotted decimal?
CIDR notation like /24 and dotted decimal like 255.255.255.0 mean the same thing. The number after the slash tells you how many bits are part of the network address. You can convert between them using an online CIDR calculator, or just remember that /24 = 255.255.255.0, /16 = 255.255.0.0, and /8 = 255.0.0.0.
Why does my device have a different subnet mask than another device on the same network?
This usually means one device is misconfigured. All devices on the same local network should have the same subnet mask. If they do not, they may not be able to communicate directly and will try to route traffic through the gateway instead, which is slower and can cause connection problems.
Do I need to change the subnet mask if I change my IP address?
Not usually. If you are getting a new IP address from DHCP, the server will send you the correct subnet mask automatically. If you are setting a static IP, you need to use the same subnet mask that DHCP would have given you, or the one your network administrator specifies.
What happens if I use the wrong subnet mask?
Your device will not be able to communicate correctly with other devices on the network. It might think devices are on a different network and try to send traffic through the gateway. This causes slow connections, dropped packets, and devices that appear to be offline even though they are actually reachable.