Raspberry Pi DHCP Server Guide
All devices connected to a network need an IP address to communicate. Whether it’s a laptop, smartphone, printer, smart TV, security camera or another Raspberry Pi, all devices need to have valid network settings before they can talk to other devices or the internet.
Most home networks use a router to automatically provide these settings using a service called Dynamic Host Configuration Protocol (DHCP). This is done well enough by routers in basic environments . However , many enthusiasts , home lab users and network admins prefer to run their own DHCP server for greater flexibility and control .
Raspberry Pi makes a great DHCP server. It uses very little power, runs all the time, and has enough performance to handle IP address allocation for homes, labs, classrooms, and small offices.
This guide covers how DHCP works, why you might want a dedicated DHCP server, how to install and configure a DHCP server on Raspberry Pi, and how to troubleshoot common issues.
What Is DHCP?
DHCP stands for Dynamic Host Configuration Protocol.
It is a network service that automatically provides devices with:
- IP addresses
- Subnet masks
- Default gateways
- DNS server addresses
- Lease durations
- Additional network settings
Without DHCP, every device would require manual network configuration.
Imagine configuring dozens or hundreds of devices individually. DHCP eliminates this complexity by automating the entire process.
Why Use a Raspberry Pi as a DHCP Server?
Although most routers include DHCP functionality, there are several reasons to deploy a dedicated DHCP server.
Greater Control
Many consumer routers provide only basic DHCP options.
A dedicated server allows:
- Static reservations
- Custom DNS settings
- Advanced lease management
- Device identification
- Detailed logging
Home Lab Environments
Home labs often contain:
- Virtual machines
- Multiple Raspberry Pi systems
- Network storage devices
- Test servers
- Development environments
A dedicated DHCP server makes managing these devices significantly easier.
Educational Purposes
Building your own DHCP server helps you understand:
- Network addressing
- IP allocation
- DNS integration
- Routing
- Network troubleshooting
Small Business Networks
A Raspberry Pi DHCP server can support:
- Printers
- VoIP phones
- Desktop PCs
- Security systems
- Wireless access points
Better Device Management
Reservations allow specific devices to always receive the same address.
Examples include:
NAS Server → 192.168.1.10
Printer → 192.168.1.20
Camera System → 192.168.1.30
Pi-hole → 192.168.1.40
How DHCP Works
When a device joins a network, it typically knows nothing about the environment.
DHCP uses a process often called DORA:
Discover
The client broadcasts:
I need network settings.
Offer
The DHCP server responds:
I can offer you 192.168.1.100.
Request
The client replies:
I would like to use 192.168.1.100.
Acknowledge
The server confirms:
The address is yours.
The device can now communicate on the network.
DHCP Lease Explained
An IP address assignment is called a lease.
Example:
| Device | Address | Lease Time | | | – | – | | Laptop | 192.168.1.100 | 24 Hours | | Phone | 192.168.1.101 | 24 Hours | | Tablet | 192.168.1.102 | 24 Hours |
Before the lease expires, devices attempt renewal automatically.
This ensures efficient use of available addresses.
Hardware Requirements
DHCP requires minimal resources.
Suitable Raspberry Pi models include:
| Model | Suitability | | | — | | Raspberry Pi 5 | Excellent | | Raspberry Pi 4 | Excellent | | Raspberry Pi 3B+ | Excellent | | Raspberry Pi Zero 2 W | Very Good | | Raspberry Pi Zero W | Good |
Even older models can comfortably handle DHCP services.
Recommended Setup
For maximum reliability:
| Component | Recommendation |
|---|---|
| Operating System | Raspberry Pi OS Lite |
| Connection | Ethernet |
| Power Supply | Official PSU |
| Storage | Quality microSD Card |
DHCP services should ideally run on a wired connection.
Installing Raspberry Pi OS
Begin with a fully updated system.
Update packages:
sudo apt update
sudo apt full-upgrade -y
Reboot:
sudo reboot
Assign a Static IP Address
A DHCP server must always have a predictable address.
Check current address:
hostname -I
Example:
192.168.1.50
The preferred method is creating a DHCP reservation on your router.
Example:
| Device | Reserved Address | | | – | | Raspberry Pi DHCP Server | 192.168.1.50 |
Important: Disable Router DHCP First
Before activating a second DHCP server, disable DHCP on the router.
Running multiple DHCP servers on the same network often causes:
- Duplicate addresses
- Random assignments
- Connectivity issues
- DNS problems
Only one active DHCP server should exist on a simple network.
Installing ISC DHCP Server
The most common DHCP package for Linux is ISC DHCP Server.
Install:
sudo apt install isc-dhcp-server -y
Verify installation:
sudo systemctl status isc-dhcp-server
Initially it may show errors until configuration is completed.
Configure Network Interface
Edit:
sudo nano /etc/default/isc-dhcp-server
Specify interface:
INTERFACESv4="eth0"
For wireless setups:
INTERFACESv4="wlan0"
Ethernet remains the preferred option.
Configuring DHCP Scope
Edit:
sudo nano /etc/dhcp/dhcpd.conf
A basic configuration might look like:
authoritative;
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 1.1.1.1, 1.0.0.1;
default-lease-time 86400;
max-lease-time 604800;
}
This configuration:
- Assigns addresses from 192.168.1.100–200
- Uses router 192.168.1.1 as gateway
- Uses Cloudflare DNS
- Creates 24-hour leases
- Allows maximum leases of seven days
Understanding the Configuration
Subnet
192.168.1.0
Defines the network.
Range
192.168.1.100-192.168.1.200
Specifies assignable addresses.
Router Option
192.168.1.1
Defines the default gateway.
DNS Option
1.1.1.1
1.0.0.1
Provides DNS settings to clients.
Lease Times
Control how long addresses remain assigned.
Starting the DHCP Service
Restart:
sudo systemctl restart isc-dhcp-server
Enable automatic startup:
sudo systemctl enable isc-dhcp-server
Verify:
sudo systemctl status isc-dhcp-server
You should see:
active (running)
Checking Assigned Leases
View current leases:
cat /var/lib/dhcp/dhcpd.leases
This file contains:
- Device addresses
- Lease times
- MAC addresses
- Client information
Creating DHCP Reservations
Reservations ensure devices always receive the same address.
Example:
host printer {
hardware ethernet AA:BB:CC:DD:EE:FF;
fixed-address 192.168.1.20;
}
Now that printer always receives:
192.168.1.20
regardless of reconnects.
Useful Reservation Examples
Network Storage
192.168.1.10
Security Cameras
192.168.1.20-29
Printers
192.168.1.30-39
Servers
192.168.1.40-49
Dynamic Clients
192.168.1.100-200
This approach keeps networks organized.
Using Pi-hole as DNS
Many users pair DHCP with Pi-hole.
Instead of:
option domain-name-servers 1.1.1.1;
use:
option domain-name-servers 192.168.1.40;
where:
192.168.1.40
is the Pi-hole server.
All clients automatically benefit from ad blocking.
DHCP and VLANs
Advanced networks often separate traffic:
| VLAN | Purpose |
|---|---|
| VLAN 10 | PCs |
| VLAN 20 | IoT Devices |
| VLAN 30 | Cameras |
| VLAN 40 | Guest Wi-Fi |
A Raspberry Pi DHCP server can provide separate scopes for each VLAN.
This is common in business and laboratory environments.
Monitoring DHCP Activity
View logs:
sudo journalctl -u isc-dhcp-server
Or:
sudo tail -f /var/log/syslog
Logs reveal:
- Address assignments
- Renewals
- Client requests
- Errors
Troubleshooting DHCP Problems
No Addresses Assigned
Check service status:
sudo systemctl status isc-dhcp-server
Wrong Interface Selected
Verify:
INTERFACESv4="eth0"
matches the actual network adapter.
Duplicate DHCP Servers
Ensure the router DHCP service is disabled.
Two DHCP servers frequently create unpredictable behavior.
Clients Not Renewing
Release and renew manually.
Linux:
sudo dhclient -r
sudo dhclient
Windows:
ipconfig /release
ipconfig /renew
Configuration Errors
Validate configuration:
sudo dhcpd -t
This checks syntax before restarting services.
Security Best Practices
Restrict Administrative Access
Use SSH keys rather than passwords where possible.
Keep Software Updated
sudo apt update
sudo apt full-upgrade
Regular updates improve reliability and security.
Use a Firewall
Install:
sudo apt install ufw
Enable necessary services only.
Back Up Configuration Files
Save copies of:
/etc/dhcp/dhcpd.conf
and
/var/lib/dhcp/
Backups simplify disaster recovery.
Advanced DHCP Features
A Raspberry Pi DHCP server can support:
Multiple Subnets
Manage several networks simultaneously.
PXE Boot
Boot computers from the network.
VoIP Configuration
Automatically configure IP phones.
Dynamic DNS Updates
Update DNS records automatically.
Vendor-Specific Options
Support specialized devices.
High Availability
Deploy redundant DHCP servers.
These capabilities make DHCP far more powerful than many consumer router implementations.
Final Thoughts
A Raspberry Pi DHCP server provides far greater flexibility and control than the DHCP functionality built into most home routers. Whether you are building a home lab, managing dozens of devices, deploying network services, or simply learning more about networking, operating your own DHCP server is an excellent project.
With minimal hardware requirements and straightforward configuration, a Raspberry Pi can reliably handle IP address management for homes, classrooms, small offices, and advanced laboratory environments. Combined with DNS services, Pi-hole, and network monitoring tools, it becomes a powerful foundation for a well-organized and efficient network.
