Understanding IP Address Structure: Classes, Subnetting, and Network Calculations
This article explains how IP addresses are composed of network, subnet, and host parts, details the five IP classes (A‑E) with their ranges, default subnet masks, and shows how to determine if two addresses belong to the same subnet using binary AND operations.
If an IP address is subnetted, it can be expressed as:
IP address = network address + subnet address + host addressA network address is the logical address of a node on the Internet; MAC addresses operate at the data link layer, IP addresses at the network layer, and port numbers at the transport layer.
Example IP address 192.168.54.4 belongs to a Class C network. Its network address is 192.168.54.0 and its host address is 0.0.0.4.
Each IP address contains two identifiers: a network ID and a host ID. All hosts on the same physical network share the same network ID, while each host has a unique host ID. IP addresses are divided into five classes: A class , B class , C class , D class , and E class .
1. A Class IP Address
An A class address consists of one byte network address and three bytes host address; the highest bit of the network address is 0 . The network range is 1.0.0.0 to 126.0.0.0 with default subnet mask 255.0.0.0. There are 126 usable A networks, each supporting 2^24-2 hosts (about 16 million).
Application: A class addresses are assigned to very large networks such as those of major corporations.
2. B Class IP Address
A B class address uses two bytes for the network address and two bytes for the host address; the highest bits are 10 . The address range is 128.0.0.0 to 191.255.255.255 with default subnet mask 255.255.0.0 . Approximately 2^8 × 64 (≈ 1.6 × 10⁴) B networks exist, each supporting 2^16 hosts (≈ 6 × 10⁴). Application: B class addresses are typically allocated to medium‑sized networks.
3. C Class IP Address
A C class address consists of three bytes network address and one byte host address; the highest bits are 110 . The range is 192.0.0.0 to 223.255.255.255 with default subnet mask 255.255.255.0 . About 2^16 × 32 (≈ 2.09 × 10⁶) C networks exist, each supporting 254 hosts. Application: C class addresses are used for small networks such as typical LANs and campus networks.
4. D Class Address
D class addresses are reserved for multicast; they start with 1110 and do not refer to a specific network.
5. E Class Address
E class addresses start with 11110 and are reserved for future use.
Note: The all‑zero address 0.0.0.0 refers to the current host, and the all‑ones address 255.255.255.255 is the broadcast address of the current subnet.
IP address ranges by class:
A class: 1.0.0.1–126.255.255.254 B class: 128.0.0.1–191.255.255.254 C class: 192.168.0.0–192.168.255.255 D class: 224.0.0.1–239.255.255.254 E class: 240.0.0.1–255.255.255.254 To determine whether two IP addresses belong to the same subnet, perform a bitwise AND between each address and the subnet mask; if the resulting network numbers are identical, the addresses are in the same subnet.
Example using subnet mask 255.255.254.0:
211.95.165.24 11010011.01011111.10100101.00011000
255.255.254.0 11111111.11111111.11111110.00000000
Result: 11010011.01011111.10100100.00000000 211.95.164.78 11010011.01011111.10100100.01001110
255.255.254.0 11111111.11111111.11111110.00000000
Result: 11010011.01011111.10100100.00000000Both results are identical, confirming the two IPs are in the same subnet.
Default subnet masks without subnetting are: A class: 255.0.0.0 B class: 255.255.0.0 C class: 255.255.255.0 Default (classless): 255.255.255.0
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.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
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.
