Notes3:1DHCP - echadbourne/NET-330 GitHub Wiki

Dynamic Host Configuration Protocol (DHCP)

DHCP - used to automatically assign an IP address to a host, ay include a lot more network information too

Key information:

  • IP address
  • Subnet Mask
  • Default Gateway/Router
  • DNS Server Address

How does DHCP work?

The client does not know what network it's on, so it sends out a broadcast asking for help

If a DHCP Server hears this broadcast, it will respond with an IP address that the client can use

DHCP employs a connectionless service model over UDP. It is implemented with two known UDP port numbers

  • Server port: 67
  • Client port: 68

DHCP has two primary Operation Phases

  • Initialization: Client request, receives, and confirms an IP address
  • Renewal: Client asks to renew its "lease" of the IP address

DHCP Header

Key fields:

  • Operation Code: indicates if this is a request or a reply
  • Hardware Type: Type of HW address
  • Hardware Length: Length of HW address
  • Transaction ID: Random number used to pair requests and replies (since UDP is connectionless)
  • Client IP Address: Eventual client IP
  • Your IP Address: Offered client IP
  • Server IP Address: IP of DHCP server
  • Gateway IP Address: Default gateway IP
  • Client Hardware Address: Client's MAC

image

DHCP Initialization

DORA: Four step process

  • Discover: Client attempts to discover a DHCP server
  • Offer: IP lease offer from server to client
  • Request: client requests to use the IP lease sent by the server
  • Acknowledgement: Server sends acknowledgement to client that the lease was accepted

DHCP Renewal

Process for client to request continued use (renewal) of it's lease

  • By default, this begins 50% of the way through the current DHCP lease
  • The client sends DHCP Request packets directly to the server
  • If the server respond with a DHCP Acknowledgement, the IP lease is renewed and its time clock restarts

image

Rebinding

If the server does not respond to the client's renewal requests, we eventually reach the rebinding phase

  • By default, this begins 87.5% of the way through the current IP lease
  • The client begins sending its DHCP request packets as broadcasts to see if any DHCP server will allow them to continue using their IP
  • If a server responds, the lease is renewed and the timer restarts

Expiration

If no server responds before the lease ends, the lease expires and the IP is released

  • All TCP/IP communication stops
  • The client must go through the DORA initialization process once again to get a new IP address

DHCP Relay

Remember, unconfigured clients have no IP configuration

  • They know nothing about the subnet gateway, etc
  • All they can do is broadcast into the wild

But broadcasts are layer 2 only... what happens if a network doesn't have a local DHCP server?

  • Layer 3 devices (routers, servers) can be configured as DHCP relays (aka helpers)
  • Pick up broadcasts and forward to the DHCP Server

On Cisco

Uses "ip helper-address"

Can be assigned to a physical or VLAN interface

If configured, grabs DHCP broadcasts seen on that interface and sends to DHCP server

  • ex is DHCP server is 10.16.1.50
  • (config) interface vlan 100
  • `(config-if) ip helper-address 10.16.1.50

Sends any DHCP broadcasts on VLAN 100 to the server