Install Kea DHCP server from source on ubuntu

Kea is an open source implementation of the Dynamic Host Configuration Protocol (DHCP) servers, developed and maintained by Internet Systems Consortium (ISC).

So, we can build and install Kea DHCP server from source on ubuntu.

#!/usr/bin/env bash
# Define variable
KEA_VER="v1_8_0"
CPU_CORES=$(grep -c processor /proc/cpuinfo)
if [ ${CPU_CORES} -gt 1 ]; then
CPU_CORES=$((CPU_CORES 1))
fi
if [ "$(whoami)" != "root" ]; then
SUDO=sudo
fi
# Install libary for build kea DHCP server
${SUDO} apt update && ${SUDO} apt -y full-upgrade
${SUDO} apt -y install build-essential autoconf automake curl git
${SUDO} apt -y build-dep kea-dhcp6-server
# Get kea DHCP source code
rm -rf kea
git clone https://gitlab.isc.org/isc-projects/kea.git -b ${KEA_VER}
# Goto source file
cd kea
# Config to use mysql backend
autoreconf –install –force –warnings='all'
./configure –prefix='/usr' \
–sbindir='/usr/local/sbin' \
–sysconfdir='/etc' \
–localstatedir='/var' \
–with-openssl \
–with-boost-lib-dir='/usr/lib/x86_64-linux-gnu' \
–with-mysql \
–with-pgsql
# Make and install kea DHCP
make -j${CPU_CORES} && ${SUDO} make install
${SUDO} ldconfig
# Add systemd service
cat <<EOF >/lib/systemd/system/kea-dhcp.service
[Unit]
Description=Kea DHCP Server
Documentation=man:kea-dhcp4(8)
Wants=network-online.target
After=network-online.target
After=time-sync.target
[Service]
PermissionsStartOnly=true
Type=forking
RuntimeDirectory=/var/run/kea
RuntimeDirectoryMode=0775
ExecStart=/usr/sbin/keactrl start
ExecReload=/usr/sbin/keactrl reload
ExecStop=/usr/sbin/keactrl stop
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
# Reload service
${SUDO} systemctl daemon-reload
# Enable service
${SUDO} systemctl enable kea-dhcp
# Start service
${SUDO} systemctl restart kea-dhcp
# Edit config file
# /etc/kea/keactrl.conf
exit 0

view raw
kea-dhcp.sh
hosted with ❤ by GitHub

โซเชียล

Leave a Reply