The IP address is a 32-bit binary value used to mark the address of each computer in TCP/IP communication protocol. We usually use the dot decimal representation, such as 192.168.0.5. Each IP address can be divided into two parts. That is, the Network part and host part: the network number indicates the network segment number to which it belongs, and the host number indicates the address number of the host in the network segment. According to the size of the network, IP addresses can be divided into five categories: A, B, C, D, and E. Class A, B, and C are the three main types of IP addresses, class D is the multi-object address used for multi-object transmission, and Class E is used to expand the standby address. The valid ranges of IP addresses A, B, and C are as follows ~ 126/8 0 ~ 255 0 ~ 255 1 ~ 254/24 national B 128 ~ 191 0 ~ 255/16 0 ~ 255 1 ~ 254/16 cross-organizational unit C 192 ~ 223 0 ~ 255 0 ~ 255/24 1 ~ 254/8 with the expansion of Internet applications, enterprise organizations gradually revealed the disadvantages of IPv4, that is, the network number occupies too many places, while the number of hosts is too small, therefore, the host addresses it provides become increasingly scarce. Currently, in addition to using NAT to allocate reserved addresses within an enterprise, a high-category IP address is usually further divided, to form multiple subnets, which can be used by different user groups. This is mainly to effectively use the IP address in the case of network segmentation. By taking the high part of the host number as the subnet number, we can expand or compress the subnet mask from the usual network bit boundary, creates more subnets for a specific type of address. However, when more subnets are created, the number of available host addresses on each subnet is reduced. The subnet mask of www.2cto.com indicates whether the two IP addresses belong to the same subnet and are also 32-bit binary addresses. Each of the two IP addresses is 1, indicating that the IP address is a network bit and 0 indicates the host bit. It is represented in decimal format like an IP address. If the bitwise AND calculated results of the subnet mask are the same, the two IP addresses belong to the same subnet. When calculating the subnet mask, pay attention to the reserved IP addresses, that is, the "0" address and broadcast address, these are IP addresses when the host address or network address is "0" or "1". They represent the current network address and broadcast address, which cannot be included. The following example describes the subnet mask algorithm: for IP addresses that do not need to be divided into subnets, The subnet mask is very simple, that is, it can be written according to its definition: if a Class B IP address is 10.12.3.0 and you do not need to split the subnet, The subnet mask of the IP address is 255.255.0.0. If it is a class C address, its subnet mask is 255.255.255.0. And so on. Next, we will introduce an IP address. We also need to use its high host bit as the assigned subnet network number. The rest is the host number of each subnet, how to calculate the mask of each subnet.
1. Before using the number of subnets to calculate the subnet mask, you must first understand the number of subnets to be divided and the number of hosts in each subnet. 1) convert the number of subnets to a binary value. 2) obtain the number of digits of the binary value, which is N. 3) obtain the class subnet mask of the IP address, obtain the subnet mask of the IP address that is divided into subnets based on the first N positions 1 of the host address. If you want to divide the Class B IP address 168.195.0.0 into 27 subnets: 1) 27 = 11011 2) the binary value is five digits, N = 5 3) set the subnet mask of the Class B address to the first 5 locations 1 of the host address of 255.0.0, and obtain the subnet mask of the Class B IP address 168.195.0.0 that is divided into 27 subnets.
2. Calculate the number of hosts. 1) convert the number of hosts into binary values. 2) if the number of hosts is less than or equal to 254 (remove the two reserved IP addresses ), obtain the binary number of the host, which is N. N <8. If it is greater than 254, N> 8, which means the host address occupies more than 8 digits. 3) Use 255.255.255.255.255 to set the number of host addresses of this type of IP address to 1, and then set all the N digits to 0 from the forward, that is, the subnet mask value. Www.2cto.com if you want to divide the B-type IP address 168.195.0.0 into several subnets, each subnet has 700 hosts: 1) 700 = 1010111100 2) the binary value is ten digits, N = 10 3) set all the host addresses of the subnet mask 255.255.0.0 of the B-type address to 1, get 255.255.255.255.255, and then forward the last 10 positions to 0, that is, 11111111.1111111100.00000000, that is, 255.255.255.252.0. This is the subnet mask of the Class B IP address 168.195.0.0 to be divided into 700 hosts. The following lists all subnets that can be divided by various IP addresses. The number of hosts and subnets after the subnet is divided, and the maximum number of hosts and subnets, note that you need to remove the reserved IP address (that is, the host bit or subnet bit is "0" or "1" After Division): Class a ip Address: subnet bit/host bit subnet mask maximum subnet 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 255.254.0.0 7/17 255.255.255.0.0 126/131070 8/16 255.128.0 254/65536 255.255.255.192.0 1022/16382 11/13 201710000224.0 2046 /8190 12/12 255.255.255.240.0 4094/4094 13/11 255.255.252.0 8190/2046 14/10 255.255.255.254.0 16382/1022 15/9 255.255.255.0 32766/510 16/8 255.255.255.128 65536/254 17/7 131070/126 255.255.255.255.255.255.255.255.252 18/6 262142/62 255.255.255.255.248 19/5 524286/30 255.255.255.255.255.252 20/4 1048574/14 Class B IP Address: www.2cto.com subnet bit/host bit subnet mask subnet max/host Max 2/14 255. 2017192.0 2/16382 3/13 255.6/8190 4/12 255.255.255.240.0 14/4094 5/11 30/2046 255.255.255.252.0 6/10 62/1022 255.255.254.0 7/9 126/510 255.255.255.0 8/8 254/254 255.255.255.255.128 9/7 510/126 255.254.0 10/6 255.255.255.255.255.240 1022/62 11/5 255.255.255.255.248 2046/30 12/4 255.4094/14 C Class IP Address: subnet bit/host bit subnet mask maximum subnet number/host maximum number 2/6 255.255.255. 192 2/62 3/5 questions asked why? 6/30 4/4 14/14 questions asked why? 5/3 30/6 6/2 then according to the questions in CCNA, I would like to give you an example: first, let's take a look at the common questions in the exam: the IP address of a host is 202.112.14.133, And the mask is 202.112.14.133. The network address and broadcast address of the host must be calculated. The general method is to convert the host address and subnet mask into binary numbers. The network address can be obtained after the logic and calculation of the two. As a matter of fact, you only need to think about it and you can get another method: The Mask of zookeeper contains 256-224 = 32 IP addresses (including network addresses and broadcast addresses ), the network address with this mask must be a multiple of 32. The network address is the beginning of the subnet IP address, and the broadcast address is the end. The available host address is within this range. Therefore, it is slightly smaller than 137, and only 128 is the multiple of 32, therefore, the network address is 202.112.14.128. The broadcast address is the network address of the next network minus 1. The next 32 is a multiple of 160. Therefore, the broadcast address is 202.112.14.159. You can refer to the following table to understand this example. Sub-network binary number of sub-network domain binary number of host domain range 1st sub-network 000 00000 thru 11111. 0 thru.31 2nd sub-network 001 00000 thru 11111. 32 thru.63 3rd sub-network 010 00000 thru 11111. 64 thru.95 4th sub-network 011 00000 thru 11111. 96 thru.127 5th sub-network 100 00000 thru 11111. 128 thru.159 6th sub-network 101 00000 thru 11111. 160 thru.191 7th sub-network 110 00000 thru 11111. 192 thru.223 8th sub-Network 111 00000 thru 11111. in the 124 thru.255 CCNA exam, you need to plan the subnet address based on the number of hosts on each network. And calculate the subnet mask. This can also be calculated based on the above principles. For example, if a subnet has 10 hosts, the IP address required for this subnet is 10 + 1 + 1 + 1 = 13. Note: the first one is the gateway address required for the network connection, and the second two are the network address and broadcast address. Because 13 is less than 16 (16 is equal to the 4 power of 2), the host space is 4 bits. And 256-16 = 240 www.2cto.com, so the subnet mask is 255.255.255.255.240. If a subnet has 14 hosts, many people often make the mistake of allocating a subnet with 16 address spaces instead of allocating addresses to the gateway. In this case, the error occurs because: 14 + 1 + 1 + 1 = 17 17 is greater than 16, so we can only allocate subnets with 32 addresses (32 equals to the power of 2. In this case, the subnet mask is too large. References: http://zhidao.baidu.com/question/5137270.html Author toskyroom