How to Manually Configure a DHCP Server on Ubuntu (With Script Example)

How to Manually Configure a DHCP Server on Ubuntu (With Script Example)

On this page

Whether you're setting up a home lab, provisioning virtual machines, or simulating enterprise networks, having your own DHCP server can make things a lot easier. In this guide, I’ll show you how to manually install and configure an ISC DHCP server on Ubuntu, step-by-step.

We'll also walk through a Bash script you can use to automate the process—ideal for reproducible labs or automated testing environments.

What is DHCP?

DHCP stands for Dynamic Host Configuration Protocol. It automatically assigns IP addresses and network parameters (like subnet mask, default gateway, and DNS servers) to devices in a network—saving you from manually configuring each one.

Prerequisites

To follow along, you'll need:

  • A machine running Ubuntu (any recent LTS version should work fine)
  • sudo access or root privileges
  • A network interface available for DHCP service (e.g. ens4, eth0, etc.)
  • Internet access to install packages

Step-by-Step Manual Setup

1. Update Your System

sudo apt update && sudo apt upgrade -y

2. Install the ISC DHCP Server

sudo apt install -y isc-dhcp-server

This package provides a robust DHCP server used widely in Linux environments.

3. Configure the DHCP Server

Edit the main configuration file:

sudo nano /etc/dhcp/dhcpd.conf

Paste in a basic configuration like this:

option domain-name "localdomain";
option domain-name-servers 8.8.8.8;

default-lease-time 600;
max-lease-time 7200;

authoritative;

subnet 192.168.18.0 netmask 255.255.255.0 {
  range 192.168.18.10 192.168.18.50;
  option routers 192.168.18.1;
  option subnet-mask 255.255.255.0;
  option broadcast-address 192.168.18.255;
}
Adjust subnet, range, and routers to suit your network layout.

This post is for subscribers only

Subscribe to LevelUp I.T. newsletter and stay updated.

Don't miss anything. Get all the latest posts delivered straight to your inbox. It's free!
Great! Check your inbox and click the link to confirm your subscription.
Error! Please enter a valid email address!