Subnet division method

Source: Internet
Author: User

Subnet division & subnet mask Calculation Method
An Internet organization defines five IP addresses, which are used for host A, host B, and host C. There are 126 Class A networks, and each class A network may have 16,777,214 master nodes.
Machines in the same broadcast domain. It is impossible to have so many nodes in the same broadcast domain. The network will be saturated due to broadcast communication, resulting in 16,777,214 addresses.
Most of them are not allocated, resulting in waste. On the other hand, with the expansion of Internet applications, there are fewer and fewer IP Address resources. To implement a smaller broadcast domain and better
Using each bit of the host address, you can further divide a class-based IP network into smaller networks. Each subnet is defined by the router and assigned a new subnet network address,
The subnet address is created from the host part of the class-based network address. After dividing the subnet, you can use a mask to hide the subnet so that the network remains unchanged from the outside,
This is the subnet mask.
1. Subnet Mask
RFC 950 defines the use of the subnet mask. The subnet mask is a 32-bit binary number, and all the bits corresponding to the network address are set to 1, all locations corresponding to the host address are set
0. The default subnet mask of the-class network is 255.0.0.0, the default subnet mask of the B-class network is 255.255.0.0, and the default subnet mask of the C-class network is 25.
5.20.255.0. Perform the logical "and" Operation on the subnet mask and IP address in bit to obtain the network address of the IP address. The remaining part is the host address.
The network address and host address in the P address. The subnet mask is commonly expressed in dotted decimal notation. We can also use the network prefix to represent the subnet mask, that is, "/<number of network addresses> ".
For example, 138.96.0.0/16 indicates that the subnet mask of Class B network 138.96.0.0 is 255.255.0.0.
The subnet mask informs the router which part of the address is the network address and which part is the host address, so that the router can correctly determine whether any IP address is in this segment.
. For example, there are two hosts. The IP address of Host 1 is 222.21.160.6, The subnet mask is 255.255.255.192, And the IP address of host 2 is 222.21.160.73.
The subnet mask is 255.255.255.255.192. To send data to host 2, you must first determine whether the two hosts are in the same CIDR block.
HOST 1
222.21.160.6: 11011110.00010101.1000000.00000110
255.255.255.192: 11111111.11111111.11111111.1120.00
The bitwise logic and calculation result is: 11011110.00010101.1000000.00000000.
Host 2
222.21.160.73: 11011110.00010101.101_0.01001001
255.255.255.192: 11111111.11111111.11111111.1120.00
The bitwise logic and calculation result is: 11011110.00010101.1000000.0000000.
The two results are different. That is to say, if the two hosts are not in the same network, the data must be sent to the default gateway first and then to the network where the two hosts are located. So, if host 2's
What happens if the subnet mask is set to 255.255.255.255.128 by mistake?
Let's "match" the IP address of host 2 with the incorrect subnet mask ":
222.21.160.73: 11011110.00010101.101_0.01001001
2017100000000128: 11111111.11111111.11111111.0000000
The result is 11011110.00010101.1000000.00000000.
The result is the same as the network address of the host. HOST 2 and host 2 are considered to be in the same network, and data is not sent to the default gateway, but directly transmitted in this network. Because
The two hosts are not actually in the same network, and the data packets will be cyclically in the subnetwork until timeout and discarding. Data cannot arrive at the target machine correctly, resulting in network transmission errors.
In turn, if the subnet mask of the two hosts is originally set to 255.255.255.255.128, And the subnet mask of host 2 is set to 255.255.255.255.192, when host 2 always sends data
If the IP address is in a different network with the incorrect subnet mask, the communication between machines in the same subnet is considered as cross-network transmission, and data
All packages are delivered to the default gateway, which will inevitably increase the burden on the default gateway, resulting in reduced network efficiency. Therefore, the subnet mask cannot be set at will. The subnet mask setting is related
The subnet.
2. subnet division and mask settings
Subnet division is achieved by dividing the original network into several subnets by using several host locations of IP addresses as subnet addresses. When dividing subnets, The subnet address is borrowed
As the number of hosts increases, the number of subnets increases, and the number of available hosts in each subnet decreases. Take the class C network as an example. The original 8-bit host space is 2 ^ 8, that is, 256 host locations
The default subnet mask 255.255.255.0. Borrow 1-bit host space to generate 2 ^ 1 subnet, each subnet has 2 ^ 7 host addresses; borrow 2-bit host space to generate 2 ^ 2 subnets,
Each subnet has 2 ^ 6 host addresses ...... Based on the number of hosts borrowed by the subnet ID, we can calculate the number of subnets, masks, and number of hosts in each subnet. The list is as follows:
Number of subnets
Subnet count
Subnet Mask (Binary)
Subnet Mask (decimal)
Number of hosts per Subnet
1 ~ 2
1
11111111.111111.1111111111.0000000
2017100000000128
128
3 ~ 4
2
11111111.111111.1111111111.1120.00
Maximum capacity limit 192
64
5 ~ 8
3
11111111.111111.1111111111.11100000
255.255.255.224
32
9 ~ 16
4
11111111.111111.1111111111.11110000
20171000000000000240
16
17 ~ 32
5
11111111.111111.1111111111.11111000
255.255.255.248
8
33 ~ 64
6
11111111.111111.1111111111.11111100
255.255.255.252
4

