Subnet mask and CIDR in IP address

Convert the conventional subnet mask to binary, and you will find that the format of the subnet mask is consecutive binary 1s and consecutive 0s, where the 1 part of the subnet mask represents the network ID, and the 0 part of the subnet mask represents the host ID. For example, 255.255.0.0 converted to binary is 11111111 11111111 00000000 00000000.

In the previous example, why not use consecutive 1 parts to represent the network ID, and consecutive 0 parts to represent the host ID? The answer is yes, the IP addressing technology using this scheme is called Classless Inter-Domain Routing (CIDR). CIDR technology uses the continuous 1 part in the subnet mask to represent the network ID, and the continuous 0 part to represent the host ID. For example, if there are 2000 computers in the network, only 11 bits are needed to represent the host ID, and 21 bits are used to represent the network ID, then the subnet mask is expressed as 11111111.11111111.11100000.00000000, and converted to decimal is 255.255.224.0. Check the location of the IP address At this point, the network will contain 2046 computers, which will neither cause waste of IP addresses nor use routers to connect to the network, increasing the amount of additional management and maintenance.

CIDR representation method: the number of digits of IP address/network ID, such as 192.168.23.35/21, where 21 bits are used to represent the network ID.

Example 1: 192.168.23.35/21

Subnet mask: 11111111 11111111 11111000 00000000 is 255.255.248.0

Network ID: 192.168.00010111.0 (the red part of the third byte indicates the network ID, the others indicate the host ID, and the network ID means that the network ID part remains unchanged and the host ID becomes 0), then the network ID is 192.168.16.0

Starting IP address: 192.168.16.1 (the host ID cannot be all 0, all 0 means the last bit of the network ID is 1)

End IP address: 192.168.00010111.11111110 (the host ID cannot be all 1, all 1 means local broadcast), then the end IP address is: 192.168.23.254.

Example 2: Divide 163.135.0.0 into 16 subnets, and calculate the network ID, subnet mask, and start and end IP addresses of the first two subnets.

Step 1: Express 163.135.0.0/20 in CIDR, then the subnet mask is 255.255.240 (11110000).0.

Step 2: First network ID (subnet mask and IP address AND operation): 163.135.0.0

First IP address: 163.135.0.1 End IP address: 163.135.15.254;

Step 3: Second Network ID: 163.135.16.0

First IP address: 163.135.16.1 Ending IP address: 163.135.31.254.

 

Guess you like

Origin blog.csdn.net/TTmanghe/article/details/131069045