1. IP Addressing
An IP address uniquely identifies a device on a network, enabling communication. IPv4 uses 32 bits, represented as four octets (8-bit numbers) separated by dots (e.g., 192.168.1.1). Each octet ranges from 0 to 255 (28 = 256 values).
Example:
- Binary: 11000000.10101000.00000001.00000001
- Decimal: 192.168.1.1
2. IPv4 Address Structure
An IPv4 address has two parts:
- Network Portion: Identifies the network.
- Host Portion: Identifies the specific device on that network.
The subnet mask determines the boundary between these portions.
graph LR
A[IPv4 Address] --> B(Network Portion);
A --> C(Host Portion);
D[Subnet Mask] --> B;
D --> C;
3. Subnetting
Subnetting divides a large network into smaller, logical subnetworks (subnets). This improves:
- IP Address Efficiency: Better use of available addresses.
- Network Performance: Reduced broadcast traffic.
- Security and Management: Easier to isolate and manage network segments.
4. Subnet Mask
A subnet mask uses binary 1s to represent the network portion and 0s for the host portion of an IP address.
Example:
- Subnet Mask: 255.255.255.0
- Binary: 11111111.11111111.11111111.00000000
A bitwise AND operation between the IP address and subnet mask yields the network address.
Example:
- IP Address: 192.168.1.1
- Subnet Mask: 255.255.255.0
- Network Address: 192.168.1.0 (Result of bitwise AND)
graph LR
A[192.168.1.1] -.AND.- B[255.255.255.0];
B --> C[192.168.1.0];
C --> D[Network Address];
5. CIDR Notation
CIDR (Classless Inter-Domain Routing) notation uses a forward slash followed by the number of 1s in the subnet mask.
Example:
- Subnet Mask: 255.255.255.0
- CIDR Notation: /24 (24 leading 1s)
6. Subnetting Calculations
Subnetting involves these calculations:
- Number of Subnets: 2n (where ‘n’ is the number of bits borrowed from the host portion)
- Number of Usable Hosts per Subnet: 2m - 2 (where ‘m’ is the remaining host bits; subtract 2 for network and broadcast addresses)
7. Practical Subnetting Example
To create 4 subnets from 192.168.1.0/24:
- Borrow 2 bits: This changes the subnet mask to /26 (255.255.255.192).
- Resulting Subnets:
Subnet | Address Range | Usable Hosts |
---|---|---|
Subnet 1 | 192.168.1.0 - 192.168.1.63 | 62 |
Subnet 2 | 192.168.1.64 - 192.168.1.127 | 62 |
Subnet 3 | 192.168.1.128 - 192.168.1.191 | 62 |
Subnet 4 | 192.168.1.192 - 192.168.1.255 | 62 |
graph LR
A[192.168.1.0/24] --> B(Subnet 1: 192.168.1.0 - 192.168.1.63);
A --> C(Subnet 2: 192.168.1.64 - 192.168.1.127);
A --> D(Subnet 3: 192.168.1.128 - 192.168.1.191);
A --> E(Subnet 4: 192.168.1.192 - 192.168.1.255);
8. IPv4 Address Classes (Historical)
Historically, IPv4 addresses were divided into classes based on network size (largely obsolete with CIDR):
Class | Starting IP Range | Ending IP Range | Default Subnet Mask | CIDR Notation | Purpose |
---|---|---|---|---|---|
Class A | 1.0.0.0 | 126.255.255.255 | 255.0.0.0 | /8 | Large networks |
Class B | 128.0.0.0 | 191.255.255.255 | 255.255.0.0 | /16 | Medium-sized networks |
Class C | 192.0.0.0 | 223.255.255.255 | 255.255.255.0 | /24 | Small networks |
Class D | 224.0.0.0 | 239.255.255.255 | N/A | N/A | Multicast communication |
Class E | 240.0.0.0 | 255.255.255.255 | N/A | N/A | Experimental use |