How To Set Up DHCP Server on Ubuntu 22.04 LTS
In this tutorial, we will show you how to set up a DHCP server on Ubuntu 22.04 LTS. For those of you who didn’t know, DHCP also known as a “Dynamic Host Configuration Protocol” server is a network service that automatically assigns IP addresses and other network configuration parameters to client devices on a network. This allows clients to communicate with each other and access the Internet without the need for manual configuration.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo
‘ to the commands to get root privileges. I will show you the step-by-step setup DHCP server on Ubuntu 22.04 (Jammy Jellyfish). You can follow the same instructions for Ubuntu 22.04 and any other Debian-based distribution like Linux Mint, Elementary OS, Pop!_OS, and more as well.
Prerequisites
- A server running one of the following operating systems: Ubuntu 22.04, 20.04, and any other Debian-based distribution like Linux Mint.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- SSH access to the server (or just open Terminal if you’re on a desktop).
- An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies for setup DHCP.
- A
non-root sudo user
or access to theroot user
. We recommend acting as anon-root sudo user
, however, as you can harm your system if you’re not careful when acting as the root.
Set Up DHCP Server on Ubuntu 22.04 LTS Jammy Jellyfish
Step 1. First, make sure that all your system packages are up-to-date by running the following apt
commands in the terminal.
sudo apt update sudo apt upgrade sudo apt install wget apt-transport-https gnupg2 software-properties-common
Step 2. Set Up DHCP Server on Ubuntu 22.04.
To set up a DHCP server on Ubuntu, you will need to install the “isc-dhcp-server
” package and configure it to specify the range of IP addresses that it can assign to clients, as well as other options such as the default gateway and DNS servers:
sudo apt-get install isc-dhcp-server
Once the installation is completed, start the DHCP service and enable it to start at system reboot with the following command:
sudo systemctl start isc-dhcp-server sudo systemctl enable isc-dhcp-server
Step 3. Configure DHCP Service.
To begin with, configure to listen on an interface. You can configure your DHCP server by editing the config file located at /etc/default/isc-dhcp-server
. Open the config file with a text editor of your choice:
nano /etc/default/isc-dhcp-server
Define your network interface as shown below:
INTERFACESv4="eth0"
Next, open the DHCP server configuration file using your favorite text editor:
sudo nano /etc/dhcp/dhcpd.conf
Specify the range of IP addresses that the DHCP server can assign to clients. For example, to specify a range of IP addresses from 192.168.1.100 to 192.168.1.200, you can add the following lines to the configuration file:
subnet 192.168.1.0 netmask 255.255.255.0 { range 192.168.1.100 192.168.1.200; }
Specify the default gateway and DNS servers that the DHCP server should assign to clients. For example, to specify a default gateway of 192.168.1.1 and DNS servers of 8.8.8.8 and 8.8.4.4, you can add the following lines to the configuration file:
option routers 192.168.1.1; option domain-name-servers 8.8.8.8, 8.8.4.4;
Save the configuration file and restart the DHCP server using the following command:
sudo systemctl restart isc-dhcp-server
Congratulations! You have successfully configured the DHCP server. Thanks for using this tutorial to set up the DHCP server on Ubuntu 22.04 LTS Jammy Jellyfish system. For additional help or useful information, we recommend you check the official Ubuntu website.