Computer Networks Essentials / Network Protocols in Detail

DHCP (Dynamic Host Configuration Protocol)

πŸ€” What is DHCP? (Basic Idea)

When a device joins a network, it needs:

  • IP address 🧾

  • Subnet mask

  • Default gateway

  • DNS server

πŸ“Œ Manually assigning these to every device is difficult and error-prone.

πŸ‘‰ DHCP automates this entire process.


🧠 Simple Definition

πŸ“Œ DHCP (Dynamic Host Configuration Protocol) is a network protocol that automatically assigns IP addresses and other network configuration parameters to devices.


🧠 Why DHCP is Needed?

Without DHCP ❌:

  • Manual IP configuration

  • IP conflicts

  • Time-consuming

  • High chance of errors

With DHCP βœ…:

  • Automatic configuration

  • No IP conflicts

  • Plug-and-play networking

πŸ“Œ That’s why DHCP is used everywhere (home, office, campus).


🧠 Real-Life Analogy

🏨 Hotel Room Allocation

  • Guest checks in

  • Hotel assigns room automatically

  • Room reused when guest leaves

πŸ‘‰ DHCP:

  • Device connects

  • IP assigned

  • IP reused when device disconnects


🧭 Where Does DHCP Work?

  • DHCP is an Application Layer protocol

  • Uses UDP (fast & lightweight)


πŸ”Œ Ports Used by DHCP

Device

Port

DHCP Client

68 (UDP)

DHCP Server

67 (UDP)


🧩 Main Components of DHCP

1️⃣ DHCP Client – Device requesting IP

2️⃣ DHCP Server – Assigns IP & config

3️⃣ DHCP Relay Agent – For different networks


πŸ“¦ What Information Does DHCP Provide?

DHCP assigns:

  • IP address

  • Subnet mask

  • Default gateway

  • DNS server

  • Lease time

πŸ“Œ All in one automatic process βœ”οΈ


πŸ”„ How DHCP Works (DORA Process)

DHCP follows 4 simple steps, called DORA:

πŸ“Œ Client broadcasts:

β€œIs there any DHCP server?”

  • Source IP: 0.0.0.0

  • Destination IP: 255.255.255.255

πŸ“Œ DHCP server replies:

β€œI can give you this IP.”

Includes:

  • Offered IP

  • Configuration info

πŸ“Œ Client responds:

β€œI want to use this IP.”

  • Confirms selection

πŸ“Œ Server confirms:

β€œIP assigned successfully.”

πŸ‘‰ Device is now part of network βœ”οΈ


⏱️ DHCP Lease Time

πŸ“Œ IP addresses are assigned for a limited time, called lease.

  • Can be renewed

  • Prevents IP wastage

πŸ“Œ After lease expires β†’ IP returned to pool.


🧠 Types of DHCP IP Allocation


πŸ”Ή 1. Dynamic Allocation

  • IP assigned temporarily

  • Most common

πŸ”Ή 2. Automatic Allocation

  • Permanent IP after first assignment

πŸ”Ή 3. Manual Allocation (Reservation)

  • Fixed IP based on MAC address

πŸ“Œ Used for:

  • Servers

  • Printers


🌍 DHCP Relay Agent

πŸ“Œ Used when:

  • Client & server are on different networks

πŸ‘‰ Relay forwards DHCP messages between them.


πŸ” Security Issues with DHCP

  • Rogue DHCP servers

  • IP spoofing

  • Unauthorized access

πŸ“Œ Protection methods:

  • DHCP snooping

  • Network access control


βš–οΈ DHCP vs Manual IP Configuration

Feature

DHCP

Manual

IP assignment

Automatic

Manual

Errors

Very low

High

Scalability

High

Low

Management

Easy

Difficult


🧠 Advantages of DHCP

  • Easy configuration ⚑

  • No IP conflicts

  • Centralized management

  • Time saving

❌ Disadvantages of DHCP

  • DHCP server failure affects network

  • Security risks

  • Less control per device


🧠 Memory Tricks

  • DHCP = Don’t Handle Config Personally πŸ˜„

  • DORA = Dora the Explorer 🧭

  • 67 = Server

  • 68 = Client


⭐ One-Line Summary

πŸ”Ή DHCP automatically assigns IP addresses and network configuration to devices, enabling easy and error-free networking.