Subnet Mask and subnet division

Source: Internet
Author: User

Transferred from:

Http://bbs.51cto.com/thread-68584-1-1.html

 

Subnet Mask and subnet division

Directory:
I. Summary
Ii. Concepts and functions of subnet mask
3. Why do I need to use the subnet mask?
4. How to obtain the Network/Host address using the subnet mask
V. Classification of subnet masks
Vi. subnet addressing technology
7. How to divide subnets and determine subnet masks
VIII. Related judgment methods

I. Summary 

Recently, in my forum, we have many discussions on subnet masks and subnet division, because we have also written a tutorial on IP addresses. For the sake of continuity, I wrote this tutorial on subnet mask and subnet division. It takes some basic knowledge to learn this tutorial (except for the master). I suggest you read the previous tutorial on IP address before reading this tutorial. Are you ready? Let's get started !!

Ii. Concepts and functions of subnet mask 

The subnet mask is a 32-bit binary value applied to TCP/IP networks. It can block part of an IP address and separate the network part from the host part. Based on the subnet mask, the administrator can further divide the network into several subnets.

3. Why do I need to use the subnet mask? 

Although we can say that the subnet mask can separate the network part and host part of the IP address, we still have questions. For example, why do we need to distinguish the network address from the host address? What will happen after the distinction? Well, let's talk about it in detail!

When two computers using the TCP/IP protocol communicate with each other, we perform the 'and' operation by comparing the subnet mask of the local computer with the IP address of the receiver's host, you can get the network number of the target host. Because each host is configured with a local IP address and subnet mask When configuring the TCP/IP protocol, you can know the network number of the host.

By comparing the two network numbers, you can know whether the receiver host is on the current network. If the network number is the same, it indicates that the receiver is on the current network, data packets can be directly sent to the target host through the relevant protocol. If the network number is different, it indicates that the target host is on the remote network, then the data packet will be sent to the vro on the current network. The vro sends the data packet to other networks until it reaches the destination. In this process, you can see that the subnet mask is indispensable!

4. How to obtain the Network/Host address using the subnet mask 

Since the subnet mask is so important, how does it separate the network address and host address in the IP address?

The process is as follows:
1. Convert the IP address and subnet mask to binary;
2. perform the "and" Operation on the IP address and subnet mask in the binary format, and convert the answer to the decimal format to get the network address;
3. Remove the subnet mask in binary form from the back ';
4. perform the "and" Operation on the subnet mask and IP address after the "inverse". Convert the answer to the decimal format to get the host address.

The following is an example:
Assume there is an I P address: 192.168.0.1
Subnet Mask: 255.255.255.0
Converted to binary: I P address 111000000.10101000.20.0000.00000001
Subnet Mask 11111111.111111.1111111111.00000000
Perform the "and" Operation on the two: 11000000.10101000.00000000.00000000
Convert it to decimal: 192.168.0.0
This is the network address of the above IP address, host address, and so on.
Tip: as we observe that the subnet mask above is the default subnet mask of the class C address (I .e., the subnet is not divided), we can see that the network address is the first three parts of the IP address, that is, the first three bytes.

Q:
What? You still don't understand? Ask me why I want to perform the "and" operation instead of other operations? In fact, you should be able to understand the above example carefully.
'1' does not affect the result when performing the 'and' operation. '0' returns 0 when performing the 'and' operation, using this feature of 'and, when the administrator sets the subnet mask, the bits corresponding to the network address on the subnet mask are set to '1', And the other bits are set to '0 ', when it is treated as "and", the network number in the IP address will be retained into the result, and the host number will be set to 0. In this way, the network number will be parsed and the host number will be the same, you only need to first take the subnet mask as the 'back', while doing the 'and '.

V. Classification of subnet masks 

1) default subnet mask:
That is, no subnet is divided. The bits of the corresponding network number are set to 1, and the host number is set to 0.
Default subnet mask of Class A network: 255.0.0.0
Default subnet mask of type B network: 255.255.0.0
Default subnet mask for Class C networks: 255.255.255.0

