Skip to content

Latest commit

 

History

History
89 lines (58 loc) · 3.51 KB

File metadata and controls

89 lines (58 loc) · 3.51 KB

DHCP (Dynamic Host Configuration Protocol)

What is DHCP?

Imagine joining a Wi-Fi network at a coffee shop. You don’t type in an IP address, subnet mask, or DNS server yourself yet your laptop just works on the internet.
That convenience is thanks to DHCP.

DHCP (Dynamic Host Configuration Protocol) is a service that automatically hands out IP addresses and other network details (like the default gateway, subnet mask, and DNS servers) to devices. Without it, every device would need manual setup, which quickly becomes messy and error-prone in large networks.


Why Do We Need DHCP?

  • Scalability: Configuring a few computers manually is fine, but imagine 500+ devices in an office. DHCP makes this painless.
  • Mobility: Phones and laptops that move between networks get the right settings automatically.
  • Error Prevention: No risk of duplicate IP addresses or typos when things are auto-assigned.

How Does DHCP Work?

The process is often called the DORA cycle (Discover, Offer, Request, Acknowledge). Here’s how it plays out:

  1. Discover (DHCPDISCOVER)
    When a device connects to the network, it shouts: “Hey, is there any DHCP server out there?”
    This is a broadcast because the device doesn’t yet have an IP.

  2. Offer (DHCPOFFER)
    The DHCP server replies: “Yes! Here’s an IP you can use, plus some extra settings.”
    The reply includes things like the IP address, subnet mask, gateway, and DNS.

  3. Request (DHCPREQUEST)
    The client responds: “Great, I’ll take that offer!”
    This is also broadcast so that if multiple servers answered, the others know their offers were ignored.

  4. Acknowledge (DHCPACK)
    The server finalizes the deal: “Done! That IP is officially yours for now.”
    The device configures itself with those settings and is ready to communicate on the network.


Leases, Renewal, and Release

  • Lease Time: The IP isn’t forever. It’s “leased” for a set period (say, 24 hours).
  • Renewal: Before the lease expires, the client quietly asks the server if it can keep the same IP.
  • Release: If a device shuts down or leaves the network, it can give the IP back early.

This recycling keeps addresses available and ensures efficient use of the IP pool.


DHCP Options

Besides the IP address, DHCP can also provide:

  • Subnet mask
  • Default gateway
  • DNS servers
  • Domain name
  • Time servers

These details help the device fully integrate into the network.


Security Concerns

DHCP is convenient but not bulletproof. Possible issues:

  • Rogue DHCP servers: A malicious device could hand out fake IP settings.
  • Unauthorized clients: Unknown devices might grab valid IPs.

To counter this, admins use techniques like DHCP snooping (to block fake servers) and IP reservations (to bind specific IPs to trusted devices).


In Summary

DHCP is like a hotel receptionist:

  • You check in (connect to the network).
  • They assign you a room number (IP address).
  • They give you info about the hotel (gateway, DNS, etc.).
  • When you leave, the room is freed up for the next guest.

Without DHCP, networking would be a lot more complicated for both admins and users.


Further Reading