Networking - DHCP (Dynamic Host Configuration Protocol)

What is DHCP?

DHCP is a network protocol that automatically assigns IP addresses and other network settings to devices on a network.
Instead of configuring each device manually, DHCP handles it dynamically.


Why DHCP is Important

  • Saves time: No need to manually set IPs for every device.

  • Avoids conflicts: Prevents two devices from using the same IP.

  • Scalability: Essential in networks with hundreds/thousands of devices.

  • Flexibility: Devices can join/leave without manual intervention.


How DHCP Works (The DORA Process)

When a device (client) joins a network, it goes through DORA:

  1. Discover → Client broadcasts a DHCP Discover message: “Is there a DHCP server?”

  2. Offer → DHCP server replies with an Offer: “I can give you IP 192.168.1.10, subnet mask, gateway, DNS…”

  3. Request → Client replies: “Yes, I’ll take that IP, please reserve it for me.”

  4. Acknowledge → DHCP server confirms with an Acknowledgment, and the client starts using the IP.


Information DHCP Provides

A DHCP server doesn’t just hand out IP addresses; it can also give:

  • IP address

  • Subnet mask

  • Default gateway

  • DNS servers

  • Lease time (how long the IP is valid)

  • Other options (e.g., NTP servers, domain name)


DHCP Lease

  • An IP lease is temporary.

  • The client must renew it before expiration.

  • If it leaves the network, the IP is returned to the DHCP pool for reuse.


Real-Life Example

  • At home: Your router usually acts as a DHCP server, automatically giving your phone/laptop an IP.

  • In enterprises: Dedicated DHCP servers manage thousands of addresses.


Security Considerations

  • Rogue DHCP Servers: An attacker can set up a fake DHCP server to hand out malicious settings.

  • Defenses: DHCP snooping (switch feature), using authentication.


 In short: DHCP is like a hotel receptionist. Instead of every guest picking a random room (IP), the receptionist (DHCP server) assigns rooms (addresses) efficiently, keeps track of who has which, and reuses them when guests leave.