Master IP Address Classes, Subnetting, and CIDR in One Guide
This article explains the history and logic behind IP address classes, how subnetting transforms a two‑level address into three levels, the role of subnet masks in determining network membership, and the advantages of CIDR notation for flexible address allocation, concluding with a practical VPC exercise.
IP Address Classification
Originally a 32‑bit IP address consists of a network part and a host part. It was divided into five classes (A, B, C, D, E), with classes A, B and C being the most commonly used.
In the IP addressing standard, a network address of all zeros represents a local address, while a network address of all ones is a broadcast address; both are not usable as host IPs on the Internet.
A‑class IP address: 2 7 ‑2 = 126 network addresses, each supporting 2 24 ‑2 = 16,777,214 hosts.
B‑class IP address: 2 14 ‑2 = 16,382 network addresses, each supporting 2 16 ‑2 = 65,534 hosts.
C‑class IP address: 2 21 ‑2 = 2,097,150 network addresses, each supporting 2 8 ‑2 = 254 hosts.
This two‑level addressing scheme often leads to inefficient use of address space, prompting the need for subnetting.
Subnetting
Subnetting further divides the original two‑level IP address into three levels: network, subnet, and host. The subnet portion is taken from the host bits, reducing the number of hosts per subnet but allowing multiple subnets within the same network.
For example, a university can allocate a large address block to different faculties using subnetting, while external devices still see a single large network.
Subnet Mask
A subnet mask separates the network and host portions of an IP address and can determine whether two hosts belong to the same subnet by performing a bitwise AND operation.
192.168.1.1 > 11000000.10101000.00000001 00000001 255.255.255.240 > 11111111.11111111.11111111.11110000 AND result: 11000000.10101000.00000001 00000000Network address: 192.168.1.0 Host address: 0.0.0.1 Two IPs with the same mask (255.255.255.0) share the network address 192.168.1.0 and belong to the same subnet. Changing the mask to 255.255.0.0 changes the network address to 192.168.0.0, placing the hosts in different subnets.
CIDR (Classless Inter‑Domain Routing)
CIDR eliminates the traditional class concept, allowing flexible address allocation using a prefix length notation (e.g., /21).
For a company needing about 2,000 addresses, a CIDR block can be allocated with a 21‑bit network prefix and an 11‑bit host portion. The corresponding subnet mask in binary is: 11111111.11111111.11111000.00000000 Example binary representation of a CIDR block starting with 192.168: 11000000.10101000.11111xxx.xxxxxxxx The network prefix in binary is 11000000.10101000.11111, which corresponds to 192.168.248. An individual host could be addressed as 192.168.248.15/21.
Classroom Exercise
To apply these concepts, you can create a Virtual Private Cloud (VPC). A VPC provides an isolated virtual network for cloud resources such as servers and databases, allowing you to define private IP ranges and subnets.
When creating a VPC, you select a private network segment (e.g., 10.0.0.0/8‑/24, 172.16.0.0/12‑/24, or 192.168.0.0/16‑/24). Subnets must be defined within this private segment, and each cloud resource must be placed in a subnet.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Huawei Cloud Developer Alliance
The Huawei Cloud Developer Alliance creates a tech sharing platform for developers and partners, gathering Huawei Cloud product knowledge, event updates, expert talks, and more. Together we continuously innovate to build the cloud foundation of an intelligent world.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
