DHCP Server Setup Guide Using ISC DHCP Server
DHCP Server Setup Guide Using ISC DHCP Server
This guide explains how to configure a DHCP server on Ubuntu or Debian using ISC DHCP Server.
1. What Is DHCP?
DHCP, or Dynamic Host Configuration Protocol, automatically provides network settings to client devices.
A DHCP server can assign:
- IP address
- Subnet mask
- Default gateway
- DNS server
- Lease duration
- Reserved IP addresses for specific devices
For example, instead of manually configuring every computer, DHCP can automatically assign:
IP address: 192.168.1.100
Subnet mask: 255.255.255.0
Gateway: 192.168.1.1
DNS server: 192.168.1.10
2. Important DHCP Terms
| Term | Definition |
|---|---|
| DHCP server | Provides IP addresses and network configuration |
| DHCP client | A device requesting network settings |
| DHCP lease | Temporary assignment of an IP address |
| DHCP pool/range | Range of addresses available for clients |
| Reservation | A fixed IP assigned to a particular device |
| Subnet mask | Defines the size of the local network |
| Default gateway | Router used to access other networks |
| DNS server | Converts domain names into IP addresses |
| MAC address | Hardware address identifying a network device |
| DORA | DHCP Discover, Offer, Request, and Acknowledgment |
3. Example Network
This guide uses the following network:
Network: 192.168.1.0/24
DHCP server IP: 192.168.1.10
Router/gateway: 192.168.1.1
DNS server: 192.168.1.10
DHCP address range: 192.168.1.100–192.168.1.200
Interface: eth0
Domain: example.local
Your values may be different.
Only one DHCP server should normally operate on the same network. Disable DHCP on your router if this Linux server will provide DHCP.
4. Requirements
You need:
- Ubuntu or Debian server
- Root or sudo access
- A fixed IP address for the DHCP server
- Network interface connected to the client network
- A network router or gateway
- At least one DHCP client for testing
The DHCP server must have a static IP address. Do not allow the DHCP server itself to receive its address from DHCP.
5. Identify the Network Interface
List network interfaces:
ip link
Example output:
1: lo: ...
2: eth0: ...
3: ens18: ...
The connected interface may be named:
eth0
ens18
enp0s3
Find its current IP address:
ip addr
For this guide, we use:
eth0
Replace eth0 with your actual interface name.
6. Configure a Static IP Address
Ubuntu commonly uses Netplan.
List Netplan files:
ls /etc/netplan/
Open the configuration file:
sudo nano /etc/netplan/00-installer-config.yaml
Example configuration:
network:
version: 2
ethernets:
eth0:
dhcp4: false
addresses:
- 192.168.1.10/24
routes:
- to: default
via: 192.168.1.1
nameservers:
addresses:
- 192.168.1.10
- 1.1.1.1
Apply the configuration:
sudo netplan apply
Check the address:
ip addr show eth0
Test the gateway:
ping -c 4 192.168.1.1
Test Internet connectivity:
ping -c 4 1.1.1.1
Static configuration definitions
dhcp4: false: Prevents the server from receiving an IPv4 address through DHCP.addresses: Sets the server’s fixed IP address./24: Equivalent to subnet mask255.255.255.0.routes: Defines the default gateway.nameservers: Defines DNS servers used by the DHCP server itself.
7. Install the DHCP Server
Update the package list:
sudo apt update
Install ISC DHCP Server:
sudo apt install isc-dhcp-server -y
Check the service:
sudo systemctl status isc-dhcp-server
It may show an error initially because it has not yet been configured. This is normal.
8. Configure the DHCP Interface
Open the DHCP server defaults file:
sudo nano /etc/default/isc-dhcp-server
Find:
INTERFACESv4=""
Change it to:
INTERFACESv4="eth0"
If you use IPv6 DHCP, you can configure:
INTERFACESv6="eth0"
For a basic IPv4 setup, leave it empty:
INTERFACESv6=""
Save the file.
9. Configure the DHCP Scope
A DHCP scope defines the network and addresses that the server can assign.
Open the main DHCP configuration file:
sudo nano /etc/dhcp/dhcpd.conf
You can replace the contents with this example:
authoritative;
default-lease-time 600;
max-lease-time 7200;
option domain-name "example.local";
option domain-name-servers 192.168.1.10, 1.1.1.1;
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.100 192.168.1.200;
option subnet-mask 255.255.255.0;
option routers 192.168.1.1;
option broadcast-address 192.168.1.255;
}
Configuration definitions
authoritative
authoritative;
Declares that this is the official DHCP server for the network.
Use this only if you control the network.
default-lease-time
default-lease-time 600;
Sets the default lease duration in seconds.
600 seconds = 10 minutes
max-lease-time
max-lease-time 7200;
Sets the maximum lease duration.
7200 seconds = 2 hours
option domain-name
option domain-name "example.local";
Provides a local DNS domain name to clients.
option domain-name-servers
option domain-name-servers 192.168.1.10, 1.1.1.1;
Tells clients which DNS servers to use.
If your DNS server is configured correctly, you can use:
option domain-name-servers 192.168.1.10;
subnet
subnet 192.168.1.0 netmask 255.255.255.0
Defines the network served by DHCP.
range
range 192.168.1.100 192.168.1.200;
Defines the addresses that may be dynamically assigned.
option routers
option routers 192.168.1.1;
Sets the default gateway for clients.
option broadcast-address
option broadcast-address 192.168.1.255;
Sets the broadcast address for the subnet.
10. Validate the DHCP Configuration
Before starting the service, check the configuration:
sudo dhcpd -t -cf /etc/dhcp/dhcpd.conf
If successful, you should see no serious errors.
You can also check the service configuration:
sudo systemctl status isc-dhcp-server
11. Start and Enable the DHCP Service
Start the service:
sudo systemctl start isc-dhcp-server
Enable automatic startup:
sudo systemctl enable isc-dhcp-server
Restart the service after configuration changes:
sudo systemctl restart isc-dhcp-server
Check its status:
sudo systemctl status isc-dhcp-server
View recent DHCP logs:
sudo journalctl -u isc-dhcp-server --no-pager -n 50
You can also monitor logs in real time:
sudo journalctl -u isc-dhcp-server -f
12. Configure the Firewall
DHCP uses:
UDP port 67: DHCP server
UDP port 68: DHCP client
Allow DHCP through UFW:
sudo ufw allow 67/udp
sudo ufw reload
Check the firewall:
sudo ufw status
If the server is inside a virtual machine or cloud environment, also check the external firewall or security group.
13. Test from a Linux Client
On a Linux client, identify its interface:
ip link
Release its current DHCP lease:
sudo dhclient -r eth0
Request a new lease:
sudo dhclient -v eth0
Replace eth0 with the client’s actual interface.
Display the assigned address:
ip addr show eth0
Check the routing table:
ip route
Check DNS configuration:
resolvectl status
The client should receive an address in this range:
192.168.1.100–192.168.1.200
14. Test from a Windows Client
Open Command Prompt as Administrator and run:
ipconfig /release
ipconfig /renew
ipconfig /all
Check that the client received:
IPv4 Address: 192.168.1.x
Subnet Mask: 255.255.255.0
Default Gateway: 192.168.1.1
DHCP Server: 192.168.1.10
DNS Servers: 192.168.1.10
15. Create a Reserved IP Address
A DHCP reservation assigns the same IP address to a specific device.
You need the device’s MAC address.
On Linux:
ip link
Example:
link/ether 00:11:22:33:44:55
On Windows:
ipconfig /all
Add this reservation to /etc/dhcp/dhcpd.conf:
host office-pc {
hardware ethernet 00:11:22:33:44:55;
fixed-address 192.168.1.50;
option host-name "office-pc";
}
The reserved address should be outside the dynamic range:
Dynamic range: 192.168.1.100–192.168.1.200
Reserved IP: 192.168.1.50
Validate and restart:
sudo dhcpd -t -cf /etc/dhcp/dhcpd.conf
sudo systemctl restart isc-dhcp-server
Then renew the client’s lease.
16. Create Multiple DHCP Networks
If the server has multiple network interfaces, you can configure separate subnets.
Example:
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 192.168.1.10;
}
subnet 192.168.2.0 netmask 255.255.255.0 {
range 192.168.2.100 192.168.2.200;
option routers 192.168.2.1;
option subnet-mask 255.255.255.0;
option domain-name-servers 192.168.1.10;
}
Each subnet must be connected to the correct interface or VLAN.
17. DHCP Relay for Different Networks
A DHCP broadcast normally does not cross routers. A DHCP relay forwards DHCP requests from another network to the DHCP server.
Install the relay:
sudo apt install isc-dhcp-relay -y
During installation, specify the DHCP server address:
192.168.1.10
You can edit the relay configuration later:
sudo nano /etc/default/isc-dhcp-relay
Example:
SERVERS="192.168.1.10"
INTERFACES="eth1 eth2"
OPTIONS=""
Restart the relay:
sudo systemctl restart isc-dhcp-relay
The DHCP server also needs a subnet declaration for the remote network:
subnet 192.168.2.0 netmask 255.255.255.0 {
range 192.168.2.100 192.168.2.200;
option routers 192.168.2.1;
option subnet-mask 255.255.255.0;
option domain-name-servers 192.168.1.10;
}
18. View DHCP Leases
Active leases are stored in:
/var/lib/dhcp/dhcpd.leases
View the file:
sudo cat /var/lib/dhcp/dhcpd.leases
Look for entries such as:
lease 192.168.1.100 {
starts 2026/08/31 10:00:00;
ends 2026/08/31 10:10:00;
hardware ethernet 00:11:22:33:44:55;
client-hostname "office-pc";
}
19. Troubleshooting
DHCP service does not start
Check the configuration:
sudo dhcpd -t -cf /etc/dhcp/dhcpd.conf
Check service logs:
sudo journalctl -u isc-dhcp-server -n 100
Incorrect interface configured
Check the interface name:
ip link
Edit:
sudo nano /etc/default/isc-dhcp-server
Set the correct interface:
INTERFACESv4="ens18"
Then restart:
sudo systemctl restart isc-dhcp-server
Clients do not receive IP addresses
Check the following:
- The client is connected to the correct network.
- The DHCP server interface is connected.
- Another DHCP server is not running.
- UDP port 67 is allowed.
- The DHCP range is not exhausted.
- The server and clients use the same subnet.
- VLAN configuration is correct.
- A DHCP relay is configured if the client is on another subnet.
Monitor DHCP traffic:
sudo tcpdump -i eth0 -n port 67 or port 68
You should see messages such as:
DHCPDISCOVER
DHCPOFFER
DHCPREQUEST
DHCPACK
These four messages are known as DORA:
- Discover — Client searches for a DHCP server.
- Offer — Server offers an IP address.
- Request — Client requests the offered address.
- Acknowledgment — Server confirms the lease.
Clients receive addresses from the wrong server
Disable DHCP on the router or other DHCP server. Multiple DHCP servers on one network can cause incorrect gateways, DNS settings, and IP addresses.
20. Complete Example Configuration
The final /etc/dhcp/dhcpd.conf may look like this:
authoritative;
default-lease-time 600;
max-lease-time 7200;
option domain-name "example.local";
option domain-name-servers 192.168.1.10;
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.100 192.168.1.200;
option subnet-mask 255.255.255.0;
option routers 192.168.1.1;
option broadcast-address 192.168.1.255;
}
host office-pc {
hardware ethernet 00:11:22:33:44:55;
fixed-address 192.168.1.50;
option host-name "office-pc";
}
Validate and restart:
sudo dhcpd -t -cf /etc/dhcp/dhcpd.conf
sudo systemctl restart isc-dhcp-server
sudo systemctl enable isc-dhcp-server
Conclusion
Your DHCP server should now automatically assign IP addresses and network settings to devices on the configured network. Clients simply connect and lease their configuration automatically — no manual IP setup required.
Table of Contents