Reprinted: Subnet mask and subnet division

table of Contents

Theoretical basis of subnetting

Why subnetting

  • Reduce network traffic, no matter what kind of traffic, we want it to be less, and the same is true for network traffic. If there is no reliable router, network traffic may cause the entire network to stop, but with a router, most of the traffic will stay in the local network, and only packets destined for other networks will traverse the router. The router adds broadcast domains. The more broadcast domains there are, the smaller the subnet domains can be easily divided into each broadcast, and the less network traffic in each network segment.

  • Optimize network performance, which is the result of reducing network traffic.

  • Simplify management. Compared with a huge network, it is easier to find and isolate network problems in a series of connected small networks.

  • It helps to cover large geographic areas. WAN links are much slower and more expensive than LAN links; a single large-span large-scale network may have problems in all aspects mentioned above, and multiple small networks are connected Can improve the efficiency of the system.
    ## Clear requirements When
    we create a subnet, it must be created according to certain requirements. This requirement is our actual network requirement. Generally, we follow the steps below to clarify our network requirements:
    (1) Determine the number of network IDs required:

  • One for each LAN subnet;

  • One for each WAN connection.

(2) Determine the number of hosts required for each subnet:

  • One for each TCPIIP host;
  • One for each router interface.

(3) Based on the above requirements, determine the following:

  • A subnet mask for the entire network;
  • The unique subnet ID of each physical network segment;
  • The host range of each subnet.

Knowledge points

  • IP address: We need to know that the network address is divided into three categories: A, B, C, and know that the ip address is composed of network segment number (net_id) + host number (host_id). If you want to know more about ip address, please refer to my article Blog post: Why is the ip found by Baidu different from that found by ipconfig; explain the public IP and private IP; explain the network classification ABC;

  • Subnet mask: For the subnet division scheme to work, each machine in the network must know which part of the host address is the subnet address. This is achieved by assigning a subnet mask to each machine. The subnet mask is a 32-bit value that allows the receiver of the IP packet to distinguish the network ID part of the IP address from the host ID part. The network administrator creates a 32-bit subnet mask composed of 1 and 0, where 1 indicates that the corresponding part of the IP address is a network address or a subnet address.

Not all networks need a subnet, which means that the network can use the default subnet mask. This is equivalent to saying that the IP address does not contain the subnet address. The following table lists the default subnet masks for Class A, Class B, and Class C networks.
Write picture description here

  • CIDR: (Classless Inter-Domain Routing). We need to understand this network representation. The format is such as: 192.168.10.32/28. The first number is our network address, the next 28 means using 28 bits to represent the network bit, and 32-28=4 bits to represent the host bit. Through this notation, we can clarify two pieces of information:
    • Network address: 192.168.10.32
    • Subnet mask: 255.255.255.240

Through the following table, we can clarify the relationship between the subnet mask and the slash notation,
Write picture description here
Write picture description here
where /8-/15 can only be used for type A networks, /16-/23 can be used for type A and B networks, and /24 -/30 can be used for Class A, Class B and Class C networks. This is one of the major reasons why most companies use Class A network addresses, because they can use all subnet masks and have the greatest flexibility in network design.

Frequently Asked Questions about Subnetting

  • How many subnets will the selected subnet mask create?
    2^x, where x is the number of host bits borrowed by the subnet mask. For example: 192.168.10.32/28, we know that the default subnet mask of class C ip is: 255.255.255.0, and from the above CIDR knowledge, we know that the actual subnet mask of this ip is: 255.255.255.240. Originally the last byte should be 0 (00000000), but now it is 240 (11110000). Therefore, it borrows 4 bits of the host bit to serve as the network bit.
    ** If you don't understand this place, you can take a look at the actual case behind me **
  • How many hosts can each subnet contain?
    2^y-2, where y is the number of bits of the host that has not been borrowed. -2 is because the part where the host bits are all 0 is the network segment number (Net_id) of this subnet, and the part where all 1s are the broadcast address of this network segment.
  • What are the legal subnets?
    Calculate the step size (increment) of the subnet. An example is 256-192 = 64, that is, when the subnet mask is 192, the step size is 64. Start from 0 and continue to increase the drama until it reaches the subnet mask value. The intermediate result is the subnet, namely 0, 64, 128, and 192.
  • What is the broadcast address of each subnet? The
    host bit is all 1 is the broadcast address of the subnet. Generally we calculate this: the broadcast address is always the number before the next subnet. The subnets are determined as 0, 64, 128 and 192, for example, the broadcast address of subnet 0 is 63, because the next subnet is 64; The broadcast address of subnet 64 is 127, because the next subnet is 128, and so on. Remember, the broadcast address of the last subnet is always 255
  • What host addresses can each subnet contain?
    Legal host addresses are located between the two subnets, except for addresses with all 0s and all ones. For example, if the subnet number (network segment number) is 64 and the broadcast address is 127, the legal host address range is 65-126, which is the number between the subnet address and the broadcast address.

