Lecture ‐ DHCP - Dleifnesor/NET-215 GitHub Wiki

DHCP – Dynamic Host Configuration Protocol

DHCP automatically assigns:

  • IP address
  • Subnet mask
  • Default gateway
  • DNS server

When you connect to a Wi-Fi network, this info is assigned via DHCP.


DHCP Uses UDP

  • Client Port: 68
  • Server Port: 67
  • DHCP uses no ephemeral ports
  • It is a connectionless protocol (like BOOTP)

DHCP Process: DORA

DHCP works in 4 steps:

  1. Discover – Client broadcasts request for a DHCP server
  2. Offer – Server replies with an IP lease offer
  3. Request – Client requests offered IP
  4. Acknowledge – Server confirms the assignment

This four-step handshake ensures multiple offers can be managed and prevents spoofing.


DHCP Lease Lifecycle

Initialization:

  • First-time IP assignment using DORA

Renewal:

  • Client contacts DHCP server before lease expires
  • Default: 50% of lease time (T1)

Rebinding:

  • If server doesn't respond to renewal, client broadcasts a rebind request
  • Default: 87.5% of lease time (T2)

Expiration:

  • If lease expires with no server response, client must restart DORA

DHCP Packet Highlights

Discover Packet

  • Layer 2: Destination MAC is FF:FF:FF:FF:FF:FF
  • Layer 3: Destination IP is 255.255.255.255
  • Layer 4: UDP port 68 → 67
  • Source IP: 0.0.0.0 (client has no IP yet)

Offer Packet

  • Sent from server to client
  • Includes:
    • Offered IP address
    • Subnet mask
    • Default gateway
    • DNS server

Request Packet

  • From client to server
  • Confirms intent to use offered IP
  • Still uses source IP 0.0.0.0

Acknowledge Packet

  • Final confirmation from server
  • IP officially assigned to client

DHCP Lease Times

  • Static networks (e.g., labs): Longer leases (hours/days)
  • Dynamic networks (e.g., café Wi-Fi): Short leases (minutes)

Lease duration affects traffic, performance, and how quickly IPs are reclaimed.


DHCP Header Fields (Simplified)

  • OpCode – Request or reply
  • Transaction ID – Matches responses to requests
  • Client/Your IP Address – IP assignment data
  • MAC Address – Client identifier
  • Gateway & Server IPs – Routing info
  • Options – Extended info (only required: Message Type – Option 53)

DHCP Relay Agents

  • DHCP relies on broadcasts (Layer 2).
  • Clients can't reach DHCP servers across subnets.
  • Routers can act as DHCP relays to forward requests to the proper server.

Useful in enterprise networks where the DHCP server isn't on the same subnet.