Subnet Mask, what it is and what it is for

34

What is the subnet mask, and how the assignment of IP addresses within the network works? How to understand which network a system belongs to by looking at its IP, subnet mask, or netmask.

Among the commonly used parameters to configure a network or set access by the devices that connect to it, the subnet mask is that value whose meaning is ignored by most users.

Yet it appears everywhere: in the settings of the configuration panel of the router, a switch, an access point, and any system with a network interface (computer, tablet, smartphone, IP camera, Ethernet or WiFi printers, IP video surveillance systems, …).

Subnet Mask, what it is and what it is for

To detect the subnet mask used on a Windows system, just open the command prompt ( Windows + R, cmd ) then type ipconfig / all.

The subnet mask in use will be read in correspondence with the data relating to the Ethernet card or WiFi interface.

Similar information can be obtained (with the possibility of changing it) by pressing the combination of Windows + R keys and then typing ncpa.cpl .

By double-clicking on the name of the network interface, then on the Properties button, and, finally, on Internet Protocol version 4, you will access the data relating to the subnet mask, if manually set.

Subnet Mask, what it is and what it is for.

What is the subnet mask?

The subnet mask or netmask allows you to determine the range of IP addresses within a subnet. In the example in the figure, the subnet mask 255.255.255.0 is used: it means that the private IPs that can be used for the local network are, in this case, those included between 192.168.1.1 and 192.168.1.254.

The subnet mask allows you to derive the network to which a device belongs starting from its IP address (in the example, it is 192.168.1.2, a statically assigned private IP address). It allows you to establish which resources are to be considered local and which are remote.

As in the case of IPv4 addresses, the subnet mask is also made up of a sequence of 32 bits or 4 bytes: each of the four 8-bit groups is separated with a period.

Each group is said to have 8 bits because they can assume a numbering between 0 and 255 (2 8 possible values) or equivalent to one byte (1 byte = 8 bits).

By applying the logical AND operator to the IP address and its subnet mask or netmask, it is possible to calculate the network to which the IP belongs.

What is the subnet mask?

As you can see, by setting 192.168.1.2 as the IP address and 255.255.255.0 as the subnet mask, you can trivially find that the network to which the IP belongs is 192.168.1.0 (the IP addresses that can be used and assigned to the various devices are included between 192.168 .1.1 and 192.168.1.254).

However, keep in mind that it is impossible to trace the network simply by setting the last byte of the IP to 0. Everything depends on the structure of the subnet mask.

We always assume that the device we are dealing with has IP 192.168.1.2 but subnet mask 255.255.128.0.

In this case, the membership network would be 192.168.0.0, so the assignable IP addresses would even be 32.768 and not 256 as in the previous case.

The address space would be between 192.168.0.1 and 192.168.127.254.

What is the subnet mask

Most used subnet masks

Using the service mentioned above, you can try various combinations of subnet masks. Some are used only by large providers who need to use large IP addresses by assigning them statically or dynamically to customers’ networking devices.

For example, try typing nslookup www. google.it at the command prompt and note the IPv4 address associated with the Google domain name.

Most used subnet masks

Entering this public IP address on this page will result in the following:

Most used subnet masks.

The CIDR ( Classless Inter-Domain Routing ) notation indicates that in this case, 16 bits are used to express the subnet mask, so it is 255.255.0.0 :

Most used subnet masks..

This Google network, made up of public IPs therefore publicly reachable by any system connected to the Internet, is, in this case, made up of 65,536 IPs (2 16 ), and the usable addresses are between 172.217.0.0 and 172.217.255.255.

The subnet mask 255.255.255.255 is a bit particular because it represents the host itself (it is a “degenerate case” in which not a network is identified but the address of the same device).

The subnet mask 255.255.255.0 is called class C and offers a total of 254 addresses that can be assigned to the computers and networking devices of the network, as already seen above.

The subnet 255.255.0.0 is instead called class B. It has local addresses available for 256 classes C. Finally, the netmask 255.0.0.0 is also called class A and has local addresses available for 256 classes B.

Most used subnet masks?

The subnet mask 255.255.255.252 identifies the smallest usable network with just two addresses available for assignment: it is often used in point-to-point connections where one address is the IP of a host placed on the first side of the connection while the other is the IP address of the second and last host involved in the communication.

A third address is the broadcast address (always available in all networks), which allows information to be sent to all hosts on the same subnet rather than to a single recipient.