Analysis of subnetting examples

Example analysis of class C subnet division

First of all, we need to know all the subnet masks available for class C:
Write picture description here

Know the network address and subnet mask, find the result of subnet division

  • Case 1:
    255.255.255.128 (/25)
    The binary representation of 128 is 10000000, only 1 bit is used to define the subnet, and the remaining 7 bits are used to define the host. Here, the class C network 192.168.10.0 will be divided into subnets.
    Network address=192.168.10.0
    Subnet mask=255.255.255.128
    Answer the five major questions:
    • How many subnets?
      In 128 (10000000), the number of digits with the value of 1 is 1, and one host bit is borrowed, so the answer is 2^1=2.
    • How many hosts in each subnet?
      There are 7 host bits with the value o (10000000), and there are 7 host bits left, so the answer is 2^7-2 = 126 hosts.
    • What are the legal subnets?
      256 -128 = 128. That is, the increment of the subnet is 128. So the subnet is 0 and 128
    • What is the broadcast address of each subnet? In
      the numbers before the next subnet, all the host bits have the value 1, which is the broadcast address of the current subnet. For subnet 0, the next subnet is 128, so its broadcast address is 127
    • What legal host addresses does each subnet contain? The
      legal host addresses are the numbers between the subnet address and the broadcast address. To determine the host address, the easiest way is to write the subnet address and broadcast address, so that the legal host address is obvious.

Below I use diagrams and drawings to show the subnet division, in the hope that everyone can have a deeper understanding.
Write picture description here
Write picture description here

  • Case 2:
    255.255.255.192 (/26)
    In the second example, we will use the subnet mask 255.255.255.192 to subnet the network 192.168.10.0.
    Network address = 192.168.10.0
    Subnet mask = 255.255.255.192
    Let's answer the five major questions below
    • How many subnets?
      In 192 (11000000), the number of digits with a value of 1 is 2, so the answer is 2^2=4 subnets.
    • How many hosts per subnet? There are 6 host bits with the value o(11000000), so the answer is 2^6-2=62 hosts.
    • What are the legal subnets?
      256 -192 = 64. So the step size [increment] of the subnet is 64, so the subnet is 0, 64, 128 and 192
    • What is the broadcast address of each subnet? In
      the numbers before the next subnet, all the host bits have the value 1, which is the broadcast address of the current subnet. For subnet 0, the next subnet is 64, so its broadcast address is 63. And so on.
    • What are the
      legal host addresses ? The legal host address is the number between the subnet address and the broadcast address. To determine the host address, the easiest way is to write the subnet address and broadcast address, so that the legal host address is obvious.

Below I use diagrams and drawings to show the answers to these five questions more vividly.
Write picture description here
Write picture description here

  • Case 3:
    Starting from this case, I will not answer these five questions one by one. Most of the thoughts are repeated. I only give answers to questions and diagrams.
    255.255.255.224 (/27)
    This time we will use the subnet mask 255.255.255.224 to subnet the network 192.168.10.0.
    Network address = 192.168.10.0
    Subnet mask = 255.255.255.224 The
    following table shows the results of subnetting of the chart type
    Write picture description here

  • Case 4:
    255.255.255.240 (/28)
    Let’s look at another example:
    network address=192.168.10.0
    subnet mask=255.255.255.240
    subnet division result:
    Write picture description here

  • Case 5:
    255.255.255.248 (/29)
    Continue to practice:
    Network address=192.168.10.0
    Subnet mask=255.255.255.248
    Subnet division result:
    Write picture description here
    ### Known IP address and subnet mask for subnet division
    **Case 1: **
    Known ip address = 192.168.10.33, subnet mask = 255.255.255.224, find the subnet division of the network.

  1. Find the subnet increment:
    Since the subnet mask is 224, the subnet step size is 256-224=32
  2. What are the legal subnets:
    From the above, the step size of the subnet is 32. So the subnet is 0, 32, 64, etc.
  3. Find the subnet number corresponding to the IP address.
    Because the host address 33 is located between the subnets 32 and 64, it belongs to the subnet 192.168.10.32
  4. Find the corresponding broadcast address of the subnet: the
    next subnet is 64, so the broadcast address of subnet 32 ​​is 63 (the broadcast address is always the number before the next subnet).
  5. Seek the legal host address range:
    33~62 (the number between the subnet and the broadcast address).

