Reprinted: determines whether the subnet mask is in the same network segment.

Source: Internet
Author: User

We can determine whether the IP address is in the same CIDR Block through the IP address directly. The following describes how the computer uses the subnet mask to determine whether the IP addresses of two hosts are in the same CIDR block ~
How can I calculate the network ID if I want to have the same network ID in the same network segment? Network Identification Algorithms for various IP addresses are different

. Class A is only the first segment. Class B, only the first and second sections. Class C: calculates the first, second, and third sections.
The algorithm only needs to set the IP address and subnet mask each digit and.
And method: 0 and 1 = 0 0 and 0 = 0 1 and 1 = 1
For example: And 192.168.0.1, 255.255.255.0, first converted to binary, And each and
IP 112.1600.10101000.20.0000.00000001
Subnet Mask 11111111.111111.1111111111.00000000
Obtain the and result 112.1600.10101000.00000000.00000000.
Convert to 192.168.0.0 in decimal format. This is the network ID,
Then, the subnet mask is reversed, that is, the IP address and
The result is calculated as follows: 2017.hangzhou.hangzhou.00000001, which is converted to a 10-digit system, that is, 0.0.0.1,
0.0.0.1 indicates the host ID. To be in the same network segment, you must have the same network ID.
Let's take a look at the Class B IP address changed to the default subnet mask.
For example, IP Address: 188.188.0.111, 188.188.5.222, all subnet masks are set to 255.255.254.0. Are they in the same network segment?
First convert these to binary
188.188.0.111 101100.10111100.20.20.20.1101111
188.188.5.222 10111100.10111100.00000101.11011010
201710000254.0 11111111.111111.11111110.00000000
Respectively and, get
10111100.10111100.00000000.00000000
10111100.10111100.00000100.00000000
The network IDs are different, that is, they are not in the same CIDR block.
Check whether the IP address is in the same CIDR block. Now, let's look at it.
A company has 530 computers to form a peer-to-peer lan. What is the most suitable subnet mask and IP address?
The subnet mask is not mentioned. The previous calculation result is 11111111.1111111100.00000000, that is

255.255.252.0
Now we need to determine how to allocate IP addresses. First, select a Class B IP segment. Here we will select 188.188.x.x.
In this way, the key to determining the first two IP segments is to determine the third segment, as long as the network ID is the same. Let's first determine the network

Network ID. (We can set the "1" in the subnet mask to the "IP", and "0" to "*", as shown below :)
201710000252.0 11111111.111111.11111100.00000000
188.188.x.x 10111100.10111100 .**.********
Network ID 10111100.10111100. 00.00000000
From this we can see that the field can be left blank (only 0 and 1 can be used, not necessarily 0 and 1)

Reprinted: determines whether the subnet mask is in the same network segment.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.