What a subnet mask does, and why you need to know yours

A subnet mask is a set of four numbers (like 255.255.255.0) that tells your device which part of an IP address belongs to your local network and which part identifies individual devices on that network. When you have an IP address but not the mask, you can figure out the mask by understanding what class the IP address falls into — or by checking what your router is actually using.

The reason this matters: your device uses the subnet mask to decide whether another device is on the same local network or somewhere else on the internet. If the mask is wrong, your computer might try to send data to a device on the wrong path, or fail to reach devices that are actually nearby. Most home networks use 255.255.255.0, but some use different masks, and knowing which one you have prevents connection problems.

Key Takeaways

  • IP addresses are divided into five classes (A through E), and each class has a default subnet mask based on how many devices the network is designed to hold.
  • The first number in an IP address tells you the class: 1–126 is Class A, 128–191 is Class B, and 192–223 is Class C.
  • Most home and small office networks use Class C addresses with the mask 255.255.255.0, which allows up to 254 devices on one network.
  • The fastest way to find your actual subnet mask is to check your router's settings or run a command on your device rather than calculating it by hand.

The five IP address classes and their default masks

IP addresses are sorted into classes based on their first number. Each class has a default subnet mask — the mask that was originally assigned to that class when the internet was designed. Knowing the class tells you the default mask immediately.

Class A addresses start with 1 to 126. The default mask is 255.0.0.0. This class is designed for very large networks with millions of devices. Only a handful of organizations (like major internet providers) use Class A addresses.

Class B addresses start with 128 to 191. The default mask is 255.255.0.0. These networks can hold about 65,000 devices and are used by large companies and universities.

Class C addresses start with 192 to 223. The default mask is 255.255.255.0. These networks hold up to 254 devices and are the standard for home networks, small offices, and most business locations.

Class D (224 to 239) and Class E (240 to 255) are reserved for special uses and are not assigned to regular networks.

How to identify the class from your IP address

Look at the first number in your IP address — the one before the first dot. That number alone tells you the class and therefore the default mask.

If your IP address is 192.168.1.50, the first number is 192. That falls in the range 192–223, which is Class C. The default mask for Class C is 255.255.255.0.

If your IP address is 172.16.0.5, the first number is 172. That falls in the range 128–191, which is Class B. The default mask for Class B is 255.255.0.0.

This method works for any IP address you encounter, but remember: this gives you the default mask for that class. Some networks use a different mask than the default, so checking your actual device or router is more reliable if you need to be certain.

Finding your actual subnet mask on Windows

The default mask for your IP address class is a good starting point, but your network might use a different one. To see what mask your device is actually using, open the Command Prompt and type ipconfig, then press Enter.

Look for the section labeled "Ethernet adapter" or "Wireless LAN adapter" (depending on how you connect). You will see your IP Address listed, and directly below it you will see "Subnet Mask" with four numbers. That is the mask your device is currently using.

If you are on Windows 11 or later, you can also go to Settings > Network & Internet > Advanced Network Settings, find your connection, and click "Edit" to see the subnet mask listed there.

Finding your actual subnet mask on Mac or Linux

On a Mac, open Terminal (found in Applications > Utilities) and type ifconfig, then press Enter. Look for your active connection — usually "en0" for Ethernet or "en1" for Wi-Fi. The line labeled "netmask" shows your subnet mask in hexadecimal format (0xffffff00 means 255.255.255.0).

On Linux, open a terminal and type the same command: ifconfig. The "Mask" line shows your subnet mask in the same format as Windows.

Both commands show you what your device is actually using right now, which is more reliable than calculating from the IP address class alone.

Understanding the four numbers in a subnet mask

A subnet mask has four numbers separated by dots, just like an IP address. Each number ranges from 0 to 255. The mask works by using 255 to mark "this part belongs to the network" and 0 to mark "this part identifies individual devices."

In the mask 255.255.255.0, the first three numbers are 255 (network), and the last number is 0 (devices). This means the first three numbers of your IP address identify the network, and the last number identifies your specific device on that network.

In the mask 255.255.0.0, the first two numbers are 255 (network), and the last two are 0 (devices). This means the first two numbers of your IP address identify the network, and the last two numbers identify your device.

The reason this matters: if two devices have the same network part (the part marked by 255), they are on the same local network and can reach each other directly. If the network parts are different, they are on different networks and data has to go through a router.

When you might need to use a non-default mask

Most home networks and small offices use the default mask for their IP class and never need to think about this. But some networks divide their address space differently using CIDR notation — a shorthand that looks like 192.168.1.0/24.

The number after the slash (24 in this example) tells you how many bits of the address are reserved for the network. 24 bits equals 255.255.255.0. A /16 mask equals 255.255.0.0. A /8 mask equals 255.0.0.0. If you see CIDR notation in your router settings or network documentation, you can convert it to a regular mask using this pattern.

You do not need to calculate these by hand. Your router assigns the mask automatically, and you can always check what it is using the commands listed above. The only time you would manually set a subnet mask is if you are configuring a network device from scratch, and in that case your network administrator or router manual will tell you which mask to use.

Frequently Asked Questions

What is the difference between a subnet mask and an IP address?

An IP address identifies a single device on a network (like 192.168.1.50). A subnet mask tells your device which part of that IP address identifies the network and which part identifies the device. The mask is the same for all devices on the same local network.

Can I use a different subnet mask than the default for my IP class?

Yes. Networks often use non-default masks to divide their address space differently. Your router assigns the mask to your device automatically, so you do not have to choose. If you are setting up a device manually, your network administrator will tell you which mask to use.

Why does my device show a different subnet mask than the default for my IP class?

Your network administrator or router may have configured a non-default mask. This is common in larger networks that need to divide their address space in a specific way. The mask your device is actually using (shown by ipconfig or ifconfig) is the correct one for your network.

What happens if I use the wrong subnet mask?

Your device will not be able to reach other devices on your local network correctly. It might try to send data through a router when it should send it directly, or fail to reach devices that are actually nearby. Always use the mask your router assigns, which you can verify with ipconfig or ifconfig.