In network division, if you want to use a subnet, you must know the number of subnets.
For example, if a class C network needs to be divided into subnets and six subnets are to be created, what is the mask?
First, let's talk about the IP address and the mask
The total length of the IP address is 32 characters, which is 4 bytes long.
The mask is also 32-bit and consists of 4 bytes.
The IP address uses mask to know the network number and host number, for example:
192.168.0.5
255.255.255.0
Obtain the network number 192.168.0.0.
Host No.: 5
This mask is a non-subnet mask, which is the standard mask for Class C networks.
Set 6 subnets and the binary value of 6 is 110. Therefore, we know that the last byte of the mask is 11100000,
Then how does the mask obtain six subnets?
Take a look at the binary 110 of 6, from 1-6
001
010
011
100
101
110
Perform the and operation with mask 111 respectively, and the IP addresses of each subnet can be calculated.
For example, the first subnet 001
The available address is
00100001-33, 192.168.0.33/192.168.0.33
00100010-34
.
.
.
00111110-62
30 addresses from 192.168.0.33-62
Both 32 and 63 are reserved addresses, which represent the network itself and broadcast addresses, so they are not included.
The formula for calculating the number of subnets is as follows:
Subnet COUNT = (the bit power of the subnet mask of 2)-2
Number of hosts = (bit power of 2 hosts)-2