Subnet mask is also called network mask, address mask and subnet mask. It is used to indicate which bits of an IP address identify the subnet where the host is located and which bits identify the bit mask of the host. The subnet mask cannot exist alone. It must be used in combination with the IP address. The subnet mask has only one function, which is to divide an IP address into two parts: network address and host address. The subnet mask is the basic knowledge that everyone who uses the Internet must master. Only by mastering it can you truly understand the TCP/IP protocol settings. Let's explain what subnet mask is in simple terms.
How to divide the subnet? First, you must memorize the power of 2: the values from the 0th power to the 9th power of 2 are: 1, 2, 4, 8, 16, 32, 64, 128, 256, and 512. Another thing to understand is: subnetting is based on taking away the host bit, and using this taken away part as the subnet bit. So this means that the more subnets there are, the fewer hosts there will be.
The subnet mask is used to distinguish which part of the IP address is the network address and which part is the host address. It consists of 1 and 0, 32 bits long, and all 1 bits represent the network number. Not all networks require subnets. Therefore, a concept is introduced: default subnet mask. The default subnet mask of class A IP address is 255.0.0.0; that of class B is 255.255.0.0; and that of class C is 255.255.255.0.
CIDR is called classless inter-domain routing. ISPs often use this method to assign addresses to customers. ISPs provide customers with a block size (block size), similar to this: 192.168.10.32/28, this row of numbers tells you your subnet mask How much is it, /28 represents how many bits are 1, and the maximum is /32. But you must know that: no matter it is a class A, class B or other class address, the maximum available address can only be /30, that is, 2 bits are reserved for the host bit.
Several shortcuts for subnetting:
- How many subnets will be generated by the subnet mask you choose?: 2 to the power of x-2 (x represents the subnet bit, that is, the part whose binary system is 1) PS: here x means to exclude the default The subnet bits after the mask, for example, the network address 192.168.1.1, the mask 255.255.255.192, because it is a class C address, the mask is 255.255.255.0. Then 255.255.255.192(x.x.x.11000000) uses two 1s as subnet bits.
- How many hosts can each subnet have?: 2 to the power of y-2 (y represents the host bit, that is, the part whose binary system is 0)
- What is the effective subnet?: Effective subnet number = 256-decimal subnet mask (the result is called block size or base number)
- What is the broadcast address of each subnet?: Broadcast address = next subnet number - 1
- What are the effective hosts of each subnet?: Ignore the addresses of all 0s and all 1s in the subnet, and the remaining ones are valid host addresses.
The last valid host address = the next subnet number - 2 (that is, the broadcast address - 1)