2) custom subnet mask:
Dividing a network into several subnets requires different network numbers or subnet numbers for each segment. In fact, we can think of host numbers as two parts: Subnet numbers and subnet host numbers. The format is as follows:
IP addresses not divided by subnets: network number + host number
IP address after subnet division: network number + subnet host number
That is to say, after the IP address is divided into subnets, part of the previous host number is assigned to the subnet number, and the rest is the subnet host number.

Vi. subnet addressing technology 

The previous sections introduce some knowledge about subnet masks. Let's take a look at subnet division. Do not think that subnet division has nothing to do with subnet masks. subnet division also relies on subnet masks.

A subnet is a logical network generated on an IP address. It allows a network address to span multiple physical networks, that is, a network address represents multiple networks (obviously this can save IP addresses ). Oh, does it sound strange? How can a network be divided into many subnets inexplicably? So what is the purpose of doing so?

Let me give you an example: for example, if you are a network administrator of a school, your school has four network classrooms in different physical locations, each of which has 25 machines, your task is to configure IP addresses and subnet masks for these machines. You may think this is simple. Apply for four class C addresses, one for each classroom, and then configure them one by one. Well, this is true in theory, but have you ever thought it would be a waste? You have wasted a total of (254-25) x 4 = 916 IP addresses, if all network administrators do this, the IP addresses on the Internet will be exhausted in a very short period of time. Obviously, you cannot do this. You should divide subnets.

To put it bluntly, the subnet division is like this: because after the subnet is divided, the network number of the IP address remains the same, so there is still only one network outside the LAN, that is, the network represented by the network number, but it is another scene inside the network, because the subnet numbers of each of our subnets are different, use the IP address and subnet mask after dividing the subnet (note that the subnet mask here is not the default subnet mask, but the custom subnet mask, which is calculated by the Administrator) when performing the "and" operation, each subnet will get a different subnet address, thus realizing the division of the network (with a different address, of course, it will be able to differentiate each subnet, interesting ).

Subnet addressing technology, I .e., subnet partitioning, helps solve the following problems:
1) huge network address management costs: if you are a class a network administrator, you will surely have a headache in managing a large number of hosts;
2) sharp expansion of the routing table in the vro: When the vro and other vrouters exchange the routing table, the Internet load is very high and the calculation required is also high;
3) Limited IP address space and eventually depletion: this is a crucial issue. The rapid development of the Internet makes the original addressing method unable to adapt, but some IP addresses cannot be fully utilized, this results in waste.
Therefore, it is important and sometimes necessary to divide subnets as needed when configuring a LAN or other networks. Currently, subnet addressing technology has been used by most local networks.

7. How to divide subnets and determine subnet masks 

Before division, you must consider the current network requirements and future demand plans.
Subnetworks are divided mainly from the following aspects:
1. Number of physical segments in the network (that is, the number of subnets to be divided)
2. Number of hosts in each physical segment

To determine the subnet mask:
Step 1: determine the number of physical network segments, convert the number to the binary number, and determine the number of digits n. For example, if you need 6 subnets, the binary value of 6 is 110, and there are 3 digits in total, that is, n = 3;
Step 2: write out the default subnet mask based on your IP address type. For example, Class C, the default subnet mask is 11111111.111111.111111.00000000;
Step 3: Set the positions in the subnet mask corresponding to the first n digits of the host number to 1, and the remaining positions to 0. If n = 3 and
Class C address: The obtained subnet mask is 1111111111.111111.111111.11100000, which is in decimal format.
Class B address: The obtained subnet mask is 11111111.111111.112.160.00000000, which is converted into decimal format to obtain 255.255.224.0.
Class A address: The obtained subnet mask is 11111111.112.160.20.0000.00000000, which is converted into decimal format to get 255.224.0.0.
In addition, because the network is divided into six subnets, it occupies the first three digits of the host number. If it is a class C address, the host number can only be expressed as five digits, therefore, the number of hosts in each subnet = (5 to the power of 2)-2 = 30, the total number of hosts identified by the six subnets will be less than 254. Please note that!

