Ultimate Dynamic Host Configuration Protocol (DHCP) Cheat Sheet: Commands and Configuration

Ultimate Dynamic Host Configuration Protocol (DHCP) Cheat Sheet

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:

StepNameDescription
1DiscoverClient broadcasts a request looking for a DHCP server
2OfferServer responds with an available IP address offer
3RequestClient requests the offered IP address
4AcknowledgeServer 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

TermMeaning
ScopeA range of IP addresses available for assignment on a subnet
LeaseThe duration a client is allowed to use an assigned IP address
ReservationA specific IP address permanently assigned to a specific MAC address
ExclusionAn IP address range within a scope that DHCP will not assign
Lease timeHow long before a client must renew its IP address
Relay agentA device that forwards DHCP requests across subnets/broadcast domains
OptionAdditional 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 NumberNamePurpose
1Subnet MaskDefines the subnet mask for the client
3Router (Default Gateway)Specifies the default gateway
6DNS ServersList of DNS servers for the client
12HostnameClient’s hostname
15Domain NameDNS domain name
42NTP ServersTime synchronization servers
50Requested IP AddressUsed in DHCPREQUEST messages
51IP Address Lease TimeDuration of the lease
53DHCP Message TypeIdentifies Discover/Offer/Request/Ack
54DHCP Server IdentifierIdentifies which server sent the message
66TFTP Server NameUsed for network boot
67Bootfile NameUsed 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

CommandPurpose
sudo systemctl start isc-dhcp-serverStart the DHCP service
sudo systemctl restart isc-dhcp-serverRestart after config changes
sudo systemctl status isc-dhcp-serverCheck service status
sudo journalctl -u isc-dhcp-server -fTail live DHCP server logs
dhcpd -t -cf /etc/dhcp/dhcpd.confTest configuration file syntax
cat /var/lib/dhcp/dhcpd.leasesView current active leases
sudo dhclient -rRelease the current DHCP lease (client side)
sudo dhclient eth0Request a new DHCP lease on interface eth0
ip addr showView 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

CommandPurpose
Get-DhcpServerv4ScopeList all configured scopes
Get-DhcpServerv4Lease -ScopeId 192.168.1.0View active leases in a scope
Get-DhcpServerv4StatisticsView server-wide DHCP statistics
Remove-DhcpServerv4LeaseManually remove a lease
Set-DhcpServerv4Scope -LeaseDurationChange lease duration for a scope
Export-DhcpServerExport DHCP configuration for backup
Import-DhcpServerImport DHCP configuration from backup
Restart-Service DHCPServerRestart the DHCP service

Windows Client-Side Commands (Command Prompt)

CommandPurpose
ipconfig /allView full IP configuration including lease info
ipconfig /releaseRelease current DHCP lease
ipconfig /renewRequest a new lease
ipconfig /flushdnsClear the local DNS resolver cache
ipconfig /displaydnsShow 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

CommandPurpose
show ip dhcp bindingView current DHCP lease bindings
show ip dhcp poolView pool configuration and usage stats
show ip dhcp conflictView any detected IP address conflicts
show ip dhcp server statisticsView overall DHCP server stats
clear ip dhcp binding *Clear all current bindings
debug ip dhcp server eventsReal-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.

StepNameDescription
1SolicitClient broadcasts to locate a DHCPv6 server
2AdvertiseServer responds with available configuration
3RequestClient requests the offered configuration
4ReplyServer 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 ModeDescription
Load BalanceBoth servers actively issue leases, splitting the load
Hot StandbyOne 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.

MessageDirectionPurpose
DHCPDISCOVERClient → ServerBroadcast to locate available DHCP servers
DHCPOFFERServer → ClientOffers an IP address and configuration
DHCPREQUESTClient → ServerRequests the offered IP (or renews an existing lease)
DHCPACKServer → ClientConfirms the lease is finalized
DHCPNAKServer → ClientRejects the request (e.g., IP no longer valid)
DHCPDECLINEClient → ServerClient detects the offered IP is already in use
DHCPRELEASEClient → ServerClient voluntarily gives up its lease
DHCPINFORMClient → ServerClient 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
MetricWhy I Track It
Scope utilization %Warns me before a pool runs out of addresses
Lease duration vs. renewal rateHelps tune lease times for the actual usage pattern
DHCPDECLINE frequencyHigh counts often indicate IP conflicts or static IP overlap
DHCPNAK frequencyCan indicate misconfigured relay agents or stale client cache
Number of active reservationsHelps 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:

  1. Confirm the physical/logical connection — is the interface up? ip link show or ipconfig /all.
  2. Check for an APIPA address (169.254.x.x on Windows) — this tells me the client never got a DHCP response at all.
  3. Verify the DHCP service is running on the server: systemctl status isc-dhcp-server or Get-Service DHCPServer.
  4. Check scope utilization — is the scope exhausted? show ip dhcp pool or Get-DhcpServerv4ScopeStatistics.
  5. Check for DHCP relay/IP helper misconfiguration if the client is on a different subnet than the server.
  6. 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.
  7. Review logs — journalctl -u isc-dhcp-server on Linux, Event Viewer on Windows, or debug ip dhcp server events on Cisco.
  8. Check for MAC address conflicts or duplicate reservations.
  9. Test manually — release and renew the lease (dhclient -r && dhclient, or ipconfig /release && ipconfig /renew) to see if the issue is transient.
SymptomLikely Cause
Client has a 169.254.x.x addressNo DHCP response received (APIPA)
Client gets an IP but wrong subnet/gatewayScope misconfiguration or wrong relay target
Some clients get IPs, others don’tScope exhaustion
Intermittent random IP conflictsRogue DHCP server on the network
Clients across VLANs can’t get IPsMissing or misconfigured IP helper-address
Lease not renewing properlyFirewall 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-address entries 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-server handles 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)

  1. Overlapping scopes across VLANs — assigning the same IP range to two different subnets, causing conflicts the moment routing changes.
  2. Forgetting to exclude the gateway/router address from the scope range, leading to it eventually being handed out to a client.
  3. Setting lease times too long in dynamic environments like guest networks, leading to exhausted scopes.
  4. Not configuring failover/redundancy for critical DHCP servers — a single point of failure that takes down an entire office when the server reboots.
  5. Ignoring DHCP snooping on switches, leaving the network wide open to rogue DHCP servers.
  6. Not documenting reservations, leading to confusion later about which device owns which static lease.
  7. Assuming DNS issues are DHCP issues (or vice versa) without actually checking ipconfig /all output 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

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.

Total
4
Shares

Leave a Reply

Previous Post
Ultimate DNS Cheat Sheet

Ultimate DNS Cheat Sheet: Essential DNS Records, Commands, and Troubleshooting

Next Post
The first step in the acquisition of wisdom is silence, the second listening, the third memory, the fourth practice, the fifth teaching others.

Ibn Sina Quotes: Timeless Wisdom from a Great Thinker

Related Posts