Case 2:
ip address=192.168.10.174
subnet mask=255.255.255.240. What is the legal host address range?
Answer: The subnet mask is 240, so subtract 240 from 256. The result is 16, which is the subnet mask. Net increment. To determine the subnet to which you belong, you only need to increase by 16 from zero, and stop after the host address 174 is exceeded: 0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, etc. The host address 174 is located between 160 and 176, so the subnet to which it belongs is 160. The broadcast address is 175, and the legal host address range is 161~174.
Case 3:
ip address=192.168.10.17
subnet mask=255.255.255.252 Which subnet does this IP address belong to? What is the broadcast address of this subnet?
Answer: 256 -252= 4, so the subnets are 0, 4, 8, 12, 16, 20, etc. (Unless otherwise specified, it always starts from 0). The host address 17 is located between the subnets 16 and 20, so it belongs to the subnet 192.168.10.16, and the broadcast address of this subnet is 19, and the legal host address range is 17-18.
##Class B address subnetting example
CIDR address table
Write picture description here
that can be used for class B address: Note: In class B address, 16 bits can be used for host address. This means that up to 14 bits can be used for subnetting, because at least 2 bits need to be reserved for host addressing. The use of /16 means that no subnetting is performed on the Class B network, but it is a usable subnet mask.

Know the network address and subnet mask to find the subnet division

Case 1:
255.255.128.0 (/17)
network address=172.16.0.0
subnet mask=255.255.128.0

  • How many subnets?
    2^1 = 2 (same as type C network) borrowed a host bit.
  • How many hosts per subnet?
    2^15 -2 = 32766 (a total of 15 host bits, 7 bits in the third byte, and 8 bits in the fourth byte).
  • What are the legal subnets?
    256 -128 = 128, so the subnets are 0 and 128. Since the subnetting is done in the third byte, the subnet numbers are actually 0.0 and 128.0
  • What is the broadcast address of each subnet? (Same as class C, the broadcast address is always the number before the next subnet)
  • What is the legal host address? (The address between the subnet number and the broadcast address is the legal host address)

Use a chart to show the above parameter
Write picture description here
Case 2:
255.255.255.128 (/25)
This is a very difficult but very suitable subnet combination of production environment
Network address = 172.16.0.0
Subnet mask = 255.255.255.128

  • How many subnets?
    2^9=512. A total of 9 host slots were borrowed
  • How many hosts per subnet?
    2^7-2 = 126. There are 16-9=7 host bits
  • What are the legal subnets?
    This is the tricky part. The increment of the subnet in this place should be 256-255=1, so the possible values ​​of the third byte are 0, 1, 2, 3...255; but don’t forget, there is a subnet in the fourth byte. Net bit. Remember how to deal with the situation where there is only one subnet bit in a class C network? The processing method is the same here. That is to say, each value of the third byte has two cases of 0 and 128. For example, if the value of the third byte is 3, the corresponding two subnets are 3.0 and 3.128. So there are a total of 512 subnets.
  • What is the broadcast address of each subnet? (The previous digit of the next subnet address)
  • What is the legal host address? (The host address between the subnet address and the broadcast address of the subnet is the host address)
    The following chart lists the subnet division results of this example:
    Write picture description here

Know the IP address and subnet mask to find the subnet division

