The first time I had to troubleshoot a DHCP outage, it was on a Friday afternoon, half the office had no internet, and I was frantically scrolling through half-remembered commands trying to figure out why an entire floor of laptops couldn’t get an IP address. It turned out to be a scope that had run out of leases — something I could have spotted in thirty seconds if I’d had a proper reference in front of me.
That’s exactly what I’ve built here. This is the DHCP cheat sheet I wish I’d had that day — commands for Linux, Windows Server, and Cisco devices, real configuration examples, the troubleshooting steps I actually use, and the security practices that keep DHCP from becoming an attack vector on a network. I’ve organized it so you can jump straight to what you need, whether that’s a dhcpd.conf snippet or a PowerShell one-liner.
What DHCP Actually Does
DHCP automatically assigns IP addresses, subnet masks, default gateways, and other network configuration details to devices on a network, so nobody has to manually configure each machine. It works through a four-step process commonly remembered as DORA:
| Step | Name | Description |
|---|---|---|
| 1 | Discover | Client broadcasts a request looking for a DHCP server |
| 2 | Offer | Server responds with an available IP address offer |
| 3 | Request | Client requests the offered IP address |
| 4 | Acknowledge | Server confirms and finalizes the lease |
I think of DORA as the handshake that happens every time a device joins a network — understanding it makes troubleshooting dramatically easier because you can tell exactly where in that sequence things are breaking down.
Key DHCP Terminology
| Term | Meaning |
|---|---|
| Scope | A range of IP addresses available for assignment on a subnet |
| Lease | The duration a client is allowed to use an assigned IP address |
| Reservation | A specific IP address permanently assigned to a specific MAC address |
| Exclusion | An IP address range within a scope that DHCP will not assign |
| Lease time | How long before a client must renew its IP address |
| Relay agent | A device that forwards DHCP requests across subnets/broadcast domains |
| Option | Additional configuration data sent with the lease (DNS servers, gateway, etc.) |
DHCP Options I Reference Most Often
These are the option numbers I look up constantly when configuring scopes.
| Option Number | Name | Purpose |
|---|---|---|
| 1 | Subnet Mask | Defines the subnet mask for the client |
| 3 | Router (Default Gateway) | Specifies the default gateway |
| 6 | DNS Servers | List of DNS servers for the client |
| 12 | Hostname | Client’s hostname |
| 15 | Domain Name | DNS domain name |
| 42 | NTP Servers | Time synchronization servers |
| 50 | Requested IP Address | Used in DHCPREQUEST messages |
| 51 | IP Address Lease Time | Duration of the lease |
| 53 | DHCP Message Type | Identifies Discover/Offer/Request/Ack |
| 54 | DHCP Server Identifier | Identifies which server sent the message |
| 66 | TFTP Server Name | Used for network boot |
| 67 | Bootfile Name | Used for PXE boot |
Linux DHCP Server (ISC DHCP / dhcpd) Configuration
I use isc-dhcp-server most often on Linux for lab and small production environments. Here’s how I set it up.
Installation
# Debian/Ubuntu
sudo apt update && sudo apt install isc-dhcp-server -y
# RHEL/CentOS/Fedora
sudo dnf install dhcp-server -y
Basic Configuration File (/etc/dhcp/dhcpd.conf)
default-lease-time 600;
max-lease-time 7200;
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.100 192.168.1.200;
option routers 192.168.1.1;
option subnet-mask 255.255.255.0;
option domain-name-servers 8.8.8.8, 8.8.4.4;
option domain-name "myhomelab.local";
}
Setting a Static Reservation
host printer-01 {
hardware ethernet 00:1A:2B:3C:4D:5E;
fixed-address 192.168.1.50;
}
Common Linux Commands
| Command | Purpose |
|---|---|
sudo systemctl start isc-dhcp-server | Start the DHCP service |
sudo systemctl restart isc-dhcp-server | Restart after config changes |
sudo systemctl status isc-dhcp-server | Check service status |
sudo journalctl -u isc-dhcp-server -f | Tail live DHCP server logs |
dhcpd -t -cf /etc/dhcp/dhcpd.conf | Test configuration file syntax |
cat /var/lib/dhcp/dhcpd.leases | View current active leases |
sudo dhclient -r | Release the current DHCP lease (client side) |
sudo dhclient eth0 | Request a new DHCP lease on interface eth0 |
ip addr show | View assigned IP addresses |
Windows Server DHCP Configuration (PowerShell)
I manage most of my Windows Server DHCP roles through PowerShell now rather than the GUI — it’s faster and scriptable.
Installing the DHCP Role
Install-WindowsFeature DHCP -IncludeManagementTools
Creating a New Scope
Add-DhcpServerv4Scope -Name "Office-LAN" `
-StartRange 192.168.1.100 `
-EndRange 192.168.1.200 `
-SubnetMask 255.255.255.0 `
-State Active
Setting Scope Options
Set-DhcpServerv4OptionValue -ScopeId 192.168.1.0 `
-DnsServer 8.8.8.8,8.8.4.4 `
-Router 192.168.1.1
Creating a Reservation
Add-DhcpServerv4Reservation -ScopeId 192.168.1.0 `
-IPAddress 192.168.1.50 `
-ClientId "00-1A-2B-3C-4D-5E" `
-Description "Office Printer"
Useful PowerShell Cheat Table
| Command | Purpose |
|---|---|
Get-DhcpServerv4Scope | List all configured scopes |
Get-DhcpServerv4Lease -ScopeId 192.168.1.0 | View active leases in a scope |
Get-DhcpServerv4Statistics | View server-wide DHCP statistics |
Remove-DhcpServerv4Lease | Manually remove a lease |
Set-DhcpServerv4Scope -LeaseDuration | Change lease duration for a scope |
Export-DhcpServer | Export DHCP configuration for backup |
Import-DhcpServer | Import DHCP configuration from backup |
Restart-Service DHCPServer | Restart the DHCP service |
Windows Client-Side Commands (Command Prompt)
| Command | Purpose |
|---|---|
ipconfig /all | View full IP configuration including lease info |
ipconfig /release | Release current DHCP lease |
ipconfig /renew | Request a new lease |
ipconfig /flushdns | Clear the local DNS resolver cache |
ipconfig /displaydns | Show cached DNS entries |
Cisco IOS DHCP Configuration
I configure Cisco routers as DHCP servers fairly often in small branch office setups.
Router(config)# ip dhcp excluded-address 192.168.1.1 192.168.1.10
Router(config)# ip dhcp pool OFFICE-POOL
Router(dhcp-config)# network 192.168.1.0 255.255.255.0
Router(dhcp-config)# default-router 192.168.1.1
Router(dhcp-config)# dns-server 8.8.8.8 8.8.4.4
Router(dhcp-config)# lease 7
Configuring a DHCP Relay Agent (IP Helper)
When the DHCP server sits on a different subnet than the clients, I configure the interface to relay broadcasts:
Router(config)# interface GigabitEthernet0/1
Router(config-if)# ip helper-address 192.168.1.5
Cisco Verification Commands
| Command | Purpose |
|---|---|
show ip dhcp binding | View current DHCP lease bindings |
show ip dhcp pool | View pool configuration and usage stats |
show ip dhcp conflict | View any detected IP address conflicts |
show ip dhcp server statistics | View overall DHCP server stats |
clear ip dhcp binding * | Clear all current bindings |
debug ip dhcp server events | Real-time debug of DHCP server events |
DHCPv6 Quick Reference
IPv6 networks use a similar but distinct process, often abbreviated SARR (Solicit, Advertise, Request, Reply) instead of DORA.
| Step | Name | Description |
|---|---|---|
| 1 | Solicit | Client broadcasts to locate a DHCPv6 server |
| 2 | Advertise | Server responds with available configuration |
| 3 | Request | Client requests the offered configuration |
| 4 | Reply | Server confirms and finalizes |
# Linux ISC DHCPv6 config snippet
subnet6 2001:db8:1::/64 {
range6 2001:db8:1::100 2001:db8:1::200;
option dhcp6.name-servers 2001:4860:4860::8888;
}
DHCP Failover and High Availability
I never put a single DHCP server in charge of a production network without a redundancy plan — a downed server means no new devices can connect until it’s back up.
Windows Server DHCP Failover
Add-DhcpServerv4Failover -Name "Failover-Cluster1" `
-PartnerServer "DHCP2.contoso.com" `
-ScopeId 192.168.1.0 `
-Mode LoadBalance
| Failover Mode | Description |
|---|---|
| Load Balance | Both servers actively issue leases, splitting the load |
| Hot Standby | One server is primary, the other only takes over if the primary fails |
Linux ISC DHCP Failover Configuration
failover peer "dhcp-failover" {
primary;
address 192.168.1.5;
port 647;
peer address 192.168.1.6;
peer port 647;
max-response-delay 60;
max-unacked-updates 10;
load balance max seconds 3;
}
subnet 192.168.1.0 netmask 255.255.255.0 {
pool {
failover peer "dhcp-failover";
range 192.168.1.100 192.168.1.200;
}
}
I always test failover by deliberately stopping the primary service in a maintenance window and confirming the secondary picks up new lease requests without a gap.
DHCP Message Types Explained
Understanding the actual message types exchanged during DORA helps enormously when reading packet captures in Wireshark.
| Message | Direction | Purpose |
|---|---|---|
| DHCPDISCOVER | Client → Server | Broadcast to locate available DHCP servers |
| DHCPOFFER | Server → Client | Offers an IP address and configuration |
| DHCPREQUEST | Client → Server | Requests the offered IP (or renews an existing lease) |
| DHCPACK | Server → Client | Confirms the lease is finalized |
| DHCPNAK | Server → Client | Rejects the request (e.g., IP no longer valid) |
| DHCPDECLINE | Client → Server | Client detects the offered IP is already in use |
| DHCPRELEASE | Client → Server | Client voluntarily gives up its lease |
| DHCPINFORM | Client → Server | Client already has an IP but requests additional config |
When I’m capturing traffic with tcpdump or Wireshark to debug a DHCP issue, I filter specifically on these message types rather than trying to read raw UDP 67/68 traffic blindly:
sudo tcpdump -i eth0 port 67 or port 68 -vv
Configuring DHCP Options for Special Use Cases
Beyond the basics, I regularly configure a few option types for more specialized network needs.
VoIP Phone Configuration (Option 66/150)
subnet 192.168.2.0 netmask 255.255.255.0 {
range 192.168.2.50 192.168.2.150;
option tftp-server-name "192.168.2.10";
option option-150 192.168.2.10;
}
Vendor-Specific Options (Option 43)
Used often for wireless access point controllers to auto-discover their controller on boot:
option space cisco;
option cisco.controller-ip code 241 = ip-address;
subnet 192.168.3.0 netmask 255.255.255.0 {
vendor-option-space cisco;
option cisco.controller-ip 192.168.3.5;
}
PXE Boot Configuration
subnet 192.168.4.0 netmask 255.255.255.0 {
range 192.168.4.50 192.168.4.200;
next-server 192.168.4.10;
filename "pxelinux.0";
}
Auditing and Monitoring DHCP Health
I check these regularly, not just when something breaks, since catching scope exhaustion or lease anomalies early prevents outages before they happen.
# Windows: check scope utilization percentage
Get-DhcpServerv4ScopeStatistics -ScopeId 192.168.1.0 |
Select-Object ScopeId, Free, InUse, PercentageInUse
# Linux: quick lease count check
grep -c "lease" /var/lib/dhcp/dhcpd.leases
| Metric | Why I Track It |
|---|---|
| Scope utilization % | Warns me before a pool runs out of addresses |
| Lease duration vs. renewal rate | Helps tune lease times for the actual usage pattern |
| DHCPDECLINE frequency | High counts often indicate IP conflicts or static IP overlap |
| DHCPNAK frequency | Can indicate misconfigured relay agents or stale client cache |
| Number of active reservations | Helps me keep documentation in sync with reality |
Migrating or Backing Up a DHCP Server
Before any major change, I always back up the current configuration — this has saved me more than once when a scope change went wrong.
# Windows: export configuration
Export-DhcpServer -File "C:\Backup\dhcp-backup.xml" -Leases
# Windows: import configuration on a new server
Import-DhcpServer -File "C:\Backup\dhcp-backup.xml" -Leases -BackupPath "C:\Backup"
# Linux: simple config and lease backup
sudo cp /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.bak
sudo cp /var/lib/dhcp/dhcpd.leases /var/lib/dhcp/dhcpd.leases.bak
Troubleshooting DHCP: My Actual Workflow
When a device can’t get an IP address, this is the order I check things in:
- Confirm the physical/logical connection — is the interface up?
ip link showoripconfig /all. - Check for an APIPA address (
169.254.x.xon Windows) — this tells me the client never got a DHCP response at all. - Verify the DHCP service is running on the server:
systemctl status isc-dhcp-serverorGet-Service DHCPServer. - Check scope utilization — is the scope exhausted?
show ip dhcp poolorGet-DhcpServerv4ScopeStatistics. - Check for DHCP relay/IP helper misconfiguration if the client is on a different subnet than the server.
- Look for rogue DHCP servers on the network — a second, misconfigured DHCP server handing out bad leases is one of the most common causes of intermittent connectivity issues I’ve encountered.
- Review logs —
journalctl -u isc-dhcp-serveron Linux, Event Viewer on Windows, ordebug ip dhcp server eventson Cisco. - Check for MAC address conflicts or duplicate reservations.
- Test manually — release and renew the lease (
dhclient -r && dhclient, oripconfig /release && ipconfig /renew) to see if the issue is transient.
| Symptom | Likely Cause |
|---|---|
| Client has a 169.254.x.x address | No DHCP response received (APIPA) |
| Client gets an IP but wrong subnet/gateway | Scope misconfiguration or wrong relay target |
| Some clients get IPs, others don’t | Scope exhaustion |
| Intermittent random IP conflicts | Rogue DHCP server on the network |
| Clients across VLANs can’t get IPs | Missing or misconfigured IP helper-address |
| Lease not renewing properly | Firewall blocking DHCP ports (UDP 67/68) |
Security Best Practices
DHCP is inherently a trust-based protocol, and I’ve learned to treat it as a genuine attack surface rather than just “plumbing.”
- Enable DHCP snooping on managed switches to prevent rogue DHCP servers from handing out malicious configurations. On Cisco switches:
Switch(config)# ip dhcp snoopingSwitch(config)# ip dhcp snooping vlan 10Switch(config-if)# ip dhcp snooping trust - Limit the number of leases per port to guard against DHCP starvation attacks, where an attacker floods a server with bogus requests to exhaust the address pool.
- Use reservations for critical infrastructure (printers, servers, access points) so their addresses never change and can be tracked reliably.
- Segment DHCP traffic with VLANs so broadcast domains stay small and rogue servers on one segment can’t affect others.
- Monitor DHCP logs regularly for unexpected servers responding to client requests — this is often the first sign of a man-in-the-middle attempt.
- Set conservative lease times in high-security environments, since shorter leases reduce the window an attacker has if they manage to obtain an address.
- Disable unused DHCP relay agents and restrict
ip helper-addressentries to only the subnets that need them.
Real-World Use Cases
- Small office network: A single Cisco router or a Linux box running
isc-dhcp-serverhandles a /24 subnet, hands out addresses to laptops and printers, with static reservations for shared devices. - Enterprise multi-VLAN environment: A centralized Windows Server DHCP failover cluster serves multiple VLANs via IP helper-addresses configured on each Layer 3 switch, with scope options tailored per VLAN (different DNS servers or domain suffixes per department).
- Data center PXE boot environment: DHCP options 66 and 67 point servers to a TFTP server and boot file for automated OS deployment across racks of bare-metal servers.
- ISP/carrier-grade networks: DHCPv6 with prefix delegation (option 25) hands out entire IPv6 prefixes to customer routers rather than single addresses.
- Guest Wi-Fi networks: Short lease times and a dedicated scope with heavy exclusions keep guest device turnover manageable and isolated from internal VLANs.
Common Mistakes I See (and Have Made Myself)
- Overlapping scopes across VLANs — assigning the same IP range to two different subnets, causing conflicts the moment routing changes.
- Forgetting to exclude the gateway/router address from the scope range, leading to it eventually being handed out to a client.
- Setting lease times too long in dynamic environments like guest networks, leading to exhausted scopes.
- Not configuring failover/redundancy for critical DHCP servers — a single point of failure that takes down an entire office when the server reboots.
- Ignoring DHCP snooping on switches, leaving the network wide open to rogue DHCP servers.
- Not documenting reservations, leading to confusion later about which device owns which static lease.
- Assuming DNS issues are DHCP issues (or vice versa) without actually checking
ipconfig /alloutput first to isolate which layer is failing.
Frequently Asked Questions
What’s the difference between a DHCP reservation and a static IP configuration? A reservation is still assigned dynamically through DHCP but always resolves to the same address for a given MAC address, so it remains centrally managed. A static configuration is set manually on the device itself, outside of DHCP entirely.
How long should a DHCP lease last? It depends on the environment. Stable corporate networks often use lease times of a day or more, while guest or high-turnover networks (like public Wi-Fi) benefit from shorter leases of just a few hours to free up addresses faster.
Can two DHCP servers run on the same network? Yes, but only intentionally through a properly configured failover or load-balancing setup with non-overlapping scopes. Two independent, uncoordinated DHCP servers on the same broadcast domain will cause conflicts.
What ports does DHCP use? UDP port 67 for the server and UDP port 68 for the client.
What happens when a DHCP scope runs out of addresses? New clients requesting an address will fail to get one and typically fall back to an APIPA address (169.254.x.x on Windows) or simply fail to connect, depending on the OS.
Does DHCP work across different subnets? Not natively, since DHCP relies on broadcasts. A relay agent (using ip helper-address on Cisco, for example) is required to forward requests from clients on a remote subnet to a DHCP server elsewhere.
Interview Questions on DHCP (with Answers)
1. Explain the DORA process. Discover (client broadcasts for a server), Offer (server proposes an IP), Request (client asks to use it), Acknowledge (server confirms the lease) — the four-step handshake behind every DHCP-assigned address.
2. What is DHCP starvation, and how do you prevent it? It’s an attack where a malicious device floods a DHCP server with bogus requests using spoofed MAC addresses to exhaust the available address pool. Prevented with port security and DHCP snooping.
3. What’s the purpose of an IP helper-address? It configures a router interface to forward DHCP broadcast requests as unicast packets to a DHCP server on a different subnet, since broadcasts don’t normally cross subnet boundaries.
4. How does DHCP failover work? Two DHCP servers share a pool of addresses and lease state information, so if one goes down, the other continues issuing and renewing leases without interruption.
5. What DHCP option is used for PXE network booting? Options 66 (TFTP server name) and 67 (bootfile name) work together to point a booting client to the correct boot image.
6. How would you detect a rogue DHCP server on your network? By monitoring DHCP snooping logs on managed switches, watching for unexpected DHCPOFFER responses from unauthorized MAC addresses, or using packet capture tools like Wireshark to inspect DHCP traffic sources.
Printable Quick-Reference Summary
DORA PROCESS
Discover -> Offer -> Request -> Acknowledge
KEY PORTS
UDP 67 - DHCP Server
UDP 68 - DHCP Client
LINUX
systemctl restart isc-dhcp-server
cat /var/lib/dhcp/dhcpd.leases
dhclient -r / dhclient eth0
WINDOWS (PowerShell)
Add-DhcpServerv4Scope
Get-DhcpServerv4Lease
Add-DhcpServerv4Reservation
WINDOWS (Client)
ipconfig /release
ipconfig /renew
ipconfig /all
CISCO IOS
ip dhcp pool NAME
show ip dhcp binding
ip helper-address <server-ip>
SECURITY
ip dhcp snooping
Limit leases per port
Use reservations for critical devices
Official Documentation and Further Reading
- RFC 2131 — Dynamic Host Configuration Protocol
- ISC DHCP Documentation (dhcpd.conf)
- Microsoft DHCP Server PowerShell Documentation
- Cisco IOS DHCP Configuration Guide
DHCP is one of those protocols that quietly does its job until it doesn’t — and when it doesn’t, everything grinds to a halt fast. Keep this reference nearby, and the next time a floor full of laptops loses connectivity on a Friday afternoon, you’ll know exactly where to look first.