What is a Subnet Mask?


Answering the question: What is a Subnet Mask?

When working with Ethernet Addressing, you might be asking, What is a Subnet Mask? Simply put, the subnet mask, or net mask separates the network portion of the address from the device on the network. We also consider a device to be a host. Each host on the network must have a unique IP address on the network. In this post, we’ll discuss the subnet mask in IP Version 4 (IPv4).

How to find your Subnet Mask

An easy way to find your net mask is with the “ipconfig” command. We enter this into the command prompt. To open the command prompt, simply, type “cmd” into your search box in Windows 10. If you are on a Linux or Unix system, use the command, “ifconfig”.

Here is an example in Windows:

Likewise, here you will see an example in Debian / Linux.

How the Subnet Mask works

We consider each section of a net mask to be an “Octet”. As you can see, four “Octets” make up an IP address. Basically, wherever we have a 255 in the net mask, the value of that octet must be the same on the devices we wish to communicate. This applies to a local area network. For the most part, this applies to the devices within your house or office area. When you go through a router to other networks, you can access other subnets. This depends on the configuration of the router.

Basic Example of devices which will communicate:

For example, we have two devices. The first device has the IP address of 10.1.1.4. The second device has an IP address of 10.1.1.5. Our subnet mask on both devices is 255.255.255.0. In this case, both devices will communicate with each other directly. Because the first 3 octets of the subnet mask are 255, this means the first 3 octets of both IP addresses much match. We would say the “Network Address” of both devices is 10.1.1. The first device is host #4 on the network. Likewise, the second devices is host #5 on the network.

Example of devices which will NOT communicate:

On the other hand, we have two devices: The first device has an IP address of 10.1.1.4, and the second device has an address of 10.1.2.5. Once again, both devices have the subnet mask of 255.255.255.0. In this case, the devices will not communicate directly. They are in different subnets. The first device is is network 10.1.1. The second devices is in network 10.1.2.

Example of a different Subnet Mask:

Let’s look at the above example. First device has an IP address of 10.1.1.4, and the second devices is 10.1.2.5. However, this time, both devices use the net mask of 255.255.0.0. In this case both devices will communicate with each other. The net mask tells us that only the first two octets much match. As you can see, both devices are in network 10.1. Obviously, the devices will communicate directly without a router.

Why 255?

Remember, each octet is an 8 bit number. When we break 255 down into binary, we see that all 8 bits are high. Wherever there is a 1 in the net mask, the same bit in both devices must match. At this point, let’s break the first octet down into binary.

0000 1010 . 1 . 1 . 4 First Device (with first octet in Binary)

1111 1111 . 255. 255 . 0 Subnet Mask (with first octet in Binary)

0000 1010 . 1 . 1 . 5 Second Device (with first octet in Binary)

Look at the first octet only. As you can see, the subnet mask for the first octet is all 1’s. It’s important to realize that all bits in the first device must match all bits in the second device. Obviously, if all of the bits must match, then both devices need to have the same bit pattern. This means the entire digit must have the same value in the first device and second device. In this case, both devices will communicate with each other.

What if I have a 254 in the Third octet of the subnet mask?

Now that you understand how the subnet mask works, you can simply break all of your addresses down into binary. This allows you to determine if they will communicate. Basically, with a mask of 255.255.254.0, the third octet includes odd and even numbers as part of the same subnet. For example: 10.1.2.5, and 10.1.3.6 are in the same subnet. The third octet can be 0 or 1… 2 or 3… 4 or 5, etc.

Summary

What is a Subnet Mask? In short, it’s just a way for your network administrator to divide your network into different “subnets”. We might have sales on network 192.168.1. On the other hand, we might have marketing on network 192.168.2. Engineering might be on network 192.168.3. It’s important to realize, that to communicate with a device on the network, you must be sure your IP address is in the same subnet as the target IP address.

For other information on Industrial our Home automation, visit the Main Site!

— Ricky Bryce

Leave a comment

Your email address will not be published. Required fields are marked *