A summary of the concept and function of two-subnet mask how to use subnet mask four how to get network/host address by subnet mask classification of five subnet masks six subnet addressing technology seven how to divide subnets and determine subnet mask eight correlation judgment method A tutorial on subnet mask and subnetting, learn This tutorial requires a certain foundation (except the Master of course), it is recommended to read the previous tutorial on IP, then the tutorial. You ready? Here we go!! The concept and function of two subnet mask the subnet mask is a 32-bit binary value that is applied to a TCP/IP network, it can block out part of the IP address, thereby separating the network part and the host part of the IP address, and based on the subnet mask, the administrator can further divide the network into several subnets. Three why do I need to use a subnet mask although we say that the subnet mask can separate the network part and the host part of the IP address, you still have questions, such as why to distinguish between network address and host address? What happens after the distinction? So good, let's talk about it in detail! When communicating between two computers using the TCP/IP protocol, we can get the network number of the target host by the ' and ' operation of the subnet mask and the host IP address of the receiver, and because each host is configured tcp/ IP protocol is set with a native IP address and subnet mask, so you can know the network number where the natively is located. By comparing the two network numbers, you can know whether the host hosts are on this network. If the network number is the same, indicating that the recipient is on the network, the packet can be sent directly to the target host through the relevant protocol, if the network number is different, indicating that the target host is on the remote network, then the packet will be sent to the router on the network, the router will send the packet to the other network until the destination. In this process you can see that the subnet mask is indispensable! Four how to get a network/host address with a subnet mask since the subnet mask is so important, how does it isolate the network address and host address in the IP address? The process is as follows: 1 convert IP address and subnet mask to binary; 2 The binary form of the IP address and the subnet mask do ' and ' operations, the answer into decimal to get the network address, 3 the binary form of the subnet mask to ' anti '; 4 will take the ' anti ' subnet mask and IP address to do ' and ' operation, Turn the answer into decimal to get the host address. Below we use an example to illustrate: suppose there is an I P Address: 192.168.0.1 subnet mask is 255.255.255.0 to binary: I P Address 11000000.10101000.00000000.00000001 Subnet MaskCode 11111111.11111111.11111111.00000000 will do both ' and ' operations: 11000000.10101000.00000000.00000000 will be converted to decimal: 192.168.0.0 This is the network address of the above IP, the host address and so on. Tip: By observing that the subnet mask above is the default subnet mask for Class C addresses (that is, the subnet is not divided), you can see directly that the network address is the first three parts of the IP address, the first three bytes. FAQ: What? You still don't understand? Ask me why do I do ' and ' arithmetic instead of anything else? In fact, you should be able to understand the above example carefully. ' 1 ' in doing ' and ' operations, does not affect the result, ' 0 ' in doing ' and ' operations, will get 0, the use of ' and ' this feature, when the administrator set the subnet mask, the subnet mask and network address corresponding to the bit is set to ' 1 ', the other bits are set to ' 0 ', then as ' and ', The IP address of the network number will be retained in the results, and the host number will be set 0, so that the network number is resolved, the resolution of the host number is the same, only the net mask to take the "counter", in doing ' and '. classification of five subnet masks 1) Default subnet mask: That is, the subnet is not divided, the corresponding network number of the bits are 1, the host number is 0. a class Network default subnet mask: 255.0.0.0 B class Network default subnet mask: 255.255.0.0 c class Network default subnet mask:255.255.255.0 2) Custom Subnet mask: Divide a network into several subnets, need each segment to use a different network number or subnet number, in fact we can to think is the host number is divided into two parts: subnet number, subnet host number. The form is as follows: Subnet partition IP Address: Network number + host number for subnetting IP address: Network number + subnet number + Subnet host number that is, the IP address in the molecular network, the previous host number is part of the location of the sub-network number, the remaining subnet host number. Six subnet addressing technology before the introduction of some knowledge of the subnet mask, let's look at the Sub-network division, do not think that the subnet partition and subnet mask does not have a relationship yo, subnetting is also by the subnet mask to achieve. A subnet is a logical network that is generated on an IP address that allows a network address to span multiple physical networks, meaning that one network address represents multiple networks (obviously, this can save IP addresses). Oh, it sounds strange? How can a network be divided into many subnets in an inexplicable way? So what's the use of this? Let me give you an example to tell you: for example, you are a school network management, your school has four in different physical location of the classroom, each network classroom25 machines, your task is to configure the IP address and subnet mask for these machines. You might think it's easy, you can apply 4 class C addresses, one in each classroom, and then the one by one configuration is done. Well, it's theoretically true, but did you ever think it would be wasteful, you wasted (254-25) *4=916 IP address, if all the network management is like you do, then the Internet IP address will be exhausted in a very short period of time, obviously, you can not do this, You should do sub-network partitioning. Subnetting This is one thing: because after dividing the subnet, the IP address network number is constant, so outside the LAN, there is still only one network, that network number represents the network, but inside the network is another scene, Because the subnet number of each of our subnets is different, when using the IP address and subnet mask (note that the subnet mask referred to here is not the default subnet mask, but instead of a custom netmask, which is calculated by the administrator) do ' and ' operations, each subnet will have a different subnet address, Thus realize the division of the network (get a different address, of course, can distinguish the various subnets, interesting bar). Subnet addressing technology, subnetting will help solve the following problems: 1) Huge network address management costs: If you are an administrator of a-class network, you will have headaches for managing a large number of hosts. 2) The rapid expansion of the routing table in the router: When the router exchanges the routing table with other routers, the load on the Internet is very high and the amount of computation required is very high; 3) The IP address space is limited and will eventually run out: This is a critical issue, the rapid development of the Internet, so that the original address method can not adapt, And some IP addresses can not be fully exploited, resulting in waste. Therefore, when configuring a LAN or other network, it is important and sometimes necessary to divide the subnets as needed. Now, the subnet addressing technology has been used by most local area networks. Seven how to divide subnets and determine subnet masks Before you do this, be sure to consider the current needs of the network and future demand plans. Subnetting is mainly considered from the following aspects: 1. The number of physical segments in the network (that is, the number of subnets to divide) 2. Number of hosts per physical segment steps to determine the subnet mask: First step: Determine the number of physical segments, convert them to binary numbers, and determine the number of bits N. Such as: You need 6 subnets, 6 of the binary value is 110, a total of 3 bits, that is n=3; step two: Write out its default subnet mask according to the type of your IP address. In the case of Class C, the default subnet mask is 11111111.11111111.11111111.00000000; The third step is to place 1 in the subnet mask corresponding to the first n bits of the host number, and 0 for the remaining positions. If n=3 and for the Class C address: The subnet mask is 11111111.11111111.11111111.11100000 into decimal to get the 255.255.255.224B class address: The subnet mask is 11111111.11111111.11100000.00000000 To the decimal to get the 255.255.224.0A class address: Then get the subnet mask 11111111.11100000.00000000.00000000 to decimal to get 255.224.0.0 another: Because the network is divided into 6 subnets, occupies the first 3 of the host number, if the C-class address, then the main The machine number can only use 5 bits to represent the host number, so the number of hosts in each subnet = (2 of 5) -2=30,6 subnet Total can identify the number of hosts will be less than 254, please pay attention! 1 You may have such a question, for example, in the above example, 6 of the binary value is 110, then why should the subnet mask and the host number of the first n bits corresponding to the location of 1, instead of 6 binary 110 to replace the first n bit? Oh, this question is very good, the answer is this: we calculate the purpose of the subnet mask? Just want it to do ' and ' when the network number can be resolved, that is, it and the network number corresponds to the location should be 1 (of course, including the sub-network number corresponding to the location), then it is obvious that you write 110 is not right, if you write so, then it is the first two of the host number as the subnet number, So this will be divided by up to 2 subnets (not sure, there is a way to calculate the number of subnets below), and we originally wanted to divide the 6 subnets is obviously inconsistent. So you can understand the horse? 2 attentive people may find that dividing 4 subnets, 5 subnets and 6 subnets is the same subnet mask, with 255.255.255.224, is it wrong? Three subnet masks should be different? Hehe, is this, because the binary value of the 4,5,6 is 3, so in the subnet mask this three bits are set 1, division is no problem, but your understanding of a little bit of a problem, divided into 4 subnets, in fact, can be understood as divided into 6 subnets, but you only use 4 of them. For example, if you want to divide 8 subnets, the subnet masks that are obtained by dividing 14 subnets are the same, taking up 4 bits as the subnet number. Eight related Judgment Method 1) How to determine whether subnetting is done? The problem is simple, if it uses the default subnet mask, then it means that it is not subnetting, and the other is subnetting. 2) How to calculate the subnet address? Still the old way, the IP address and the subnet mask binary form do ' and ', the resulting result is the subnet address. 3) How to calculate the host address? This also needless to say, first the subnet mask binary "counter", and then do with the IP address ' and '. 4) How to calculateHow many subnets? This question everyone will often mention, or from the subnet mask to start, there are two steps: 1 observe the binary form of the subnet mask, determine the number of bits as the subnet number of n;2 subnet is 2 of the n-th square 2. (Why minus 2, hehe, look down) For example, for example, there is a subnet mask: 255.255.255.224 The second binary is: 11111111.11111111.11111111.11100000 visible n=3,2 3 square is 8, The description of the subnet address may have the following 8 cases: 000001010011100101110111 But it represents the network itself 000; 111 of the broadcast address is reserved, so you have to subtract 2, understand?  5) How to calculate the total number of hosts, the number of subnets in the subnet? Total number of hosts = number of subnets x subnets number of hosts and then an example to illustrate, such as the subnet mask for 255.255.255.224 above the discussion that it can divide up to 6 subnets, then the maximum number of hosts in each subnet? In fact, I have already given you the above, because the network is divided into 6 subnets, occupies the first 3 of the host number, and is a C-class address, the host number can only use 5-bit to represent the host number, so the number of hosts within the subnet = (2 5)- 2=30. So through this subnet mask we can figure out that this network can identify up to 6*30=180 hosts (visible, the number of hosts that can be identified by the entire network after the molecular network is reduced).  6) computes the IP address range through a custom subnet mask, we can get all possible IP address ranges for this network. Specific steps: 1 Write out the binary subnet address, 2 the subnet address into decimal, 3 compute subnet can accommodate the number of hosts, 4 to derive the IP range (start address: subnet address +1; termination Address: Subnet address + host number) Suppose a subnet mask is: 255.255.255.224, it can be divided up to 6 subnets, the number of hosts in the subnet is 30, then all possible IP addresses and the calculation process is as follows: subnet-subnet address (binary)----------subnet address--Real IP range 1th number--11001010.01 110000.00001010.00100000--202.112.10.32-- 202.112.10.33-202.112.10.622,--11001010.01110000.00001010.01000000--202.112.10.64-- 202.112.10.65-202.112.10.943,--11001010.01110000.00001010.01100000--202.112.10.96-- 202.112.10.97-202.112.10.1264,--11001010.01110000.00001010.10000000--202.112.10.128-- 202.112.10.129-202.112.10.1585,--11001010.01110000.00001010.10100000--202.112.10.160-- 202.112.10.161-202.112.10.1906,--11001010.01110000.00001010.11000000--202.112.10.192-- 202.112.10.193-202.112.10.222
[Go] subnet mask and subnetting