Network Subnets: What Are Subnet Masks and How Do They Work?



If you've ever set up a network or heard about IP addresses, you've probably come across the concept of subnetting. But what exactly does it mean?

🔗 Do you like Techelopment? Check out the site for all the details!

What are Subnets?

Computer networks, such as the Internet or a corporate network, must be organized efficiently to best manage traffic between devices. Just as a city is divided into neighborhoods to make it easier to manage homes and streets, a network can be divided into subnets, which are smaller networks.

This division allows for:
✅ Optimize the use of available IP addresses.
✅ Improve network performance by reducing unnecessary traffic.
✅ Increase security by isolating groups of devices.

A key tool for creating subnets is the subnet mask, which helps determine which devices belong to the same network. In this article, we will explain in a simple way what subnets are and how to calculate the right subnet mask for your needs.


What is a Subnet Mask?

The subnet mask is like a filter that tells us which IP addresses belong to the same network.

Every device connected to a network has an IP address, which is made up of four numbers separated by dots, for example:

🔹 192.168.1.10

The subnet mask also follows this structure. The most common is:

🔹 255.255.255.0

This mask tells us that the first three numbers of the IP (192.168.1) identify the network, while the last number (.10) indicates the device within that network.

Now let's see how to calculate a custom mask based on the number of devices to be connected.


How to Calculate a Subnet Mask?

Now let's see how to choose the right mask for a network, without complications!

1️⃣ How many devices do we need to connect?

Suppose we want to connect 50 computers.

Each subnet must have enough IP addresses available for all devices. But how many addresses do you need exactly?

There is a simple formula to know how many addresses we can have in a subnet:

2n2

Where n is the number of bits reserved for hosts (i.e. devices), and -2 is used to exclude two special addresses (one to identify the network and one for broadcast).

Now let's find a number of bits that gives us at least 50 available addresses:

🔹 If n = 6, we get:

262=62 available addresses

So to have at least 50 addresses available, we need to use 6 bits for hosts.


2️⃣ Convert to Subnet Mask

We have seen that an IP address is written in this form:

🔹 192.168.1.10

But in reality, an IP address is made up of 32 bits (i.e. a sequence of 0s and 1s). Each number between the dots is actually a group of 8 bits.

For example, the address 192.168.1.10 in binary is:

11000000.10101000.00000001.00001010

Each group of numbers is a block of 8 bits. The same goes for the subnet mask.

We calculated that 6 bits are needed for the devices, so the remaining:

326=26 bits for the network

This means that our subnet will be /26 (CIDR notation, which indicates how many bits are reserved for the network), which corresponds to the mask:

🔹 255.255.255.192

But why 192?

When we write the mask /26 in binary, we get:

11111111.11111111.11111111.11000000

The first 26 bits are all 1 (indicate the network).
The last 6 bits are 0 (indicate the addresses available for the devices).

Let's convert each group into a decimal number:

🔹 255.255.255.192

So, the mask for this subnet is 255.255.255.192.


Practical Example

If we have the network 192.168.1.0/26, the available IP addresses will be:
✅ Da 192.168.1.1 a 192.168.1.62 (for devices)
🚫 192.168.1.0 → Network address
🚫 192.168.1.63 → Broadcast address

So, in the example in the article, the calculated subnet is 192.168.1.0/26, which means that:

  • All IPs from 192.168.1.1 to 192.168.1.62 belong to the same network.
  • The address 192.168.1.0 identifies the network.
  • The address 192.168.1.63 is used for broadcast, that is, to send messages to all devices in the subnet.

What we have learned

Subnets are like neighborhoods in a city: they divide a large network into smaller parts to better manage devices.

The subnet mask is the "border" that separates networks from each other.

To calculate it, remember these steps:

1️⃣ We use the formula 2ⁿ - 2 to find the number of available addresses.
2️⃣ The value n found represents the bits reserved for hosts.
3️⃣ We subtract n from 32 to find out how many bits are left for the network.
4️⃣ We convert the obtained value into the subnet mask.

Classless Inter-Domain Routing (CIDR) notation is a compact way to write the subnet, specifying how many bits are reserved for the network. For example, /26 means that the first 26 bits are dedicated to the network and the remaining 6 bits to the hosts.

Now you have all the tools to calculate and understand subnets!



Follow me #techelopment

Official site: www.techelopment.it
facebook: Techelopment
instagram: @techelopment
X: techelopment
Bluesky: @techelopment
telegram: @techelopment_channel
whatsapp: Techelopment
youtube: @techelopment