About the subnet mask

Before finding the subnet mask, you must first figure out the number of subnets to be divided and the required number of hosts in each subnet.
1) Convert the number of subnets into binary to represent
2) Obtain the number of digits in the binary, which is N
3) Obtain the class subnet mask of the IP address, and set the first N position of the host address part to 1 to obtain the IP The subnet mask for the subnetted address.
To divide the class B IP address 168.195.0.0 into 27 subnets:
1) 27=11011
2) The binary is five digits, N = 5
3) Subnet mask 255.255.0.0 of the host address of the class B address The first 5 bits are 1 (the host bit of the class B address includes the last two bytes, so here the first 5 bits of the third byte are set to 1), and 255.255.248.0
is the class B IP address divided into 27 subnets The subnet mask of 168.195.0.0 (actually divided into 32-2=30 subnets).

------------------------The following is a simple one---------------
According to the number of hosts Use the number
of hosts To calculate
1) Convert the number of hosts into binary to represent
2) If the number of hosts is less than or equal to 254 (note that the reserved two IP addresses are removed), then the binary digits of the host are obtained, which is N, where N<8 for sure. If it is greater than 254, then N>8, which means that the host address will occupy more than 8 bits.
3) Use 255.255.255.255 to set all the host address bits of this type of IP address to 1, and then set all N bits to 0 from the back to the front, which is the subnet mask value.
To divide the class B IP address 168.195.0.0 into several subnets, each with 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 of the class B address to 1, get 255.255.255.255,
and then set the last 10 bits to 0 from the back to the front, That is : 11111111.11111111.11111100.00000000
or 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.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326307450&siteId=291194637