Calculation of CIDR blocks and number of hosts of Class A, Class B, and class C IP addresses

Source: Internet
Author: User

Calculation of CIDR blocks and number of hosts of Class A, Class B, and class C IP addresses

 

An IP address is a 32-bit binary number consisting of four eight-bit fields. Each IP address consists of two parts: the network ID and the host ID.

 

The first eight digits of Class A addresses are network IDs. The last 24 digits are the Host IDS. The CIDR Block and number of hosts are calculated as follows:

AClass CIDR Block calculation:

According to regulations, the network ID of a Class A address must start with "0. The number of CIDR blocks should be 0xxxxxxx. yyyyyyyy, which is followed by seven digits. Because it is a binary number, the number of CIDR blocks should be:

27, that is, the 7 power CIDR block of 2 is equal to 128, that is, the CIDR block should be between 0 and. However, in network space computing, "2" is required, because two reserved addresses must be deducted: the binary values are all "0" and the total values are "1. "0" is the network number, and "1" is the broadcast number. Therefore, the CIDR Block of the Class A address is 1-126.

ACompute the number of hosts:

Because the last 24 bits are the Host IDS, the number of hosts should be 224, that is, the 24 power of 2

224 = 412 = 166 = 2563 = 16777216. After two reserved addresses are deducted, the maximum number of hosts is 16777214.

To sum up, the range of Class a ip addresses should be 1.0.0.1 ~ 126.00000000254

Red indicates the network ID, and Green indicates the host ID.

 

BClass CIDR Block calculation:

According to regulations, the network ID of a Class A address must start with "10. The number of CIDR blocks should be 10xxxxxx. XXXXXXXX. yyyyyyyy. yyyyyyyy, which is followed by 14 digits. Because it is a binary number, the number of CIDR blocks should be:

214, that is, the 14 Power CIDR blocks of 2, equal to 16384. after deducting two reserved addresses with full "0" and full "1", the B-class network can have 16382 CIDR blocks.

What is the number before the first decimal point of the IP address after the IP address is converted to decimal? Because the first segment is 10 xxxxxx, it should be 26, that is, the 6 power of 2, equal to 64. 127 indicates that the reserved CIDR block is not currently used. Therefore, the CIDR block should start from 128 to 128 + 64-1 = 191. That is, the first digit of the decimal IP address is between 128-191.

BCompute the number of hosts:

Because the last 16 bits are the Host IDS, the number of hosts should be 216, that is, the power of 16 of 2.

216 = 48 = 164 = 2562 = 65536. After two reserved addresses are deducted, the maximum number of hosts is 65534.

 

To sum up, the range of Class B IP addresses should be 128.0.0.1 ~ 191.00000000254

Red indicates the network ID, and Green indicates the host ID.

 

CClass CIDR Block calculation:

According to regulations, the network ID of a Class C address must start with "110. The number of CIDR blocks should be 110xxxxx. XXXXXXXX. XXXXXXXX. yyyyyyyy, which is followed by 21 digits. Because it is a binary number, the number of CIDR blocks should be:

221, that is, 21 Power CIDR blocks of 2, equal to 2097152. after deducting two "0" and "1" Reserved addresses, a Class B network can have 2097150 CIDR blocks.

What is the number before the first decimal point of the IP address after the IP address is converted to decimal? Because the first section is 110 XXXXX, it should be 25, that is, the 5 power of 2, equal to 32. Therefore, the CIDR block should start from 192 to 192 + 32-1 = 223. That is, the first digit of the decimal IP address is.

CCompute the number of hosts:

Because the last eight digits are the Host IDS, the number of hosts should be 28, that is, the power of 2.

28 = 44 = 162 = 2562. After two reserved addresses are deducted, the maximum number of hosts is 254.

 

To sum up, the range of class c ip addresses should be: 192.0.0.1 ~ 223.00000000254

Red indicates the network ID, and Green indicates the host ID.

 

Source: http://hi.baidu.com/acalephe/blog/item/f40eb7df4278751c632798ac.html

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.