How to Divide a subnet

The following uses class C private IP address segment 192.168.0.0 to 192.168.0.255 as an example

1. First introduce three proprietary terms (important concepts) and convert two IP addresses into binary for easy understanding

Network: 192.168.0.0:11000000.10101000.00000000.00000000 Broadcast: 192.168.0.255: 11000000.10101000.00000000.11111111 NetMask: 255.255.255.0 11111111.11111111.11111111.00000000 Network: Broadcast: indicates the Broadcast IP address. The binary host ID is 1. In this example, the binary host ID is 192.168.0.255Copy the code
  • IPv4 has 32 bits, including the network number and host number. NetMask is used to distinguish the network number and host number. 1 indicates the network number and 0 indicates the host number

  • In this example, the first 24 bits of the network number are used, and the last eight bits of the host number are used. That is, the number of IP addresses that can be added to the host is 2^8-2, that is, 254

  • Therefore, the essence of subnets is to change the NetMask


2. Divide the network segment into two network segments

The first 25 bits of the host number and the last 7 bits of the host number are assigned to the Network number. Network indicates the Network segment. The 25th bit can be either 0 or 1, that is, it can represent two Network segments

When the 25th bit of Network is 0, the subnets are divided as follows

Network: 0000000 192.168.0.0 11000000.10101000.00000000.0 Broadcast: 1111111 192.168.0.127 11000000.10101000.00000000.0 | -- -- -- -- -- -- -- -- -- -- Net_ID -- -- -- -- -- -- -- -- -- -- - | - host - | Netmask: 0000000 255.255.255.128 11111111.11111111.11111111.1Copy the code

When the 25th bit of Network is 1, the subnets are divided as follows

Network: 0000000 192.168.0.128 11000000.10101000.00000000.1 Broadcast: 1111111 192.168.0.255 11000000.10101000.00000000.1 | -- -- -- -- -- -- -- -- -- -- Net_ID -- -- -- -- -- -- -- -- -- -- - | - host - | Netmask: 0000000 255.255.255.128 11111111.11111111.11111111.1Copy the code
  • In other words, a Network can be divided into two Network segments by adding one bit. If two bits are added, the Network has four values, that is, it can be divided into four Network segments.
  • Accordingly, the finer the division, the fewer host numbers can be assigned to each network segment

CIDR (Classless Interdomain Routing)

The Network/Netmask 192.168.0.0/255.255.255.0 192.168.0.0/24 / / Network number 24, it can be saidCopy the code

CIDR is simply another representation of network division. It can also represent a network segment, and CIDR does not discriminate between IP levels. For example, if 256 class C networks are represented as a network segment, this network segment becomes a class B network