Subnet mask algorithm

A, is calculated using the number of subnets
must first find out the number of subnets to be divided, and the number in the desired host prior to seeking each subnet Subnet Mask.
1) into the binary number represented subnet
2) acquires the binary digits, N is
made based subnet mask IP address 3), the N position thereof before the host address portion of the obtained 1 i.e. IP addresses are divided subnet mask.
For a class B IP addresses 168.195.0.0 Subnet divided into 27:
1) 27 = 11011
2) Five-digit of the binary number, N =. 5
. 3) Class B subnet mask address of the host address 255.255.0.0 5 before position 1, to give 255.255.248.0
mask is the subnet is divided into 27 class B IP addresses of 168.195.0.0.
Second, using the calculated number of hosts
1) into the binary number represented host
2) If the number is less than or equal to the host 254 (note that the removal of two reserved IP address), to obtain the number of bits of the host, is N, where certainly N <8. If more than 254, the N> 8, which means that the host address will take more than 8.
3) using the IP address 255.255.255.255 class to the host address bits all set to 1, and then from back to front of the N bits are all set to 0, is the subnet mask value.
For a class B IP addresses 168.195.0.0 divided into several subnets, each with a host subnet 700:
1) 700 = 1,010,111,100
2) of the binary digits of ten, N = 10
. 3) the Class B addresses 255.255.0.0 Subnet Mask host addresses all set to give 255.255.255.255
After 10 and then forwardly from the position 0, that is: 11111111.11111111.11111100.00000000
i.e., 255.255.252.0. This is to be the host 700 into the class B IP addresses 168.195.0.0 of subnet mask.

Guess you like

Origin www.cnblogs.com/a-1187629089/p/11951659.html