IP Addressing & Subnetting
A deep dive into IPv4 structure, addressing classes, and the logic of subnetting.
The IPv4 address is a unique 32-bit identifier for a host or router interface.
Dotted Decimal Notation
| Class | Range (1st Octet) | Structure | Max Hosts | Target User |
|---|---|---|---|---|
| Class A | 1 - 126 | N . H . H . H | 16,777,214 | Governments & Giant Corps |
| Class B | 128 - 191 | N . N . H . H | 65,534 | Medium to Large Companies |
| Class C | 192 - 223 | N . N . N . H | 254 | Small Groups & Home LANs |
The "Missing" 127
Address 127.0.0.1 is reserved for Loopback (diagnostics). It points back to your own machine.
Multicasting (Class D)
Used for streaming (Audio/Video). Instead of 1-to-1 (Unicast), it is 1-to-Many.
How many Hosts can we have? (The Power of 2)
The separation between Network and Host is defined by the Subnet Mask. If we have 16 bits for Hosts, how many IPs is that?
⚠️ ليه بنطرح 2؟ (Reserved Addresses)
- الـ 0: محجوز لعنوان الشبكة نفسها (Network Address).
- الـ 255 (أو آخر رقم): محجوز للـ Broadcast (عشان تبعت رسالة لكل الناس في الشبكة).
CIDR: The Solution to IP Exhaustion
Old "Classful" addressing was wasteful. If you needed 300
hosts, Class C was too small (254) and Class B was too big (65k).
CIDR (Classless Inter-Domain Routing) allows us to define the network
boundary at any bit using /Notation.
Subnets (الشبكات)
y = bits borrowed from Host portion.
Hosts (الأجهزة)
x = remaining Host bits after borrowing.
Solving a Subnetting Problem
For 192.168.43.0, it's Class C (Default /24).
We have /26. Borrowed bits = 26 - 24 = 2 bits.
Increment = 256 - 192 = 64.
| Net ID | First Host | Last Host | Broadcast |
|---|---|---|---|
| .0 | .1 | .62 | .63 |
| .64 | .65 | .126 | .127 |
| .128 | .129 | .190 | .191 |
| .192 | .193 | .254 | .255 |
Private IP addresses are used for internal networks and are not routable on the public internet.