Jan 30, 2023 8 min read

Kea DHCP4 Installation & Configuration

Kea DHCP4 Installation & Configuration
Table of Contents

This article contains information regarding the installation, configuration, and testing of ISC's Kea DHCP4 server. I run my tests of Kea on Debian Linux within KVM. To give a bit of a foundation you will find two pre-work videos covering the basic installation and configuration of Kea.

Installation

Here I install The ISC Kea DHCP server to a Debian Linux virtual machine. Below you will find video and step-by-step instruction that documents the procedure. In the video I have already installed a Debian server (no gui) running version 10.4 and have SSH'd into the server from my main system. You can get Debian from this link. This page is dedicated to testing Kea DHCP but I wanted to give a bit of a foundation by going through a quick installation first.

I am running this lab in a test environment within KVM.

Warning! Do not attempt this in a production environment, or any other environment that you do not own, unless you have express permission.

Duration: 13 minutes


Procedure

1: SSH into the server.

2: Once you have connected, elevate privileges to root (or a user in sudoers)

3: Curl the repo! By this I mean use the curl command to make a connection to the ISC Kea repository of files. The ISC provides a bash script to make this as painless as possible for you. Below is an easy one-liner that you can run from the command line to run the script. In the video I actually make a script so that I can run it again if needed later, but that is not necessary.

curl -1sLf 'https://dl.cloudsmith.io/public/isc/kea-1-6/cfg/setup/bash.deb.sh'| sudo bash

Note: sudo is not installed by default on Debian servers (with no graphical interface selected). If you want to use sudo, you would have to install it apt install sudo and then configure users appropriately. If you follow what I do in the video, you will see that I am logged in as root, so sudo is not necessary. If you are connected as root, omit "sudo" from the command.

That will connect to the Kea repository, set up a GPG key, and ready the system to accept installations of Kea packages. You might note a failure or two during the curl process. However, this is okay, and it means that the process saw that there were missing dependencies and installed them properly.

Note: The previous command allows you to curl the 1.6 version of the Kea repo. However, in the video I use version 1.7, which as of the recording of the video was not considered a stable release. Only use stable releases in production environments. Newer, unsupported versions should only be run in isolated, test environments. To install the 1.7 repo, simply change the command (or script) to read kea-1-7 instead of kea-1-6.

4: Install the ISC Kea packages. In this lab I installed the common package (which the other Kea packages rely on) and the DHCP4 package. You can install both at once with the following command:

apt install -y isc-kea-common isc-kea-dhcp4-server

5: Check the installation:

systemctl status isc-kea-dhcp4-server

It should show the service as active. But don't worry, it won't start handing out addresses all of a sudden. You still have to configure a listening interface and a proper IP subnet.

Success! That's it! ISC Kea DHCP4 server is installed and ready to be configured to hand out IP addresses to clients.

Note: For more information on the Kea packages and repository installation options, go to this link.
To download individual packages and check their SHA keys, go to the main Cloudsmith repository at this link.


Basic Configuration and Client Connection

In this video I show a basic configuration of a Kea DHCP4 server. Then I connect from a Linux client. I'm using Debian Linux for both and have already installed the ISC Kea DHCP4 server.

Duration: 15 minutes


Procedure

1: Access the kea directory:

cd /etc/kea

2: Open the configuration file and analyze it:

vim kea-dhcp4.conf

3: Rename the configuration file as a backup:

mv kea-dhcp4.conf _kea-dhcp4.conf

4: Create a new configuration file:

vim kea-dhcp4.conf

5: I made a basic configuration file, the contents are below.
Copy the following into the new file:

# The whole configuration starts here.
{
    # DHCPv4 specific configuration starts here.
    "Dhcp4": {
        "interfaces-config": {
            "interfaces": [ "enp1s0" ],
            "dhcp-socket-type": "raw"
        },
        "valid-lifetime": 4000,
        "renew-timer": 1000,
        "rebind-timer": 2000,

        "subnet4": [
	{
	"subnet": "172.21.0.0/16",  
	"pools": [ { "pool": "172.21.50.1-172.21.50.254" } ]
	}],

	"option-data": [
		{
		"name": "routers",
		"data": "172.21.0.1"},
		
		{		
		"name": "domain-name-servers",
		"data": "172.21.0.1"        
		}
		],
	
       # Now loggers are inside the DHCPv4 object.
       "loggers": [{
            "name": "*",
            "severity": "DEBUG"
        }]
    }

# The whole configuration structure ends here.
}

6: Modify the configuration file to reflect your network adapter's name and your particular IP network scheme and save the file.

Note: If you are configuring this on a virtual machine, then you are most likely doing it in NAT mode. If so, your gateway and DNS server IP addresses might be something similar to the following:

  • VirtualBox: 10.0.2.1
  • VMware Workstation: 192.168.80.2
    If you are working in bridged mode, then the gateway and DNS IP will be whatever is supplying those services on your LAN.

7: Restart the DHCP4 server and check its status:

systemctl restart isc-kea-dhcp4-server

systemctl status isc-kea-dhcp4-server

8: Disable any running DHCP servers. If you are using NAT in your virtualization system, then a DHCP server is most likely running and will have to be disabled so there is not a conflict. See the end of this article for more information on how to disable the DHCP servers in VirtualBox, VMware Workstation, and KVM.

9: Connect from a client. Any client set up to obtain an IP address automatically will do! In the video I am using Debian with the Gnome desktop environment.

10: Verify the IP address assigned to the client.
In Linux, type either nmcli or ip a in the Terminal.
In Windows, type ipconfig in the Command Prompt or PowerShell.

Success: Now you have a working DHCP server and connected client (hopefully). Enjoy!


Basic Performance Testing (using perfdhcp)

This is a basic video about testing the performance of a Kea DHCP server. Both the target DHCP server and the testing system are Debian 10.4 virtual machines with 2 CPUs and 4 GB RAM running within KVM. Prior to the video I curled the Kea 1-7 repository on the testing system.

In this video I perform the following:

  • Install the Kea common and admin packages.

  • Test a Kea DHCP4 server using the perfdhcp tool.

Duration: 10 minutes


Procedure

1: Make sure you have the following set up:

  • A Debian server with ISC Kea installed and configured.

  • A Linux client computer to run the tests, with the Kea repository installed. Again, for this lab I am using Debian for both systems.
    See my previous videos on how to install and configure everything required.

2: Install the common and admin packages to the testing computer.

apt install -y isc-kea-common isc-kea-admin

3: From the testing system, test the DHCP server. The syntax for that is:

perfdhcp <IP address>

So for example, in the video I typed:

perfdhcp 172.21.0.211

Your IP address will be different. Let the test run for a minute or so and then end the test by pressing Ctrl+c.

4: View the results. what was the maximum rate of 4-way exchanges/second? Compare that to the results in my video (which was 1688.13 exchanges/sec.)

5: Now try modifying the amount of exchanges per second. For example:

perfdhcp -r 1000 <ip address>

6: Try different values for -r until you find one that is close to a 0% drop rate but allows for as many exchanges as possible.

That's about it for this initial basic test. For more information on perfdhcp, access the MAN page, man perfdhcp, or see this link for the official Kea documentation.

How to shut off DHCP in the Virtualization Platform (VirtualBox, VMware Workstation, and KVM)

If you have a DHCP server already running (and you most likely do) then there can be a conflict. So the pre-existing DHCP server should be temporarily shut off. If you are running a virtualization platform using NAT, then the program has a built-in DHCP server. This video shows how to disable that DHCP server in VirtualBox, VMware Workstation, and KVM. If you are working in bridged mode, then you would need to disable the DHCP server on your LAN.

Warning! Important! Do not attempt to disable a DHCP server in a work or production environment. You will most likely be tracked down and roasted alive.

Duration: 10:30

The video starts with VirtualBox.

VMware Workstation is at 2:15.

KVM is at 4:45.


VirtualBox

Shut down any running virtual machines.

Go to File > Preferences > Network.

Double-click your NAT Network.

Deselect the checkbox for "Network Options: Supports DHCP

Click OK for both Windows.

Close and restart VirtualBox.

VMware Workstation

Shut down any running virtual machines.

Go to Edit > Virtual Network Editor.

Click Change Settings. Be ready to supply an administrator password.

Click the NAT network at the top.

Deselect the checkbox that says: "Use local DHCP service to distribute IP addresses to VMs.

Click Apply and OK.

KVM

Here you have two options: modify the KVM network with virsh, or modify the configuration file directly. As root, do one of the following:

  • Option 1: Type:
virsh net-edit default

Default is the name of the first KVM network that is made automatically for you. Replace "default" with the name of your network if you created another one.

  • Option 2: Type:
vim /etc/libvirt/qemu/networks/default.xml

Note: I prefer to make a backup of the file in case any modifications have unforeseen errors. Do this by typing:

`cp default.xml default-backup.xml`

For either of these, you need to remove the DHCP section:

    <dhcp>
      <range start='192.168.122.2' end='192.168.122.254'/>
    </dhcp>

Then, restart the Virtual Machine Manager.

Note: Newer versions of the Virtual Machine Manager may have a simple checkbox to disable DHCP instead of having to modify default.xml, or using the command virsh net-edit default.

Note: I don't support VMware Fusion, but click here for an article that might help you with Fusion DHCP and Fusion networking in general. Another good link that might help is here.

That's all folks! If you liked this content, click the bookmark below for the entire video course. I'll see you on the Internet!

Building Linux Servers: DHCP, DNS, and Directory Services
13+ Hours of Video Instruction Overview Building Linux Servers: DHCP, DNS, and Directory Services LiveLessons provides a hands-on experience for both new technicians and more experienced technicians, specifically with networking … - Selection from Building Linux Servers: DHCP, DNS, and Directory Se…
Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to Prowse Tech.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.