Setting up DHCP Server on Ubuntu 20.04

In this article I am demonstrating how to easily install and set up a DHCP Server on Ubuntu 20.04 LTS.

DHCP (Domain Host Configuration Protocol) is a service used to automatically assign network configuration to client systems suck like Printers, Workstations and much more. It is mostly used to provide IP configuration settings, suck as IP addresses, subnet masks and default gateways as well as DNS Server. However it can also be used to configure the time server and hostname on the client device.

DHCP Server
DHCP Server

Installation

Lets get started and get DHCP installed. As usual at this point I have to expect that you already have a running Ubuntu Server. If this is not he case please read here. Execute the following command:

sudo apt install isc-dhcp-server

It should similar to the following screenshot.

DHCP Server installation
DHCP Server installation (isc-dhcp-server)

Configuration

Now that the DHCP Server is installed lets get to the configuration part. Executed the following command:

sudo vim /etc/dhcp/dhcpd.conf

The first two option we should look at and adjust to our environment are the following:

dhcpd.conf file
dhcpd.conf file

Adjust option domain-name “example.org”; to reflect you domain name. I am changing it to: option domain-name “cyberhelp.us”;

The second configuration line I am adjusting is the one right below it and add my DNS Server to so it looks like the following:

option domain-name 8.8.8.8, 8.8.4.4;

Next add the following lines to the end of the file. I will explain below that.

subnet 192.168.69.0 netmask 255.255.255.0 {
range 192.168.69.150 192.168.69.200;
option routers 192.168.69.1;
option domain-name-servers 192.168.69.2, 192.168.69.3;
option domain-name “cyberhelp.us”
}

Save the configuration file. So the first two lines we adjusted are for the common for all subnets options which apply in the subnet configuration if it does not provide those exact option. This will ensure that DHCP hands out IP configuration that will work even though something int he subnet configuration is missing.

Below that we added and entire subnet configuration. Lets break it down. The first directive is based upon two parts.

subnet <IP address for the subnet> netmask <specifies the size of the subnet> {



}

The next directive range <start ip> <end ip>; specifies the subnet IP Range that DHCP can use to hand out IP Addresses.

The one right after that option routers <router or gateway ip> specifies which one the router or gateway IP address is that DHCP will hand out to the clients

lastly the remaining lines you already seen above in the common area are the ones that specifies the domain name and domain name servers but this time it is specific for this subnet we created.

Save and close the dhcpd.conf file and lets restart the DHCP Service with the following command:

sudo systemctl restart isc-dhcp-server

Conclusion

As you can see it is very easy to install and set up a basic DHCP Server on Ubuntu. If you wish to read up on the ISC-DHCP Server read here.
You can find a list of possible subnet configuration in this CIDR Chart.

Hopefully you liked this article. Please let a comment below.

Ciao!