When using cidr to indicate subnetting, the number of network bits is greater than 24, such as /25, /27. We only need to consider the fourth byte. When <=24, we only need to consider the third byte, because the host bit of the fourth byte is not borrowed and does not participate in subnetting.

  • Question: Which subnet does 172.16.10.33/27 belong to? What is the broadcast address of this subnet?
    Answer: Only the fourth byte needs to be considered here. 256-224=32, so the change of the fourth byte is 0, 32, 64... 33 is between 32 and 64, but part of the subnet number is in the third byte, so the
    answer is that the address is in subnet 10.32. Since the next subnet is 10.64, the broadcast address of this subnet is 172.16.10.63
  • Question: IP address=172.16.66.10; subnet mask=255.255.192.0(/18) Which subnet belongs to? What is the broadcast address of this subnet?
    Answer: The third byte needs to be considered here, not The fourth byte. 256-192=64, so the subnet is 0.0, 64.0, 128.0, etc. The subnet it belongs to is 172.16.64.0. Since the next subnet is 128.0, the broadcast address of this subnet is 172.16.127.255.
  • Question: IP address=172.16.50.10; Subnet mask=255.255.224.0(/19) Which subnet belongs to? What is the broadcast address of this subnet?
    Answer: Only the third byte needs to be considered. 256-224=32, so the subnet is 0.0, 32.0, 64.0, etc. (The subnet to which it belongs is 172.16.32.0, so its broadcast address is 172.16.63.255, because the next subnet is 64.0.
  • Question: IP address=172.16.45.14; subnet mask=255.255.255.252(/30) Which subnet belongs to? What is the broadcast address of this subnet?
    Answer: Which byte should be considered here? Fourth. 256-252=4, so the subnet is 0, 4, 8, 12, 16, etc. The subnet to which it belongs is 172.16.45.12, and the broadcast address of this subnet is 172.16.45.15, because the next subnet is 172.16.45.16.
    ## Example of
    Class A Subnet Division The subnet division of Class A network is no different from Class B and Class C networks, but it needs to deal with 24 bits, while Class B and Class C networks need to deal with 16 bits and 8 bits.
    All subnet masks that can be used for class A:
    Write picture description here

Know the network address and subnet mask to find the subnet division

Case 1: When
255.255.240.0(/20)
network address=10.0.0.0 and
subnet mask=255.255.240.0(/20), 12 bits are used for subnetting, and the remaining 12 bits are used for host addressing.

  • How many subnets?
    2^12=4096.
  • The number of hosts per subnet?
    2^12-2=4094
  • What are the legal subnets?
    Which bytes need to be considered? The borrowed host number comes from the second and third bytes, so the second and third bytes should be considered. In the second byte, the subnet The interval of the network number is 1; in the third byte, the subnet number is 0, 16, 32, etc., because 256-240=160
  • What is the broadcast address of each subnet?
  • What is the legal host address? The
    specific division is shown in the table:
    Write picture description here

Case 2:
Network address=10.0.0.0
Subnet mask=255.255.255.192(/26)
This example uses the second, third, and fourth bytes to divide the subnet.

  • How many subnets?
    2^18=262144.
  • The number of hosts per subnet?
    2^6-2=62.
  • What are the legal subnets?
    In the second and third bytes, the interval between subnet numbers is 1, and in the fourth byte, the interval between subnet numbers is 64
  • What is the broadcast address of each subnet?
  • What is the legal host address?

Only the last part of the subnetting is listed below
Write picture description here

Know the IP address and subnet mask to find the subnet division

The last case:
ip address=10.1.3.65/23
Find the subnet corresponding to the ip address and the legal host address and broadcast address of the subnet:
**Answer:** First of all, if you don’t know the subnet corresponding to /23 Code, you can’t answer this question. Its corresponding subnet mask is 255.255.254.0. The byte that needs attention here is the third. 256-254=2, so the subnet number of the third byte is 0, 2, 4, 6, etc. In this problem, the host is located in subnet 2.0, and the next subnet is 4.0, so the broadcast address of this subnet is 3.255. Any address in 10.1.2.1~10.1.3.254 is a legal host in this subnet address.
# Summary
All are based on Class C subnetting as a basis, if we can break through this difficulty c class will certainly slow connection subnetting. In addition, a large number of examples in this blog post are from the "CCNA Study Guide Book". If you want to learn more about computer networks, you can download this book: CCNA Study Guide download link
**ps: Blogging is not easy, please indicate the source for reprinting , By Xiaoxiaodai**

Reprinted source: https://blog.csdn.net/gui951753/article/details/79412524

Guess you like

Origin blog.csdn.net/weixin_40734030/article/details/114011960