Encyclopedia business cards
A cidr Block refers to the part in a computer network that uses the same physical layer device (transport medium, repeater, hub, and so on) for direct communication. From one IP address to another, it is like a network segment from 192.168.0.1 to 192.168.255.255.
The subnet mask assigned by the IP address is only 255 or 0 in each segment by default.
Class A default subnet mask 255.0.0.0 a subnet can accommodate up to 16.77 million computers
Default subnet mask of type B 255.255.0.0 a subnet can accommodate a maximum of 60 thousand computers
Class C default subnet mask 255.255.255.0 a subnet can accommodate a maximum of 254 computers
If you want to be in the same network segment, as long as the network ID is the same, what should you do with the network ID? The first thing to do is to convert the IP address of each segment to binary. (Some people say that I won't change it. It doesn't matter. We can use the built-in calculator in windows. Open the calculator, click "View"> "programmer", enter a decimal number, and click "binary" to switch to binary .)
After switching the subnet mask to binary, we will find that all the subnet masks are composed of a string of consecutive 1 and a string of consecutive 0 (a total of 4 segments, each segment of 8 bits, 32 digits in total ).
This is the binary form of the default subnet mask of Class A/B/C. In fact, there are many subnet masks, as long as it is a string of continuous 1 and a string of continuous 0 (each segment is 8 bits ). For example, 11111111.111111.11111000.00000000, which is also a valid subnet mask. The subnet mask determines the number of computers in a subnet. The computer formula is 2 to the power of M. In this formula, we can regard m as the number of computers following 0. For example, when 255.255.255.0 is converted to a binary value, it is 11111111.1111.1111.00000000. There are 8 digits behind it, and m is 8. The 255.255.255.0 subnet mask can accommodate 2 Power 8 computers, that is, 256 machines, but two IP addresses are not available, that is, the last segment cannot be 0 or 255. If the two IP addresses are subtracted, the number is 254.
00 converts it to a four-digit binary number (each segment is 8 bits. If it is 0, it can be written as 8 zeros, that is, 00000000)
Then, there are several zeros behind the number, and there are 11 in total, that is, the power of 2, equal to 2048, this subnet mask can accommodate up to (2048-2) = 2046 computers.
Let's take a look at the Class B IP address changed to the default subnet mask.
For example, IP Address: 188.8.131.52, 184.108.40.206, all subnet masks are set to 255.255.254.0. Are they in the same network segment?
First convert these to binary
IP (a) 220.127.116.11 10111100.1011118.104.22.1681111
IP (B) 22.214.171.124 10111100.10111100.00000101.11011010
Mask 201710000254.0 11111111.111111.11111110.00000000
255.255.254.0 is composed of 23 1 s, that is, a 23-bit mask. Simply put, after converting the decimal IP address into binary format from left to right, if the first 23 bits and 1 are the same, the IP address belongs to the same network segment, the one after the 24-bit path changes randomly and belongs to the same network segment. In this example, the IP address (a) 126.96.36.199 is in the range of 188.8.131.52 ~ 184.108.40.206, which belongs to the same network segment only. The IP address range of IP (B) In the same network segment is 220.127.116.11 ~ The range of 18.104.22.168 is obviously not in the range of IP (a), so IP (A) and IP (B) are not in the same network segment.
Calculate and separately.
The network IDs are different, that is, they are not in the same CIDR block.
Ip cidr Block and subnet mask
Today's enterprises are growing in size, ranging from dozens to dozens, and now hundreds. The number of IP addresses is also increasing. We all know that the number of IP addresses in a network segment is 0-255. Apart from 0 and 255, there are only 254 computers. If there are more than 254 computers, we need to add IP addresses. How can we add IP addresses, therefore, the subnet mask is required.
Currently, an IP address is composed of four digits (which will be expanded and changed later) and is usually divided into three types:
Class A: 0.0.0.0 to 22.214.171.124
Class B: 126.96.36.199 to 188.8.131.52
Class C: 192.0.0.0 to 184.108.40.206
In the same CIDR Block, the network ID must be the same. The network ID uses the binary data of the IP address and the subnet mask as the "and" operations (the Windows Calculator can be used as the binary data), so the results are the same, it indicates that the IP address is in the same CIDR block. When calculating the network ID, Class a ip is regarded as the first segment, Class B is regarded as the first and second segments, and class C IP is regarded as the first, second, and third segments.
For example, the network ID of 192.168.0.1 255.255.255.0 is 192.168.0.0.
The subnet mask determines the number of computers in a subnet. A simple algorithm is 2 to the power of M. M indicates the number of zeros after the subnet mask of the binary.
There are eight 0 s behind, and m is 8. This subnet mask can accommodate two eight power computers, that is, 256 computers. Remove 0 and 255, that is, 254 computers.
Example: A company has 530 computers and forms an equivalent network. How can I set the subnet mask? How do I set an IP address?
2 to the power of M = 530, M = 10
The last subnet mask is 10 0, so 11111111.11111111.1111111100.00000000.
In decimal format: 255.255.252.0
Let's look at the IP address. Let's select a Class B IP address, for example, 188. 188. ×. ×.
You can set the first two segments according to the B type. The key is the third segment. If the network ID is the same, it can be in the same network segment. Let's first look at the network ID:
188. 188. ×. ×: 10111100.10111100 .?????? ××. ××××××××
Network ID: 10111100.10111100 .?????? 00.00000000
No matter the number x above is set to 0 or 1, the result is 0.
? Fill in 0 and 1 are the same, we fill in 0, the result is IP is:
10111100.10111100.000000 ××. ××××××× this IP address has a total of 530 computers. The last segment of the IP address is allocated to 254 computers. The total segment is 530/254 = 2.086. The first segment is divided into three segments, therefore, the IP address 000000 × can be divided into three different data types, for example, 20170001,00000010, 00000011, respectively, 1, 2, 3, so that the IP address is determined by 188.188.1. ×, 188.188.2. ×, 188.188.3. ×.