📡
Networking & Server

DHCP Server

Automatic IP address assignment for network clients

🐧 Linux🍎 Mac🪟 Windows
Reviewed: Tested on: Kubernetes 1.29 · Terraform 1.8 · Ubuntu 22.04

What is this?

DHCP automatically assigns IP addresses to devices on your network so they can connect.

📁

Config files for DHCP Server

Where to create or edit the main configuration — paths below match the setup steps.

  • /etc/dhcp/dhcpd.conf

    Location: ISC DHCP server

    Subnets, ranges, and options

📥

Step 01

Install DHCP Server

(01)Install ISC DHCP or dnsmasq

Linux
1# Option A — ISC DHCP (Ubuntu)
2sudo apt-get install -y isc-dhcp-server
3
4# Option B — dnsmasq (lightweight, DNS+DHCP)
5sudo apt-get install -y dnsmasq
6
7# RHEL / Fedora
8sudo dnf install -y dhcp-server
⚙️

Step 02

Configure DHCP

(01)ISC DHCP server config

Linux
1sudo nano /etc/dhcp/dhcpd.conf
2
3# Example:
4default-lease-time 600;
5max-lease-time 7200;
6authoritative;
7
8subnet 192.168.1.0 netmask 255.255.255.0 {
9 range 192.168.1.100 192.168.1.200;
10 option routers 192.168.1.1;
11 option domain-name-servers 192.168.1.10, 8.8.8.8;
12 option domain-name "example.com";
13}
14
15# Set interface in /etc/default/isc-dhcp-server:
16# INTERFACESv4="eth0"
17
18sudo systemctl restart isc-dhcp-server

(02)dnsmasq DHCP + DNS combo

Linux
1sudo nano /etc/dnsmasq.conf
2
3interface=eth0
4dhcp-range=192.168.1.100,192.168.1.200,255.255.255.0,12h
5dhcp-option=3,192.168.1.1
6dhcp-option=6,192.168.1.10
7domain=example.com
8
9sudo systemctl restart dnsmasq

Step 03

Verify DHCP

(01)Check leases

Linux
1cat /var/lib/dhcp/dhcpd.leases
2sudo journalctl -u isc-dhcp-server -f
3# On client: sudo dhclient -v eth0

Step 04

Manage DHCP

(01)Static reservations

Linux
1# In dhcpd.conf:
2host webserver {
3 hardware ethernet 00:11:22:33:44:55;
4 fixed-address 192.168.1.50;
5}
6
7sudo systemctl restart isc-dhcp-server