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:

  1. Network Portion: Identifies the network.
  2. 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:

  1. Number of Subnets: 2n (where ‘n’ is the number of bits borrowed from the host portion)
  2. 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:

  1. Borrow 2 bits: This changes the subnet mask to /26 (255.255.255.192).
  2. Resulting Subnets:
SubnetAddress RangeUsable Hosts
Subnet 1192.168.1.0 - 192.168.1.6362
Subnet 2192.168.1.64 - 192.168.1.12762
Subnet 3192.168.1.128 - 192.168.1.19162
Subnet 4192.168.1.192 - 192.168.1.25562
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):

ClassStarting IP RangeEnding IP RangeDefault Subnet MaskCIDR NotationPurpose
Class A1.0.0.0126.255.255.255255.0.0.0/8Large networks
Class B128.0.0.0191.255.255.255255.255.0.0/16Medium-sized networks
Class C192.0.0.0223.255.255.255255.255.255.0/24Small networks
Class D224.0.0.0239.255.255.255N/AN/AMulticast communication
Class E240.0.0.0255.255.255.255N/AN/AExperimental use