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:
CATEGORY network number/Occupied number host number/Occupied number usage
A 1 ~ 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 enterprise organizations
With the continuous expansion of Internet applications, the disadvantages of ipv4 have gradually been exposed, that is, the network number occupies too many places, and the number of hosts is too small, so the host addresses it provides become increasingly scarce, currently, in addition to using the reserved IP address to allocate nat addresses within an enterprise, a high-class IP address is usually divided to form multiple subnets for use 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 indicates whether two IP addresses belong to the same subnet and is also a 32-bit binary address. 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, they can be written according to their definition: for example, if a Class B IP address is 10.12.3.0, there is no need to separate subnets, 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. Use the number of subnets for Calculation
Before obtaining the subnet mask, you must first understand the number of subnets to be divided and the number of hosts required in each subnet.
1) convert the number of subnets to binary representation.
2) The number of digits to obtain the binary value is n.
3) obtain the subnet mask of the IP address, and obtain the subnet mask of the IP address.
To divide Class B IP address 168.195.0.0 into 27 subnets:
1) 27 = 11011
2) the binary is five digits, n = 5
3) set the subnet mask of the Class B address to the first 5 locations of the host address of 255.255.0.0, and obtain 255.255.248.0.
That is, the subnet mask of Class B IP address 168.195.0.0 divided into 27 subnets.
Ii. computing using the number of hosts
1) convert the number of hosts to binary representation
2) If the number of hosts is less than or equal to 254, remove the two reserved IP addresses.) then, 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.
To divide Class B IP address 168.195.0.0 into several subnets, each subnet contains 700 hosts:
1) 700 = 1010111100
2) the binary is ten digits, n = 10
3) set all the host addresses of the subnet mask 255.255.0.0 for the Class B address to 1, and obtain 255.255.255.255.255.
Then, move the last 10 positions 0 from the back to the back, that is, 11111111.1111111100.00000000.
That is, 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 number of subnets/Maximum number of hosts 2/22 listen 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 201710000128.0 510/32766 10/14 100000000192.0 1022/16382 11/13 201710000224.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 1000000000000128 131070/126 18/6 2017100000000192 262142/62 19/5 million bytes faster than 524286/30 20/4 1000000000000240 1048574/14 21/3 255.255.255.248 2097150/6 22/2 255.255.255.252 4194302/2 Type B IP Address: Subnet bit/host bit subnet mask maximum number of subnets/Maximum number of hosts 2/14 100000000192.0 2/16382 3/13 201710000224.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 1000000000000128 510/126 10/6 2017100000000192 1022/62 11/5 million bytes faster than 2046/30 12/4 1000000000000240 4094/14 13/3 255.255.255.248 8190/6 14/2 255.255.255.252 16382/2 Class c IP Address: Subnet bit/host bit subnet mask maximum number of subnets/Maximum number of hosts 2/6 2017100000000192 2/62 3/5 million bytes faster than 6/30 4/4 1000000000000240 14/14 5/3 255.255.255.248 30/6 6/2 255.255.255.252 62/2 |
Related Articles]
- Subnet Mask Quick Algorithm
- Simple subnet mask algorithm
- Subnet Mask and host Segment Algorithm