Dynamic Host Configuration Protocol (DHCP)
DHCP is a critical network service that automates the assignment of IP addresses and other network configuration parameters to hosts. It eliminates the need for manual IP address configuration, especially in large, dynamic networks.
Without DHCP, every device would need to be manually configured with:
- An IP address
- Subnet mask
- Default gateway
- DNS server(s)
DHCP Process (DORA)
Section titled “DHCP Process (DORA)”DHCP operates using a four-step process commonly referred to as DORA:
- Discover – Client broadcasts to locate available DHCP servers.
- Offer – Server responds with an available IP address and configuration options.
- Request – Client requests to lease the offered IP address.
- Acknowledgment – Server acknowledges and finalizes the lease.
This is all handled using broadcast and unicast messages over UDP port 67 (server) and 68 (client).
DHCP Roles
Section titled “DHCP Roles”- DHCP Server: Allocates IP addresses from a defined pool and tracks active leases
- DHCP Client: Dynamically requests IP configuration
- DHCP Relay Agent: Forwards DHCP packets between clients and servers across different subnets
DHCP is a Layer 7 (application layer) protocol but relies heavily on Layer 2 and 3 broadcast behavior, which is why relay agents (e.g., ip helper-address) are often required in routed environments.
DHCP Configurations
Section titled “DHCP Configurations”Basic Server Configuration
Section titled “Basic Server Configuration”service dhcp
ip dhcp excluded-address 192.168.1.1 192.168.1.10
ip dhcp pool USERS network 192.168.1.0 255.255.255.0 default-router 192.168.1.1 dns-server 8.8.8.8 1.1.1.1 lease 7excluded-addressprevents those IPs from being assigneddefault-routersets the gateway for clientsleasedefines the number of days (or optionally hours and minutes)
Basic Client Configuration
Section titled “Basic Client Configuration”interface GigabitEthernet0/0 ip address dhcpManual Binding on Server
Section titled “Manual Binding on Server”debug ip dhcp server packetThen copy the client-identifier that is outputted when a DHCP message is received. Some devices use the MAC address by default though, including Ubuntu or Linux.
ip dhcp pool STATIC1 host 192.168.1.10 255.255.255.0 client-identifier [...]The client identifier can be found by running
debug dhcp detailon the end host, then wait for it to generate a DHCP Discovery message. Then copy and paste the client-identifier. If the client ID in the running-config is not even 4 char between periods, add leading zeros.
DHCP Relay (Forwarding)
Section titled “DHCP Relay (Forwarding)”If the DHCP server is on a different subnet, configure a DHCP relay agent using:
interface Vlan10 ip helper-address 192.168.100.10This command causes the router to:
- Convert DHCP broadcasts to unicasts
- Forward them to the server IP
- Translate replies back to the requesting client
Specifying a VRF in an DHCP pool only works, if the helper address also points to that same VRF locally configured & directly connected.
DHCP Option Codes
Section titled “DHCP Option Codes”DHCP options are used to send additional information to the client beyond just an IP address.
Option Configurations
Section titled “Option Configurations”ip dhcp pool USERS option [option-number] [hex | ascii] [value]Common DHCP Options
Section titled “Common DHCP Options”| Option | Purpose | Example |
|---|---|---|
| 1 | Subnet Mask | Auto-included |
| 3 | Default Gateway | default-router |
| 6 | DNS Servers | dns-server |
| 15 | Domain Name | domain-name example.com |
| 66 | TFTP Server Name (VoIP, PXE boot) | option 66 ascii tftp-server.local |
| 67 | Bootfile Name (PXE boot image) | option 67 ascii pxelinux.0 |
| 82 | Relay Agent Info (inserted by switch/relay) | Controlled via ip dhcp relay information |
Options 66 and 67 are frequently tested in PXE boot, IP phone, and controller-based environments.
Troubleshooting
Section titled “Troubleshooting”show ip dhcp bindingshow ip dhcp pooldebug ip dhcp server eventsdebug ip dhcp server packetThese are useful for checking which clients have active leases, what pools exist, and whether DHCP messages are being exchanged.