In the class C network shown in the table above, if the subnet occupies 7-bit host bit, only one host bit is left, whether set to 0 or 1, it means that the host space is all 0 or all 1. Because the host space is full
0 indicates the current network, and all 1 is reserved as the broadcast address. In this case, the subnet actually does not have the available host address, so the host bit should be at least two.
The table above summarizes the steps for dividing subnets or calculating the subnet mask:
2.1 determine the number of subnets to be divided and the number of hosts in each subnet.
2.2 obtain the number of subnets that correspond to the number of BITs N and the number of hosts that correspond to the number of BITs M.
2.3 The Atomic netmask for the IP address. The subnet mask after dividing the IP address into subnets is obtained by dividing the IP address from the first N positions 1 or the last M positions 0.
For example, for a Class B network, 135.41.0.0/16 must be divided into 20 networks that can accommodate 200 hosts. Because 16 <20 <32, that is, 2 ^ 4 <20 <2 ^ 5
You can divide a five-bit host into 32 subnets to meet the requirements of 20 subnets. The default subnet mask of the B-type network is 255.0.0, And the binary value is 11111.
111.111111.20.2.16.00000000. The subnet now occupies five more host bits. According to the definition of the subnet mask, the subnet mask after the subnet is divided should be 11111111.11
111111.11111000.00000000, which should be converted to decimal format 248.0. Now let's take a look at the number of hosts in each subnet. The available host space in the subnet also has 1
1-bit, 2 ^ 11 = 2048. If the host space is completely 0 and 1, 2046 Host IDS can be allocated, and the subnet can accommodate 200 hosts, follow these steps
Divide subnets. Each subnet can accommodate a larger number of hosts than required, resulting in a waste of IP Address resources. To make more effective use of resources, we can also
The number of hosts required for the subnet. In addition, for the above example, 128 <200 <256, that is, 2 ^ 7 <200 <2 ^ 8, that is, the 8-bit master is retained in the 16-bit host bit of the B-class network.
The other 16-8 = 8 bits are considered as subnet bits. You can set the Class B network to 138. 96.0.0 is divided into 256 (2 ^ 8) units, which can accommodate 256-1-1 = 253 units (remove all 0, all 1, and
The subnet of the host. In this case, the subnet mask is 11111111.111111.00000000 and the decimal value is 255.255.0.
In the above example, we divided the subnets based on the number of subnets and the number of hosts. Two different results can meet the requirements. In fact, the subnet occupies 5 ~ 8-bit host Space
The obtained subnet can all meet the above requirements. In actual work, what principles should we use to determine how many hosts should we use?
When dividing subnets, consider not only the current needs, but also the number of subnets and hosts required in the future. Use more host bits than the subnet mask to obtain more sub-
Network, which saves IP Address resources. If you need more subnets in the future, you do not need to re-allocate the IP addresses, but the number of hosts in each subnet is limited. Otherwise, the subnet mask is used less
The number of hosts in each subnet can increase, but the number of available subnets is limited. Generally, a network has too many nodes, and the network will communicate with each other through broadcast.
However, the increase in the number of hosts in the network is limited. That is to say, when conditions permit, more host locations will be used for subnet locations.
To sum up, the subnet mask settings are related to the division of subnets. The subnet mask is set differently and the obtained subnet is different. Each subnet can accommodate different numbers of hosts. If
Errors may cause data transmission errors.
Origin: http://www.tianyablog.com/blogger/post_show.asp? BlogID = 674972 & PostID = 7378389

Attach: Calculate the subnet mask.
1. Use the number of subnets for Calculation
Before obtaining the subnet mask, you must first understand the number of subnets to be divided and the number of hosts required in each subnet.
1) convert the number of subnets to binary representation.
2) The number of digits to obtain the binary value is N.
3) obtain the subnet mask of the IP address, and obtain the subnet mask of the IP address.
To divide Class B IP address 168.195.0.0 into 27 subnets:
1) 27 = 11011
2) the binary is five digits, N = 5
3) set the subnet mask of the Class B address to the first 5 locations 1 of the host address of 255.255.0.0 to obtain 255.255.248.0, that is, 168.195.0.0 of the Class B IP address divided into 27 subnets.
Subnet Mask.
Ii. computing using the number of hosts
1) convert the number of hosts to binary representation
2) If the number of hosts is less than or equal to 254 (note that the reserved two IP addresses are removed), the number of binary digits of the host is N. N8 indicates the host address.
It will occupy more than 8 digits.
3) Use 255.255.255.255.255 to set the number of host addresses of this type of IP address to 1, and then set all the N digits to 0 from the forward, that is, the subnet mask value.
To divide B (c) class IP address 168.195.0.0 into several subnets, each subnet contains 700 hosts (17 ):
1) 700 = 1010111100
2) the binary is ten digits, N = 10 (1001)
3) set all the host addresses of the subnet mask 255.255.0.0 for this Class B address
1. Obtain 255.255.255.255, and then forward the value from the back to the left to 0, that is: 11111111.1111111100.00000000 (10 0), that is, 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.
Attach: a method that easily calculates the subnet mask. (I personally think it is useless !!! Master the above methods !!!)
Everyone should know how many hosts are between the power 0 and the power 10 of 2? Let us also say that they are:
1 2 4 8 16 32 64 128 256 512 1024.
If you want only five IP addresses in each subnet to be available to machines, you need to prepare at least seven IP addresses for each subnet, because two unavailable networks must be added.
Network and broadcast ip, so you need to select the nearest one, that is, eight, that is, select eight ip addresses for each subnet. Okay. Now you can calculate the mask.
The last mask is 256 minus the number of IP addresses required by each subnet. In this example, 256-8 = 248.
Some ip addresses are unavailable. See 0-7, 8-15, 16-23,24-31, the 0, 7, 8, 15, 16, 23, 24, 31 (and so on) on the top cannot be used,
You should use an IP address between two digits. That is an available IP address of a subnet. What's wrong? Don't believe it? It's too simple...
Let me try again. Let's take the 200 machines into 4 sub-networks for example.
There are 200 machines and 4 subnets. Each subnet has 50 machines and is set to 192.168.10.0 and class c ip addresses. The large Subnet Mask should be 255.255.255.0.
We need a molecular network, so according to the above, we use 32 IP addresses and one sub-network is not enough. We should use 64 IP addresses for each subnet (62 of them are available, enough ), and then use my
Method: The subnet mask should be 256-64 = 192, then the total subnet mask should be: 255.255.255.255.192. Don't believe it? Calculation: 0-63,64-127,128-191,192-255
In this way, you can set the four regions to the machines in the four subnets, isn't it easy? You don't need software... Haha .. I hope you can understand what I write.
....
The re-division of the subnet is like this: for example, a class c address is 192. 168. 1. 0/24. The available host addresses in this subnet are 255-2 = 253, one network address and one wide range
The multicast address cannot be assigned to the host. The network address is 1. 0. The broadcast address is 1. 255.
If some of my machines and ip addresses are in this subnet, they can ping each other without going through the route because it is a communication within the subnetwork. If my rules
The rule is as follows: each department of the company occupies one subnet. For security reasons, departments cannot communicate with each other. What if one department has only two machines? A Class c
If the subnet has 253 addresses, will those two machines be occupied? Is that a waste? The private network address is enough. You can use it whenever you want. If it is a public network address
Address?
So there is a subnet division, that is, dividing a subnet into more small subnets, but the number of subnets is defined as the Npower of 2, that is, a subnet can be divided into 2, 4
, 8, 16, 32, 64, and 128 subnets. If they are divided into 2, the original 256 addresses except 2 equals 128, that is, each small subnet has 128 addresses, and the mask is originally 2.
The four-digit subnet is now divided into two small subnets, so the mask is increased by 1 and becomes longer. The mask is changed to 25, which is called vlsm. If it is divided again, that is to say, in the original foundation
It is divided into four subnets (you can also divide the 25-bit subnet once again, just like cell division .), In this case, 256, except 4, is 64, that is, a small subnet has 64 addresses,
The mask is added to 1 and changed to 26 again. Similarly, the mask is divided into 32 subnets (mask 27), 16 (28), and 8 (29 ), 4 (30), 2 (31), 1 (32
), The 31-bit subnet has no available addresses, only one network address and one broadcast address (the first address at the beginning of each subnet is the network address, and the last one is the Broadcast
Address, Which is required). 32-bit is not called the network, but a single host. If 24, 25, 26, and so on are not used to represent the mask, they can also be expressed by the value of 256-Number of subnet addresses (see
Upstairs ).
In this way, if a department with 28 hosts is assigned a subnet, what about that subnet? Let's see, 1, 2, 4, 8, 16, 32 ........ 28 between 16 and
Therefore, only one subnet greater than 32 can be allocated to each other. To save the address, a 32 address is allocated. Therefore, the mask is 256-32 = 224, good, 25
6 Tib 32 = 8, so 8 subnets are divided, that is, 3 times, so 24 + 3 = 27. Address range: 0-31,32-63,64-127,128-159,160-191,192-22
3,224-256, Which subnet can be divided, but the mask must be included. Otherwise, the default abc Address Mask is used! Just like cutting tofu, a piece of big, cut into several
Small, small, and can be further divided, but it must be the Npower of 2.

This article is from "Internet and IT"

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.