What Is DHCP? A Deep Dive into Automated IP Management

What Is DHCP? A Deep Dive into Automated IP Management

1. Introduction to DHCP

DHCP (Dynamic Host Configuration Protocol) is a network protocol that automatically assigns IP addresses and network configuration details (like subnet mask, gateway, DNS) to devices (clients) on a network.

For example, when you connect to a Wi-Fi network and immediately get internet access — DHCP is what makes that happen behind the scenes.

2. Why Do We Need DHCP?

Because:

  • Manually assigning IP, subnet mask, gateway, DNS to each device is inefficient
  • In large networks, this is error-prone and unmanageable
  • Mobile or temporary clients (phones, guests) need dynamic setups
  • DHCP automates this entire process and centralizes control

3. How DHCP Works – The DORA Process

DHCP follows a 4-step handshake called DORA:

D – Discover

The client broadcasts a message asking for a DHCP server:

Who can give me an IP address?

O – Offer

The DHCP server responds with an available IP and config:

I can offer you 192.168.1.100, subnet 255.255.255.0

R – Request

Client says it wants that specific IP:

Yes, I’d like to take 192.168.1.100

A – Acknowledge

Server confirms and leases the IP to the client:

Confirmed. IP is yours for 24 hours.

All this occurs over UDP:

  • Port 67: Server
  • Port 68: Client

4. DHCP Traffic at OSI Layer

  • Layer 7 (Application): DHCP
  • Layer 4 (Transport): UDP
  • Layer 3 (Network): IP (often from 0.0.0.0)
  • Layer 2 (Data Link): Ethernet broadcast (via MAC address)

5. DHCP Packet Structure

FieldDescription
OP Code1 = Request, 2 = Reply
Transaction IDRandom ID to match request and response
Client IP AddressUsually 0.0.0.0
Your IP AddressOffered IP address
Server IP AddressThe DHCP server’s IP
Gateway IP AddressIf a relay is used
Client MAC AddressDevice identifier
OptionsDNS, lease time, subnet mask, etc.

Common DHCP Options

  • 1 – Subnet mask
  • 3 – Default gateway
  • 6 – DNS servers
  • 51 – Lease time
  • 53 – DHCP message type (Discover, Offer, etc.)

6. Lease Management

DHCP leases IP addresses temporarily (not permanently). A lease might last 24 hours, for example.

Renewal Phases:

  • T1 (Renew): At 50% of lease time, client requests renewal from the same server
  • T2 (Rebind): At 87.5%, client can request renewal from any server
  • Expiration: If no renewal, lease expires and client starts over with a new Discover

7. DHCP Roles: Server, Client, Relay Agent

RoleFunction
DHCP ServerAssigns IP addresses and configuration
DHCP ClientRequests IP (e.g., laptop, smartphone)
Relay AgentForwards DHCP traffic across networks/subnets

8. Types of IP: Dynamic, Static, Reserved

  • Dynamic IP: Leased from a pool, temporary
  • Static IP: Manually assigned by administrator
  • Reserved IP: DHCP always assigns the same IP to a specific MAC address

Reserved IPs are perfect for printers, cameras, servers that need consistent addresses.

9. DHCP Security Vulnerabilities

Despite its usefulness, DHCP has security weaknesses:

DHCP Spoofing

A rogue server offers false DNS/gateway info → enables MITM

Rogue DHCP

An unauthorized device acts as a DHCP server and disrupts the network

DHCP DoS

Flooding the server with fake requests → exhausts IP pool and crashes service

10. Securing DHCP

  • Switch port security: Blocks unauthorized clients per port
  • DHCP Snooping: Identifies trusted vs untrusted interfaces
  • 802.1X Authentication: Only allows verified clients on the network
  • Firewall rules: Block rogue DHCP traffic
  • Use static/reserved IPs for critical infrastructure

11. Tools & Commands for DHCP

ip a or ifconfig

Shows assigned IP and interface status

dhclient (Linux)

sudo dhclient -r  # Release IP
sudo dhclient # Request new IP

Wireshark

Filter:

bootp || dhcp

Capture full DORA process and analyze DHCP options

tcpdump, dhcpdump

Terminal-based packet capture for DHCP traffic

12. Real-World Uses of DHCP

  • Home routers – act as DHCP servers
  • Corporate networks – use centralized DHCP with relays
  • Virtual machines – hypervisors assign IPs dynamically
  • ISP networks – assign IPs to customer modems
  • IoT environments – automate IP setup for hundreds of sensors/devices

13. Why DHCP Is Indispensable

Automates IP assignment
Scales from small LANs to enterprise WANs
Supports dynamic + reserved configurations
Can integrate with DNS and VLAN systems
Must be secured — but foundational to modern networking

Leave a Reply

Your email address will not be published. Required fields are marked *