The IP address is 32-bit binary values for taught the address of each computer in the TCP / IP Communication protocol. Usually we use a dot decimal, such as 192.168.0.5, and more.
Each IP address can be divided into two parts. That is, the network number section and the host number section: The network number indicates the network segment number thereof, and the host number indicates the address number of the host in the network segment. According to the size of the network, the IP address can be divided into five categoriescent A, B, C, D, E, where A, B, C class are three main types of addresses, and the D-class is available for multi-purpose addresses. And class E is used to extend the standby address. A, B, and C three type IP addresses are valid for the following table:
Category Network / Placard Most Number / Place
A 1 ~ 126/8 0 ~ 255 0 ~ 255 1 ~ 254/24 National Class
B 128 ~ 191 0 ~ 255/16 0 ~ 255 1 ~ 254/16 Cross the tissue
C 192 ~ 223 0 ~ 255 0 ~ 255/24 1 ~ 254/8 Enterprise Organization
With the continuous expansion of interconnection network applications, the prior IPv4's drawbacks are gradually exposed, that is, there are too many network numbers, and the host number is too small, so the host address that it can provide is increasingly scarce. In addition to using NAT In addition to the retention address self-assignment in the enterprise, a high catei IP address is usually divided to form a plurality of subnets, providing a user base for different sizes.
Here, it is mainly to effectively utilize the IP address in the case of network segmentation, and the subnet number is taken as a subnet number in the high portion of the host number, and the subnet mask is expanded or compressed from the usual network bit boundary. More subnets. However, when you create more subnets, the number of available host addresses on each subnet will be reduced.
The subnet mask is the two IP addresses that belong to one subnet, and the 32-bit binary address, each of which means that the bit is a network bit, which represents the host bit. It is also the same as the IP address is also expressed. If the two IP addresses are the same as the result of the subnet mask, it indicates that they belong to the same subnet.
When calculating the subnet mask, we should pay attention to the retention address in the IP address, "0" address and broadcast address, which refers to the IP address when the host address or network address is "0" or "1", which Represents this network address and broadcast address, generally cannot be calculated.
Below will be used to illustrate the algorithm of subnet mask:
For IP addresses that do not need to be divided into subnets, their subnet masks are very simple, that is, according to their definitions, it will be written: such as a Class B IP address is
10.12.3
.0, no need to divide the subnet, the subnet mask of the IP address is 255.255.0.0. If it is a C class address, its subnet mask is 255.255.255.0. Other types of push, no more detailed. Below we are the key to introducing an IP address, but also need to use its high host bits as a divided subnet number, and the remaining is the host number of each subnet. How to make a mask for each subnet Calculate.
First, use the number of subnets to calculate
You must first clear the number of subnets to be divided before asking for subnet mask, and the number of desired hosts in each subnet.
1) Transform the number of subnets into binary
2) Number of binary bits, for N
3) A sub-net mask of the IP address is acquired, and the front N position 1 of the host address portion is obtained, the subnet mask of the IP address division subnet.
To divide the Class B IP address 168.195.0.0 into 27 subnets:
1) 27 = 11011
2) This binary is five digits, n = 53) Position 5 5555.248.0, 5555.0.0 hosts B-class addresses 1 555.255.248.0
In order to divide the subnet mask of the B class IP address 168.195.0.0 of 27 subnets.
Second, use the number of hosts to calculate
1) Transform the number of hosts into binary
2) If the number of hosts is less than or equal to 254 (pay attention to the two IP addresses reserved), the number of binary bits of the host will be obtained, which is n <8 here. If it is greater than 254, n> 8, this means that the host address will occupy more than 8 bits.
3) Use 255.255.255.255 to set all of the host address bits of this class of IP addresses, and then all from the backward n-bit to 0, that is, the subnet mask value.
If you want to divide B IP address 168.195.0.0 into a number of subnets, there are 700 hosts in each subnet:
1) 700 = 1010111100
2) This binary is ten digits, n = 10
3) Set all the host addresses of the subnet mask 255.255.0.0 of the class B address 1, 555.255.255.255
Then, then the rear 10 position is 0, ie: 111111111, 111111111, 11111100.00000000
That is, 255.255.252.0. This is the subnet mask that should be divided into 700 B-class IP addresses 168.195.0.0.
The following is listed below all subnets that can be divided by various IP addresses. The number of hosts and subnets, as well as the number of hosts and subnets (maximum), pay attention to the reserved IP address (ie, there are hosts after dividing The bit or subnet is all "0" or all "1"):
Class A IP address:
Subnet / host bit subnet mask subnet maximum number / host maximum number
2/22 255.192.0.0 2/4194302
3/21 255.224.0.0 6/2097150
4/20 255.240.0.0 14/1048574
5/19 255.248.0.0 30/524286
6/18 255.252.0.0 62/262142
7/17 255.254.0.0 126/131070
8/16 255.255.0.0 254/65536
9/15 255.255.128.0 510/32766
10/14 255.255.192.0 1022/16382
11/13 255.255.224.0 2046/8190
12/12 255.255.240.0 4094/4094
13/11 255.255.248.0 8190/2046
14/10 255.255.252.0 16382/1022
15/9 255.255.254.0 32766/510
16/8 255.255.255.0 65536/254
17/7 255.255.255.128 131070/126
18/6 255.255.255.192 262142/62
19/5 255.255.255.224 524286/30
20/4 255.255.255.240 1048574/14
21/3 255.255.255.248 2097150/6
22/2 255.255.255.252 4194302 / 2B class IP address:
Subnet / host bit subnet mask subnet maximum number / host maximum number
2/14 255.255.192.0 2/16382
3/13 255.255.224.0 6/8190
4/12 255.255.240.0 14/4094
5/11 255.255.248.0 30/2046
6/10 255.255.252.0 62/1022
7/9 255.255.254.0 126/510
8/8 255.255.255.0 254/254
9/7 255.255.255.128 510/126
10/6 255.255.255.192 1022/62
11/5 255.255.255.224 2046/30
12/4 255.255.255.240 4094/14
13/3 255.255.255.248 8190/6
14/2 255.255.255.252 16382/2
Class C IP address:
Subnet / host bit subnet mask subnet maximum number / host maximum number
2/6 255.255.255.192 2/62
3/5 255.255.255.224 6/30
4/4 255.255.255.240 14/14
5/3 255.255.255.248 30/6
6/2 255.255.255.252 62/2