December 04, 2023

How to set subnet mask for hundreds of IP addresses? Determine subnet mask from IP address?

ForewordHello everyone, I'm Mr. Lin. Yesterday, in our background, some friends reported that due to fact that subnet mask was set too large, there were some breaks in network. Wire.

This problem often occurs in real projects. We have already read many articles about IP address, but about subnet mask, many friends tend to ignore its setting. In this issue, let's summarize content of this aspect together and at same time understand in detail content of subnet mask.Text1. The role of subnet mask

The subnet mask cannot exist on its own, it must be used in conjunction with IP address. The subnet mask has only one function: to divide IP address into two parts: network address and host address.

In layman's terms, it is used to separate subnets and distinguish between those IP addresses that are on same network segment and those that do not belong to each other.

In real projects, we usually come across such IP addresses.

IP address: Subnet mask:

IP address: Subnet mask:

We can directly judge that these are IP addresses belonging to same network segment.

What about next one?

IP address: Subnet mask:

IP address: Subnet mask:

Even though these two IP addresses are similar regardless of mask, they are not on same network segment.

This can be judged by subnet mask, belongs to network segment

And belongs to network segment

Secondly, how to determine IP address of a network segment by mask

We have given an example to understand role of subnet mask, and then we will learn how to determine subnet mask and determine network segment of an IP address.

We usually use following examples when splitting VLANs:

Example 1:

Create vlan1: IP address:, subnet mask:

Create vlan2: IP address:, subnet mask:

Are they on same network segment?

Friends who typically have many IP addresses configured can intuitively tell that they don't belong to same network segment and are in different vlans because their subnet masks can only accommodate 254 IP addresses.

Example 2:

IP address 1: Subnet mask:

IP address 2: Subnet mask:

Obviously our IP address is same as example 1 above, but subnet mask is different. If you don't look at subnet mask, you may at first decide that it's not same network segment.

The only change here and in example 1 above is that subnet mask has been changed from Let's see if they belong to same network segment?

Detailed calculationConvert IP address to binary11000000 10101000 00000001 00000001Convert subnet mask to binary11111111.11111111.1111 1100.0 0000 000Then supply two matching Operation "and":11000000 10101000 00000001 0000000111111111.11111111.11111100.00000000Then we get: 000 0000translates to network number: >translate ip address to binary11000000 10101000 00000010 00000001 then "and" two "Operation:11000000 10101000 00000010 00000001< br> 11111111.11111111.11111100.00000000Then get:11000000 10101000 00000000 0000000 0convert to network number: two The result is same, they all refer to so they belong to same and same network segment.

Of course, if you're familiar with subnetting, you don't need to do these calculations. Most network segments can be judged whether they belong to a network segment by analyzing subnet mask and IP address, but premise is that you need to be familiar with principles and methods for calculating network segments.

3. How to set a subnet mask for a network with 600 IP addresses

In most cases, if our network has less than 254 hosts, we can set subnet mask to What if there are more than 254 hosts? How to set subnet mask for project with 600 ip addresses?

Vlan can be split, and it can also be installed in a large network segment. We will not talk about VLAN separation. There are examples above. There is a difficulty in setting up a large network segment. How to determine subnet mask in this big network segment code?

Let's look at following example.

For exampleAssuming there are 600 points in monitoring network, we don't want to divide it into vlanes now (most real projects will divide vlanes), assuming we only want to use a large Network Segment to separate these 600 points Points to assign ip addresses, how to set ip addresses, how to confirm subnet mask? Analysis: First, we know 600 points, which can be identified using three segments of 254 IP addresses. You can useIP segment 1:—— segment 2:—— segment 3:—— 192.168. 2.254 Each network segment has 254 IP addresses, which is enough for 600 points. The question then becomes, if these three IP segments are to be on same network segment, what is overall subnet mask for this large network segment? Let's analyze:Convert IP address to binary11000000 10101000 00000000 00000001Convert IP address to binary11000000 10101000 000 000010 00000 01The IP address will be converted to binary11000000 10101000 00000010 00000001When converted to binary, you can see that first 22 bits of binary code of three ip segments do not change, so they can be expressed as follows IP segment 1: segment 2: segment 3: is considered to be form of IP address 192.168.1.x/22 is visible to everyone, that is, subnet was told to disguise itself. In other words, first 22 bits of their common binary subnet mask are all 1. 11111111 11111111 11111100 00000000Convert to decimal, i.e., so their common subnet mask is

Thus, more accurate subnet mask, better. The range should not be too large. Don't write same way. If range is too large, after allocating an IP address, some disconnect errors will easily disappear. In real projects, there is no need to do these complicated things, having familiarized yourself with principle, you can basically write out number of IP addresses by seeing this.

If you don't want to share too many VLANs in a project, IP address of your large network segment must be specified exactly.

Usually like this:Net segment IP address is less than 254, subnet mask can be set to segment IP address is less than 600, subnet mask Can be set code IP address of network segment is less than 1000 and subnet mask can be set to