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 1 of the host address of 255.255.0.0 to obtain 255.255.248.0, which is the subnet mask of the 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 (note that the reserved two IP addresses are removed), the binary number of the host is obtained, 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 B (c) class IP address 168.195.0.0 into several subnets, each subnet contains 700 hosts (17 ):
1) 700 = 1010111100
2) the binary is ten digits, n = 10 (1001)
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.1111.111100.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.