There are several components in network connections that can go unnoticed, but you need to be aware of them to prevent configuration errors from occurring. One such component is the netmask.
Its main function is to notify the router that messages have different addresses, enabling the network and host identifier to be recognized. In this article, we will simply explain what a netmask is, what it does, how subnets are calculated, and much more. Read on to better understand this subject!
What is the relationship between IP address, network address and host address?
Before we even talk about netmask, it is critical that you understand the differences between IP address, network address, and host address, as these three concepts are necessary for us to cover about netmask.
The IP address is one of the main internet protocols, being responsible for delivering data packets over the network and directing them according to addresses.
All computers with internet access have an IP address to be identified. They can be found in the computer's connection properties, have decimal format and are interpreted by the equipment as binary, and are also separated by four dots. Example of an IP address: 18.104.22.168.
Each part is called an octet, since in binary form it has eight numbers. All in all, we have 32 positions and that's why IP addresses are 32 bits long.
That said, the IPv4 address, which is the IP version 4 address, has two components: the network address and the host address. The first is in charge of identifying the entire network, so that all hosts on the network have the same bit sequence.
Meanwhile, the host address identifies the connection to a specific host, so each host has a unique address within the network. This means that every end device needs an address that is its own to communicate on the network.
What is the netmask?
The netmask is 32 bits, just like the IP address, and is intended to mask a part of the IP address. Thus, every IP address has a corresponding mask, serving to identify which part of the address is from the network and which is from the host.
There is also an addressing class for each netmask. See below:
- Addressing class A: 255.0.0.0
- Address class B: 255.255.0.0;
- Addressing class C: 255.255.255.0.
As an example, let's assume that the IP address 22.214.171.124 has a netmask that is 255.255.255.0 (class C). In this case, the part corresponding to the network is 191.171.0 and the part referring to the host is 50. That is:
- Network: 191.171.0;
- Host: 50.
So, in order to divide the network, it is possible to divide the mask, using values from 0 to 255. Thus, the subnet mask is created, which manages to notify the router that messages identified with sender and destination present a different address.
In this way, it is able to recognize both the network part and the host part, enabling, for example, the router to understand when packets must stay in the network and when they must be transmitted to another.
It is important to remember that subnetting is a process that aims to improve performance, security and organization by dividing a large IP address into several smaller networks.
Let's imagine the following situation: in a single building, the company has an HR, Finance and Sales area, in which each department has 30 hosts.
The network of all sectors started to slow down due to dense files being sent by one sector. After all, as a single network is used for all departments, if something happens to one, all the others will be affected.
In that case, we could think of assigning addresses to each sector, right? However, this practice would result in a waste of IP addresses.
Therefore, the ideal would be to divide the network into smaller parts, in which each one would be linked to a specific sector. So we're talking about creating subnets. Did you understand the importance of these components in network connections?
How to calculate subnet masks?
Remember our previous IP address and netmask example? Every three digits in the mask, we have a part of the host address, remembering that each part has eight bits, forming an octet.
Also, each bit has a value in decimal format to match its position. Another detail that you need to keep in mind is that, as it is a bit, there is only 0, which represents the host, and 1, which represents the network.
That said, in the example we gave of the class C subnet mask, which is 255.255.255.0, we have the binary representation 11111111.11111111.11111111.00000000, where the first three octets refer to the network and the last octet refers to the host:
- Mask: 255.255.255.0;
- Binary: 11111111.11111111.11111111.00000000.
In this way, all eight bits that have a value of 1 are represented by 255 in decimal form, while bits of value 0 are also 0 in decimal form.
In short, every subnet is a different network that needs to communicate with each other from a router.
In this topic, we use a class C subnet mask as an example, but the configuration works for all other addressing classes.
Also, another important piece of information is that instead of talking about the netmask in decimal form, we can also talk about just the amount of bits that exist in it.
Although it is a somewhat complex subject for non-experts, understanding what netmasks are and how they work is necessary so that you can avoid configuration errors. That's why anyone working with IT shouldn't ignore it.
In addition to knowing the netmask, why not delve into the gateway? Learn more about this tool in our article!
Junte-se à conversa.