Q:
1. you may have such questions. For example, in the above example, the binary value of 6 is 110, so why do we need to set the positions corresponding to the first n digits of the host number in the subnet mask to 1, instead of replacing the first n digits with the binary 110 of 6?
The answer is: What is the purpose of the subnet mask calculation? It is hoped that it will be able to parse the network number when doing "and, that is to say, the location corresponding to the network number should be 1 (of course, including the location corresponding to the subnet number). Obviously, it is wrong to write 110, if you write this statement, it means that the first two digits of the host number are used as the subnet number. In this way, a maximum of two subnets can be divided, the following describes how to calculate the number of subnets). It is obviously different from the six subnets we originally divided. In this way, you can understand white horse?

2. Careful people may find that the subnet mask is the same for dividing 4 subnets, 5 subnets and 6 subnets, and the same as the subnet mask, is it wrong? Should the three subnet masks be different? Well, this is the case. Because the binary values of and 6 are 3, the three digits in the subnet mask are set to 1, so there is no problem with the Division, it's just a small problem in your understanding. If you divide it into four subnets, you can actually divide it into six subnets, but you only use four of them. For example, if you want to divide 8 subnets, The subnet mask is the same as that obtained by dividing 14 subnets, and all of them occupy 4 digits as the subnet number.

VIII. Related judgment methods 

1) How can I determine whether a subnet is divided?
This problem is very simple. If it uses the default subnet mask, it indicates that no subnet is divided. Otherwise, it must be divided.

2) How do I calculate the subnet address?
The old method is to combine the IP address and subnet mask in binary form, and the result is the subnet address.

3) How do I calculate the host address?
Let alone this. First, take the binary of the subnet mask as an 'back' and then use the IP address as an 'and '.

4) How do I calculate the number of subnets?
We often mention this issue, starting with the subnet mask, there are two main steps:
1. Observe the binary form of the subnet mask and determine the number of digits N as the subnet number;
2. The number of subnets is 2 to the Npower-2. (Why do I subtract 2)
For example, if there is such a subnet mask: the binary value of the subnet mask is:
11111111.11111111.1111111111.11100000 the three times of N = 3 and 2 are 8, indicating that the subnet address may have
The following eight cases:
000
001
010
011
100
101
110
111
However, it represents the network's 000; it represents that the broadcast address's 111 is retained, so it needs to be reduced by 2. Do you understand?

5) How do I calculate the total number of hosts and the number of hosts in the subnet?
Total number of hosts = number of subnets X number of hosts in the subnet
The following example shows how to use a subnet mask:
The above discussion knows that it can be divided into a maximum of six subnets. How many hosts can there be in each subnet? In fact, I have already calculated for you. Because the network is divided into six subnets, it occupies the first three digits of the host number and is a class C address, the host number can only be expressed as a host number of five digits. Therefore, the number of hosts in the subnet is equal to (Power 5 of 2)-2 = 30.
Therefore, we can use this subnet mask to calculate that this network can identify a maximum of 6*30 = 180 hosts (as shown in the following figure, after dividing the subnet, the number of hosts that the entire network can identify will be reduced ).

6) Calculate the IP address range
With a custom subnet mask, we can obtain all possible IP address ranges of the network.
Procedure:
1. Write out the binary subnet address;
2. Convert the subnet address into decimal;
3. Calculate the number of hosts that the subnet can accommodate;
4. Obtain the IP address range (Starting address: Subnet address + 1; ending address: Subnet address + number of hosts)

Assume that a subnet mask is too many hosts. We can see that it can be divided into a maximum of six subnets and the number of hosts in the subnet is 30. All possible IP addresses and the calculation process are as follows:
Subnet -- subnet address (Binary) -------- subnet address ----- actual IP address range
1-11001010.0112.16.20.1010.00100000-202.112.10.32-202.112.10.33-202.112.10.62
2-11001010.0112.16.20.1010.0000000-202.112.10.64-202.112.10.65-202.112.10.94
3-11001010.0112.16.20.1010.01100000-202.112.10.96-202.112.10.97-202.112.10.126
-11001010.0112.16.20.1010.0000000-202.112.10.128-202.112.10.129-202.112.10.158
-11001010.0112.16.20.1010.10100000-202.112.10.160-202.112.10.161-202.112.10.190
-11001010.0112.16.20.1010.11000000-202.112.10.192-202.112.10.193-202.112.10.222

Subnet Mask and subnet division

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.