What is a subnet mask? IP address and subnet mask

As you know, every computer, no matter in which network it is located, has a certain digital address called an IP address. Naturally, this rule is relevant only for networks based on the TCP / IP protocol, however, today almost any network is based on it. One way or another, in addition to this address, the network workstation has several more parameters that affect its interaction with other devices. First of all, one of them is the network mask, which we will talk about in this article.

tcp ip

Subnet mask, gateway and address ...

If you try to get information about the current connection, in addition to the IP address allocated to your computer, you will also see fields such as a subnet mask, a default gateway, and one or more DNS servers, or rather, their addresses. For an uninitiated person, all this data is just a pile of numbers, but if you plan to configure computer networks based on the TCP / IP protocol, you should know a little more about these indicators.

A few words about IP addresses

Before diving into the wilds and explaining what a subnet mask is, you should remember what an IP address is: what the numbers in it mean and what values ​​they can take. We will mention one point in advance: all the information in this article will be about IPv4, since it is still the most popular one today.

subnet mask table
So, the IP address consists of four digits, each of which can take a value from zero to 255. You should not be a professor of mathematics to calculate: there can be a little more than four billion combinations. Any device on a TCP / IP network has a similar address, regardless of what functions it performs - whether it is a network printer, router, ADSL router or smartphone, the device will only connect to the network when it has a unique sequence of all the same four digits.

About local addresses

ip address and subnet mask
If you have several computers at home, then you probably noticed that all their addresses have much in common - most often their difference is only in the last digit, for example, if one of your computers has the address 192.168.1.10, then the second one may be 192.168.1.9. Such a situation is quite natural for home networks, because these addresses are internal. They are used to transfer data within your home network, for example between computers. And what happens when you need to get information from the Internet?

Gateway

ip subnet mask
Before you begin to answer the question of what a subnet mask is, you need to deal with another component of the network - the gateway. As you know, in order for your home computer to access the World Wide Web, it needs a gateway - as a rule, its role is played either by a router or a modem, or (if the conversation is not about home, but about work) server. When you request a web page, your computer will know if the server you are looking for is on your home network. If it is there (for example, if you keep the site on one of your computers), then, in fact, nothing special happens - the computers establish a connection through the local network and begin data transfer. However, if you try to open a site located on a remote server, the gateway comes into play.

What is a subnet mask for?

So, we are close to the question of what a subnet mask is. In fact, this is a brief reference about which computers are on the same network as yours and which require a gateway to connect. A mask is a pattern applied by a computer to the IP address with which it wants to connect. If the template “lies flat”, then everything is fine, but if not, the request is sent to the device registered in the network settings as the default gateway.

What does a subnet mask look like?

If you are an average user of a home network consisting of several computers that has a gateway to the Internet, then your subnet mask most likely looks like this: 255.255.255.0. These numbers are the so-called 24 subnet mask, which indicates that if the first three digits in the computer's IP address match your address, then it is available directly.

what is a subnet mask
By the way, the example with 255.255.255.0 is relevant only if you are dealing with simple and familiar operating systems, such as Windows. Linux-based systems, including the notorious and ubiquitous Android, use a slightly different approach in which a subnet mask is specified by a one or two digit number. In the above example, a similar number is 24.

Can I recognize the subnet mask?

Despite the fact that this question makes little sense, users do not stop asking search engines. It is almost impossible to determine the subnet mask by IP, since, based on the IP address alone, it is impossible to say exactly what scale a local or distributed network has. Partly in such cases, information about the gateway can help, for example, if your computer has the address 192.168.1.2, and the gateway has the address 192.168.0.1, then the subnet mask should be at least 255.255.0.0, otherwise the gateway will be unreachable.

define subnet mask by ip
In general, the IP address and subnet mask are almost completely unrelated, or rather, one cannot figure out one on the basis of the other. On a network, a computer must operate with both parameters in order to create successful connections with a device.

About the price of errors

And what can happen if you make a mistake? Based on the fact that we now know what a subnet mask is, we can confidently say that if it is set incorrectly, there is a high probability that your computer will be cut off from the outside world. For example, if you enter 0.0.0.0 as a mask, the operating system will consider any IP address local and will not even try to use a gateway, which will lead to a loss of the ability to communicate with computers outside your local network.

If you make another mistake by specifying a too “tight” subnet mask, then your computer may begin to experience problems connecting to “neighbors” on the local network — even if you access the local IP, the subnet mask will indicate that access it is possible only through a gateway, and this can lead either to an increased load on the network, or to the absolute inaccessibility of computers in the "LAN".

Subnet Mask Options

Various operating systems use appropriate approaches to formulating a netmask. While Windows uses four eight-bit numbers as the standard spelling, other operating systems, in particular Unix-based ones, use a record based on the IP address of the workstation, as well as the number of bits that should remain static.

subnet mask 24
Consider a specific example. Having the IP address 192.168.111.222 and indicating that its bit is static, 32, we get the following record: 192.168.111.222/32. In practice, this means that the computer will use an available gateway to connect to any computers other than itself. This is because 32 is the total number of bits that the IP address contains in the fourth version of the protocol. If we consider this mask in a more familiar form for most people (as is done in Windows), then it would look like 255.255.255.255.

What about the more familiar version of the subnet mask, which is used in most in-house LANs? The conversation, of course, is about 255.255.255.0. If you carefully read this article, then there was already a conversation about this mask, and the number of its fixed bits is 24 (i.e., the first three numbers are 8 bits each).

Thus, you can draw a simple logical chain - 8 bits are allocated for each fixed number, which means that the same 255.0.0.0 will be written as / 8, since only the first number is fixed in it.

As for the intermediate variants, for example, 255.255.255.128, their bitness is also easy to calculate, in this case it is / 25 - 24 bits of the first three fixed numbers, as well as another bit that divides the segment from 0 to 255 exactly in half.

If you need more options and examples, you can always turn your attention to specialized sources. On their pages devoted to the topic of our article, there is a table of subnet masks, which includes almost all possible options for compiling these sequences.

Source: https://habr.com/ru/post/C14001/


All Articles