'\" t .\" Man page generated from reStructuredText. . . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. .TH "KEA-ARM" "1" "Aug 07, 2025" "3.0.0" "Kea" .SH NAME kea-arm \- Kea Administrator Reference Manual Documentation [image] .sp Kea is an open source implementation of the Dynamic Host Configuration Protocol (DHCP) servers, developed and maintained by Internet Systems Consortium (ISC). .sp This is the reference guide for Kea version 3.0.0\&. Links to the most up\-to\-date version of this document (in PDF, HTML, and plain text formats) can be found on \X'tty: link https://kea.readthedocs.io'\fI\%Read the Docs\fP\X'tty: link'\&. Other useful Kea information can be found in our \X'tty: link https://kb.isc.org'\fI\%Knowledgebase\fP\X'tty: link'\&. .SH INTRODUCTION .sp Kea is the next generation of DHCP software, developed by Internet Systems Consortium (ISC). It supports both the DHCPv4 and DHCPv6 protocols along with their extensions, e.g. prefix delegation and dynamic updates to DNS. .sp This guide covers Kea version 3.0.0\&. .sp For information about supported platforms see \fI\%Supported Platforms\fP\&. .SS Supported Platforms .sp In general, this version of Kea builds and runs on any POSIX\-compliant system with a C++ compiler (with C++14 support), the Botan cryptographic library, the log4cplus logging library and the Boost system library. .sp ISC regularly tests Kea on many operating systems and architectures, but lacks the resources to test all of them. Consequently, ISC is only able to offer support on a \(dqbest\-effort\(dq basis for some. .SS Regularly Tested Platforms .sp Kea is officially supported on Alpine, Debian, Fedora, FreeBSD, RHEL, and Ubuntu systems. Kea\-3.0.0 builds have been tested on: .INDENT 0.0 .IP \(bu 2 Alpine — 3.18, 3.19, 3.20, 3.21 .IP \(bu 2 Debian — 10, 11, 12 .IP \(bu 2 Fedora — 40, 41 .IP \(bu 2 FreeBSD — 14 .IP \(bu 2 RHEL — 8, 9 .IP \(bu 2 Ubuntu — 20.04, 22.04, 24.04 .UNINDENT .sp There are currently no plans to port Kea to Windows systems. .SS Best\-Effort .sp The following are platforms on which Kea is known to build and run. ISC makes every effort to fix bugs on these platforms, but may be unable to do so quickly due to lack of hardware, less familiarity on the part of engineering staff, and other constraints. .INDENT 0.0 .IP \(bu 2 macOS — 13, 14 .UNINDENT .SS Community\-Maintained .sp These systems have once been regularly tested, but official support for it has been abandoned, usually due to discontinued support on their own part. Older versions may not have the required dependencies for building Kea easily available, although it is possible in many cases to compile on those directly from source. The community and interested parties may wish to help with maintenance, and we welcome patch contributions, although we cannot guarantee that we will accept them. All contributions are assessed against the risk of adverse effect on officially supported platforms. .sp These include platforms past their respective EOL dates, such as: .INDENT 0.0 .IP \(bu 2 Alpine — 3.16 (EOL 23 May 2022) and older .IP \(bu 2 CentOS — 8 (EOL 31 December 2021) and older .IP \(bu 2 Debian — 9 (EOL 30 June 2022) and older .IP \(bu 2 Fedora — 38 (EOL 21 May 2024) and older .IP \(bu 2 FreeBSD — 12 and older .IP \(bu 2 macOS — 10.15 (EOL 12 September 2022) and older .IP \(bu 2 Ubuntu — 21.04 (EOL 20 January 2022) and older .UNINDENT .SS Unsupported Platforms .sp These are platforms on which versions of Kea since 1.7 are known \fInot\fP to build or run: .INDENT 0.0 .IP \(bu 2 Windows (all versions) .IP \(bu 2 Windows Server (all versions) .IP \(bu 2 Any platform with OpenSSL 1.0.1 or earlier, which does not also have Botan as an alternative .IP \(bu 2 Any platform with log4cplus version 1.0.2 or earlier. .IP \(bu 2 Any platform with a compiler that doesn\(aqt support C++14. .UNINDENT .SS Required Software at Runtime .sp Kea uses various extra software packages which may not be provided in the default installation of some operating systems, nor in the standard package collections. This required software may need to be installed separately. (For the build requirements, also see \fI\%Build Requirements\fP\&.) .INDENT 0.0 .IP \(bu 2 Kea supports two cryptographic libraries: Botan and OpenSSL. Only one of them is required to be installed during compilation. Kea uses the Botan library for C++ (\X'tty: link https://botan.randombit.net/'\fI\%https://botan.randombit.net/\fP\X'tty: link'), version 2.0 or later; support for Botan versions earlier than 2.0 was removed as of Kea 1.7.0. As an alternative to Botan, Kea can use the OpenSSL cryptographic library (\X'tty: link https://www.openssl.org/'\fI\%https://www.openssl.org/\fP\X'tty: link'), version 1.0.2 or later. .IP \(bu 2 Kea uses the log4cplus C++ logging library (\X'tty: link https://sourceforge.net/p/log4cplus/wiki/Home/'\fI\%https://sourceforge.net/p/log4cplus/wiki/Home/\fP\X'tty: link'). It requires log4cplus version 1.0.3 or later. .IP \(bu 2 Kea requires the Boost system library (\X'tty: link https://www.boost.org/'\fI\%https://www.boost.org/\fP\X'tty: link'). Building with the header\-only version of Boost is no longer recommended. .UNINDENT .sp Some optional features of Kea have additional dependencies. .INDENT 0.0 .IP \(bu 2 To store lease information in a MySQL database, Kea requires MySQL headers and libraries. This is an optional dependency; Kea can be built without MySQL support. .IP \(bu 2 To store lease information in a PostgreSQL database, Kea requires PostgreSQL headers and libraries. This is an optional dependency; Kea can be built without PostgreSQL support. .IP \(bu 2 Kea provides a NETCONF interface with the \fBkea\-netconf\fP agent. This Kea module requires Sysrepo software when used. Building Kea with NETCONF support requires many dependencies to be installed, which are described in more detail in \fI\%Installing NETCONF\fP\&. This is an optional dependency; Kea can be built without NETCONF support. .IP \(bu 2 To sign and verify DNS updates the Kea DDNS server may use GSS\-TSIG, which requires MIT Kerberos 5 or Heimdal libraries. The dependencies required to be installed are described in more detail in \fI\%GSS\-TSIG Compilation\fP\&. This is an optional dependency; Kea can be built without GSS\-TSIG support. .UNINDENT .SS Kea Software .sp Kea is a modular DHCP server solution. This modularity is accomplished using multiple cooperating processes which, together, provide the server functionality. The following software is included with Kea: .INDENT 0.0 .IP \(bu 2 \fI\%keactrl\fP — This tool starts, stops, reconfigures, and reports the status of the Kea servers. .IP \(bu 2 \fI\%kea\-dhcp4\fP — The DHCPv4 server process. This process responds to DHCPv4 queries from clients. .IP \(bu 2 \fI\%kea\-dhcp6\fP — The DHCPv6 server process. This process responds to DHCPv6 queries from clients. .IP \(bu 2 \fI\%kea\-dhcp\-ddns\fP — The DHCP Dynamic DNS process. This process acts as an intermediary between the DHCP servers and external DNS servers. It receives name update requests from the DHCP servers and sends DNS update messages to the DNS servers. .IP \(bu 2 \fI\%kea\-admin\fP — This is a useful tool for database backend maintenance (creating a new database, checking versions, upgrading, etc.). .IP \(bu 2 \fI\%kea\-lfc\fP — This process removes redundant information from the files used to provide persistent storage for the memfile database backend. While it can be run standalone, it is normally run as and when required by the Kea DHCP servers. .IP \(bu 2 \fI\%kea\-ctrl\-agent\fP — The Kea Control Agent (CA) is a daemon that exposes a RESTful control interface for managing Kea servers. .IP \(bu 2 \fI\%kea\-netconf\fP \- kea\-netconf is an agent that provides a YANG/NETCONF interface for configuring Kea. .IP \(bu 2 \fI\%kea\-shell\fP — This simple text client uses the REST interface to connect to the Kea Control Agent. .IP \(bu 2 \fI\%perfdhcp\fP — This is a DHCP benchmarking tool which simulates multiple clients to test both DHCPv4 and DHCPv6 server performance. .UNINDENT .sp The tools and modules are covered in full detail in this guide. In addition, manual pages are also provided in the default installation. .sp Kea also provides C++ libraries and programmer interfaces for DHCP. These include detailed developer documentation and code examples. .SH QUICK START .sp This section describes the basic steps needed to get Kea up and running. For further details, full customizations, and troubleshooting, see the respective chapters elsewhere in this Kea Administrator Reference Manual (ARM). .SS Quick Start Guide Using tarball .INDENT 0.0 .IP 1. 3 Install required runtime and build dependencies. See \fI\%Build Requirements\fP for details. .IP 2. 3 Download the Kea source tarball from \X'tty: link https://www.isc.org/download/'\fI\%the main isc.org downloads page\fP\X'tty: link', \X'tty: link https://downloads.isc.org/isc/kea/'\fI\%the ISC downloads site\fP\X'tty: link', or \X'tty: link https://cloudsmith.io/~isc/packages/?q=format%3Araw'\fI\%the ISC Cloudsmith page\fP\X'tty: link'\&. .IP 3. 3 Extract the tarball. For example: .INDENT 3.0 .INDENT 3.5 .sp .EX $ tar \-Jxvf kea\-3.0.0\&.tar.xz .EE .UNINDENT .UNINDENT .IP 4. 3 Go into the source directory and set up the build: .INDENT 3.0 .INDENT 3.5 .sp .EX $ cd kea\-3.0.0 $ meson setup build [your extra parameters] .EE .UNINDENT .UNINDENT .IP 5. 3 Build it: .INDENT 3.0 .INDENT 3.5 .sp .EX $ meson compile \-C build .EE .UNINDENT .UNINDENT .IP 6. 3 Install it (by default it will be placed in \fB/usr/local/\fP, so root privileges are likely required for this step): .INDENT 3.0 .INDENT 3.5 .sp .EX $ meson install \-C build .EE .UNINDENT .UNINDENT .UNINDENT .SS Quick Start Guide Using Native Packages .sp ISC provides native Alpine, deb, and RPM packages, which make Kea installation much easier than building from source. Unless specific compilation options are desired, it is usually easier to install Kea using native packages. .INDENT 0.0 .IP 1. 3 Go to \X'tty: link https://cloudsmith.io/~isc/repos/'\fI\%Kea on cloudsmith.io\fP\X'tty: link'\&. .IP 2. 3 Choose the Cloudsmith repository e.g. kea\-3\-0 for Kea 3.0.0\&. .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 All stable releases are stored in separate repositories, such as kea\-2\-6, kea\-3\-0, and so on. All development releases, which are not recommended for production use, are located in the kea\-dev repository. .UNINDENT .UNINDENT .INDENT 0.0 .IP 3. 3 Click on the arrow beside the \(dqSet Me Up\(dq button and select the desired OS flavor: Alpine, Debian, or RedHat. .IP 4. 3 Follow the onscreen instructions. .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 For example, the Debian setup instructions for Kea 3.0 can be found here: \X'tty: link https://cloudsmith.io/~isc/repos/kea-3-0/setup/#formats-deb'\fI\%https://cloudsmith.io/~isc/repos/kea\-3\-0/setup/#formats\-deb\fP\X'tty: link' .sp The dropdown near the top of the page offers instructions for other operating systems. .UNINDENT .UNINDENT .INDENT 0.0 .IP 5. 3 Kea is split into various packages. The entire list is available on the Cloudsmith repository page under \fBPackages\fP, or it can be retrieved using \fBapk\fP/\fBapt\fP/\fBdnf\fP\&. .UNINDENT .TS box center; l|l. T{ Debian/Ubuntu T} T{ .INDENT 0.0 .INDENT 3.5 .sp .EX $ apt search isc\-kea .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 \fBisc\-kea\-dhcp4\-server\fP and \fBisc\-kea\-dhcp6\-server\fP are empty transitional packages. The working server packages are \fBisc\-kea\-dhcp4\fP and \fBisc\-kea\-dhcp6\fP\&. .UNINDENT .UNINDENT T} _ T{ Fedora/RedHat T} T{ .INDENT 0.0 .INDENT 3.5 .sp .EX $ dnf search \(aqisc\-kea*\(aq .EE .UNINDENT .UNINDENT T} _ T{ Alpine T} T{ .INDENT 0.0 .INDENT 3.5 .sp .EX $ apk search isc\-kea .EE .UNINDENT .UNINDENT T} .TE .INDENT 0.0 .IP 6. 3 Install the metapackage containing all the tools, libraries, servers, documentation, and open source hooks: .UNINDENT .TS box center; l|l. T{ Debian/Ubuntu T} T{ .INDENT 0.0 .INDENT 3.5 .sp .EX $ sudo apt install isc\-kea .EE .UNINDENT .UNINDENT T} _ T{ Fedora/RedHat T} T{ .INDENT 0.0 .INDENT 3.5 .sp .EX $ sudo dnf install isc\-kea .EE .UNINDENT .UNINDENT T} _ T{ Alpine T} T{ .INDENT 0.0 .INDENT 3.5 .sp .EX # apk add isc\-kea .EE .UNINDENT .UNINDENT T} .TE .sp or specific packages: .TS box center; l|l. T{ Debian/Ubuntu T} T{ .INDENT 0.0 .INDENT 3.5 .sp .EX $ sudo apt install isc\-kea\-dhcp6 .EE .UNINDENT .UNINDENT T} _ T{ Fedora/RedHat T} T{ .INDENT 0.0 .INDENT 3.5 .sp .EX $ sudo dnf install isc\-kea\-dhcp6 .EE .UNINDENT .UNINDENT T} _ T{ Alpine T} T{ .INDENT 0.0 .INDENT 3.5 .sp .EX $ apk add isc\-kea\-dhcp6 .EE .UNINDENT .UNINDENT T} .TE .sp or ALL Kea\-related packages, including development headers, debug symbols, and subscriber hooks (if available): .TS box center; l|l. T{ Debian/Ubuntu T} T{ .INDENT 0.0 .INDENT 3.5 .sp .EX $ sudo apt install \(aqisc\-kea*\(aq .EE .UNINDENT .UNINDENT T} _ T{ Fedora/RedHat T} T{ .INDENT 0.0 .INDENT 3.5 .sp .EX $ sudo dnf install \(aqisc\-kea*\(aq .EE .UNINDENT .UNINDENT T} _ T{ Alpine T} T{ Installing packages via globbing (\fB*\fP) is not available for Alpine, but it can be simulated with the following command: .INDENT 0.0 .INDENT 3.5 .sp .EX # apk search isc\-kea | sed \(aqs/\-[0\-9].*//g\(aq | xargs apk add .EE .UNINDENT .UNINDENT T} .TE .sp or all packages with a specified version number: .TS box center; l|l. T{ Debian/Ubuntu T} T{ .INDENT 0.0 .INDENT 3.5 .sp .EX $ sudo apt install \(aqisc\-kea*=2.4.0\-isc20230921141113\(aq .EE .UNINDENT .UNINDENT T} _ T{ Fedora/RedHat T} T{ .INDENT 0.0 .INDENT 3.5 .sp .EX $ sudo dnf install \(aqisc\-kea*2.4.0\-isc20230921141113*\(aq .EE .UNINDENT .UNINDENT T} _ T{ Alpine T} T{ Installing packages via globbing (\fB*\fP) is not available for Alpine, but it can be simulated with the following command: .INDENT 0.0 .INDENT 3.5 .sp .EX # apk search isc\-kea | sed \(aqs/\-[0\-9].*//g\(aq | grep r20230921141113 | xargs apk add .EE .UNINDENT .UNINDENT T} .TE .INDENT 0.0 .IP 8. 3 All installed packages should be now available. .INDENT 3.0 .INDENT 3.5 You can start a server manually: .INDENT 0.0 .INDENT 3.5 .sp .EX # kea\-dhcp6 \-c /etc/kea/kea\-dhcp6.conf .EE .UNINDENT .UNINDENT .UNINDENT .UNINDENT .sp or using systemd: .INDENT 3.0 .INDENT 3.5 .INDENT 0.0 .INDENT 3.5 .sp .EX # systemctl restart kea\-dhcp6 .EE .UNINDENT .UNINDENT .UNINDENT .UNINDENT .sp or using OpenRC on Alpine: .INDENT 3.0 .INDENT 3.5 .INDENT 0.0 .INDENT 3.5 .sp .EX # service kea\-dhcp6 restart .EE .UNINDENT .UNINDENT .UNINDENT .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 \fI\%keactrl\fP is not available in packages, as similar functionality is provided by the native systemctl scripts. .UNINDENT .UNINDENT .INDENT 0.0 .IP 9. 3 On Debian/Ubuntu systems, the service is automatically enabled at boot time when the package is installed. On Fedora/RHEL and Alpine, the service is not automatically enabled, so if desired, it must be enabled manually. .INDENT 3.0 .INDENT 3.5 With systemd on Fedora/RedHat: .INDENT 0.0 .INDENT 3.5 .sp .EX # systemctl enable kea\-dhcp6 .EE .UNINDENT .UNINDENT .sp With OpenRC on Alpine: .INDENT 0.0 .INDENT 3.5 .sp .EX # rc\-update add kea\-dhcp6 .EE .UNINDENT .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS Quick Start Guide Using Docker Containers .INDENT 0.0 .IP 1. 3 Go to the \X'tty: link https://cloudsmith.io/~isc/repos/docker/packages/'\fI\%ISC docker repository on cloudsmith.io\fP\X'tty: link'\&. .IP 2. 3 Create an ipvlan network attached to the client\-facing host interface and assigned to the subnet that is served by Kea. .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX $ docker network create \-\-driver ipvlan \-\-ipv6 \-\-subnet 2001:db8::/64 \-\-opt parent=eth0 ipvlan0 .EE .UNINDENT .UNINDENT .INDENT 0.0 .IP 3. 3 Pick the desired image and pull it locally. .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX $ docker pull docker.cloudsmith.io/isc/docker/kea\-dhcp6 .EE .UNINDENT .UNINDENT .INDENT 0.0 .IP 4. 3 Create a container from the image. Mount the configuration volume and the data volume if needed. .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX $ docker create \e \-\-name kea\-dhcp6 \e \-\-network ipvlan0 \e \-\-volume /local/kea/config:/etc/kea \e \-\-volume /local/kea/data:/var/lib/kea \e docker.cloudsmith.io/isc/docker/kea\-dhcp6 .EE .UNINDENT .UNINDENT .INDENT 0.0 .IP 5. 3 Start the docker container. .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX $ docker start kea\-dhcp6 .EE .UNINDENT .UNINDENT .INDENT 0.0 .IP 6. 3 To stop the docker container, run: .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX $ docker stop kea\-dhcp6 .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Refer to the \X'tty: link https://gitlab.isc.org/isc-projects/kea-docker#user-content-docker-files-for-building-kea-containers'\fI\%kea\-docker readme\fP\X'tty: link' for more complex scenarios. .UNINDENT .UNINDENT .SS Quick Start Guide for DHCPv4 and DHCPv6 Services .INDENT 0.0 .IP 1. 3 Edit the Kea configuration files, which by default are installed in the \fB[kea\-install\-dir]/etc/kea/\fP directory. These are: \fBkea\-dhcp4.conf\fP, \fBkea\-dhcp6.conf\fP, \fBkea\-dhcp\-ddns.conf\fP and \fBkea\-ctrl\-agent.conf\fP, \fBkeactrl.conf\fP for the DHCPv4 server, DHCPv6 server, D2, Control Agent, and keactrl script, respectively. .IP 2. 3 To start the DHCPv4 server in the background, run the following command (as root): .INDENT 3.0 .INDENT 3.5 .sp .EX # keactrl start \-s dhcp4 .EE .UNINDENT .UNINDENT .sp Or run the following command to start the DHCPv6 server: .INDENT 3.0 .INDENT 3.5 .sp .EX # keactrl start \-s dhcp6 .EE .UNINDENT .UNINDENT .sp Note that it is also possible to start all servers simultaneously: .INDENT 3.0 .INDENT 3.5 .sp .EX # keactrl start .EE .UNINDENT .UNINDENT .IP 3. 3 Verify that the Kea server(s) is/are running: .INDENT 3.0 .INDENT 3.5 .sp .EX # keactrl status .EE .UNINDENT .UNINDENT .sp A server status of \(dqinactive\(dq may indicate a configuration error. Please check the log file (by default named \fB[kea\-install\-dir]/var/log/kea/kea\-dhcp4.log\fP, \fB[kea\-install\-dir]/var/log/kea/kea\-dhcp6.log\fP, \fB[kea\-install\-dir]/var/log/kea/kea\-ddns.log\fP, or \fB[kea\-install\-dir]/var/log/kea/kea\-ctrl\-agent.log\fP) for the details of any errors. .IP 4. 3 If the server has started successfully, test that it is responding to DHCP queries and that the client receives a configuration from the server; for example, use the \X'tty: link https://www.isc.org/download/'\fI\%ISC DHCP client\fP\X'tty: link'\&. .IP 5. 3 To stop running the server(s): .INDENT 3.0 .INDENT 3.5 .sp .EX # keactrl stop .EE .UNINDENT .UNINDENT .UNINDENT .sp For system\-specific instructions, please read the \X'tty: link https://kb.isc.org/docs/installing-kea'\fI\%system\-specific notes\fP\X'tty: link', available in the Kea section of \X'tty: link https://kb.isc.org/docs'\fI\%ISC\(aqs Knowledgebase\fP\X'tty: link'\&. .sp The details of \fI\%keactrl\fP script usage can be found in \fI\%Managing Kea with keactrl\fP\&. .sp Once Kea services are up and running, consider deploying a dashboard solution to monitor running services. For more details, see \fI\%Monitoring Kea With Stork\fP\&. .SS Running the Kea Servers Directly .sp The Kea servers can be started directly, without the need to use \fI\%keactrl\fP or \fBsystemctl\fP\&. To start the DHCPv4 server run the following command: .INDENT 0.0 .INDENT 3.5 .sp .EX # kea\-dhcp4 \-c /path/to/your/kea4/config/file.json .EE .UNINDENT .UNINDENT .sp Similarly, to start the DHCPv6 server, run the following command: .INDENT 0.0 .INDENT 3.5 .sp .EX # kea\-dhcp6 \-c /path/to/your/kea6/config/file.json .EE .UNINDENT .UNINDENT .SH INSTALLATION .SS Packages .sp ISC publishes native RPM, deb, and APK packages, as well as tarballs with the source code. The packages are available in \X'tty: link https://cloudsmith.io/~isc/repos'\fI\%ISC\(aqs Cloudsmith repositories\fP\X'tty: link'\&. The native packages can be downloaded and installed using the system available in a specific distribution (such as dpkg or rpm). The Kea repository can also be added to the system, making it easier to install updates. For details, please go to \X'tty: link https://cloudsmith.io/~isc/repos'\fI\%https://cloudsmith.io/~isc/repos\fP\X'tty: link', choose the desired Kea version, and then click the \(dqSet Me Up\(dq button. For detailed instructions, please refer to this \X'tty: link https://kb.isc.org/docs/isc-kea-packages'\fI\%Knowledgebase article\fP\X'tty: link'\&. .sp ISC maintains two types of repositories: stable and development. The stable repositories contain a single stable release (e.g., kea\-2\-6 or kea\-3\-0) along with all its maintenance updates. Separate repositories were introduced to minimize the risk of unintentionally upgrading from one stable release to another. .sp The development repository, kea\-dev, includes current and future development releases, which ISC does not recommend for production use. Packages in the kea\-dev repository are subject to cleanup, and older versions may be removed. .SS Installation From Cloudsmith Packages .sp ISC provides Kea packages for Alpine, Debian, Fedora, RHEL, and Ubuntu. The recommended method for installing Kea on any of these systems is to install the \fBisc\-kea\fP metapackage from the Cloudsmith repository. This metapackage is included on all supported distros and installs all of the services offered by the Kea software suite. .sp Specific Kea components can be installed individually, with any of the following packages: .INDENT 0.0 .IP \(bu 2 \fBisc\-kea\-dhcp4\fP — Kea DHCPv4 server package .IP \(bu 2 \fBisc\-kea\-dhcp6\fP — Kea DHCPv6 server package .IP \(bu 2 \fBisc\-kea\-dhcp\-ddns\fP — Kea DHCP DDNS server .IP \(bu 2 \fBisc\-kea\-ctrl\-agent\fP — Kea Control Agent for remote configuration .IP \(bu 2 \fBisc\-kea\-admin\fP — Kea database administration tools .IP \(bu 2 \fBisc\-kea\-hooks\fP — Kea open source DHCP hooks .UNINDENT .sp The Kea subscriber hook packages are not included in the \fBisc\-kea\-hooks\fP package. For ISC customers with access to the subscriber hooks, those packages have the \fBisc\-kea\-subscriber\-\fP prefix. For users interested in purchasing professional support services from ISC and getting access to the subscriber hooks, please fill out our contact form at \X'tty: link https://www.isc.org/contact'\fI\%https://www.isc.org/contact\fP\X'tty: link'\&. .sp Once installed, the services can be managed through the distribution\(aqs service manager. The services are named: \fI\%kea\-dhcp4\fP, \fI\%kea\-dhcp6\fP, \fI\%kea\-dhcp\-ddns\fP, and \fI\%kea\-ctrl\-agent\fP\&. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The real service names on Debian and Ubuntu use slightly different package names, to maintain compatibility with some older scripts. A systemd service alias is used to allow users to refer to them with shorter names. Calling \fBsystemctl enable\fP on these services requires the real service names, which are: \fBisc\-kea\-dhcp4\-server\fP, \fBisc\-kea\-dhcp6\-server\fP, \fBisc\-kea\-dhcp\-ddns\-server\fP, and \fBisc\-kea\-ctrl\-agent\fP\&. .UNINDENT .UNINDENT .SS Caveats When Upgrading Kea Packages .sp To upgrade to a current version of Kea from version 2.3.2 or earlier on Debian and Ubuntu systems, run \fBapt dist\-upgrade\fP instead of the usual \fBapt upgrade\fP\&. Once this upgrade has been completed, it is possible to upgrade to later versions normally using \fBapt upgrade\fP on Debian and Ubuntu systems. .sp Users may notice differences in the packages distributed in Kea versions prior to 2.3.2 and those distributed with 2.3.2 and later. As a result of an overhaul of our package design with that release, some packages were renamed or removed. To ensure that upgrades go as smoothly as possible, pay attention to which packages are being removed and installed by the upgrade transaction, and ensure that all required packages are reinstalled. .sp Specifically, there is a possibility for the following packages to be removed during the upgrade, depending on which packages were originally installed: .INDENT 0.0 .IP \(bu 2 \fBisc\-kea\-dhcp4\fP .IP \(bu 2 \fBisc\-kea\-dhcp6\fP .IP \(bu 2 \fBisc\-kea\-dhcp\-ddns\fP .IP \(bu 2 \fBisc\-kea\-hooks\fP .UNINDENT .sp To install the entire Kea software suite, simply run \fBapt install isc\-kea\fP after upgrading, which will install all of the relevant subpackages that make up Kea. .sp This upgrade path issue does not apply to RPM and Alpine systems. .sp Customers with ISC support contracts who experience difficulties with upgrading are invited to open a ticket in their support queue. Other users are encouraged to describe their situation on the \X'tty: link https://lists.isc.org/mailman/listinfo/kea-users'\fI\%kea\-users mailing list\fP\X'tty: link' for best\-effort support from other list members. .SS Installation Hierarchy .sp The following is the directory layout of the complete Kea installation. (All directory paths are relative to the installation directory.) .INDENT 0.0 .IP \(bu 2 \fBetc/kea/\fP — configuration files. .IP \(bu 2 \fBinclude/\fP — C++ development header files. .IP \(bu 2 \fBlib/\fP — libraries. .IP \(bu 2 \fBlib/kea/hooks\fP — additional hook libraries. .IP \(bu 2 \fBsbin/\fP — server software and commands used by the system administrator. .IP \(bu 2 \fBshare/doc/kea/\fP — this guide, other supplementary documentation, and examples. .IP \(bu 2 \fBshare/kea/\fP — API command examples and database schema scripts. .IP \(bu 2 \fBshare/man/\fP — manual pages (online documentation). .IP \(bu 2 \fBvar/lib/kea/\fP — server identification and lease database files. .IP \(bu 2 \fBvar/log/kea/\fP \- log files. .IP \(bu 2 \fBvar/run/kea\fP \- PID file and logger lock file. .UNINDENT .SS Build Requirements .sp In addition to the runtime requirements (listed in \fI\%Required Software at Runtime\fP), building Kea from source code requires various development include headers and program development tools. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Some operating systems have split their distribution packages into a runtime and a development package. The development package versions, which include header files and libraries, must be installed to build Kea from the source code. .UNINDENT .UNINDENT .sp Building from source code requires the following software installed on the system: .INDENT 0.0 .IP \(bu 2 The development tools meson, ninja, and pkg\-config. .IP \(bu 2 Boost C++ libraries (\X'tty: link https://www.boost.org/'\fI\%https://www.boost.org/\fP\X'tty: link'). The oldest Boost version used for testing is 1.67 (although Kea may also work with older versions e.g. 1.66). The Boost system library must also be installed. Installing a header\-only version of Boost is not recommended. .IP \(bu 2 OpenSSL (at least version 1.0.2) or Botan (at least version 2). OpenSSL version 1.1.1 or later is strongly recommended. .IP \(bu 2 log4cplus (at least version 1.0.3) development include headers. .IP \(bu 2 A C++ compiler (with C++14 support) and standard development headers. .IP \(bu 2 The MySQL client and the client development libraries, when using the \fB\-D mysql=enabled\fP configuration flag to build the Kea MySQL database backend. In this case, an instance of the MySQL server running locally or on a machine reachable over a network is required. Note that running the unit tests requires a local MySQL server. .IP \(bu 2 The PostgreSQL client and the client development libraries, when using the \fB\-D postgresql=enabled\fP configuration flag to build the Kea PostgreSQL database backend. In this case an instance of the PostgreSQL server running locally or on a machine reachable over a network is required. Note that running the unit tests requires a local PostgreSQL server. .IP \(bu 2 Sysrepo v1.4.140 and libyang v1.0.240, needed to connect to a Sysrepo datastore. Earlier versions are no longer supported. When compiling from sources, the configure switch that can be used is \fB\-D netconf=enabled\fP\&. If these dependencies were installed in custom paths, point PKG_CONFIG_PATH to them. .IP \(bu 2 The MIT Kerberos 5 or Heimdal libraries are needed by Kea DDNS server to sign and verify DNS updates using GSS\-TSIG. The configuration switch which enables this functionality is \fB\-D krb5=enabled\fP\&. If this dependency is installed in a custom path, point PKG_CONFIG_PATH to the .pc file or PATH to the krb5\-config tool. .IP \(bu 2 googletest (version 1.8 or later) is required when using the \fB\-D tests=enabled\fP configuration option to build the unit tests. .IP \(bu 2 The documentation generation tools \X'tty: link https://www.sphinx-doc.org/'\fI\%Sphinx\fP\X'tty: link', texlive with its extensions, and Doxygen, to create the documentation. Specifically, with Fedora, \fBpython3\-sphinx\fP, \fBpython3\-sphinx_rtd_theme\fP, \fBtexlive\fP, and \fBtexlive\-collection\-latexextra\fP are necessary. With Ubuntu, \fBpython3\-sphinx\fP, \fBpython3\-sphinx\-rtd\-theme\fP, \fBtexlive\fP, and \fBtexlive\-latex\-extra\fP are needed. If LaTeX packages are missing, Kea skips PDF generation and produces only HTML documents. .UNINDENT .sp Visit ISC\(aqs Knowledgebase at \X'tty: link https://kb.isc.org/docs/installing-kea'\fI\%https://kb.isc.org/docs/installing\-kea\fP\X'tty: link' for system\-specific installation tips. .SS Installation From Source .sp Although Kea may be available in pre\-compiled, ready\-to\-use packages from operating system vendors, it is open source software written in C++. As such, it is freely available in source code form from ISC as a downloadable tar file. The source code can also be obtained from the Kea GitLab repository at \X'tty: link https://gitlab.isc.org/isc-projects/kea'\fI\%https://gitlab.isc.org/isc\-projects/kea\fP\X'tty: link'\&. This section describes how to build Kea from the source code. .SS Download Tar File .sp The Kea release tarballs may be downloaded from: \X'tty: link https://downloads.isc.org/isc/kea/'\fI\%https://downloads.isc.org/isc/kea/\fP\X'tty: link'\&. .SS Verify The Tar File Signature .sp The tar file with the source code is distributed together with its GPG signature. The signature is a file with the same name as the tar file appended by the \fB\&.asc\fP extension. You can find the signature file on our download page, FTP, or CloudSmith. .sp The signature is created using the ISC code\-signing key. The current set of ISC code\-signing keys is available from the ISC website at \X'tty: link https://www.isc.org/pgpkey'\fI\%https://www.isc.org/pgpkey\fP\X'tty: link' (the \X'tty: link https://www.isc.org/docs/isc-keyblock.asc'\fI\%Current Set of ISC Code\-Signing Keys\fP\X'tty: link' link). .sp The signature can be verified using the GnuPGP \fBgpg\fP tool. The following commands import the code\-signing keys (\fBisc\-keyblock.asc\fP) and verify the signature: .INDENT 0.0 .INDENT 3.5 .sp .EX $ gpg \-\-import isc\-keyblock.asc $ gpg \-\-verify kea\-X.Y.Z.tar.xz.asc kea\-X.Y.Z.tar.xz .EE .UNINDENT .UNINDENT .sp The verification allows users to confirm that the tar file has not been tampered with and that it was created by ISC. .SS Retrieve From Git .sp The latest development code is available on GitLab (see \X'tty: link https://gitlab.isc.org/isc-projects/kea'\fI\%https://gitlab.isc.org/isc\-projects/kea\fP\X'tty: link'). The Kea source is public and development is done in the “master” branch. .sp Downloading this \(dqbleeding edge\(dq code is recommended only for developers or advanced users. Using development code in a production environment is not recommended. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 When building from source code retrieved via git, additional software is required: automake (v1.11 or later), libtoolize, and autoconf (v2.69 or later). These may need to be installed. .UNINDENT .UNINDENT .sp The code can be checked out from \fBhttps://gitlab.isc.org/isc\-projects/kea.git\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX $ git clone https://gitlab.isc.org/isc\-projects/kea.git .EE .UNINDENT .UNINDENT .sp The code checked out from the git repository does not include the build files. They can be created by running \fBmeson setup build\fP\&. .sp Write access to the Kea repository is only granted to ISC staff. Developers planning to contribute to Kea should check our \X'tty: link https://gitlab.isc.org/isc-projects/kea/blob/master/contributors-guide.md'\fI\%Contributor\(aqs Guide\fP\X'tty: link'\&. The \X'tty: link https://reports.kea.isc.org/dev_guide/'\fI\%Kea Developer\(aqs Guide\fP\X'tty: link' contains more information about the process, and describes the requirements for contributed code to be accepted by ISC. .SS Set Up the Build .sp Kea uses Meson to discover build environment details. To generate the ninja file using the defaults, simply run: .INDENT 0.0 .INDENT 3.5 .sp .EX $ meson setup build .EE .UNINDENT .UNINDENT .sp Run \fBmeson configure\fP to view the different build options. Some commonly used options are: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fB\-\-prefix\fP Define the installation location (the default is \fB/usr/local\fP). .IP \(bu 2 \fB\-D mysql=enabled\fP Build Kea with code to allow it to store leases and host reservations in a MySQL database. .IP \(bu 2 \fB\-D postgresql=enabled\fP Build Kea with code to allow it to store leases and host reservations in a PostgreSQL database. .IP \(bu 2 \fB\-D krb5=enabled\fP Build Kea with Kerberos5 with GSS\-API support required by \fI\%libddns_gss_tsig.so\fP\&. .IP \(bu 2 \fB\-D netconf=enabled\fP Build Kea with libyang and sysrepo support required by \fI\%kea\-netconf\fP\&. .IP \(bu 2 \fB\-D crypto=botan\fP Specify the name of the Botan pkg\-config library e.g. \fBbotan\-2\fP to build with Botan for cryptographic functions. It is preferable to use OpenSSL (see below). .IP \(bu 2 \fB\-\-D crypto=openssl\fP Use the OpenSSL cryptographic library instead of Botan. By default Meson searches for a valid Botan installation; if one is not found, Kea searches for OpenSSL. Normally this is not necessary. .UNINDENT .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 For instructions concerning the installation and configuration of database backends for Kea, see \fI\%DHCP Database Installation and Configuration\fP\&. .UNINDENT .UNINDENT .sp If \fBmeson setup build\fP fails, it may be due to missing or old dependencies. .sp When \fBmeson setup build\fP succeeds, it displays a report with the parameters used to build the code. This report is saved into the file \fBbuild/config.report\fP and is also embedded into the executable binaries, e.g. \fI\%kea\-dhcp6\fP\&. .SS Build .sp After the setup step is complete, build the executables from the C++ code and prepare the Python scripts by running the command: .INDENT 0.0 .INDENT 3.5 .sp .EX $ meson compile \-C build .EE .UNINDENT .UNINDENT .SS Install .sp To install the Kea executables, support files, and documentation, issue the command: .INDENT 0.0 .INDENT 3.5 .sp .EX $ meson install \-C build .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The install step may require superuser privileges. .UNINDENT .UNINDENT .sp It should not be required, but if shared libraries are not found at runtime, you can run \fBldconfig\fP as root with \fB/usr/local/lib\fP (or with \fB${prefix}/lib\fP if set up with \fB\-\-prefix\fP) in \fB/etc/ld.so.conf\fP (or the relevant linker cache configuration file for the OS): .INDENT 0.0 .INDENT 3.5 .sp .EX $ ldconfig .EE .UNINDENT .UNINDENT .sp If \fBldconfig\fP is not run where required, users may see errors like the following: .INDENT 0.0 .INDENT 3.5 .sp .EX program: error while loading shared libraries: libkea\-something.so.1: cannot open shared object file: No such file or directory .EE .UNINDENT .UNINDENT .SS Cross\-Building .sp It is possible to cross\-build Kea, i.e. to create binaries in a separate system (the \fBbuild\fP system) from the one where Kea runs (the \fBhost\fP system). .sp It is outside of the scope of common administrator operations and requires some developer skills, but the Developer Guide explains how to do that using an x86_64 Linux system to build Kea for a Raspberry Pi box running Raspbian: see this \X'tty: link https://reports.kea.isc.org/dev_guide/de/d9a/crossCompile.html'\fI\%Kea Cross\-Compiling Example\fP\X'tty: link'\&. .SS DHCP Database Installation and Configuration .sp Kea stores its leases in a lease database. The software has been written in a way that makes it possible to choose which database product should be used to store the lease information. Kea supports three database backends: MySQL, PostgreSQL, and memfile. To limit external dependencies, MySQL and PostgreSQL support are disabled by default and only memfile is available. Support for the optional external database backend must be explicitly included when Kea is built. This section covers the building of Kea with one of the optional backends and the creation of the lease database. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 When unit tests are built with Kea (i.e. the \fB\-D tests=enabled\fP configuration option is specified), the databases must be manually pre\-configured for the unit tests to run. The details of this configuration can be found in the \X'tty: link https://reports.kea.isc.org/dev_guide/'\fI\%Kea Developer\(aqs Guide\fP\X'tty: link'\&. .UNINDENT .UNINDENT .SS Building with MySQL Support .sp Install MySQL according to the instructions for the system. The client development libraries must be installed. .sp Build and install Kea as described in \fI\%Installation\fP, with the following modification. To enable the MySQL database code, at the setup step (see \fI\%Set Up the Build\fP), the \fB\-D mysql=enabled\fP switch should be specified: .INDENT 0.0 .INDENT 3.5 .sp .EX $ meson setup build \-D mysql=enabled .EE .UNINDENT .UNINDENT .sp If MySQL was not installed in the default location, the location can be selected by setting \fBPKG_CONFIG_PATH=/path/to/mariadb.pc:${PKG_CONFIG_PATH}\fP or \fBPATH=/path/to/mariadb\-config:${PATH}\fP prior to \fBmeson setup\fP\&. .INDENT 0.0 .INDENT 3.5 .sp .EX $ PKG_CONFIG_PATH=/opt/mariadb/lib/pkgconfig PATH=/opt/mariadb/bin meson setup build \-D mysql=enabled .EE .UNINDENT .UNINDENT .sp See \fI\%First\-Time Creation of the MySQL Database\fP for details regarding MySQL database configuration. .SS Building with PostgreSQL Support .sp Install PostgreSQL according to the instructions for the system. The client development libraries must be installed. Client development libraries are often packaged as \fBlibpq\fP\&. .sp Build and install Kea as described in \fI\%Installation\fP, with the following modification. To enable the PostgreSQL database code, at the setup step (see \fI\%Set Up the Build\fP), the \fB\-D postgresql=enabled\fP switch should be specified. .sp If PostgreSQL was not installed in the default location, the location can be selected by setting \fBPKG_CONFIG_PATH=/path/to/libpq.pc:${PKG_CONFIG_PATH}\fP or \fBPATH=/path/to/pg_config:${PATH}\fP prior to \fBmeson setup\fP\&. .INDENT 0.0 .INDENT 3.5 .sp .EX $ PKG_CONFIG_PATH=/opt/postgresql/lib/pkgconfig PATH=/opt/postgresql/bin meson setup build \-D postgresql=enabled .EE .UNINDENT .UNINDENT .sp See \fI\%First\-Time Creation of the PostgreSQL Database\fP for details regarding PostgreSQL database configuration. .SS Hammer Building Tool .sp Hammer is a Python 3 script that lets users automate tasks related to building Kea, such as setting up virtual machines, installing Kea dependencies, compiling Kea with various options, running unit\-tests and more. This tool was created primarily for internal QA purposes at ISC and it is not included in the Kea distribution; however, it is available in the Kea git repository. This tool was developed primarily for internal purposes and ISC cannot guarantee its proper operation. Administrators who decide to use it should do so with care. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Use of this tool is completely optional. Everything it does can be done manually. .UNINDENT .UNINDENT .sp The first\-time user is strongly encouraged to look at Hammer\(aqs built\-in help: .INDENT 0.0 .INDENT 3.5 .sp .EX $ ./hammer.py \-\-help .EE .UNINDENT .UNINDENT .sp It will list available parameters. .sp Hammer is able to set up various operating systems running either in LXC or in VirtualBox. For a list of supported systems, use the \fBsupported\-systems\fP command: .INDENT 0.0 .INDENT 3.5 .sp .EX $ ./hammer.py supported\-systems fedora: \- 37: lxc \- 38: centos: \- 8: lxc, virtualbox \- 9: rhel: \- 8: virtualbox \- 9: ubuntu: \- 18.04: lxc, virtualbox \- 20.04: lxc \- 22.04: lxc debian: \- 10: lxc, virtualbox \- 11: lxc \- 12: lxc freebsd: \- 12.0: virtualbox \- 12.1: \- 13.0: virtualbox alpine: \- 3.15: lxc \- 3.16: lxc \- 3.17: lxc .EE .UNINDENT .UNINDENT .sp It is also possible to run the build locally, in the current system (if the OS is supported). .sp First, the Hammer dependencies must be installed: Vagrant and either VirtualBox or LXC. Hammer can install Vagrant and the required Vagrant plugins using the command: .INDENT 0.0 .INDENT 3.5 .sp .EX $ ./hammer.py ensure\-hammer\-deps .EE .UNINDENT .UNINDENT .sp VirtualBox and LXC must be installed manually. .sp The basic functions provided by Hammer are to prepare the build environment and perform the actual build, and to run the unit tests locally in the current system. This can be achieved by running the command: .INDENT 0.0 .INDENT 3.5 .sp .EX $ ./hammer.py build \-p local .EE .UNINDENT .UNINDENT .sp The scope of the process can be defined using the \fB\-\-with\fP (\fB\-w\fP) and \fB\-\-without\fP (\fB\-x\fP) options. By default, the \fBbuild\fP command builds Kea with documentation, installs it locally, and runs unit tests. .sp To exclude the installation and generation of docs, type: .INDENT 0.0 .INDENT 3.5 .sp .EX $ ./hammer.py build \-p local \-x install docs .EE .UNINDENT .UNINDENT .sp The basic scope can be extended by mysql, pgsql, native\-pkg, shell, and forge. Please refer to \fB\&./hammer.py build \-\-help\fP for more details. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 If building Kea locally, Hammer dependencies like Vagrant are not needed. .UNINDENT .UNINDENT .sp Hammer can be told to set up a new virtual machine with a specified operating system, without the build: .INDENT 0.0 .INDENT 3.5 .sp .EX $ ./hammer.py prepare\-system \-p virtualbox \-s freebsd \-r 12.0 .EE .UNINDENT .UNINDENT .sp This way, a system can be prepared for our own use. .sp To prepare such a system using SSH, invoke: .INDENT 0.0 .INDENT 3.5 .sp .EX $ ./hammer.py ssh \-p virtualbox \-s freebsd \-r 12.0 .EE .UNINDENT .UNINDENT .sp It is possible to speed up subsequent Hammer builds via \X'tty: link https://ccache.samba.org/'\fI\%ccache\fP\X'tty: link'\&. During compilation, ccache stores objects in a shared folder. In subsequent runs, instead of doing an actual compilation, ccache returns the stored earlier objects. The cache with these objects for reuse must be stored outside of VM or LXC. To indicate the folder, the \fB\-\-ccache\-dir\fP parameter for Hammer must be included. In the indicated folder, there are separate stored objects for each target operating system. .INDENT 0.0 .INDENT 3.5 .sp .EX $ ./hammer.py build \-p lxc \-s ubuntu \-r 18.04 \-\-ccache\-dir ~/kea\-ccache .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 ccache is currently only supported for LXC in Hammer; support for VirtualBox may be added later. .UNINDENT .UNINDENT .sp For more information check: .INDENT 0.0 .INDENT 3.5 .sp .EX $ ./hammer.py \-\-help .EE .UNINDENT .UNINDENT .SS Running Kea From a Non\-root Account on Linux .sp Both Kea DHCPv4 and DHCPv6 servers perform operations that in general require root access privileges. In particular, DHCPv4 opens raw sockets and both DHCPv4 and DHCPv6 open UDP sockets on privileged ports. However, with some extra system configuration, it is possible to run Kea from non\-root accounts. .sp First, a regular user account must be created: .INDENT 0.0 .INDENT 3.5 .sp .EX useradd admin .EE .UNINDENT .UNINDENT .sp Then, change the binaries\(aq ownership and group to the new user. Note that the specific path may be different. Please refer to the \fB\-\-prefix\fP parameter passed to \fBmeson setup\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX chown \-R admin /opt/kea chgrp \-R admin /opt/kea chown \-R admin /var/log/kea/kea\-dhcp4.log chgrp \-R admin /var/log/kea/kea\-dhcp4.log chown \-R admin /var/log/kea/kea\-dhcp6.log chgrp \-R admin /var/log/kea/kea\-dhcp6.log .EE .UNINDENT .UNINDENT .sp If using systemd, modify its service file (e.g. /etc/systemd/system/kea\-dhcp6.service): .INDENT 0.0 .INDENT 3.5 .sp .EX User=admin Group=admin .EE .UNINDENT .UNINDENT .sp The most important step is to set the capabilities of the binaries. Refer to the operating system man page for \fIcapabilities\fP for more information. .INDENT 0.0 .INDENT 3.5 .sp .EX setcap \(aqcap_net_bind_service,cap_net_raw=+ep\(aq /opt/kea/sbin/kea\-dhcp4 setcap \(aqcap_net_bind_service=+ep\(aq /opt/kea/sbin/kea\-dhcp6 .EE .UNINDENT .UNINDENT .sp If using systemd, also add this to the service file (e.g. /etc/systemd/system/kea\-dhcp6.service): .INDENT 0.0 .INDENT 3.5 .sp .EX ExecStartPre=setcap \(aqcap_net_bind_service=+ep\(aq /opt/kea/sbin/kea\-dhcp6 .EE .UNINDENT .UNINDENT .sp After this step is complete, the admin user should be able to run Kea. Note that the DHCPv4 server by default opens raw sockets. If the network is only using relayed traffic, Kea can be instructed to use regular UDP sockets (refer to \fBdhcp\-socket\-type\fP parameter in the \fI\%Interface Configuration\fP section) and the \fBcap_net_raw\fP capability can be skipped. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 It is possible to avoid running Kea with root privileges by instructing Kea to use non\-privileged (greater than 1024) ports and redirecting traffic. This, however, only works for relayed traffic. This approach in general is considered experimental and has not been tested for deployment in production environments. Use with caution! .sp To use this approach, configure the server to listen on other non\-privileged ports (e.g. 1547 and 1548) by running the process with the \fB\-p\fP option in \fB/etc/systemd/system/kea\-dhcp4.service\fP: .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX ExecStart=/opt/kea/sbin/kea\-dhcp4 \-d \-c /etc/kea/kea\-dhcp4.conf \-p 2067 .EE .UNINDENT .UNINDENT .sp and \fB/etc/systemd/system/kea\-dhcp4.service\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX ExecStart=/opt/kea/sbin/kea\-dhcp6 \-d \-c /etc/kea/kea\-dhcp6.conf \-p 1547 .EE .UNINDENT .UNINDENT .sp Then configure port redirection with iptables and ip6tables for new ports (e.g. 1547 and 1548). Be sure to replace \fBens4\fP with the specific interface name. .INDENT 0.0 .INDENT 3.5 .sp .EX iptables \-t nat \-A PREROUTING \-i ens4 \-p udp \-\-dport 67 \-j REDIRECT \-\-to\-port 2067 iptables \-t nat \-A PREROUTING \-i ens4 \-p udp \-\-dport 2068 \-j REDIRECT \-\-to\-port 68 ip6tables \-t nat \-A PREROUTING \-i ens4 \-p udp \-\-dport 547 \-j REDIRECT \-\-to\-port 1547 ip6tables \-t nat \-A PREROUTING \-i ens4 \-p udp \-\-dport 1548 \-j REDIRECT \-\-to\-port 548 .EE .UNINDENT .UNINDENT .SS Deprecated Features .sp This section lists significant features that have been or will be removed. We try to deprecate features before removing them, to signal to current users to plan a migration. New users should not rely on deprecated features. .SS Sysrepo 0.x or 1.x .sp Kea 2.3.2 introduced support for Sysrepo 2.x. Unfortunately, Sysrepo continues to undergo major changes that are backward\-incompatible, and current Kea versions do not support Sysrepo earlier than versions 2.x. .SH KEA DATABASE ADMINISTRATION .SS Databases and Schema Versions .sp Kea may be configured to use a database as storage for leases or as a source of servers\(aq configurations and host reservations (i.e. static assignments of addresses, prefixes, options, etc.). As Kea is updated, new database schemas are introduced to facilitate new features and correct discovered issues with the existing schemas. .sp Each version of Kea expects a particular schema structure and checks for this by examining the version of the database it is using. Separate version numbers are maintained for the schemas, independent of the version of Kea itself. It is possible that the schema version will stay the same through several Kea revisions; similarly, it is possible that the version of the schema may go up several revisions during a single Kea version upgrade. Versions for each backend type are also independent, so an increment in the MySQL backend version does not imply an increment in that of PostgreSQL. .sp Schema versions are specified in a major.minor format. For the most recent versions, the minor version is always zero and only the major version is incremented. .sp Historically, the minor version used to be incremented when backward\-compatible changes were introduced to the schema: for example \- when a new index is added. This was opposed to incrementing the major version which implied an incompatible schema change: for example \- changing the type of an existing column. If Kea attempts to run on a schema that is too old, as indicated by a mismatched schema version, it will fail; administrative action is required to upgrade the schema. .SS The \fI\%kea\-admin\fP Tool .sp To manage the databases, Kea provides the \fI\%kea\-admin\fP tool. It can initialize a new backend, check its version number, perform a backend upgrade, and dump lease data to a text file. .sp \fI\%kea\-admin\fP takes two mandatory parameters: \fBcommand\fP and \fBbackend\fP\&. Additional, non\-mandatory options may be specified. The currently supported commands are: .INDENT 0.0 .IP \(bu 2 \fBdb\-init\fP — initializes a new database schema, which is useful during a new Kea installation. The new database is updated to match the Kea version being installed. \fI\%kea\-admin\fP is automatically invoked with this command if a missing schema is detected during startup or reconfiguration of Kea DHCP servers. .IP \(bu 2 \fBdb\-version\fP — reports the database backend version number. This is not necessarily equal to the Kea version number, as each backend has its own versioning scheme. .IP \(bu 2 \fBdb\-upgrade\fP — conducts a database schema upgrade. This is useful when upgrading Kea. .IP \(bu 2 \fBlease\-dump\fP — dumps the contents of the lease database (for MySQL or PostgreSQL backends) to a CSV (comma\-separated values) text file. .sp The first line of the file contains the column names. This can be used as a way to switch from a database backend to a memfile backend. Alternatively, it can be used as a diagnostic tool, so it provides a portable form of the lease data. .IP \(bu 2 \fBlease\-upload\fP — uploads leases from a CSV (comma\-separated values) text file to a MySQL or a PostgreSQL lease database. The CSV file needs to be in memfile format. .UNINDENT .sp \fBbackend\fP specifies the type of backend database. The currently supported types are: .INDENT 0.0 .IP \(bu 2 \fBmemfile\fP — lease information is stored on disk in a text file. .IP \(bu 2 \fBmysql\fP — information is stored in a MySQL relational database. .IP \(bu 2 \fBpgsql\fP — information is stored in a PostgreSQL relational database. .UNINDENT .sp Additional parameters may be needed, depending on the setup and specific operation: username, password, and database name or the directory where specific files are located. See the appropriate manual page for details (\fBman 8 kea\-admin\fP). .SS Supported Backends .sp The following table presents the capabilities of available backends. Please refer to the specific sections dedicated to each backend to better understand their capabilities and limitations. Choosing the right backend is essential for the success of the deployment. .SS List of available backends .TS box center; l|l|l|l. T{ Feature T} T{ Memfile T} T{ MySQL T} T{ PostgreSQL T} _ T{ Status T} T{ Stable T} T{ Stable T} T{ Stable T} _ T{ Data format T} T{ CSV file T} T{ SQL RMDB T} T{ SQL RMDB T} _ T{ Leases T} T{ yes T} T{ yes T} T{ yes T} _ T{ Host reservations T} T{ no T} T{ yes T} T{ yes T} _ T{ Options defined on per host basis T} T{ no T} T{ yes T} T{ yes T} _ T{ Configuration backend T} T{ no T} T{ yes T} T{ yes T} .TE .SS Memfile .sp The memfile backend is able to store lease information, but cannot store host reservation details; these must be stored in the configuration file. (There are no plans to add a host reservations storage capability to this backend.) .sp No special initialization steps are necessary for the memfile backend. During the first run, both \fI\%kea\-dhcp4\fP and \fI\%kea\-dhcp6\fP create an empty lease file if one is not present. Necessary disk\-write permission is required. .SS Upgrading Memfile Lease Files From an Earlier Version of Kea .sp There are no special steps required to upgrade memfile lease files between versions of Kea. During startup, the servers check the schema version of the lease files against their own. If there is a mismatch, the servers automatically launch the LFC process to convert the files to the server\(aqs schema version. While this mechanism is primarily meant to ease the process of upgrading to newer versions of Kea, it can also be used for downgrading should the need arise. When upgrading, any values not present in the original lease files are assigned appropriate default values. When downgrading, any data present in the files but not in the server\(aqs schema are dropped. To convert the files manually prior to starting the servers, run the lease file cleanup (LFC) process. See \fI\%The LFC Process\fP for more information. .SS MySQL .sp MySQL is able to store leases, host reservations, options defined on a per\-host basis, and a subset of the server configuration parameters (serving as a configuration backend). .SS MySQL 5.7 vs MySQL 8 vs MariaDB 10 and 11 .sp In our Kea performance testing, MySQL 8 shows a 60\-90% drop in speed in comparison with MySQL 5.7. Due to the upcoming MySQL 5.7 EOL, we recommend using MariaDB instead of MySQL 8. .sp MySQL 5.7, MySQL 8, MariaDB 10, and MariaDB 11 are fully compatible, interchangeable, and tested with Kea. .SS First\-Time Creation of the MySQL Database .sp Before preparing any Kea\-specific database and tables, the MySQL database must be configured to use the system timezone. It is recommended to use UTC as the timezone for both the system and the MySQL database. .sp To check the system timezone: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .INDENT 3.5 .sp .EX date +%Z .EE .UNINDENT .UNINDENT .UNINDENT .UNINDENT .sp To check the MySQL timezone: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .INDENT 3.5 .sp .EX mysql> SELECT @@system_time_zone; mysql> SELECT @@global.time_zone; mysql> SELECT @@session.time_zone; .EE .UNINDENT .UNINDENT .UNINDENT .UNINDENT .sp To configure the MySQL timezone for a specific server, please refer to the installed version documentation. .sp Usually the setting is configured in the [mysqld] section in \fB/etc/mysql/my.cnf\fP, \fB/etc/mysql/mysql.cnf\fP, \fB/etc/mysql/mysqld.cnf\fP, or \fB/etc/mysql/mysql.conf.d/mysqld.cnf\fP\&. .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .INDENT 3.5 .sp .EX [mysqld] # using default\-time\-zone default\-time\-zone=\(aq+00:00\(aq # or using timezone timezone=\(aqUTC\(aq .EE .UNINDENT .UNINDENT .UNINDENT .UNINDENT .sp When setting up the MySQL database for the first time, the database area must be created within MySQL, and the MySQL user ID under which Kea will access the database must be set up. This needs to be done manually, rather than via \fI\%kea\-admin\fP\&. .sp To create the database: .INDENT 0.0 .IP 1. 3 Log into MySQL as \(dqroot\(dq: .INDENT 3.0 .INDENT 3.5 .sp .EX $ mysql \-u root \-p Enter password: mysql> .EE .UNINDENT .UNINDENT .IP 2. 3 Create the MySQL database: .INDENT 3.0 .INDENT 3.5 .sp .EX mysql> CREATE DATABASE database_name; .EE .UNINDENT .UNINDENT .sp (\fBdatabase_name\fP is the name chosen for the database.) .IP 3. 3 Create the user under which Kea will access the database (and give it a password), then grant it access to the database tables: .INDENT 3.0 .INDENT 3.5 .sp .EX mysql> CREATE USER \(aquser\-name\(aq@\(aqlocalhost\(aq IDENTIFIED BY \(aq1234\(aq; mysql> GRANT ALL ON database\-name.* TO \(aquser\-name\(aq@\(aqlocalhost\(aq; .EE .UNINDENT .UNINDENT .sp (\fBuser\-name\fP and \fBpassword\fP are the user ID and password used to allow Kea access to the MySQL instance. All apostrophes in the command lines above are required.) .IP 4. 3 Create the database. .INDENT 3.0 .INDENT 3.5 Exit the MySQL client .INDENT 0.0 .INDENT 3.5 .sp .EX mysql> quit Bye .EE .UNINDENT .UNINDENT .sp Then use the \fI\%kea\-admin\fP tool to create the database. .INDENT 0.0 .INDENT 3.5 .sp .EX $ kea\-admin db\-init mysql \-u database\-user \-p database\-password \-n database\-name .EE .UNINDENT .UNINDENT .sp While it is possible to create the database from within the MySQL client, we recommend using the \fI\%kea\-admin\fP tool as it performs some necessary validations to ensure Kea can access the database at runtime. Among those checks is verification that the schema does not contain any pre\-existing tables; any pre\-existing tables must be removed manually. An additional check examines the user\(aqs ability to create functions and triggers. The following error indicates that the user does not have the necessary permissions to create functions or triggers: .INDENT 0.0 .INDENT 3.5 .sp .EX ERROR 1419 (HY000) at line 1: You do not have the SUPER privilege and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable) ERROR/kea\-admin: mysql_can_create cannot trigger, check user permissions, mysql status = 1 mysql: [Warning] Using a password on the command line interface can be insecure. ERROR/kea\-admin: Create failed, the user, keatest, has insufficient privileges. .EE .UNINDENT .UNINDENT .sp The simplest way around this is to set the global MySQL variable, \fBlog_bin_trust_function_creators\fP, to 1 via the MySQL client. Note this must be done as a user with SUPER privileges: .INDENT 0.0 .INDENT 3.5 .sp .EX mysql> set @@global.log_bin_trust_function_creators = 1; Query OK, 0 rows affected (0.00 sec) .EE .UNINDENT .UNINDENT .sp To create the database with MySQL directly, follow these steps: .INDENT 0.0 .INDENT 3.5 .sp .EX mysql> CONNECT database\-name; mysql> SOURCE path\-to\-kea/share/kea/scripts/mysql/dhcpdb_create.mysql .EE .UNINDENT .UNINDENT .UNINDENT .UNINDENT .sp (where \fBpath\-to\-kea\fP is the location where Kea is installed.) .INDENT 3.0 .INDENT 3.5 The database may also be dropped manually as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX mysql> CONNECT database\-name; mysql> SOURCE path\-to\-kea/share/kea/scripts/mysql/dhcpdb_drop.mysql .EE .UNINDENT .UNINDENT .UNINDENT .UNINDENT .sp (where \fBpath\-to\-kea\fP is the location where Kea is installed.) .UNINDENT .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Dropping the database results in the unrecoverable loss of any data it contains. .UNINDENT .UNINDENT .INDENT 0.0 .IP 5. 3 Exit MySQL: .INDENT 3.0 .INDENT 3.5 .sp .EX mysql> quit Bye .EE .UNINDENT .UNINDENT .UNINDENT .sp If the tables were not created in Step 4, run the \fI\%kea\-admin\fP tool to create them now: .INDENT 0.0 .INDENT 3.5 .sp .EX $ kea\-admin db\-init mysql \-u database\-user \-p database\-password \-n database\-name .EE .UNINDENT .UNINDENT .sp Do not do this if the tables were created in Step 4. \fI\%kea\-admin\fP implements rudimentary checks; it will refuse to initialize a database that contains any existing tables. To start from scratch, all data must be removed manually. (This process is a manual operation on purpose, to avoid accidentally irretrievable mistakes by \fI\%kea\-admin\fP\&.) .SS Upgrading a MySQL Database From an Earlier Version of Kea .sp Sometimes a new Kea version uses a newer database schema, so the existing database needs to be upgraded. This can be done using the \fBkea\-admin db\-upgrade\fP command. .sp To check the current version of the database, use the following command: .INDENT 0.0 .INDENT 3.5 .sp .EX $ kea\-admin db\-version mysql \-u database\-user \-p database\-password \-n database\-name .EE .UNINDENT .UNINDENT .sp (See \fI\%Databases and Schema Versions\fP for a discussion about versioning.) If the version does not match the minimum required for the new version of Kea (as described in the release notes), the database needs to be upgraded. .sp Before upgrading, please make sure that the database is backed up. The upgrade process does not discard any data, but depending on the nature of the changes, it may be impossible to subsequently downgrade to an earlier version. .sp To perform an upgrade, issue the following command: .INDENT 0.0 .INDENT 3.5 .sp .EX $ kea\-admin db\-upgrade mysql \-u database\-user \-p database\-password \-n database\-name .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 To search host reservations by hostname, it is critical that the collation of the hostname column in the host table be case\-insensitive. Fortunately, that is the default in MySQL, but it can be verified via this command: .INDENT 0.0 .INDENT 3.5 .sp .EX mysql> SELECT COLLATION(\(aq\(aq); +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ | COLLATION(\(aq\(aq) | +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ | utf8_general_ci | +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ .EE .UNINDENT .UNINDENT .sp According to mysql\(aqs naming convention, when the name ends in \fB_ci\fP, the collation is case\-insensitive. .UNINDENT .UNINDENT .SS Improved Performance With MySQL .sp Changing the MySQL internal value \fBinnodb_flush_log_at_trx_commit\fP from the default value of 1 to 2 can result in a huge gain in Kea performance. In some deployments, the gain was over 1000% (10 times faster when set to 2, compared to the default value of 1). It can be set per\-session for testing: .INDENT 0.0 .INDENT 3.5 .sp .EX mysql> SET GLOBAL innodb_flush_log_at_trx_commit=2; mysql> SHOW SESSION VARIABLES LIKE \(aqinnodb_flush_log%\(aq; .EE .UNINDENT .UNINDENT .sp or permanently in \fB/etc/mysql/my.cnf\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX [mysqld] innodb_flush_log_at_trx_commit=2 .EE .UNINDENT .UNINDENT .sp Be aware that changing this value can cause problems during data recovery after a crash, so we recommend checking the \X'tty: link https://dev.mysql.com/doc/refman/8.0/en/innodb-parameters.html#sysvar_innodb_flush_log_at_trx_commit'\fI\%MySQL documentation\fP\X'tty: link'\&. With the default value of 1, MySQL writes changes to disk after every INSERT or UPDATE query (in Kea terms, every time a client gets a new lease or renews an existing lease). When \fBinnodb_flush_log_at_trx_commit\fP is set to 2, MySQL writes the changes at intervals no longer than 1 second. Batching writes gives a substantial performance boost. The trade\-off, however, is that in the worst\-case scenario, all changes in the last second before crash could be lost. Given the fact that Kea is stable software and crashes very rarely, most deployments find it a beneficial trade\-off. .SS PostgreSQL .sp PostgreSQL can store leases, host reservations, and options defined on a per\-host basis. .SS First\-Time Creation of the PostgreSQL Database .sp Before preparing any Kea\-specific database and tables, the PostgreSQL database must be configured to use the system timezone. It is recommended to use UTC as the timezone for both the system and the PostgreSQL database. .sp To check the system timezone: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .INDENT 3.5 .sp .EX date +%Z .EE .UNINDENT .UNINDENT .UNINDENT .UNINDENT .sp To check the PostgreSQL timezone: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .INDENT 3.5 .sp .EX postgres=# show timezone; postgres=# SELECT * FROM pg_timezone_names WHERE name = current_setting(\(aqTIMEZONE\(aq); .EE .UNINDENT .UNINDENT .UNINDENT .UNINDENT .sp To configure the PostgreSQL timezone for a specific server, please refer to the installed version documentation. .sp Usually the setting is configured in the \fBpostgresql.conf\fP with the varying version path \fB/etc/postgresql//main/postgresql.conf\fP, but on some systems the files may be located in \fB/var/lib/pgsql/data\fP\&. .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .INDENT 3.5 .sp .EX timezone = \(aqUTC\(aq .EE .UNINDENT .UNINDENT .UNINDENT .UNINDENT .sp The first task is to create both the database and the user under which the servers will access it. A number of steps are required: .INDENT 0.0 .IP 1. 3 Log into PostgreSQL as \(dqpostgres\(dq: .INDENT 3.0 .INDENT 3.5 .sp .EX $ sudo \-u postgres psql postgres Enter password: postgres=# .EE .UNINDENT .UNINDENT .IP 2. 3 Create the database: .INDENT 3.0 .INDENT 3.5 .sp .EX postgres=# CREATE DATABASE database\-name; CREATE DATABASE postgres=# .EE .UNINDENT .UNINDENT .sp (\fBdatabase\-name\fP is the name chosen for the database.) .IP 3. 3 Create the user under which Kea will access the database (and give it a password), then grant it access to the database: .INDENT 3.0 .INDENT 3.5 .sp .EX postgres=# CREATE USER user\-name WITH PASSWORD \(aq1234\(aq; CREATE ROLE postgres=# GRANT ALL PRIVILEGES ON DATABASE database\-name TO user\-name; GRANT postgres=# \ec database\-name You are now connected to database \(dqdatabase\-name\(dq as user \(dqpostgres\(dq. postgres=# GRANT ALL PRIVILEGES ON SCHEMA public TO user\-name; GRANT postgres=# .EE .UNINDENT .UNINDENT .IP 4. 3 Exit PostgreSQL: .INDENT 3.0 .INDENT 3.5 .sp .EX postgres=# \eq Bye $ .EE .UNINDENT .UNINDENT .IP 5. 3 At this point, create the database tables either using the \fI\%kea\-admin\fP tool, as explained in the next section (recommended), or manually. To create the tables manually, enter the following command. PostgreSQL will prompt the administrator to enter the new user\(aqs password that was specified in Step 3. When the command completes, Kea will return to the shell prompt. The output should be similar to the following: .INDENT 3.0 .INDENT 3.5 .sp .EX $ psql \-d database\-name \-U user\-name \-f path\-to\-kea/share/kea/scripts/pgsql/dhcpdb_create.pgsql Password for user user\-name: CREATE TABLE CREATE INDEX CREATE INDEX CREATE TABLE CREATE INDEX CREATE TABLE START TRANSACTION INSERT 0 1 INSERT 0 1 INSERT 0 1 COMMIT CREATE TABLE START TRANSACTION INSERT 0 1 COMMIT $ .EE .UNINDENT .UNINDENT .sp (\fBpath\-to\-kea\fP is the location where Kea is installed.) .sp If instead an error is encountered, such as: .INDENT 3.0 .INDENT 3.5 .sp .EX psql: FATAL: no pg_hba.conf entry for host \(dq[local]\(dq, user \(dquser\-name\(dq, database \(dqdatabase\-name\(dq, SSL off .EE .UNINDENT .UNINDENT .sp \&... the PostgreSQL configuration will need to be altered. Kea uses password authentication when connecting to the database and must have the appropriate entries added to PostgreSQL\(aqs pg_hba.conf file. This file is normally located in the primary data directory for the PostgreSQL server. The precise path may vary depending on the operating system and version, but the default location for PostgreSQL is \fB/etc/postgresql/*/main/postgresql.conf\fP\&. However, on some systems, the file may reside in \fB/var/lib/pgsql/data\fP\&. .sp Assuming Kea is running on the same host as PostgreSQL, adding lines similar to the following should be sufficient to provide password\-authenticated access to Kea\(aqs database: .INDENT 3.0 .INDENT 3.5 .sp .EX local database\-name user\-name password host database\-name user\-name 127.0.0.1/32 password host database\-name user\-name ::1/128 password .EE .UNINDENT .UNINDENT .sp These edits are primarily intended as a starting point, and are not a definitive reference on PostgreSQL administration or database security. Please consult the PostgreSQL user manual before making these changes, as they may expose other databases that are running. It may be necessary to restart PostgreSQL for the changes to take effect. .UNINDENT .SS Initialize the PostgreSQL Database Using \fI\%kea\-admin\fP .sp If the tables were not created manually, do so now by running the \fI\%kea\-admin\fP tool: .INDENT 0.0 .INDENT 3.5 .sp .EX $ kea\-admin db\-init pgsql \-u database\-user \-p database\-password \-n database\-name .EE .UNINDENT .UNINDENT .sp Do not do this if the tables were already created manually. \fI\%kea\-admin\fP implements rudimentary checks; it will refuse to initialize a database that contains any existing tables. To start from scratch, all data must be removed manually. (This process is a manual operation on purpose, to avoid accidentally irretrievable mistakes by \fI\%kea\-admin\fP\&.) .SS Upgrading a PostgreSQL Engine From an Earlier Version .sp If you upgraded your PostgreSQL from a version prior to 15.0, you need to grant additional privileges to the user: .sp First, log into PostgreSQL as \(dqpostgres\(dq: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .INDENT 3.5 .sp .EX $ sudo \-u postgres psql \-d database\-name \-U postgres Enter password: postgres=# .EE .UNINDENT .UNINDENT .UNINDENT .UNINDENT .sp Next, grant the access to the \fBpublic\fP schema. .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .INDENT 3.5 .sp .EX postgres=# GRANT ALL PRIVILEGES ON SCHEMA public TO user\-name; GRANT postgres=# .EE .UNINDENT .UNINDENT .UNINDENT .UNINDENT .sp Now, quit the PostgreSQL client: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .INDENT 3.5 .sp .EX postgres=# \eq Bye $ .EE .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS Upgrading a PostgreSQL Database From an Earlier Version of Kea .sp The PostgreSQL database schema can be upgraded using the same tool and commands as described in \fI\%Upgrading a MySQL Database From an Earlier Version of Kea\fP, with the exception that the \(dqpgsql\(dq database backend type must be used in the commands. .sp Use the following command to check the current schema version: .INDENT 0.0 .INDENT 3.5 .sp .EX $ kea\-admin db\-version pgsql \-u database\-user \-p database\-password \-n database\-name .EE .UNINDENT .UNINDENT .sp Use the following command to perform an upgrade: .INDENT 0.0 .INDENT 3.5 .sp .EX $ kea\-admin db\-upgrade pgsql \-u database\-user \-p database\-password \-n database\-name .EE .UNINDENT .UNINDENT .SS Improved Performance With PostgreSQL .sp Changing the PostgreSQL internal value \fBsynchronous_commit\fP from the default value of ON to OFF can result in significant gains in Kea performance; on slow systems, the gain can be over 1000%. It can be set per\-session for testing: .INDENT 0.0 .INDENT 3.5 .sp .EX postgres=# SET synchronous_commit = OFF; .EE .UNINDENT .UNINDENT .sp or permanently via command (preferred method): .INDENT 0.0 .INDENT 3.5 .sp .EX postgres=# ALTER SYSTEM SET synchronous_commit=OFF; .EE .UNINDENT .UNINDENT .sp or permanently in \fB/etc/postgresql/[version]/main/postgresql.conf\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX synchronous_commit = off .EE .UNINDENT .UNINDENT .sp Changing this value can cause problems during data recovery after a crash, so we recommend a careful read of the \X'tty: link https://www.postgresql.org/docs/current/wal-async-commit.html'\fI\%PostgreSQL documentation\fP\X'tty: link'\&. With the default value of ON, PostgreSQL writes changes to disk after every INSERT or UPDATE query (in Kea terms, every time a client gets a new lease or renews an existing lease). When \fBsynchronous_commit\fP is set to OFF, PostgreSQL adds some delay before writing the changes. Batching writes gives a substantial performance boost, but in the worst\-case scenario, all changes in the last moment before a crash could be lost. Since Kea is stable software and crashes very rarely, most deployments find the performance benefits outweigh the potential risks. .SS Using Read\-Only Databases With Host Reservations .sp If a read\-only database is used for storing host reservations, Kea must be explicitly configured to operate on the database in read\-only mode. Sections \fI\%Using Read\-Only Databases for Host Reservations With DHCPv4\fP and \fI\%Using Read\-Only Databases for Host Reservations with DHCPv6\fP describe when such a configuration may be required, and how to configure Kea to operate in this way for both DHCPv4 and DHCPv6. .SS Limitations Related to the Use of SQL Databases .SS Year 2038 Issue .sp The lease expiration time in Kea is stored in the SQL database for each lease as a timestamp value. Kea developers have observed that the MySQL database does not accept timestamps beyond 2147483647 seconds (the maximum signed 32\-bit number) from the beginning of the UNIX epoch (00:00:00 on 1 January 1970). Some versions of PostgreSQL do accept greater values, but the value is altered when it is read back. For this reason, the lease database backends put a restriction on the maximum timestamp to be stored in the database, which is equal to the maximum signed 32\-bit number. This effectively means that the current Kea version cannot store leases whose expiration time is later than 2147483647 seconds since the beginning of the epoch (around the year 2038). This will be fixed when database support for longer timestamps is available. .SH KEA SECURITY .sp Kea was originally designed to be installed in a protected environment, in a network datacenter; it did not offer hardened security features. However, due to customer demand and evolving network requirements, support for basic HTTP authentication and Transport Layer Security (TLS) have been added to Kea. .SS TLS/HTTPS Support .sp Since Kea 1.9.6, TLS can be used to secure HTTP communication. There are three levels of protection possible: .INDENT 0.0 .IP \(bu 2 No TLS. The connection is plain\-text, unencrypted HTTP. (This is the only option available in versions prior to Kea 1.9.6.) .IP \(bu 2 Encryption, which protects against passive attacks and eavesdropping. In this case, the server is authenticated but the client is not. This is the typical mode when securing a website, where clients and servers are not under the control of a common entity. .IP \(bu 2 Mutual authentication between the client and the server. This is the strictest security mode and is the default when TLS is enabled. .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 TLS mutual authentication is for TLS entities only. When TLS and an HTTP authentication scheme are used together, there is no binding between the two security mechanisms, and therefore no proof that the TLS client and server are the same as the HTTP authentication client and server. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 It is recommend to use privileged ports for HTTP/HTTPS against local attacks (by users which are connected to the box where Kea servers/agents run). This measure also prevents against impersonation with HTTP, and Denial of Service in general. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The server will issue an error when changing the socket type from HTTP to HTTPS or from HTTPS to HTTP using the same address and port. This action is not allowed as it might introduce a security issue accidentally caused by a user mistake. A different address or port must be specified when using the \(dqconfig\-set\(dq command to switch from HTTP to HTTPS or from HTTPS to HTTP. The same applies when modyfying the configuration file and then running \(dqconfig\-reload\(dq command. .UNINDENT .UNINDENT .SS Building Kea with TLS/HTTPS Support .sp TLS/HTTPS support is available with either the OpenSSL or the Botan cryptographic library. There are some constraints on the Boost library that must be used: .INDENT 0.0 .IP \(bu 2 OpenSSL versions older than 1.0.2 are obsolete and should not be used. Kea TLS support has not been tested with and is not supported on these versions. .IP \(bu 2 OpenSSL version 1.0.2 has extended support, but only for OpenSSL premium customers. Kea TLS support has been tested but is not supported on this version. .IP \(bu 2 OpenSSL versions 1.1.x and later have been tested and are supported. Many recent operating system versions include TLS 1.3 support. .IP \(bu 2 OpenSSL 3.x has been released and Kea will build with it. .IP \(bu 2 LibreSSL 3.2.4 has been tested. LibreSSL shares the OpenSSL 1.0.2 API, so it should work, but is not supported. .IP \(bu 2 Botan 1.x versions are obsolete and must not be used. .IP \(bu 2 Botan versions 2.14.0 and later have been tested and are supported. Kea TLS support requires the four Asio header files which are included in Botan packages and which are installed only if Botan is configured with the \fB\-\-with\-boost\fP option. .sp Many packages provided by operating systems, such as Ubuntu 20.10, do not build Botan with Boost support, making those packages unusable for Kea with TLS. .sp It is still possible to take these files from the corresponding Botan distribution and install them manually in the Botan include directory, but this should be a last\-resort procedure. .sp Without these header files, or with a Botan version prior to 2.14.0, Kea cannot build as the TLS/HTTPS support is considered essential for security. .IP \(bu 2 Very old Boost versions provide SSL support (based on OpenSSL) without offering a choice of the TLS version; Kea can still use them, but they are not recommended. .IP \(bu 2 Boost versions prior to 1.64 provide SSL support with a fixed choice of the TLS version; Kea enforces the use of TLS 1.2 with them. .IP \(bu 2 Boost versions 1.64 or newer provide SSL support with a generic TLS version; the best (highest) version available on both peers is selected. .UNINDENT .SS TLS/HTTPS Configuration .sp The TLS configuration parameters are: .INDENT 0.0 .IP \(bu 2 \fBtrust\-anchor\fP \- this string parameter specifies the name of a file or directory where the certification authority (CA) certificate of the other peer can be found. With OpenSSL, the directory must include hash symbolic links. With Botan, the directory is recursively searched for certificates. .IP \(bu 2 \fBcert\-file\fP \- this string parameter specifies the name of the file containing the end\-entity certificate of the Kea instance being configured. .IP \(bu 2 \fBkey\-file\fP \- this string parameter specifies the private key of the end\-entity certificate of the Kea instance being configured. The file must not be encrypted; it is highly recommended to restrict its access. .UNINDENT .sp The three string parameters must be either all unspecified (TLS disabled) or all specified (TLS enabled). .sp TLS is asymmetric: the authentication of the server by the client is mandatory but the authentication of the client by the server is optional. In TLS terms, this means the server may require the client certificate, or may not; there is a server\-specific TLS parameter. .INDENT 0.0 .IP \(bu 2 \fBcert\-required\fP \- this boolean parameter allows a server to not require the client certificate. Its default value is \fBtrue\fP, which means the client certificate is required and the client must be authenticated. This flag has no meaning on the client side; the server always provides a certificate which is validated by the client. .UNINDENT .sp Objects in files must be in the PEM format. Files can contain more than one certificate, but this has not been tested and is not supported. .sp Botan requires CA certificates to have the standard CA certificate attributes, verifies that end\-entity certificates are version 3 certificates (as required by the TLS standard), and supports only PKCS 8 files for the private key. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Some cryptographic libraries (e.g. Botan and recent OpenSSL) enforce minimal strength (i.e. key length), e.g. at least 2048 for RSA. .UNINDENT .UNINDENT .sp A sample set of certificates and associated objects is available at \fBsrc/lib/asiolink/testutils/ca\fP in the Kea sources, with a \fBdoc.txt\fP file explaining how they were generated using the \fBopenssl\fP command. These files are for testing purposes only. \fBDo not use them in production.\fP .sp TLS handshake, the phase where the cryptographic parameters are exchanged and authentication is verified, can fail in multiple ways. Error messages often do not help to pinpoint the source of the problem. Both OpenSSL and Botan provide a command\-line tool with a \fBverify\fP command which can be used to understand and fix handshake issues. .SS OpenSSL Tuning .sp Kea accepts the default OpenSSL configuration parameters, but administrators can also fine\-tune the OpenSSL settings. For example, it may be desirable to limit the TLS version. .sp The default OpenSSL configuration file is named \fBopenssl.cnf\fP\&. It can be found in a system\-dependent \fBetc\fP directory, and the location can be overridden using the \fBOPENSSL_CONF\fP environment variable. For OpenSSL versions greater than 1.0.2, the minimum acceptable protocol can be set via the \fBMinProtocol\fP variable. .sp For these examples, we assume that no variables are already set and no sections already exist; it is, of course, possible to reuse existing variables and sections. .sp In the default application, \fBopenssl_conf\fP, the corresponding variable must be set to the name of the section that handles defaults: in this example, \fBdefault_conf\fP\&. If \fBopenssl_conf\fP is not yet set, add this command at the beginning of the OpenSSL configuration file (before the first section): .INDENT 0.0 .INDENT 3.5 .sp .EX openssl_conf = default_conf .EE .UNINDENT .UNINDENT .sp In the \fBdefault_conf\fP section, the \fBssl_conf\fP variable must be set to the name of the section that handles SSL/TLS defaults: in this example, \fBssl_sect\fP\&. .INDENT 0.0 .INDENT 3.5 .sp .EX [ default_conf ] ssl_conf = ssl_sect .EE .UNINDENT .UNINDENT .sp In the \fBssl_sect\fP section, the \fBsystem_default\fP variable must be set to the name of the section that handles system defaults: in this example, \fBsystem_default_sect\fP\&. .INDENT 0.0 .INDENT 3.5 .sp .EX [ ssl_sect ] system_default = system_default_sect .EE .UNINDENT .UNINDENT .sp In the \fBsystem_default_sect\fP section, the \fBMinProtocol\fP variable must be set to the desired minimal SSL/TLS version: in this example, \fBTLSv1.2\fP\&. .INDENT 0.0 .INDENT 3.5 .sp .EX [ system_default_sect ] MinProtocol = TLSv1.2 .EE .UNINDENT .UNINDENT .sp The same steps can be used to enforce other crypto parameters if desired. .sp It is highly recommended to read the \fBopenssl.cnf\fP manual page, normally called \fBconfig.5ssl\fP and displayed using \fBman config\fP\&. .SS Secure Kea Control Agent .sp The Kea Control Agent natively supports secure HTTP connections using TLS. This allows protection against users from the node where the agent runs, something that a reverse proxy cannot provide. More about TLS/HTTPS support in Kea can be found in \fI\%TLS/HTTPS Support\fP\&. .sp TLS is configured using three string parameters with file names, and a boolean parameter: .INDENT 0.0 .IP \(bu 2 The \fBtrust\-anchor\fP specifies the Certification Authority file name or directory path. .IP \(bu 2 The \fBcert\-file\fP specifies the server certificate file name. .IP \(bu 2 The \fBkey\-file\fP specifies the private key file name. The file must not be encrypted. .IP \(bu 2 The \fBcert\-required\fP specifies whether client certificates are required or optional. The default is to require them and to perform mutual authentication. .UNINDENT .sp The file format is PEM. Either all the string parameters are specified and HTTP over TLS (HTTPS) is used, or none is specified and plain HTTP is used. Configuring only one or two string parameters results in an error. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 When client certificates are not required, only the server side is authenticated, i.e. the communication is encrypted with an unknown client. This protects only against passive attacks; active attacks, such as \(dqman\-in\-the\-middle,\(dq are still possible. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 No standard HTTP authentication scheme cryptographically binds its end entity with TLS. This means that the TLS client and server can be mutually authenticated, but there is no proof they are the same as for the HTTP authentication. .UNINDENT .UNINDENT .sp The \fI\%kea\-shell\fP tool also supports TLS. .SS Securing a Kea Deployment .sp Below is a list of considerations for administrators wishing to improve Kea\(aqs security. In many cases, there are trade\-offs between convenience and security. .SS Component\-Based Design .sp The Kea architecture is modular, with separate daemons for separate tasks. A Kea deployment may include DHCPv4, DHCPv6, and Dynamic DNS daemons; a Control Agent daemon run on each application server; the \fBkea\-lfc utility\fP for doing periodic lease file cleanup; MySQL and or PostgreSQL databases, run either locally on the application servers or accessed over the internal network; a Netconf daemon to perform config and stats monitoring of Kea servers; and a Stork monitoring system. This modular architecture allows the administrator to minimize the attack surface by minimizing the code that is loaded and running. For example, \fI\%kea\-dhcp\-ddns\fP should not be run unless DNS updates are required. Similarly, \fI\%kea\-lfc\fP is never triggered (and can be safely removed or never installed) if memfile is not used. Potential Kea security issues can be minimized by running only those processes required in the local environment. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 As of Kea 2.7.9, \fBdata\-directory\fP (DHCPv6 only) is deprecated. The lease files (DHCPv4 and DHCPv6) and duid file (DHCPv6 only) may only be loaded from the directory determined at compilation: \fB\(dq[kea\-install\-dir]/var/lib/kea\(dq\fP\&. This path may be overridden at startup by setting the environment variable \fBKEA_DHCP_DATA_DIR\fP to the desired path. If a path other than this value is used in \fBname\fP or \fBdata\-directory\fP, Kea will emit an error and refuse to start or, if already running, log an unrecoverable error. This restriction applies to writing lease file using \fBlease4\-write\fP and \fBlease6\-write\fP commands. If a path other than this value is used in \fBfilename\fP, Kea will emit an error and refuse to start or, if already running, log an unrecoverable error. For ease of use in specifying a custom file name simply omit the path portion from \fBfilename\fP\&. Same restriction also applies to writing cache file using \fBcache\-write\fP command. For ease of use in specifying a custom file name simply omit the path portion from \fBfilename\fP\&. .UNINDENT .UNINDENT .SS Limiting Application Permissions .sp The DHCPv4 and DHCPv6 protocols assume the server opens privileged UDP port 67 (DHCPv4) or 547 (DHCPv6), which requires root access under normal circumstances. However, via the capabilities mechanism on Linux systems, Kea can run from an unprivileged account. See \fI\%Running Kea From a Non\-root Account on Linux\fP for details on how to run Kea without root access. .sp The Control Agent (CA) can accept incoming HTTP or HTTPS connections. The default port is 8000, which does not require privileged access. .SS Securing Kea Administrative Access .sp The three primary Kea daemons (\fI\%kea\-dhcp4\fP, \fI\%kea\-dhcp6\fP and \fI\%kea\-dhcp\-ddns\fP) all support a control channel, which is implemented as a UNIX socket. The control channel, which opens a UNIX socket, is disabled by default; however, many configuration examples have it enabled, as it is a very popular feature. To read from or write to this socket, root access is generally required, although if Kea is configured to run as non\-root, the owner of the process can write to it. Access can be controlled using normal file\-access control on POSIX systems (owner, group, others, read/write). .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 As of Kea 2.7.9, control sockets may only reside in the directory determined during compilation as \fB\(dq[kea\-install\-dir]/var/run/kea\(dq\fP, which must also have \fB0750\fP access rights. This path may be overridden at startup by setting the environment variable \fBKEA_CONTROL_SOCKET_DIR\fP to the desired path. If a path other than this value is used in \fBsocket\-name\fP, Kea will emit an error and refuse to start or, if already running, log an unrecoverable error. For ease of use in simply omit the path component from \fBsocket\-name\fP\&. .UNINDENT .UNINDENT .sp Since Kea version 2.7.2 DHCP servers support HTTP/HTTPS control channels so the Control Agent (CA) is no longer needed. .sp Since Kea\-2.7.6 Kea supports multiple HTTP/HTTPS connections. Both IPv4 and IPv6 addresses can be used. Security can be enhanced if configuring HTTPS connections for all daemons. .sp Kea configuration is controlled by a JSON file on the Kea server. This file can be viewed or edited by anyone with file permissions (which are controlled by the operating system). Note that passwords are stored in clear text in the configuration file, so anyone with access to read the configuration file can find this information. As a practical matter, anyone with permission to edit the configuration file has control over Kea. Limiting user permission to read or write the Kea configuration file is an important security step. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 As of Kea 2.7.9, the config file may only be written (using the \fBconfig\-write\fP command) to the same directory as the config file used when starting Kea (passed as a \fB\-c\fP argument). .UNINDENT .UNINDENT .SS Securing Database Connections .sp Kea can use an external MySQL or PostgreSQL database to store configuration, host reservations, or/and leases, or/and for forensic logging. The use of databases is a popular feature, but it is optional; it is also possible to store data in a flat file on disk. .sp When using a database, Kea stores and uses the following credentials to authenticate with the database: username, password, host, port, and database name. \fBThese are stored in clear text in the configuration file.\fP .sp Depending on the database configuration, it is also possible to verify whether the system user matches the database username. Consult the MySQL or PostgreSQL manual for details. .sp Kea supports client TLS settings for MySQL database and it must be configured explicitly for all used connections (configuration, reservations, leases, forensic logging). .SS Information Leakage Through Logging .sp It is possible for Kea to log an entire configuration file, including passwords and secrets. Since Kea 1.9.7, this issue has been resolved by replacing the value of all entries ending in \fBpassword\fP or \fBsecret\fP with asterisks, as was already done for database logs. .sp Logs are sent to stdout, stderr, files, or syslog; system file permissions system apply to stdout/stderr and files. Syslog may export the logs over the network, exposing them further to possible snooping. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 As of Kea 2.7.9, log files may only be written to the output directory determined during compilation as: \fB\(dq[kea\-install\-dir]/var/log/kea\(dq\fP\&. This path may be overridden at startup by setting the environment variable \fBKEA_LOG_FILE_DIR\fP to the desired path. If a path other than this value is used in \fBoutput\fP, Kea will emit an error and refuse to start or, if already running, log an unrecoverable error. For ease of use simply omit the path component from \fBoutput\fP and specify only the file name. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 As of Kea 2.7.9, legal log files may only be written to the output directory determined during compilation as: \fB\(dq[kea\-install\-dir]/var/log/kea\(dq\fP\&. This path may be overridden at startup by setting the environment variable \fBKEA_LEGAL_LOG_DIR\fP to the desired path. If a path other than this value is used in \fBpath\fP, Kea will emit an error and refuse to start or if already running, log an unrecoverable error. For ease of use simply omit the \fBpath\fP parameter. .UNINDENT .UNINDENT .SS Summary of Path Restrictions .sp Path restrictions mentioned through this section can be summarized according to the following table: .TS box center; l|l|l. T{ Restricted Element T} T{ Default Value T} T{ Environment Variable Override T} _ T{ Config Files (\fBconfig\-write\fP) T} T{ Same Directory as Initial Config File T} T{ N/A T} _ T{ Host Cache Files (\fBcache\-write\fP) T} T{ \fBvar/lib/kea\fP T} T{ \fBKEA_DHCP_DATA_DIR\fP T} _ T{ Lease Files T} T{ \fBvar/lib/kea\fP T} T{ \fBKEA_DHCP_DATA_DIR\fP T} _ T{ Log Files T} T{ \fBvar/log/kea\fP T} T{ \fBKEA_LOG_FILE_DIR\fP T} _ T{ Forensic Log Files T} T{ \fBvar/log/kea\fP T} T{ \fBKEA_LEGAL_LOG_DIR\fP T} _ T{ Unix Sockets T} T{ \fBvar/run/kea\fP T} T{ \fBKEA_CONTROL_SOCKET_DIR\fP T} _ T{ Scripts used by hook libraries T} T{ \fBshare/kea/scripts/\fP T} T{ \fBKEA_HOOK_SCRIPTS_PATH\fP T} .TE .SS Cryptography Components .sp Kea supports the use of either of two cryptographic libraries: Botan or OpenSSL. The choice is made at compile time, and creates both compile and runtime dependencies between the Kea and the selected library. While OpenSSL is the most popular choice for deployments, Botan remains a fully supported alternative. .sp The primary use cases for the cryptographic libraries are: .INDENT 0.0 .IP \(bu 2 TLS support for the Control Agent (CA), introduced in Kea 1.9.6. .IP \(bu 2 TSIG signatures when sending DNS updates. .IP \(bu 2 calculating DHCID records when sending DNS updates. .IP \(bu 2 random number generation (but not for usage requiring a crypto grade generator). .UNINDENT .sp For OpenSSL and Botan, only the low\-level crypto interface is used (e.g. libcrypto). Kea does not link with libssl. Some dependent software systems, such as database client libraries, can also depend on a crypto library. .sp One way to limit exposure for potential OpenSSL or Botan vulnerabilities is not to use DDNS. The libraries would still be needed to build and run Kea, but the code would never be used, so any potential bugs in the libraries would not be exploitable. .SS TSIG Signatures .sp Kea supports the following algorithms when signing DNS updates with TSIG signatures: .INDENT 0.0 .IP \(bu 2 HMAC\-MD5 .IP \(bu 2 HMAC\-SHA1 .IP \(bu 2 HMAC\-SHA224 .IP \(bu 2 HMAC\-SHA256 .IP \(bu 2 HMAC\-SHA384 .IP \(bu 2 HMAC\-SHA512 .UNINDENT .sp See \fI\%TSIG Key List\fP for an up\-to\-date list. .sp Kea uses SHA256 to calculate DHCID records. This is irrelevant from the cryptography perspective, as the DHCID record is only used to generate unique identifiers for two devices that may have been assigned the same IP address at different times. .SS Raw Socket Support .sp In principle, Kea DHCPv4 uses raw sockets to receive traffic from clients. The difficulty is with receiving packets from devices that do not yet have an IPv4 address. When dealing with direct traffic (where both client and server are connected to the same link, not separated by relays), the kernel normally drops the packet as the source IP address is 0.0.0.0. Therefore, Kea needs to open raw sockets to be able to receive this traffic. .sp However, this is not necessary if all the traffic is coming via relays, which is often the case in many networks. In that case normal UDP sockets can be used instead. There is a \fBdhcp\-socket\-type\fP parameter that controls this behavior. .sp The default is to permit raw socket usage, as it is more versatile. .sp When using raw sockets, Kea is able to receive raw layer 2 packets, bypassing most firewalls (including iptables). This effectively means that when raw sockets are used, the iptables cannot be used to block DHCP traffic. This is a design choice of the Linux kernel. .sp Kea can be switched to use UDP sockets. This is an option when all traffic is relayed. However, it does not work for directly connected devices. If Kea is limited to UDP sockets, iptables should work properly. .sp If raw sockets are not required, disabling this access can improve security. .SS Remote Administrative Access .sp Kea\(aqs Control Agent (CA) exposes a RESTful API over HTTP or HTTPS (HTTP over TLS). The CA is an optional feature that is disabled by default, but it is very popular. When enabled, it listens on the loopback address (127.0.0.1 or ::1) by default, unless configured otherwise. See \fI\%TLS/HTTPS Support\fP for information about protecting the TLS traffic. Limiting the incoming connections with a firewall, such as iptables, is generally a good idea. .sp Note that in High Availability (HA) deployments, DHCP partners connect to each other using a CA connection. .sp Since Kea version 2.7.2 DHCP and DDNS servers support HTTP/HTTPS control channels so the Control Agent (CA) is no longer needed. .sp Since Kea\-2.7.6 Kea supports multiple HTTP/HTTPS connections. Both IPv4 and IPv6 addresses can be used. Security can be enhanced if configuring HTTPS connections for all daemons. .SS Authentication for Kea\(aqs RESTful API .sp Kea 1.9.0 added support for basic HTTP authentication (\X'tty: link https://tools.ietf.org/html/rfc7617'\fI\%RFC 7617\fP\X'tty: link'), to control access for incoming REST commands over HTTP. The credentials (username, password) are stored in a local Kea configuration file on disk. The username is logged with the API command, so it is possible to determine which authenticated user performed each command. The access control details are logged using a dedicated \fBauth\fP logger. Basic HTTP authentication is weak on its own as there are known dictionary attacks, but those attacks require a \(dqman in the middle\(dq to get access to the HTTP traffic. That can be eliminated by using basic HTTP authentication exclusively over TLS. In fact, if possible, using client certificates for TLS is better than using basic HTTP authentication. .sp Kea 1.9.2 introduced a new \fBauth\fP hook point. With this new hook point, it is possible to develop an external hook library to extend the access controls, integrate with another authentication authority, or add role\-based access control to the Control Agent. This hookpoint was renamed as \fBhttp_auth\fP and is also supported by the DHCP and DDNS servers since Kea version 2.7.2. .SS Kea Security Processes .sp The following sections discuss how the Kea DHCP development team ensures code quality and handles vulnerabilities. .SS Vulnerability Handling .sp ISC is an experienced and active participant in the industry\-standard vulnerability disclosure process and maintains accurate documentation on our process and vulnerabilities in ISC software. See \X'tty: link https://kb.isc.org/docs/aa-00861'\fI\%https://kb.isc.org/docs/aa\-00861\fP\X'tty: link' for ISC\(aqs Software Defect and Security Vulnerability Disclosure Policy. .sp In case of a security vulnerability in Kea, ISC notifies support customers ahead of any public disclosure, and provides a patch and/or updated installer package to remediate the vulnerability. .sp When a security update is published, both the source tarballs and the ISC\-maintained packages are published on the same day. This enables users of the native Linux update mechanisms (such as Debian\(aqs and Ubuntu\(aqs apt or RedHat\(aqs dnf) to update their systems promptly. .SS Code Quality and Testing .sp Kea undergoes extensive tests during its development. The following are some of the processes that are used to ensure adequate code quality: .INDENT 0.0 .IP \(bu 2 Each line of code goes through a formal review before it is accepted. The review process is documented and available publicly. .IP \(bu 2 Roughly 50% of the source code is dedicated to unit tests. As of May 2024, there were over 12000 unit tests and the number is increasing with time. Unit tests are required to commit any new feature. .IP \(bu 2 There are around 2000 system tests for Kea. These simulate both correct and invalid situations, covering network packets (mostly DHCP, but also DNS, HTTP, HTTPS and others), command\-line usage, API calls, database interactions, scripts, and more. .IP \(bu 2 There are performance tests with over 80 scenarios that test Kea overall performance and resiliency to various levels of traffic, and measuring various metrics (latency, leases per seconds, packets per seconds, CPU usage, memory utilization, and others). .IP \(bu 2 Kea uses Continuous Integration (CI). This means that the great majority of tests (all unit and system tests, and in some cases also performance tests) are run for every commit. Many \(dqlighter\(dq tests are run on branches, before the code is even accepted. .IP \(bu 2 Many unit and system tests check for negative scenarios, such as incomplete, broken, or truncated packets, API commands, and configuration files, as well as incorrect sequences (such as sending packets in an invalid order) and more. .IP \(bu 2 The Kea development team uses many tools that perform automatic code quality checks, such as danger, as well as internally developed sanity checkers. .IP \(bu 2 The Kea team uses the following static code analyzers: Coverity Scan, cppcheck, clang\-static\-analyzer, shellcheck, flawfinder, semgrep and danger. .IP \(bu 2 The Kea team uses the following dynamic code analyzers: Valgrind, Thread Sanitizer (TSAN), Address Sanitizer (ASAN), Undefined Behavior Sanitizer (UBSAN). .UNINDENT .SS Fuzz Testing .sp The Kea team has a process for running fuzz testing. Fuzzing is a software\-testing technique whereby a program is presented with a variety of generated data as input and is monitored for abnormal conditions such as crashes or hangs. .sp There are two ways to fuzz Kea. .sp Option 1. With the libfuzzer harness function LLVMFuzzerTestOneInput. .sp Option 2. With the AFL (American Fuzzy Lop \X'tty: link https://github.com/google/AFL'\fI\%https://github.com/google/AFL\fP\X'tty: link') compiler. .sp Using the LLVMFuzzerTestOneInput Harness Function: .sp This mode of fuzzing works with virtually any compiler. .sp There are four types of fuzzers implemented with this mode: .INDENT 0.0 .IP \(bu 2 Config fuzzer .IP \(bu 2 HTTP endpoint fuzzer .IP \(bu 2 Packet fuzzer .IP \(bu 2 Unix socket fuzzer .UNINDENT .sp There are two binaries under test: .INDENT 0.0 .IP \(bu 2 \fIkea\-dhcp4\fP .IP \(bu 2 \fIkea\-dhcp6\fP .UNINDENT .SS Release Integrity .sp All ISC software releases are signed with PGP and distributed via the ISC website, which is itself DNSSEC\-signed, so users can be confident the software has not been tampered with. .SS Bus Factor .sp According to the \X'tty: link https://bestpractices.coreinfrastructure.org/'\fI\%Core Infrastructure project\fP\X'tty: link', a \(dqbus factor\(dq or \(dqtruck factor\(dq is the minimum number of project members that have to suddenly disappear from a project (\(dqbe hit by a bus\(dq) before the project stalls due to lack of knowledgeable or competent personnel. It is hard to estimate precisely, but the bus factor for Kea is somewhere around five. As of 2021, there are six core developers and two quality assurance engineers, with many additional casual contributors (product manager, support team, IT, etc.). The team is geographically dispersed. .SH KEA CONFIGURATION .sp Kea uses JSON structures to represent server configurations. The following sections describe how the configuration structures are organized. .SS JSON Configuration .sp JSON is the notation used throughout the Kea project. The most obvious usage is for the configuration file, but JSON is also used for sending commands over the Management API (see \fI\%Management API\fP) and for communicating between DHCP servers and the DDNS update daemon. .sp Typical usage assumes that the servers are started from the command line, either directly or using a script, e.g. \fI\%keactrl\fP\&. The configuration file is specified upon startup using the \fB\-c\fP parameter. .SS JSON Syntax .sp Configuration files for the DHCPv4, DHCPv6, DDNS, Control Agent, and NETCONF modules are defined in an extended JSON format. Basic JSON is defined in \X'tty: link https://tools.ietf.org/html/rfc7159'\fI\%RFC 7159\fP\X'tty: link' and \X'tty: link https://www.ecma-international.org/publications/standards/Ecma-404.htm'\fI\%ECMA 404\fP\X'tty: link'\&. In particular, the only boolean values allowed are true or false (all lowercase). The capitalized versions (True or False) are not accepted. .sp Even though the JSON standard (ECMA 404) does not require JSON objects (i.e. name/value maps) to have unique entries, Kea implements them using a C++ STL map with unique entries. Therefore, if there are multiple values for the same name in an object/map, the last value overwrites previous values. Since Kea 1.9.0, configuration file parsers raise a syntax error in such cases. .sp Kea components use extended JSON with additional features allowed: .INDENT 0.0 .IP \(bu 2 Shell comments: any text after the hash (#) character is ignored. .IP \(bu 2 C comments: any text after the double slashes (//) character is ignored. .IP \(bu 2 Multiline comments: any text between /* and */ is ignored. This comment can span multiple lines. .IP \(bu 2 File inclusion: JSON files can include other JSON files by using a statement of the form . .IP \(bu 2 Extra commas: to remove the inconvenience of errors caused by leftover commas after making changes to configuration. While parsing, a warning is printed with the location of the comma to give the user the ability to correct a potential mistake. .UNINDENT .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 These features are meant to be used in a JSON configuration file. Their usage in any other way may result in errors. .UNINDENT .UNINDENT .sp The configuration file consists of a single object (often colloquially called a map) started with a curly bracket. It comprises only one of the \(dqDhcp4\(dq, \(dqDhcp6\(dq, \(dqDhcpDdns\(dq, \(dqControl\-agent\(dq, or \(dqNetconf\(dq objects. It is possible to define additional elements but they will be ignored. .sp A very simple configuration for DHCPv4 could look like this: .INDENT 0.0 .INDENT 3.5 .sp .EX # The whole configuration starts here. { # DHCPv4 specific configuration starts here. \(dqDhcp4\(dq: { \(dqinterfaces\-config\(dq: { \(dqinterfaces\(dq: [ \(dqeth0\(dq ], \(dqdhcp\-socket\-type\(dq: \(dqraw\(dq }, \(dqvalid\-lifetime\(dq: 4000, \(dqrenew\-timer\(dq: 1000, \(dqrebind\-timer\(dq: 2000, \(dqsubnet4\(dq: [{ \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.2.1\-192.0.2.200\(dq } ], \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq, \(dqid\(dq: 1 }], # Now loggers are inside the DHCPv4 object. \(dqloggers\(dq: [{ \(dqname\(dq: \(dq*\(dq, \(dqseverity\(dq: \(dqDEBUG\(dq }] } # The whole configuration structure ends here. } .EE .UNINDENT .UNINDENT .sp More examples are available in the installed \fBshare/doc/kea/examples\fP directory. .sp To avoid repetition of mostly similar structures, examples in the rest of this guide will showcase only the subset of parameters appropriate for a given context. For example, when discussing the IPv6 subnets configuration in DHCPv6, only subnet6 parameters will be mentioned. It is implied that the remaining elements (the global map that holds Dhcp6) are present, but they are omitted for clarity. Usually, locations where extra parameters may appear are denoted by an ellipsis (...). .SS Comments and User Context .sp Shell, C, or C++ style comments are all permitted in the JSON configuration file if the file is used locally. This is convenient and works in simple cases where the configuration is kept statically using a local file. However, since comments are not part of JSON syntax, most JSON tools detect them as errors. Another problem with them is that once Kea loads its configuration, the shell, C, and C++ style comments are ignored. If commands such as \fI\%config\-get\fP or \fI\%config\-write\fP are used, those comments are lost. An example of such comments was presented in the previous section. .sp Historically, to address the problem, Kea code allowed the use of \fIcomment\fP strings as valid JSON entities. This had the benefit of being retained through various operations (such as \fI\%config\-get\fP), or allowing processing by JSON tools. An example JSON comment looks like this: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqsubnet4\(dq: [{ \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq, \(dqpools\(dq: [{ \(dqpool\(dq: \(dq192.0.2.10 \- 192.0.2.20\(dq }], \(dqcomment\(dq: \(dqsecond floor\(dq }] } .EE .UNINDENT .UNINDENT .sp However, the facts that the comment could only be a single line, and that it was not possible to add any other information in a more structured form, were frustrating. One specific example was a request to add floor levels and building numbers to subnets. This was one of the reasons why the concept of user context was introduced. It allows adding an arbitrary JSON structure to most Kea configuration structures. .sp This has a number of benefits compared to earlier approaches. First, it is fully compatible with JSON tools and Kea commands. Second, it allows storing simple comment strings, but it can also store much more complex data, such as multiple lines (as a string array), extra typed data (such as floor numbers being actual numbers), and more. Third, the data is exposed to hooks, so it is possible to develop third\-party hooks that take advantage of that extra information. An example user context looks like this: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqsubnet4\(dq: [{ \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq, \(dqpools\(dq: [{ \(dqpool\(dq: \(dq192.0.2.10 \- 192.0.2.20\(dq }], \(dquser\-context\(dq: { \(dqcomment\(dq: \(dqsecond floor\(dq, \(dqfloor\(dq: 2 } }] } .EE .UNINDENT .UNINDENT .sp User contexts can store an arbitrary data file as long as it has valid JSON syntax and its top\-level element is a map (i.e. the data must be enclosed in curly brackets). However, some hook libraries may expect specific formatting; please consult the specific hook library documentation for details. .sp The user\-context mechanism has superseded the JSON comment capabilities; ISC encourages administrators to use user context instead of the older mechanisms. To promote this way of storing comments, Kea converts JSON comments to user context on the fly. .sp However, if the configuration uses the old JSON comment method, the \fI\%config\-get\fP command returns a slightly modified configuration. It is not uncommon for a call for \fI\%config\-set\fP followed by \fI\%config\-get\fP to receive a slightly different structure. The best way to avoid this problem is simply to abandon JSON comments and use user context. .sp Kea supports user contexts at the following levels: global scope, interfaces configuration, multi\-threading, shared networks, subnets, client classes, option data and definitions, pools, prefix delegation pools, host reservations, control socket, HTTP header, authentication, clients, queue control, DHCP\-DDNS, loggers, leases, and server ID. These are supported in both DHCPv4 and DHCPv6, with the exception of prefix delegation pools and server ID, which are DHCPv6 only. .sp User context can be added and edited in structures supported by commands. .sp We encourage Kea users to utilize these functions to store information used by other systems and custom hooks. .sp For example, the \fI\%subnet4\-update\fP command can be used to add user context data to an existing subnet. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqsubnet4\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq10.20.30.0/24\(dq, \(dquser\-context\(dq: { \(dqbuilding\(dq: \(dqMain\(dq, \(dqfloor\(dq: 1 } } ] } .EE .UNINDENT .UNINDENT .sp The same can be done with many other commands, like \fI\%lease6\-add\fP, etc. .sp Kea also uses user context to store non\-standard data. Currently, only \fI\%Storing Extended Lease Information\fP uses this feature. .sp When enabled, it adds the ISC key in \fBuser\-context\fP to differentiate automatically added content. .sp Example of relay information stored in a lease: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqarguments\(dq: { \(dqclient\-id\(dq: \(dq42:42:42:42:42:42:42:42\(dq, \(dqcltt\(dq: 12345678, \(dqfqdn\-fwd\(dq: false, \(dqfqdn\-rev\(dq: true, \(dqhostname\(dq: \(dqmyhost.example.com.\(dq, \(dqhw\-address\(dq: \(dq08:08:08:08:08:08\(dq, \(dqip\-address\(dq: \(dq192.0.2.1\(dq, \(dqstate\(dq: 0, \(dqsubnet\-id\(dq: 44, \(dqvalid\-lft\(dq: 3600, \(dquser\-context\(dq: { \(dqISC\(dq: { \(dqrelays\(dq: [ { \(dqhop\(dq: 2, \(dqlink\(dq: \(dq2001:db8::1\(dq, \(dqpeer\(dq: \(dq2001:db8::2\(dq }, { \(dqhop\(dq: 1, \(dqlink\(dq: \(dq2001:db8::3\(dq, \(dqoptions\(dq: \(dq0x00C800080102030405060708\(dq, \(dqpeer\(dq: \(dq2001:db8::4\(dq }] } } } } .EE .UNINDENT .UNINDENT .sp User context can store configuration for multiple hooks and comments at once. .sp For a discussion about user context used in hooks, see \fI\%User Contexts in Hooks\fP\&. .SS Simplified Notation .sp It is sometimes convenient to refer to a specific element in the configuration hierarchy. Each hierarchy level is separated by a slash. If there is an array, a specific instance within that array is referenced by a number in square brackets (with numbering starting at zero). For example, in the above configuration the valid\-lifetime in the Dhcp4 component can be referred to as Dhcp4/valid\-lifetime, and the pool in the first subnet defined in the DHCPv4 configuration as Dhcp4/subnet4[0]/pool. .SS Configuration Files Inclusion .sp The parser provides the ability to include files. The syntax was chosen to look similar to how Apache includes PHP scripts in HTML code. This particular syntax was chosen to emphasize that the include directive is an additional feature and not a part of JSON syntax. .sp The inclusion is implemented as a stack of files. You can use the include directive in nested includes. Up to ten nesting levels are supported. This arbitrarily chosen limit is protection against recursive inclusions. .sp The include directive has the form: .INDENT 0.0 .INDENT 3.5 .sp .EX .EE .UNINDENT .UNINDENT .sp The \fI[PATH]\fP pattern should be replaced with an absolute path or a path relative to the current working directory at the time the Kea process was launched. .sp To include one file from another, use the following syntax: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp6\(dq: { \(dqinterfaces\-config\(dq: { \(dqinterfaces\(dq: [ \(dq*\(dq ]}, \(dqpreferred\-lifetime\(dq: 3000, \(dqrebind\-timer\(dq: 2000, \(dqrenew\-timer\(dq: 1000, \(dqvalid\-lifetime\(dq: 4000 } } .EE .UNINDENT .UNINDENT .sp where the content of \(dqsubnets.json\(dq may be: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqsubnet4\(dq: [ { \(dqid\(dq: 123, \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq }, { \(dqid\(dq: 234, \(dqsubnet\(dq: \(dq192.0.3.0/24\(dq }, { \(dqid\(dq: 345, \(dqsubnet\(dq: \(dq10.0.0.0/8\(dq } ], \&... } .EE .UNINDENT .UNINDENT .SS Kea Configuration Backend .SS Applicability .sp The Kea Configuration Backend (CB or config backend) gives Kea servers the ability to store almost all of their configuration in one or more databases. .sp Potential features and benefits include: .INDENT 0.0 .IP \(bu 2 Re\-use of identical configuration sections across multiple Kea servers .IP \(bu 2 A \(dqsingle source of truth\(dq for all Kea servers .IP \(bu 2 All configuration done through an API with real\-time logic checks .IP \(bu 2 Easier integration with third\-party tools or in\-house automation .IP \(bu 2 Database architecture provides concurrency, consistency, and atomicity .IP \(bu 2 The ability to mine the database for statistics and reporting .IP \(bu 2 Use of database replication for real\-time fault\-tolerance .UNINDENT .sp Potential drawbacks include: .INDENT 0.0 .IP \(bu 2 Significant up\-front effort to prepare integration and/or automation .IP \(bu 2 Supported scenarios require use of API for most configuration .IP \(bu 2 The API is only available to ISC customers with a paid support contract .IP \(bu 2 Incompatible with some uses, software, and scenarios .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Use of a database for storage of leases and/or host reservations is possible without using the CB. See the \fBhost\-databases\fP and \fBlease\-database\fP config directives. .UNINDENT .UNINDENT .SS Example Scenario .sp Consider a large organization with many sites, each with a pair of Kea servers deployed in a high availability (HA) configuration. Typically such deployments use standardized configurations, leading to similar config parameters for every site. The members of each HA pair are often almost exactly the same, differing only by name. Often installations of this size will feature a high level of automation, including provisioning and management systems. .sp The CB is ideal for such deployments. While some effort is required to integrate with the provisioning automation, once accomplished, deployment of new Kea servers can be nearly automatic. A small \(dqstub\(dq JSON config, identical for every server, can be used, and all remaining configuration (shared networks, subnets, pools, etc.) loaded from the central CB database. Any updates to the central CB database are automatically propagated to all Kea instances. The CB becomes the \(dqsingle source of truth\(dq for DHCP throughout the organization. .SS Limitations and Warnings .SS Availability .sp \fI\%libdhcp_cb_cmds.so\fP is available only to ISC customers with a paid support contract. For more information on subscription options, please complete the form at \X'tty: link https://www.isc.org/contact'\fI\%https://www.isc.org/contact\fP\X'tty: link'\&. While it is theoretically possible to use the CB without this hook, this is neither supported nor recommended. .SS Preparation is Required .sp The Configuration Backend is not a \(dqplug\-and\-play\(dq solution. Supported scenarios require use of the CB API commands. Configuration information must be loaded into the CB database using the API for the CB to have any effect. The general intent is for the CB to be integrated as part of a larger provisioning solution. Please do not define \fBconfig\-databases\fP unless you have done the necessary preparation work. .SS Database Management .sp The only supported method for managing the contents of the CB database is through the \fI\%libdhcp_cb_cmds.so\fP hook, which provides API commands for config backends. As a practical matter, to use the CB, you must do almost all Kea configuration through the CB API. .sp While it is theoretically possible to use the CB without the API (using tools such as MySQL Workbench or the command\-line MySQL client), these avenues are neither recommended nor supported. .SS Config Conflicts .sp We strongly recommend against mixing configuration information from the CB and JSON config file. In other words, do not use both JSON config declarations and CB to configure the same types of objects. Ideally, when using the CB, the Kea config files should contain the absolute bare minimum necessary, with everything else coming from the CB. .sp Using both CB and JSON as a source of configuration risks conflicting definitions. Such conflicts are confusing at best, and usually lead to undesired behavior or errors from Kea. .sp In the event of a conflict, configuration instructions from the CB database generally take precedence over instructions from a JSON file. .sp In certain carefully\-controlled scenarios, it may be technically possible to use both. For example, defining one subnet in a JSON file and a second (different) subnet in the CB database would not conflict. However, other structures are replaced entirely. For example, if client classes are defined in the CB database, the DHCP server disregards any client classes defined in the JSON file. .sp In short, if you are using the CB, you should use only the CB. .SS Incompatible Software .sp API commands which modify Kea\(aqs configuration (other than the CB API) are contraindicated. This includes the \fI\%libdhcp_subnet_cmds.so\fP hook. Its APIs modify Kea\(aqs in\-memory configuration, and the modifications can only be made persistent by using \fBconfig\-write\fP to write a new JSON config file. .sp The \X'tty: link https://stork.readthedocs.io'\fI\%Stork\fP\X'tty: link' management suite does not currently support the CB. Stork makes all configuration changes through API avenues which expect to write changes into JSON config file. Support for the CB is planned for a future release of Stork. .sp In certain carefully\-controlled scenarios, it may be possible to use these tools with the CB. Namely, if they are used in strictly \(dqread\-only\(dq fashion, to retrieve Kea information, but never to modify it. However, no protection against accidental modification is provided, so this is not recommended. .SS Limitations .sp Currently, the Kea CB has the following limitations: .INDENT 0.0 .IP \(bu 2 It is only supported for MySQL and PostgreSQL databases. .IP \(bu 2 It is only supported for the DHCPv4 and DHCPv6 daemons; the Control Agent, D2 daemon, and the NETCONF daemon cannot be configured from the database, .IP \(bu 2 Only certain DHCP configuration parameters can be set in the database: global parameters, option definitions, global options, client classes, shared networks, and subnets. Other configuration parameters must be sourced from a JSON configuration file. .UNINDENT .SS Custom Options .sp Using custom option formats requires creating definitions for these options. Suppose a user wishes to set option data in the configuration backend. In that case, we recommend specifying the definition for that option in the configuration backend as well. It is essential when multiple servers are managed via the configuration backend, and may differ in their configurations. The option data parser can search for an option definition appropriate for the server for which the option data is specified. .sp In a single\-server deployment, or when all servers share the same configuration file information, it is possible to specify option definitions in the configuration files and option data in the configuration backend. The server receiving a command to set option data must have a valid definition in its configuration file, even when it sets option data for another server. .sp It is not supported to specify option definitions in the configuration backend and the corresponding option data in the server configuration files. .SS Components .sp The Kea Configuration Backend solution consists of the CB modules (hook libraries), the CB commands API (its own hook library), the external database software (MySQL or PostgreSQL), the database schema, and the Kea configuration information stored in the database. .sp In this documentation, the term \(dqConfiguration Backend\(dq may also refer to the particular Kea module providing support for that database type. For example, the MySQL Configuration Backend, \fI\%libdhcp_mysql.so\fP, provides a complete set of functions to manage and fetch the configuration information from a MySQL database. The PostgreSQL Configuration Backend, \fI\%libdhcp_pgsql.so\fP, is the corresponding module for PostgreSQL. Similarly, the term \(dqdatabase\(dq is used to refer to either a MySQL or PostgreSQL database. .sp The CB commands API provides a complete set of commands to manage Kea configuration information, as stored within the database. This API is implemented in its own hook library, \fI\%libdhcp_cb_cmds.so\fP\&. This library can be attached to both DHCPv4 and DHCPv6 server instances. It simplifies many typical operations, such as listing, adding, retrieving, and deleting global parameters, shared networks, subnets, pools, options, option definitions, and client classes. In addition, it provides essential business logic that ensures the logical integrity of the data. All CB API commands start with \fBremote\-\fP\&. See \fI\%libdhcp_cb_cmds.so: Configuration Backend Commands\fP for more information. .sp Installation and maintenance of external database software is beyond the scope of this manual. .sp The database schema is typically installed via the \fI\%kea\-admin\fP tool. See \fI\%Installation\fP for more information. The raw schema creation scripts are \X'tty: link https://gitlab.isc.org/isc-projects/kea/blob/master/src/share/database/scripts/mysql/dhcpdb_create.mysql'\fI\%dhcpdb_create.mysql\fP\X'tty: link' and \X'tty: link https://gitlab.isc.org/isc-projects/kea/blob/master/src/share/database/scripts/pgsql/dhcpdb_create.pgsql'\fI\%dhcpdb_create.pgsql\fP\X'tty: link'\&. .sp Use the CB commands API to populate the database with Kea configuration information. .sp Related design documents are available in our GitLab: .INDENT 0.0 .IP \(bu 2 \X'tty: link https://gitlab.isc.org/isc-projects/kea/wikis/designs/configuration-in-db-design'\fI\%CB Design\fP\X'tty: link' .IP \(bu 2 \X'tty: link https://gitlab.isc.org/isc-projects/kea/wikis/designs/client-classes-in-cb'\fI\%Client Classes in CB Design\fP\X'tty: link' .UNINDENT .SS Installation .sp To use either Configuration Backend, the appropriate module library (\fI\%libdhcp_mysql.so\fP or \fI\%libdhcp_pgsql.so\fP) must be compiled during the Kea build. The \fB\-D\fP switch specifies which database module to build, if any: \fB\-D mysql=enabled\fP or \fB\-D postgresql=enabled\fP\&. The appropriate database client libraries and header files must be installed prior to build. See \fI\%DHCP Database Installation and Configuration\fP for more information on building Kea with database support. ISC\(aqs Kea packaging, as well as some third\-party distributions, provide separate packages for each database type. .sp The database server hosting the CB tables must be prepared with the Kea schema. When upgrading an existing Kea installation, the database schema may also need to be upgraded. The \fI\%kea\-admin\fP tool can be used to more easily apply the schema, as described in \fI\%The kea\-admin Tool\fP\&. .sp At runtime, the DHCP servers must be configured to load the module, in the \fBhooks\-libraries\fP section. A \fBconfig\-databases\fP directive must then be used to instruct Kea to load configuration using the database backend. The DHCPv4 and DHCPv6 server\-specific configurations of the CB, as well as the list of supported configuration parameters, can be found in \fI\%Configuration Backend in DHCPv4\fP and \fI\%Configuration Backend in DHCPv6\fP, respectively. .sp Once installation is completed, the CB commands API can be used to populate the database with Kea configuration information. .SS Configuration Sharing and Server Tags .sp The configuration database is designed to store configuration information for multiple Kea servers. Depending on the use case, the entire configuration may be shared by all servers; parts of the configuration may be shared by multiple servers and the rest of the configuration may be different for these servers; or each server may have its own non\-shared configuration. .sp The configuration elements in the database are associated with the servers by \(dqserver tags.\(dq The server tag is an arbitrary string holding the name of the Kea server instance. The tags of the DHCPv4 and DHCPv6 servers are independent in the database, i.e. the same server tag can be created for both the DHCPv4 and the DHCPv6 server. The value is configured using the \fBserver\-tag\fP parameter in the \fBDhcp4\fP or \fBDhcp6\fP scope. The current server tag can be checked with the \fI\%server\-tag\-get\fP command. .sp The server definition, which consists of the server tag and the server description, must be stored in the configuration database prior to creating the dedicated configuration for that server. In cases when all servers use the same configuration, e.g. a pair of servers running as High Availability peers, there is no need to configure the server tags for these servers in the database. .sp Commands which contain the logical server \fIall\fP are applied to all servers connecting to the database. The \fIall\fP server cannot be deleted or modified, and it is not returned among other servers as a result of the \fI\%remote\-server4\-get\-all\fP and \fI\%remote\-server6\-get\-all\fP commands. .sp In most cases, there are no server tags defined in the configuration database; all connecting servers get the same configuration regardless of the server tag they use. The server tag that a particular Kea instance presents to the database to fetch its configuration is specified in the Kea configuration file, using the \fIconfig\-control\fP map (please refer to the \fI\%Enabling the Configuration Backend\fP and \fI\%Enabling the Configuration Backend\fP for details). All Kea instances presenting the same server tag to the configuration database are given the same configuration. .sp It is the administrator\(aqs choice whether multiple Kea instances use the same server tag or each Kea instance uses a different server tag. There is no requirement that the instances running on the same physical or virtual machine use the same server tag. It is even possible to configure the Kea server without assigning it a server tag. In such a case the server will be given the configuration specified for \fIall\fP servers. .sp To differentiate between different Kea server configurations, a list of the server tags used by the servers must be stored in the database. For the DHCPv4 and DHCPv6 servers, this can be done using the \fI\%remote\-server4\-set\fP and \fI\%remote\-server6\-set\fP commands. The server tags can then be used to associate the configuration information with the servers. However, it is important to note that some DHCP configuration elements may be associated with multiple server tags (known as \(dqshareable\(dq elements), while other configuration elements may be associated with only one server tag (\(dqnon\-shareable\(dq elements). The \fI\%Configuration Backend in DHCPv4\fP and \fI\%Configuration Backend in DHCPv6\fP sections list the DHCP\-specific shareable and non\-shareable configuration elements; however, in this section we briefly explain the differences between them. .sp A shareable configuration element is one which has some unique property identifying it, and which may appear only once in the database. An example of a shareable DHCP element is a subnet instance: the subnet is a part of the network topology and we assume that any particular subnet may have only one definition within this network. Each subnet has two unique identifiers: the subnet identifier and the subnet prefix. The subnet identifier is used in Kea to uniquely identify the subnet within the network and to connect it with other configuration elements, e.g. in host reservations. Some commands provided by \fI\%libdhcp_cb_cmds.so\fP allow the subnet information to be accessed by either subnet identifier or prefix, and explicitly prohibit using the server tag to access the subnet. This is because, in general, the subnet definition is associated with multiple servers rather than a single server. In fact, it may even be associated with no servers (unassigned). Still, the unassigned subnet has an identifier and prefix which can be used to access the subnet. .sp A shareable configuration element may be associated with multiple servers, one server, or no servers. Deletion of the server which is associated with the shareable element does not cause the deletion of the shareable element. It merely deletes the association of the deleted server with the element. .sp Unlike a shareable element, a non\-shareable element must not be explicitly associated with more than one server and must not exist after the server is deleted (must not remain unassigned). A non\-shareable element only exists within the context of the server. An example of a non\-shareable element in DHCP is a global parameter, e.g. \fIrenew\-timer\fP\&. The renew timer is the value to be used by a particular server and only this server. Other servers may have their respective renew timers set to the same or different values. The renew timer parameter has no unique identifier by which it could be accessed, modified, or otherwise used. Global parameters like the renew timer can be accessed by the parameter name and the tag of the server for which they are configured. For example, the \fI\%remote\-global\-parameter4\-get\fP and \fI\%remote\-global\-parameter6\-get\fP commands allow the value of the global parameter to be fetched by the parameter name and the server name. Getting the global parameter only by its name (without specifying the server tag) is not possible, because there may be many global parameters with a given name in the database. .sp When the server associated with a non\-shareable configuration element is deleted, the configuration element is automatically deleted from the database along with the server because the non\-shareable element must be always assigned to a server (or the logical server \fIall\fP). .sp The terms \(dqshareable\(dq and \(dqnon\-shareable\(dq only apply to associations with user\-defined servers; all configuration elements associated with the logical server \fIall\fP are by definition shareable. For example: the \fIrenew\-timer\fP associated with \fIall\fP servers is used by all servers connecting to the database which do not have their specific renew timers defined. In a special case, when none of the configuration elements are associated with user\-defined servers, the entire configuration in the database is shareable because all its pieces belong to \fIall\fP servers. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Be very careful when associating configuration elements with different server tags. The configuration backend does not protect against some possible misconfigurations that may arise from the wrong server tags\(aq assignments. For example: if a shared network is assigned to one server and the subnets belonging to this shared network to another server, the servers will fail upon trying to fetch and use this configuration. The server fetching the subnets will be aware that the subnets are associated with the shared network, but the shared network will not be found by this server since it doesn\(aqt belong to it. In such a case, both the shared network and the subnets should be assigned to the same set of servers. .UNINDENT .UNINDENT .SH MANAGING KEA WITH KEACTRL .SS Overview .sp \fI\%keactrl\fP is a shell script which controls the startup, shutdown, and reconfiguration of the Kea servers (\fI\%kea\-dhcp4\fP, \fI\%kea\-dhcp6\fP, \fI\%kea\-dhcp\-ddns\fP, \fI\%kea\-ctrl\-agent\fP, and \fI\%kea\-netconf\fP). It also provides the means for checking the current status of the servers and determining the configuration files in use. .sp \fI\%keactrl\fP is available only when Kea is built from sources. When installing Kea using native packages, the native \fBsystemd\fP scripts are provided. See \fI\%Native Packages and systemd\fP Section for details. .SS Command Line Options .sp \fI\%keactrl\fP is run as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX # keactrl [\-c keactrl\-config\-file] [\-s server[,server,...]] .EE .UNINDENT .UNINDENT .sp \fB\fP is one of the commands described in \fI\%Commands\fP\&. .sp The optional \fB\-c keactrl\-config\-file\fP switch allows specification of an alternate \fI\%keactrl\fP configuration file. (\fB\-\-ctrl\-config\fP is a synonym for \fB\-c\fP\&.) In the absence of \fB\-c\fP, \fI\%keactrl\fP uses the default configuration file \fB[kea\-install\-dir]/etc/kea/keactrl.conf\fP\&. .sp The optional \fB\-s server[,server,...]\fP switch selects the servers to which the command is issued. (\fB\-\-server\fP is a synonym for \fB\-s\fP\&.) If absent, the command is sent to all servers enabled in the \fI\%keactrl\fP configuration file. If multiple servers are specified, they should be separated by commas with no intervening spaces. .SS The \fI\%keactrl\fP Configuration File .sp Depending on the administrator\(aqs requirements, it may not be necessary to run all of the available servers. The \fI\%keactrl\fP configuration file sets which servers are enabled and which are disabled. The default configuration file is \fB[kea\-install\-dir]/etc/kea/keactrl.conf\fP, but this can be overridden on a per\-command basis using the \fB\-c\fP switch. .sp The contents of \fBkeactrl.conf\fP are: .INDENT 0.0 .INDENT 3.5 .sp .EX # This is a configuration file for keactrl script which controls # the startup, shutdown, reconfiguration and gathering the status # of the Kea processes. # prefix holds the location where the Kea is installed. prefix=@prefix@ # Location of Kea configuration file. kea_dhcp4_config_file=@sysconfdir@/@PACKAGE@/kea\-dhcp4.conf kea_dhcp6_config_file=@sysconfdir@/@PACKAGE@/kea\-dhcp6.conf kea_dhcp_ddns_config_file=@sysconfdir@/@PACKAGE@/kea\-dhcp\-ddns.conf kea_ctrl_agent_config_file=@sysconfdir@/@PACKAGE@/kea\-ctrl\-agent.conf kea_netconf_config_file=@sysconfdir@/@PACKAGE@/kea\-netconf.conf # Location of Kea binaries. exec_prefix=@exec_prefix@ dhcp4_srv=@sbindir@/kea\-dhcp4 dhcp6_srv=@sbindir@/kea\-dhcp6 dhcp_ddns_srv=@sbindir@/kea\-dhcp\-ddns ctrl_agent_srv=@sbindir@/kea\-ctrl\-agent netconf_srv=@sbindir@/kea\-netconf # Start DHCPv4 server? dhcp4=yes # Start DHCPv6 server? dhcp6=yes # Start DHCP DDNS server? dhcp_ddns=no # Start Control Agent? ctrl_agent=yes # Start Netconf? netconf=no # Be verbose? kea_verbose=no .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 In the example above, strings of the form @something@ are replaced by the appropriate values when Kea is installed. .UNINDENT .UNINDENT .sp Setting the \fBdhcp4\fP, \fBdhcp6\fP, \fBdhcp_ddns\fP, \fBctrl_agent\fP, and \fBnetconf\fP parameters set to \(dqyes\(dq configures \fI\%keactrl\fP to manage (start, reconfigure) all servers, i.e. \fI\%kea\-dhcp4\fP, \fI\%kea\-dhcp6\fP, \fI\%kea\-dhcp\-ddns\fP, \fI\%kea\-ctrl\-agent\fP, and \fI\%kea\-netconf\fP\&. When any of these parameters is set to \(dqno\(dq, \fI\%keactrl\fP ignores the corresponding server when starting or reconfiguring Kea. Some daemons (dhcp_ddns and netconf) are disabled by default. .sp By default, Kea servers managed by \fI\%keactrl\fP are located in \fB[kea\-install\-dir]/sbin\fP\&. This should work for most installations. If the default location needs to be altered, the paths specified with the \fBdhcp4_srv\fP, \fBdhcp6_srv\fP, \fBdhcp_ddns_srv\fP, \fBctrl_agent_srv\fP, and \fBnetconf_srv\fP parameters should be modified. .sp The \fBkea_verbose\fP parameter specifies the verbosity of the servers being started. When \fBkea_verbose\fP is set to \fByes\fP, the logging level of the server is set to DEBUG. Modification of the logging severity in a configuration file, as described in \fI\%Logging\fP, will have no effect as long as \fBkea_verbose\fP is set to \(dqyes.\(dq Setting it to \(dqno\(dq causes the server to use the logging levels specified in the Kea configuration file. If no logging configuration is specified, the default settings are used. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The verbosity for the server is set when it is started. Once started, the verbosity can only be changed by stopping the server and starting it again with the new value of the \fBkea_verbose\fP parameter. .UNINDENT .UNINDENT .SS Commands .sp The following commands are supported by \fI\%keactrl\fP: .INDENT 0.0 .IP \(bu 2 \fBstart\fP \- starts the selected servers. .IP \(bu 2 \fBstop\fP \- stops all running servers. .IP \(bu 2 \fBreload\fP \- triggers reconfiguration of the selected servers by sending the SIGHUP signal to them. .IP \(bu 2 \fBstatus\fP \- returns the status of the servers (active or inactive) and the names of the configuration files in use. .IP \(bu 2 \fBversion\fP \- prints out the version of the \fI\%keactrl\fP tool itself, together with the versions of the Kea daemons. .UNINDENT .sp Typical output from \fI\%keactrl\fP when starting the servers looks similar to the following: .INDENT 0.0 .INDENT 3.5 .sp .EX $ keactrl start INFO/keactrl: Starting kea\-dhcp4 \-c /usr/local/etc/kea/kea\-dhcp4.conf \-d INFO/keactrl: Starting kea\-dhcp6 \-c /usr/local/etc/kea/kea\-dhcp6.conf \-d INFO/keactrl: Starting kea\-dhcp\-ddns \-c /usr/local/etc/kea/kea\-dhcp\-ddns.conf \-d INFO/keactrl: Starting kea\-ctrl\-agent \-c /usr/local/etc/kea/kea\-ctrl\-agent.conf \-d INFO/keactrl: Starting kea\-netconf \-c /usr/local/etc/kea/kea\-netconf.conf \-d .EE .UNINDENT .UNINDENT .sp Kea\(aqs servers create PID files upon startup. These files are used by \fI\%keactrl\fP to determine whether a given server is running. If one or more servers are running when the start command is issued, the output looks similar to the following: .INDENT 0.0 .INDENT 3.5 .sp .EX $ keactrl start INFO/keactrl: kea\-dhcp4 appears to be running, see: PID 10918, PID file: /usr/local/var/run/kea/kea.kea\-dhcp4.pid. INFO/keactrl: kea\-dhcp6 appears to be running, see: PID 10924, PID file: /usr/local/var/run/kea/kea.kea\-dhcp6.pid. INFO/keactrl: kea\-dhcp\-ddns appears to be running, see: PID 10930, PID file: /usr/local/var/run/kea/kea.kea\-dhcp\-ddns.pid. INFO/keactrl: kea\-ctrl\-agent appears to be running, see: PID 10931, PID file: /usr/local/var/run/kea/kea.kea\-ctrl\-agent.pid. INFO/keactrl: kea\-netconf appears to be running, see: PID 10123, PID file: /usr/local/var/run/kea/kea.kea\-netconf.pid. .EE .UNINDENT .UNINDENT .sp During normal shutdowns, these PID files are deleted; they may, however, be left over as remnants following a system crash. It is possible, though highly unlikely, that upon system restart the PIDs they contain may actually refer to processes unrelated to Kea. This condition will cause \fI\%keactrl\fP to decide that the servers are running, when in fact they are not. In such a case the PID files listed in the \fI\%keactrl\fP output must be manually deleted. .sp The following command stops all servers: .INDENT 0.0 .INDENT 3.5 .sp .EX $ keactrl stop INFO/keactrl: Stopping kea\-dhcp4... INFO/keactrl: Stopping kea\-dhcp6... INFO/keactrl: Stopping kea\-dhcp\-ddns... INFO/keactrl: Stopping kea\-ctrl\-agent... INFO/keactrl: Stopping kea\-netconf... .EE .UNINDENT .UNINDENT .sp Note that the \fBstop\fP command attempts to stop all servers regardless of whether they are \(dqenabled\(dq in \fBkeactrl.conf\fP\&. If any of the servers are not running, an informational message is displayed as in the \fBstop\fP command output below. .INDENT 0.0 .INDENT 3.5 .sp .EX $ keactrl stop INFO/keactrl: kea\-dhcp4 isn\(aqt running. INFO/keactrl: kea\-dhcp6 isn\(aqt running. INFO/keactrl: kea\-dhcp\-ddns isn\(aqt running. INFO/keactrl: kea\-ctrl\-agent isn\(aqt running. INFO/keactrl: kea\-netconf isn\(aqt running. .EE .UNINDENT .UNINDENT .sp As already mentioned, the reconfiguration of each Kea server is triggered by the SIGHUP signal. The \fBreload\fP command sends the SIGHUP signal to any servers that are enabled in the \fI\%keactrl\fP configuration file and that are currently running. When a server receives the SIGHUP signal it rereads its configuration file and, if the new configuration is valid, uses the new configuration. If the new configuration proves to be invalid, the server retains its current configuration; however, in some cases a fatal error message is logged indicating that the server is no longer providing any service: a working configuration must be loaded as soon as possible. .sp A reload is executed as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX $ keactrl reload INFO/keactrl: Reloading kea\-dhcp4... INFO/keactrl: Reloading kea\-dhcp6... INFO/keactrl: Reloading kea\-dhcp\-ddns... INFO/keactrl: Reloading kea\-ctrl\-agent... .EE .UNINDENT .UNINDENT .sp If any of the servers are not running, an informational message is displayed as in the \fBreload\fP command output below. \fI\%kea\-netconf\fP does not support the SIGHUP signal. If its configuration has changed, please stop and restart it for the change to take effect. .INDENT 0.0 .INDENT 3.5 .sp .EX $ keactrl stop INFO/keactrl: kea\-dhcp4 isn\(aqt running. INFO/keactrl: kea\-dhcp6 isn\(aqt running. INFO/keactrl: kea\-dhcp\-ddns isn\(aqt running. INFO/keactrl: kea\-ctrl\-agent isn\(aqt running. INFO/keactrl: kea\-netconf isn\(aqt running. .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 NETCONF is an optional feature that is disabled by default and can be enabled during compilation. If Kea was compiled without NETCONF support, \fI\%keactrl\fP does not provide information about it. The NETCONF entries are still present in the \fBkeactrl.conf\fP file, but NETCONF status is not shown and other commands ignore it. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Currently \fI\%keactrl\fP does not report configuration failures when the server is started or reconfigured. To check if the server\(aqs configuration succeeded, the Kea log must be examined for errors. By default, the log is written to the \fIsyslog\fP file. .UNINDENT .UNINDENT .sp Sometimes it is useful to check which servers are running. The \fBstatus\fP command reports this, with typical output that looks like: .INDENT 0.0 .INDENT 3.5 .sp .EX $ keactrl status DHCPv4 server: active DHCPv6 server: inactive DHCP DDNS: active Control Agent: active Netconf agent: inactive Kea configuration file: /usr/local/etc/kea/kea.conf Kea DHCPv4 configuration file: /usr/local/etc/kea/kea\-dhcp4.conf Kea DHCPv6 configuration file: /usr/local/etc/kea/kea\-dhcp6.conf Kea DHCP DDNS configuration file: /usr/local/etc/kea/kea\-dhcp\-ddns.conf Kea Control Agent configuration file: /usr/local/etc/kea/kea\-ctrl\-agent.conf Kea Netconf configuration file: /usr/local/etc/kea/kea\-netconf.conf keactrl configuration file: /usr/local/etc/kea/keactrl.conf .EE .UNINDENT .UNINDENT .sp \fBkeactrl status\fP offers basic reporting capabilities. For more extensive insight into Kea\(aqs health and status, consider deploying Stork. For details, see \fI\%Monitoring Kea With Stork\fP\&. .SS Overriding the Server Selection .sp The optional \fB\-s\fP switch allows the selection of the server(s) to which the \fI\%keactrl\fP command is issued. For example, the following instructs \fI\%keactrl\fP to stop the \fI\%kea\-dhcp4\fP and \fI\%kea\-dhcp6\fP servers and leave the \fI\%kea\-dhcp\-ddns\fP and \fI\%kea\-ctrl\-agent\fP running: .INDENT 0.0 .INDENT 3.5 .sp .EX $ keactrl stop \-s dhcp4,dhcp6 .EE .UNINDENT .UNINDENT .sp Similarly, the following starts only the \fI\%kea\-dhcp4\fP and \fI\%kea\-dhcp\-ddns\fP servers, but not \fI\%kea\-dhcp6\fP or \fI\%kea\-ctrl\-agent\fP\&. .INDENT 0.0 .INDENT 3.5 .sp .EX $ keactrl start \-s dhcp4,dhcp_ddns .EE .UNINDENT .UNINDENT .sp Note that the behavior of the \fB\-s\fP switch with the \fBstart\fP and \fBreload\fP commands is different from its behavior with the \fBstop\fP command. On \fBstart\fP and \fBreload\fP, \fI\%keactrl\fP checks whether the servers given as parameters to the \fB\-s\fP switch are enabled in the \fI\%keactrl\fP configuration file; if not, the server is ignored. For \fBstop\fP, however, this check is not made; the command is applied to all listed servers, regardless of whether they have been enabled in the file. .sp The following keywords can be used with the \fB\-s\fP command\-line option: .INDENT 0.0 .IP \(bu 2 \fBdhcp4\fP for \fI\%kea\-dhcp4\fP\&. .IP \(bu 2 \fBdhcp6\fP for \fI\%kea\-dhcp6\fP\&. .IP \(bu 2 \fBdhcp_ddns\fP for \fI\%kea\-dhcp\-ddns\fP\&. .IP \(bu 2 \fBctrl_agent\fP for \fI\%kea\-ctrl\-agent\fP\&. .IP \(bu 2 \fBnetconf\fP for \fI\%kea\-netconf\fP\&. .IP \(bu 2 \fBall\fP for all servers (default). .UNINDENT .SS Native Packages and \fBsystemd\fP .sp \fI\%keactrl\fP is a script that was developed to assist in managing Kea processes. However, all modern operating systems have their own process\-management scripts, such as \fBsystemd\fP\&. In general, these native scripts should be used, as they have several advantages. \fBsystemd\fP scripts handle processes in a uniform way, so Kea is handled in a similar fashion to HTTP or a mail server. Second and more importantly, \fBsystemd\fP allows dependencies to be defined between services. For example, it is easy to specify that the Kea server should not start until the network interfaces are operational. Using native scripts also has other benefits, such as the ability to enable or disable services using commands, and the ability to temporarily start a disabled service. .sp Thus, it is recommended to use \fBsystemctl\fP commands if they are available. Native Kea packages do not provide \fI\%keactrl\fP; \fBsystemctl\fP service definitions are provided instead. Consult the system documentation for details. .sp Briefly, here are example commands to check status, start, stop, and restart various Kea daemons: .INDENT 0.0 .INDENT 3.5 .sp .EX # systemctl status kea\-ctrl\-agent # systemctl start kea\-dhcp4 # systemctl stop kea\-dhcp6 # systemctl restart kea\-dhcp\-ddns .EE .UNINDENT .UNINDENT .sp Note that the service names may be slightly different between Linux distributions; in general, we have followed the naming conventions in third\-party packages. In particular, some systems may not have the \fIisc\-\fP prefix. .SH THE KEA CONTROL AGENT .SS Overview of the Kea Control Agent .sp The Kea Control Agent (CA) is a daemon which exposes a RESTful control interface for managing Kea servers. The daemon can receive control commands over HTTP and either forward these commands to the respective Kea servers or handle these commands on its own. The determination whether the command should be handled by the CA or forwarded is made by checking the value of the \fBservice\fP parameter, which may be included in the command from the controlling client. The details of the supported commands, as well as their structures, are provided in \fI\%Management API\fP\&. .sp The CA can use hook libraries to provide support for additional commands or to program custom behavior of existing commands. Such hook libraries must implement callouts for the \fBcontrol_command_receive\fP hook point. Details about creating new hook libraries and supported hook points can be found in the \X'tty: link https://reports.kea.isc.org/dev_guide/'\fI\%Kea Developer\(aqs Guide\fP\X'tty: link'\&. .sp The CA processes received commands according to the following algorithm: .INDENT 0.0 .IP \(bu 2 Pass command into any installed hooks (regardless of service value(s)). If the command is handled by a hook, return the response. .IP \(bu 2 If the service specifies one or more services, forward the command to the specified services and return the accumulated responses. .IP \(bu 2 If the service is not specified or is an empty list, handle the command if the CA supports it. .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The kea\-ctrl\-agent is deprecated. As of Kea 2.7.2 the Kea servers: kea\-dhcp4, kea\-dhcp6, and kea\-dhcp\-ddns directly support command API connections over HTTPS/HTTP. (\fI\%Migration from the Control Agent\fP). .UNINDENT .UNINDENT .SS Configuration .sp The following example demonstrates the basic CA configuration. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqControl\-agent\(dq: { \(dqhttp\-host\(dq: \(dq10.20.30.40\(dq, \(dqhttp\-port\(dq: 8000, \(dqhttp\-headers\(dq: [ { \(dqname\(dq: \(dqStrict\-Transport\-Security\(dq, \(dqvalue\(dq: \(dqmax\-age=31536000\(dq } ], \(dqtrust\-anchor\(dq: \(dq/path/to/the/ca\-cert.pem\(dq, \(dqcert\-file\(dq: \(dq/path/to/the/agent\-cert.pem\(dq, \(dqkey\-file\(dq: \(dq/path/to/the/agent\-key.pem\(dq, \(dqcert\-required\(dq: true, \(dqauthentication\(dq: { \(dqtype\(dq: \(dqbasic\(dq, \(dqrealm\(dq: \(dqkea\-control\-agent\(dq, \(dqclients\(dq: [ { \(dquser\(dq: \(dqadmin\(dq, \(dqpassword\(dq: \(dq1234\(dq } ] }, \(dqcontrol\-sockets\(dq: { \(dqdhcp4\(dq: { \(dqcomment\(dq: \(dqmain server\(dq, \(dqsocket\-type\(dq: \(dqunix\(dq, \(dqsocket\-name\(dq: \(dq/path/to/the/unix/socket\-v4\(dq }, \(dqdhcp6\(dq: { \(dqsocket\-type\(dq: \(dqunix\(dq, \(dqsocket\-name\(dq: \(dq/path/to/the/unix/socket\-v6\(dq, \(dquser\-context\(dq: { \(dqversion\(dq: 3 } }, \(dqd2\(dq: { \(dqsocket\-type\(dq: \(dqunix\(dq, \(dqsocket\-name\(dq: \(dq/path/to/the/unix/socket\-d2\(dq } }, \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dq/opt/local/custom_hooks_example.so\(dq, \(dqparameters\(dq: { \(dqparam1\(dq: \(dqfoo\(dq } } ], \(dqloggers\(dq: [ { \(dqname\(dq: \(dqkea\-ctrl\-agent\(dq, \(dqseverity\(dq: \(dqINFO\(dq } ] } } .EE .UNINDENT .UNINDENT .sp The \fBhttp\-host\fP and \fBhttp\-port\fP parameters specify an IP address and port to which HTTP service will be bound. In the example configuration provided above, the RESTful service will be available at the URL \fBhttps://10.20.30.40:8000/\fP\&. If these parameters are not specified, the default URL is \fBhttp://127.0.0.1:8000/\fP\&. .sp When using Kea\(aqs HA hook library with multi\-threading, the address:port combination used for CA must be different from the HA peer URLs, which are strictly for internal HA traffic between the peers. User commands should still be sent via the CA. .sp Since Kea 2.7.5 the \fBhttp\-headers\fP parameter specifies a list of extra HTTP headers to add to HTTP responses. .sp The \fBtrust\-anchor\fP, \fBcert\-file\fP, \fBkey\-file\fP, and \fBcert\-required\fP parameters specify the TLS setup for HTTP, i.e. HTTPS. If these parameters are not specified, HTTP is used. The TLS/HTTPS support in Kea is described in \fI\%TLS/HTTPS Support\fP\&. .sp As mentioned in \fI\%Overview of the Kea Control Agent\fP, the CA can forward received commands to the Kea servers for processing. For example, \fI\%config\-get\fP is sent to retrieve the configuration of one of the Kea services. When the CA receives this command, including a \fBservice\fP parameter indicating that the client wishes to retrieve the configuration of the DHCPv4 server, the CA forwards the command to that server and passes the received response back to the client. More about the \fBservice\fP parameter and the general structure of commands can be found in \fI\%Management API\fP\&. .sp The CA uses UNIX domain sockets to forward control commands and receive responses from other Kea services. The \fBdhcp4\fP, \fBdhcp6\fP, and \fBd2\fP maps specify the files to which UNIX domain sockets are bound. In the configuration above, the CA connects to the DHCPv4 server via \fB/path/to/the/unix/socket\-v4\fP to forward the commands to it. Obviously, the DHCPv4 server must be configured to listen to connections via this same socket. In other words, the command\-socket configuration for the DHCPv4 server and the CA (for that server) must match. Consult \fI\%UNIX Control Socket\fP, \fI\%UNIX Control Socket\fP, and \fI\%UNIX Control Socket\fP to learn how the UNIX socket configuration is specified for the DHCPv4, DHCPv6, and D2 services. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 As of Kea 2.7.9, control sockets may only reside in the directory determined during compilation as \fB\(dq[kea\-install\-dir]/var/run/kea\(dq\fP, which must also have \fB0750\fP access rights. This path may be overridden at startup by setting the environment variable \fBKEA_CONTROL_SOCKET_DIR\fP to the desired path. If a path other than this value is used in \fBsocket\-name\fP, Kea will emit an error and refuse to start or, if already running, log an unrecoverable error. For ease of use in simply omit the path component from \fBsocket\-name\fP\&. .UNINDENT .UNINDENT .sp User contexts can store arbitrary data as long as they are in valid JSON syntax and their top\-level element is a map (i.e. the data must be enclosed in curly brackets). Some hook libraries may expect specific formatting; please consult the relevant hook library documentation for details. .sp User contexts can be specified on either global scope, control socket, basic authentication, or loggers. One other useful feature is the ability to store comments or descriptions; the parser translates a \(dqcomment\(dq entry into a user context with the entry, which allows a comment to be attached within the configuration itself. .sp Basic HTTP authentication protects against unauthorized uses of the control agent by local users. For protection against remote attackers, HTTPS and reverse proxy of \fI\%Secure Connections\fP provide stronger security. .sp The authentication is described in the \fBauthentication\fP block with the mandatory \fBtype\fP parameter, which selects the authentication. Currently only the basic HTTP authentication (type basic) is supported. .sp The \fBrealm\fP authentication parameter is used for error messages when the basic HTTP authentication is required but the client is not authorized. .sp When the \fBclients\fP authentication list is configured and not empty, basic HTTP authentication is required. Each element of the list specifies a user ID and a password. The user ID is mandatory, must not be empty, and must not contain the colon (:) character. The password is optional; when it is not specified an empty password is used. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The basic HTTP authentication user ID and password are encoded in UTF\-8, but the current Kea JSON syntax only supports the Latin\-1 (i.e. 0x00..0xff) Unicode subset. .UNINDENT .UNINDENT .sp To avoid exposing the user ID and/or the associated password, these values can be read from files. The syntax is extended by: .INDENT 0.0 .IP \(bu 2 The \fBdirectory\fP authentication parameter, which handles the common part of file paths. The default value is the empty string. .IP \(bu 2 The \fBpassword\-file\fP client parameter, which, alongside the \fBdirectory\fP parameter, specifies the path of a file that can contain the password, or when no user ID is given, the whole basic HTTP authentication secret. .IP \(bu 2 The \fBuser\-file\fP client parameter, which, with the \fBdirectory\fP parameter, specifies the path of a file where the user ID can be read. .UNINDENT .sp When files are used, they are read when the configuration is loaded, to detect configuration errors as soon as possible. .sp Hook libraries can be loaded by \fI\%kea\-ctrl\-agent\fP in the same way as they are loaded by \fI\%kea\-dhcp4\fP and \fI\%kea\-dhcp6\fP\&. The CA currently supports one hook point \- \fBcontrol_command_receive\fP \- which makes it possible to delegate the processing of some commands to the hook library. The \fBhooks\-libraries\fP list contains the list of hook libraries that should be loaded by \fI\%kea\-ctrl\-agent\fP, along with their configuration information specified with \fBparameters\fP\&. .sp Please consult \fI\%Logging\fP for the details on how to configure logging. The CA\(aqs root logger\(aqs name is \fI\%kea\-ctrl\-agent\fP, as given in the example above. .SS Secure Connections .sp Configuration options related to Kea Control Agent security can be found in the \fI\%Secure Kea Control Agent\fP section. .SS Starting and Stopping the Control Agent .sp \fI\%kea\-ctrl\-agent\fP accepts the following command\-line switches: .INDENT 0.0 .IP \(bu 2 \fB\-c file\fP \- specifies the configuration file. .IP \(bu 2 \fB\-d\fP \- specifies whether the agent logging should be switched to debug/verbose mode. In verbose mode, the logging severity and debuglevel specified in the configuration file are ignored and \(dqdebug\(dq severity and the maximum debuglevel (99) are assumed. The flag is convenient for temporarily switching the server into maximum verbosity, e.g. when debugging. .IP \(bu 2 \fB\-t file\fP \- specifies the configuration file to be tested. \fI\%kea\-netconf\fP attempts to load it and conducts sanity checks; certain checks are possible only while running the actual server. The actual status is reported with exit code (0 = configuration appears valid, 1 = error encountered). Kea prints out log messages to standard output and error to standard error when testing the configuration. .IP \(bu 2 \fB\-v\fP \- displays the version of \fI\%kea\-ctrl\-agent\fP and exits. .IP \(bu 2 \fB\-V\fP \- displays the extended version information for \fI\%kea\-ctrl\-agent\fP and exits. The listing includes the versions of the libraries dynamically linked to Kea. .IP \(bu 2 \fB\-W\fP \- displays the Kea configuration report and exits. The report is a copy of the \fBconfig.report\fP file produced by \fBmeson setup\fP; it is embedded in the executable binary. .sp The contents of the \fBconfig.report\fP file may also be accessed by examining certain libraries in the installation tree or in the source tree. .INDENT 2.0 .INDENT 3.5 .sp .EX # from installation using libkea\-process.so $ strings ${prefix}/lib/libkea\-process.so | sed \-n \(aqs/;;;; //p\(aq # from sources using libkea\-process.so $ strings src/lib/process/.libs/libkea\-process.so | sed \-n \(aqs/;;;; //p\(aq # from sources using libkea\-process.a $ strings src/lib/process/.libs/libkea\-process.a | sed \-n \(aqs/;;;; //p\(aq # from sources using libcfgrpt.a $ strings src/lib/process/cfgrpt/.libs/libcfgrpt.a | sed \-n \(aqs/;;;; //p\(aq .EE .UNINDENT .UNINDENT .IP \(bu 2 \fB\-X\fP \- As of Kea 3.0, disables path and permissions restrictions. The server will emit a warning at startup that sercurity restrictions have been disabled. Do not use this mode of operation without careful consideration and taking any necessary precautions. Failure to do so can expose deployments to security vulnerabilities. For more information please read section \fI\%Securing a Kea Deployment\fP\&. .UNINDENT .sp The CA is started by running its binary and specifying the configuration file it should use. For example: .INDENT 0.0 .INDENT 3.5 .sp .EX $ ./kea\-ctrl\-agent \-c /usr/local/etc/kea/kea\-ctrl\-agent.conf .EE .UNINDENT .UNINDENT .sp It can be started by \fI\%keactrl\fP as well (see \fI\%Managing Kea with keactrl\fP). .SS Connecting to the Control Agent .sp For an example of a tool that can take advantage of the RESTful API, see \fI\%The Kea Shell\fP\&. .SH THE DHCPV4 SERVER .SS Starting and Stopping the DHCPv4 Server .sp It is recommended that the Kea DHCPv4 server be started and stopped using \fI\%keactrl\fP (described in \fI\%Managing Kea with keactrl\fP); however, it is also possible to run the server directly via the \fI\%kea\-dhcp4\fP command, which accepts the following command\-line switches: .INDENT 0.0 .IP \(bu 2 \fB\-c file\fP \- specifies the configuration file. This is the only mandatory switch. .IP \(bu 2 \fB\-d\fP \- specifies whether the server logging should be switched to debug/verbose mode. In verbose mode, the logging severity and debuglevel specified in the configuration file are ignored; \(dqdebug\(dq severity and the maximum debuglevel (99) are assumed. The flag is convenient for temporarily switching the server into maximum verbosity, e.g. when debugging. .IP \(bu 2 \fB\-p server\-port\fP \- specifies the local UDP port on which the server listens. This is only useful during testing, as a DHCPv4 server listening on ports other than the standard ones is not able to handle regular DHCPv4 queries. .IP \(bu 2 \fB\-P client\-port\fP \- specifies the remote UDP port to which the server sends all responses. This is only useful during testing, as a DHCPv4 server sending responses to ports other than the standard ones is not able to handle regular DHCPv4 queries. .IP \(bu 2 \fB\-t file\fP \- specifies a configuration file to be tested. \fI\%kea\-dhcp4\fP loads it, checks it, and exits. During the test, log messages are printed to standard output and error messages to standard error. The result of the test is reported through the exit code (0 = configuration looks OK, 1 = error encountered). The check is not comprehensive; certain checks are possible only when running the server. .IP \(bu 2 \fB\-T file\fP \- specifies a configuration file to be tested. \fI\%kea\-dhcp4\fP loads it, checks it, and exits. It performs extra checks beyond what \fB\-t\fP offers, such as establishing database connections (for the lease backend, host reservations backend, configuration backend, and forensic logging backend), loading hook libraries, parsing hook\-library configurations, etc. It does not open UNIX or TCP/UDP sockets, nor does it open or rotate files, as any of these actions could interfere with a running process on the same machine. .IP \(bu 2 \fB\-v\fP \- displays the Kea version and exits. .IP \(bu 2 \fB\-V\fP \- displays the Kea extended version with additional parameters and exits. The listing includes the versions of the libraries dynamically linked to Kea. .IP \(bu 2 \fB\-W\fP \- displays the Kea configuration report and exits. The report is a copy of the \fBconfig.report\fP file produced by \fBmeson setup\fP; it is embedded in the executable binary. .sp The contents of the \fBconfig.report\fP file may also be accessed by examining certain libraries in the installation tree or in the source tree. .INDENT 2.0 .INDENT 3.5 .sp .EX # from installation using libkea\-process.so $ strings ${prefix}/lib/libkea\-process.so | sed \-n \(aqs/;;;; //p\(aq # from sources using libkea\-process.so $ strings src/lib/process/.libs/libkea\-process.so | sed \-n \(aqs/;;;; //p\(aq # from sources using libkea\-process.a $ strings src/lib/process/.libs/libkea\-process.a | sed \-n \(aqs/;;;; //p\(aq # from sources using libcfgrpt.a $ strings src/lib/process/cfgrpt/.libs/libcfgrpt.a | sed \-n \(aqs/;;;; //p\(aq .EE .UNINDENT .UNINDENT .IP \(bu 2 \fB\-X\fP \- As of Kea 3.0, disables path and permissions restrictions. The server will emit a warning at startup that sercurity restrictions have been disabled. Do not use this mode of operation without careful consideration and taking any necessary precautions. Failure to do so can expose deployments to security vulnerabilities. For more information please read section \fI\%Securing a Kea Deployment\fP\&. .UNINDENT .sp On startup, the server detects available network interfaces and attempts to open UDP sockets on all interfaces listed in the configuration file. Since the DHCPv4 server opens privileged ports, it requires root access; this daemon must be run as root. .sp During startup, the server attempts to create a PID file of the form: \fB[pidfile_dir]/[conf name].kea\-dhcp4.pid\fP where: .INDENT 0.0 .IP \(bu 2 \fBpidfile_dir\fP \- is \fB[prefix]/[localstatedir]/run/kea\fP where \fBprefix\fP and \fBlocalstatedir\fP are the values passed into meson setup using \fB\-\-prefix\fP and \fB\-\-localstatedir\fP which default to \fB/usr/local\fP and \fBvar\fP respectively. So the whole \fBpidfile_dir\fP defaults to \fB/usr/local/var\fP\&. Note that this value may be overridden at runtime by setting the environment variable \fBKEA_PIDFILE_DIR\fP intended primarily for testing purposes. .IP \(bu 2 \fBconf name\fP: The configuration file name used to start the server, minus all preceding paths and the file extension. For example, given a pathname of \fB/usr/local/etc/kea/myconf.txt\fP, the portion used would be \fBmyconf\fP\&. .UNINDENT .sp If the file already exists and contains the PID of a live process, the server issues a \fBDHCP4_ALREADY_RUNNING\fP log message and exits. It is possible, though unlikely, that the file is a remnant of a system crash and the process to which the PID belongs is unrelated to Kea. In such a case, it would be necessary to manually delete the PID file. .sp The server can be stopped using the \fBkill\fP command. When running in a console, the server can also be shut down by pressing Ctrl\-c. Kea detects the key combination and shuts down gracefully. .sp The reconfiguration of each Kea server is triggered by the SIGHUP signal. When a server receives the SIGHUP signal it rereads its configuration file and, if the new configuration is valid, uses the new configuration. If the new configuration proves to be invalid, the server retains its current configuration; however, in some cases a fatal error message is logged indicating that the server is no longer providing any service: a working configuration must be loaded as soon as possible. .SS DHCPv4 Server Configuration .SS Introduction .sp This section explains how to configure the Kea DHCPv4 server using a configuration file. .sp Before DHCPv4 is started, its configuration file must be created. The basic configuration is as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX { # DHCPv4 configuration starts on the next line \(dqDhcp4\(dq: { # First we set up global values \(dqvalid\-lifetime\(dq: 4000, \(dqrenew\-timer\(dq: 1000, \(dqrebind\-timer\(dq: 2000, # Next we set up the interfaces to be used by the server. \(dqinterfaces\-config\(dq: { \(dqinterfaces\(dq: [ \(dqeth0\(dq ] }, # And we specify the type of lease database \(dqlease\-database\(dq: { \(dqtype\(dq: \(dqmemfile\(dq, \(dqpersist\(dq: true, \(dqname\(dq: \(dq/var/lib/kea/dhcp4.leases\(dq }, # Finally, we list the subnets from which we will be leasing addresses. \(dqsubnet4\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.2.1 \- 192.0.2.200\(dq } ] } ] # DHCPv4 configuration ends with the next line } } .EE .UNINDENT .UNINDENT .sp The following paragraphs provide a brief overview of the parameters in the above example, along with their format. Subsequent sections of this chapter go into much greater detail for these and other parameters. .sp The lines starting with a hash (#) are comments and are ignored by the server; they do not impact its operation in any way. .sp The configuration starts in the first line with the initial opening curly bracket (or brace). Each configuration must contain an object specifying the configuration of the Kea module using it. In the example above, this object is called \fBDhcp4\fP\&. .sp The \fBDhcp4\fP configuration starts with the \fB\(dqDhcp4\(dq: {\fP line and ends with the corresponding closing brace (in the above example, the brace after the last comment). Everything defined between those lines is considered to be the \fBDhcp4\fP configuration. .sp In general, the order in which those parameters appear does not matter, but there are two caveats. The first one is that the configuration file must be well\-formed JSON, meaning that the parameters for any given scope must be separated by a comma, and there must not be a comma after the last parameter. When reordering a configuration file, moving a parameter to or from the last position in a given scope may also require moving the comma. The second caveat is that it is uncommon — although legal JSON — to repeat the same parameter multiple times. If that happens, the last occurrence of a given parameter in a given scope is used, while all previous instances are ignored. This is unlikely to cause any confusion as there are no real\-life reasons to keep multiple copies of the same parameter in the configuration file. .sp The first few DHCPv4 configuration elements define some global parameters. \fBvalid\-lifetime\fP defines how long the addresses (leases) given out by the server are valid; the default is for a client to be allowed to use a given address for 4000 seconds. (Note that integer numbers are specified as is, without any quotes around them.) \fBrenew\-timer\fP and \fBrebind\-timer\fP are values (also in seconds) that define the T1 and T2 timers that govern when the client begins the renewal and rebind processes. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The lease valid lifetime is expressed as a triplet with minimum, default, and maximum values using configuration entries \fBmin\-valid\-lifetime\fP, \fBvalid\-lifetime\fP, and \fBmax\-valid\-lifetime\fP\&. Since Kea 1.9.5, these values may be specified in client classes. The procedure the server uses to select which lifetime value to use is as follows: .sp If the client query is a BOOTP query, the server always uses the infinite lease time (e.g. 0xffffffff). Otherwise, the server must determine which configured triplet to use by first searching all classes assigned to the query, and then the subnet selected for the query. .sp Classes are searched in the order they were assigned to the query; the server uses the triplet from the first class that specifies it. If no classes specify the triplet, the server uses the triplet specified by the subnet selected for the client. If the subnet does not explicitly specify it, the server next looks at the subnet\(aqs shared\-network (if one exists), then for a global specification, and finally the global default. .sp If the client requested a lifetime value via DHCP option 51, then the lifetime value used is the requested value bounded by the configured triplet. In other words, if the requested lifetime is less than the configured minimum, the configured minimum is used; if it is more than the configured maximum, the configured maximum is used. If the client did not provide a requested value, the lifetime value used is the triplet default value. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Both \fBrenew\-timer\fP and \fBrebind\-timer\fP are optional. The server only sends \fBrebind\-timer\fP to the client, via DHCPv4 option code 59, if it is less than \fBvalid\-lifetime\fP; and it only sends \fBrenew\-timer\fP, via DHCPv4 option code 58, if it is less than \fBrebind\-timer\fP (or \fBvalid\-lifetime\fP if \fBrebind\-timer\fP was not specified). In their absence, the client should select values for T1 and T2 timers according to \X'tty: link https://tools.ietf.org/html/rfc2131'\fI\%RFC 2131\fP\X'tty: link'\&. See section \fI\%Sending T1 (Option 58) and T2 (Option 59)\fP for more details on generating T1 and T2. .UNINDENT .UNINDENT .sp The \fBinterfaces\-config\fP map specifies the network interfaces on which the server should listen to DHCP messages. The \fBinterfaces\fP parameter specifies a list of network interfaces on which the server should listen. Lists are opened and closed with square brackets, with elements separated by commas. To listen on two interfaces, the \fBinterfaces\-config\fP element should look like this: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqinterfaces\-config\(dq: { \(dqinterfaces\(dq: [ \(dqeth0\(dq, \(dqeth1\(dq ] }, \&... } .EE .UNINDENT .UNINDENT .sp The next lines define the lease database, the place where the server stores its lease information. This particular example tells the server to use memfile, which is the simplest and fastest database backend. It uses an in\-memory database and stores leases on disk in a CSV (comma\-separated values) file. This is a very simple configuration example; usually the lease database configuration is more extensive and contains additional parameters. Note that \fBlease\-database\fP is an object and opens up a new scope, using an opening brace. Its parameters (just one in this example: \fBtype\fP) follow. If there were more than one, they would be separated by commas. This scope is closed with a closing brace. As more parameters for the \fBDhcp4\fP definition follow, a trailing comma is present. .sp Finally, we need to define a list of IPv4 subnets. This is the most important DHCPv4 configuration structure, as the server uses that information to process clients\(aq requests. It defines all subnets from which the server is expected to receive DHCP requests. The subnets are specified with the \fBsubnet4\fP parameter. It is a list, so it starts and ends with square brackets. Each subnet definition in the list has several attributes associated with it, so it is a structure and is opened and closed with braces. At a minimum, a subnet definition must have at least two parameters: \fBsubnet\fP, which defines the whole subnet; and \fBpools\fP, which is a list of dynamically allocated pools that are governed by the DHCP server. .sp The example contains a single subnet. If more than one were defined, additional elements in the \fBsubnet4\fP parameter would be specified and separated by commas. For example, to define three subnets, the following syntax would be used: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqsubnet4\(dq: [ { \(dqid\(dq: 1, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.2.1 \- 192.0.2.200\(dq } ], \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq }, { \(dqid\(dq: 2, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.3.100 \- 192.0.3.200\(dq } ], \(dqsubnet\(dq: \(dq192.0.3.0/24\(dq }, { \(dqid\(dq: 3, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.4.1 \- 192.0.4.254\(dq } ], \(dqsubnet\(dq: \(dq192.0.4.0/24\(dq } ], \&... } .EE .UNINDENT .UNINDENT .sp Note that indentation is optional and is used for aesthetic purposes only. In some cases it may be preferable to use more compact notation. .sp After all the parameters have been specified, there are two contexts open: \fBglobal\fP and \fBDhcp4\fP; thus, two closing curly brackets must be used to close them. .SS Lease Storage .sp All leases issued by the server are stored in the lease database. There are three database backends available: memfile (the default), MySQL, PostgreSQL. .SS Memfile \- Basic Storage for Leases .sp The server is able to store lease data in different repositories. Larger deployments may elect to store leases in a database; \fI\%Lease Database Configuration\fP describes this option. In typical smaller deployments, though, the server stores lease information in a CSV file rather than a database. As well as requiring less administration, an advantage of using a file for storage is that it eliminates a dependency on third\-party database software. .sp The configuration of the memfile backend is controlled through the \fBDhcp4\fP/\fBlease\-database\fP parameters. The \fBtype\fP parameter is mandatory and specifies which storage for leases the server should use, through the \fB\(dqmemfile\(dq\fP value. The following list gives additional optional parameters that can be used to configure the memfile backend. .INDENT 0.0 .IP \(bu 2 \fBpersist\fP: controls whether the new leases and updates to existing leases are written to the file. It is strongly recommended that the value of this parameter be set to \fBtrue\fP at all times during the server\(aqs normal operation. Not writing leases to disk means that if a server is restarted (e.g. after a power failure), it will not know which addresses have been assigned. As a result, it may assign new clients addresses that are already in use. The value of \fBfalse\fP is mostly useful for performance\-testing purposes. The default value of the \fBpersist\fP parameter is \fBtrue\fP, which enables writing lease updates to the lease file. .IP \(bu 2 \fBname\fP: specifies the lease file in which new leases and lease updates are recorded. The default value for this parameter is \fB\(dq[kea\-install\-dir]/var/lib/kea/kea\-leases4.csv\(dq\fP\&. .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 As of Kea 2.7.9, lease files may only be loaded from the data directory determined during compilation: \fB\(dq[kea\-install\-dir]/var/lib/kea\(dq\fP\&. This path may be overridden at startup by setting the environment variable \fBKEA_DHCP_DATA_DIR\fP to the desired path. If a path other than this value is used in \fBname\fP, Kea will emit an error and refuse to start or, if already running, log an unrecoverable error. For ease of use in specifying a custom file name simply omit the path component from \fBname\fP\&. .UNINDENT .UNINDENT .INDENT 0.0 .IP \(bu 2 \fBlfc\-interval\fP: specifies the interval, in seconds, at which the server will perform a lease file cleanup (LFC). This removes redundant (historical) information from the lease file and effectively reduces the lease file size. The cleanup process is described in more detail later in this section. The default value of the \fBlfc\-interval\fP is \fB3600\fP\&. A value of \fB0\fP disables the LFC. .IP \(bu 2 \fBmax\-row\-errors\fP: specifies the number of row errors before the server stops attempting to load a lease file. When the server loads a lease file, it is processed row by row, each row containing a single lease. If a row is flawed and cannot be processed correctly the server logs it, discards the row, and goes on to the next row. This parameter can be used to set a limit on the number of such discards that can occur, after which the server abandons the effort and exits. The default value of \fB0\fP disables the limit and allows the server to process the entire file, regardless of how many rows are discarded. .UNINDENT .sp An example configuration of the memfile backend is presented below: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqlease\-database\(dq: { \(dqtype\(dq: \(dqmemfile\(dq, \(dqpersist\(dq: true, \(dqname\(dq: \(dqkea\-leases4.csv\(dq, \(dqlfc\-interval\(dq: 1800, \(dqmax\-row\-errors\(dq: 100 } } .EE .UNINDENT .UNINDENT .sp This configuration selects \fBkea\-leases4.csv\fP as the storage for lease information and enables persistence (writing lease updates to this file). It also configures the backend to perform a periodic cleanup of the lease file every 1800 seconds (30 minutes) and sets the maximum number of row errors to 100. .SS Why Is Lease File Cleanup Necessary? .sp It is important to know how the lease file contents are organized to understand why the periodic lease file cleanup is needed. Every time the server updates a lease or creates a new lease for a client, the new lease information must be recorded in the lease file. For performance reasons, the server does not update the existing client\(aqs lease in the file, as this would potentially require rewriting the entire file. Instead, it simply appends the new lease information to the end of the file; the previous lease entries for the client are not removed. When the server loads leases from the lease file, e.g. at server startup, it assumes that the latest lease entry for the client is the valid one. Previous entries are discarded, meaning that the server can reconstruct accurate information about the leases even though there may be many lease entries for each client. However, storing many entries for each client results in a bloated lease file and impairs the performance of the server\(aqs startup and reconfiguration, as it needs to process a larger number of lease entries. .sp Lease file cleanup (LFC) removes all previous entries for each client and leaves only the latest ones. The interval at which the cleanup is performed is configurable, and it should be selected according to the frequency of lease renewals initiated by the clients. The more frequent the renewals, the smaller the value of \fBlfc\-interval\fP should be. Note, however, that the LFC takes time and thus it is possible (although unlikely) that, if the \fBlfc\-interval\fP is too short, a new cleanup may be started while the previous one is still running. The server would recover from this by skipping the new cleanup when it detected that the previous cleanup was still in progress, but it implies that the actual cleanups will be triggered more rarely than the configured interval. Moreover, triggering a new cleanup adds overhead to the server, which is not able to respond to new requests for a short period of time when the new cleanup process is spawned. Therefore, it is recommended that the \fBlfc\-interval\fP value be selected in a way that allows the LFC to complete the cleanup before a new cleanup is triggered. .sp Lease file cleanup is performed by a separate process (in the background) to avoid a performance impact on the server process. To avoid conflicts between two processes using the same lease files, the LFC process starts with Kea opening a new lease file; the actual LFC process operates on the lease file that is no longer used by the server. There are also other files created as a side effect of the lease file cleanup. The detailed description of the LFC process is located later in this Kea Administrator\(aqs Reference Manual: \fI\%The LFC Process\fP\&. .SS Lease Database Configuration .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Lease database access information must be configured for the DHCPv4 server, even if it has already been configured for the DHCPv6 server. The servers store their information independently, so each server can use a separate database or both servers can use the same database. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Kea requires the database timezone to match the system timezone. For more details, see \fI\%First\-Time Creation of the MySQL Database\fP and \fI\%First\-Time Creation of the PostgreSQL Database\fP\&. .UNINDENT .UNINDENT .sp Lease database configuration is controlled through the \fBDhcp4\fP/\fBlease\-database\fP parameters. The database type must be set to \fBmemfile\fP, \fBmysql\fP or \fBpostgresql\fP, e.g.: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqlease\-database\(dq: { \(dqtype\(dq: \(dqmysql\(dq, ... }, ... } .EE .UNINDENT .UNINDENT .sp Next, the name of the database to hold the leases must be set; this is the name used when the database was created (see \fI\%First\-Time Creation of the MySQL Database\fP or \fI\%First\-Time Creation of the PostgreSQL Database\fP). .sp For MySQL or PostgreSQL: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqlease\-database\(dq: { \(dqname\(dq: \(dqdatabase\-name\(dq , ... }, ... } .EE .UNINDENT .UNINDENT .sp If the database is located on a different system from the DHCPv4 server, the database host name must also be specified: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqlease\-database\(dq: { \(dqhost\(dq: \(dqremote\-host\-name\(dq, ... }, ... } .EE .UNINDENT .UNINDENT .sp Normally, the database is on the same machine as the DHCPv4 server. In this case, set the value to the empty string: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqlease\-database\(dq: { \(dqhost\(dq : \(dq\(dq, ... }, ... } .EE .UNINDENT .UNINDENT .sp Should the database use a port other than the default, it may be specified as well: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqlease\-database\(dq: { \(dqport\(dq : 12345, ... }, ... } .EE .UNINDENT .UNINDENT .sp Should the database be located on a different system, the administrator may need to specify a longer interval for the connection timeout: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqlease\-database\(dq: { \(dqconnect\-timeout\(dq : timeout\-in\-seconds, ... }, ... } .EE .UNINDENT .UNINDENT .sp The default value of five seconds should be more than adequate for local connections. If a timeout is given, though, it should be an integer greater than zero. .sp The maximum number of times the server automatically attempts to reconnect to the lease database after connectivity has been lost may be specified: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqlease\-database\(dq: { \(dqmax\-reconnect\-tries\(dq : number\-of\-tries, ... }, ... } .EE .UNINDENT .UNINDENT .sp If the server is unable to reconnect to the database after making the maximum number of attempts, the server will exit. A value of 0 (the default) disables automatic recovery and the server will exit immediately upon detecting a loss of connectivity (MySQL and PostgreSQL only). .sp The number of milliseconds the server waits between attempts to reconnect to the lease database after connectivity has been lost may also be specified: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqlease\-database\(dq: { \(dqreconnect\-wait\-time\(dq : number\-of\-milliseconds, ... }, ... } .EE .UNINDENT .UNINDENT .sp The default value for MySQL and PostgreSQL is 0, which disables automatic recovery and causes the server to exit immediately upon detecting the loss of connectivity. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqlease\-database\(dq: { \(dqon\-fail\(dq : \(dqstop\-retry\-exit\(dq, ... }, ... } .EE .UNINDENT .UNINDENT .sp The possible values are: .INDENT 0.0 .IP \(bu 2 \fBstop\-retry\-exit\fP \- disables the DHCP service while trying to automatically recover lost connections, and shuts down the server on failure after exhausting \fBmax\-reconnect\-tries\fP\&. This is the default value for the lease backend, the host backend, and the configuration backend. .IP \(bu 2 \fBserve\-retry\-exit\fP \- continues the DHCP service while trying to automatically recover lost connections, and shuts down the server on failure after exhausting \fBmax\-reconnect\-tries\fP\&. .IP \(bu 2 \fBserve\-retry\-continue\fP \- continues the DHCP service and does not shut down the server even if the recovery fails. This is the default value for forensic logging. .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Automatic reconnection to database backends is configured individually per backend; this allows users to tailor the recovery parameters to each backend they use. We suggest that users enable it either for all backends or none, so behavior is consistent. .sp Losing connectivity to a backend for which reconnection is disabled results (if configured) in the server shutting itself down. This includes cases when the lease database backend and the hosts database backend are connected to the same database instance. .sp It is highly recommended not to change the \fBstop\-retry\-exit\fP default setting for the lease manager, as it is critical for the connection to be active while processing DHCP traffic. Change this only if the server is used exclusively as a configuration tool. .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqlease\-database\(dq: { \(dqretry\-on\-startup\(dq : true, ... }, ... } .EE .UNINDENT .UNINDENT .sp During server startup, the inability to connect to any of the configured backends is considered fatal only if \fBretry\-on\-startup\fP is set to \fBfalse\fP (the default). A fatal error is logged and the server exits, based on the idea that the configuration should be valid at startup. Exiting to the operating system allows nanny scripts to detect the problem. If \fBretry\-on\-startup\fP is set to \fBtrue\fP, the server starts reconnection attempts even at server startup or on reconfigure events, and honors the action specified in the \fBon\-fail\fP parameter. .sp The host parameter is used by the MySQL and PostgreSQL backends. .sp Finally, the credentials of the account under which the server will access the database should be set: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqlease\-database\(dq: { \(dquser\(dq: \(dquser\-name\(dq, \(dqpassword\(dq: \(dq1234\(dq, ... }, ... } .EE .UNINDENT .UNINDENT .sp If there is no password to the account, set the password to the empty string \fB\(dq\(dq\fP\&. (This is the default.) .SS Tuning Database Timeouts .sp In rare cases, reading or writing to the database may hang. This can be caused by a temporary network issue, or by misconfiguration of the proxy server switching the connection between different database instances. These situations are rare, but users have reported that Kea sometimes hangs while performing database IO operations. Setting appropriate timeout values can mitigate such issues. .sp MySQL exposes two distinct connection options to configure the read and write timeouts. Kea\(aqs corresponding \fBread\-timeout\fP and \fBwrite\-timeout\fP configuration parameters specify the timeouts in seconds. For example: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqlease\-database\(dq: { \(dqread\-timeout\(dq : 10, \(dqwrite\-timeout\(dq: 20, ... }, ... } .EE .UNINDENT .UNINDENT .sp Setting these parameters to 0 is equivalent to not specifying them, and causes the Kea server to establish a connection to the database with the MySQL defaults. In this case, Kea waits indefinitely for the completion of the read and write operations. .sp MySQL versions earlier than 5.6 do not support setting timeouts for read and write operations. Moreover, the \fBread\-timeout\fP and \fBwrite\-timeout\fP parameters can only be specified for the MySQL backend; setting them for any other backend database type causes a configuration error. .sp To set a timeout in seconds for PostgreSQL, use the \fBtcp\-user\-timeout\fP parameter. For example: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqlease\-database\(dq: { \(dqtcp\-user\-timeout\(dq : 10, ... }, ... } .EE .UNINDENT .UNINDENT .sp Specifying this parameter for other backend types causes a configuration error. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The timeouts described here are only effective for TCP connections. Please note that the MySQL client library used by the Kea servers typically connects to the database via a UNIX domain socket when the \fBhost\fP parameter is \fBlocalhost\fP, but establishes a TCP connection for \fB127.0.0.1\fP\&. .UNINDENT .UNINDENT .sp Since Kea.2.7.4, the libdhcp_mysql.so hook library must be loaded in order to store leases in the MySQL Lease Database Backend. Specify the lease backend hook library location: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqhooks\-libraries\(dq: [ { // the MySQL lease backend hook library required for lease storage. \(dqlibrary\(dq: \(dq/opt/lib/kea/hooks/libdhcp_mysql.so\(dq }, ... ], ... } .EE .UNINDENT .UNINDENT .sp Since Kea.2.7.4, the libdhcp_pgsql.so hook library must be loaded in order to store leases in the PostgreSQL Lease Database Backend. Specify the lease backend hook library location. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqhooks\-libraries\(dq: [ { // the PostgreSQL lease backend hook library required for lease storage. \(dqlibrary\(dq: \(dq/opt/lib/kea/hooks/libdhcp_pgsql.so\(dq }, ... ], ... } .EE .UNINDENT .UNINDENT .SS Hosts Storage .sp Kea is also able to store information about host reservations in the database. The hosts database configuration uses the same syntax as the lease database. In fact, the Kea server opens independent connections for each purpose, be it lease or hosts information, which gives the most flexibility. Kea can keep leases and host reservations separately, but can also point to the same database. Currently the supported hosts database types are MySQL and PostgreSQL. .sp The following configuration can be used to configure a connection to MySQL: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqhosts\-database\(dq: { \(dqtype\(dq: \(dqmysql\(dq, \(dqname\(dq: \(dqkea\(dq, \(dquser\(dq: \(dqkea\(dq, \(dqpassword\(dq: \(dq1234\(dq, \(dqhost\(dq: \(dqlocalhost\(dq, \(dqport\(dq: 3306 } } .EE .UNINDENT .UNINDENT .sp Depending on the database configuration, many of the parameters may be optional. .sp Please note that usage of hosts storage is optional. A user can define all host reservations in the configuration file, and that is the recommended way if the number of reservations is small. However, when the number of reservations grows, it is more convenient to use host storage. Please note that both storage methods (the configuration file and one of the supported databases) can be used together. If hosts are defined in both places, the definitions from the configuration file are checked first and external storage is checked later, if necessary. .sp Host information can be placed in multiple stores. Operations are performed on the stores in the order they are defined in the configuration file, although this leads to a restriction in ordering in the case of a host reservation addition; read\-only stores must be configured after a (required) read\-write store, or the addition will fail. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Kea requires the database timezone to match the system timezone. For more details, see \fI\%First\-Time Creation of the MySQL Database\fP and \fI\%First\-Time Creation of the PostgreSQL Database\fP\&. .UNINDENT .UNINDENT .SS DHCPv4 Hosts Database Configuration .sp Hosts database configuration is controlled through the \fBDhcp4\fP/\fBhosts\-database\fP parameters. If enabled, the type of database must be set to \fBmysql\fP or \fBpostgresql\fP\&. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqhosts\-database\(dq: { \(dqtype\(dq: \(dqmysql\(dq, ... }, ... } .EE .UNINDENT .UNINDENT .sp Next, the name of the database to hold the reservations must be set; this is the name used when the lease database was created (see \fI\%Supported Backends\fP for instructions on how to set up the desired database type): .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqhosts\-database\(dq: { \(dqname\(dq: \(dqdatabase\-name\(dq , ... }, ... } .EE .UNINDENT .UNINDENT .sp If the database is located on a different system than the DHCPv4 server, the database host name must also be specified: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqhosts\-database\(dq: { \(dqhost\(dq: remote\-host\-name, ... }, ... } .EE .UNINDENT .UNINDENT .sp Normally, the database is on the same machine as the DHCPv4 server. In this case, set the value to the empty string: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqhosts\-database\(dq: { \(dqhost\(dq : \(dq\(dq, ... }, ... } .EE .UNINDENT .UNINDENT .sp Should the database use a port different than the default, it may be specified as well: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqhosts\-database\(dq: { \(dqport\(dq : 12345, ... }, ... } .EE .UNINDENT .UNINDENT .sp The maximum number of times the server automatically attempts to reconnect to the host database after connectivity has been lost may be specified: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqhosts\-database\(dq: { \(dqmax\-reconnect\-tries\(dq : number\-of\-tries, ... }, ... } .EE .UNINDENT .UNINDENT .sp If the server is unable to reconnect to the database after making the maximum number of attempts, the server will exit. A value of 0 (the default) disables automatic recovery and the server will exit immediately upon detecting a loss of connectivity (MySQL and PostgreSQL only). .sp The number of milliseconds the server waits between attempts to reconnect to the host database after connectivity has been lost may also be specified: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqhosts\-database\(dq: { \(dqreconnect\-wait\-time\(dq : number\-of\-milliseconds, ... }, ... } .EE .UNINDENT .UNINDENT .sp The default value for MySQL and PostgreSQL is 0, which disables automatic recovery and causes the server to exit immediately upon detecting the loss of connectivity. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqhosts\-database\(dq: { \(dqon\-fail\(dq : \(dqstop\-retry\-exit\(dq, ... }, ... } .EE .UNINDENT .UNINDENT .sp The possible values are: .INDENT 0.0 .IP \(bu 2 \fBstop\-retry\-exit\fP \- disables the DHCP service while trying to automatically recover lost connections. Shuts down the server on failure after exhausting \fBmax\-reconnect\-tries\fP\&. This is the default value for MySQL and PostgreSQL. .IP \(bu 2 \fBserve\-retry\-exit\fP \- continues the DHCP service while trying to automatically recover lost connections. Shuts down the server on failure after exhausting \fBmax\-reconnect\-tries\fP\&. .IP \(bu 2 \fBserve\-retry\-continue\fP \- continues the DHCP service and does not shut down the server even if the recovery fails. .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Automatic reconnection to database backends is configured individually per backend. This allows users to tailor the recovery parameters to each backend they use. We suggest that users enable it either for all backends or none, so behavior is consistent. .sp Losing connectivity to a backend for which reconnection is disabled results (if configured) in the server shutting itself down. This includes cases when the lease database backend and the hosts database backend are connected to the same database instance. .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqhosts\-database\(dq: { \(dqretry\-on\-startup\(dq : true, ... }, ... } .EE .UNINDENT .UNINDENT .sp During server startup, the inability to connect to any of the configured backends is considered fatal only if \fBretry\-on\-startup\fP is set to \fBfalse\fP (the default). A fatal error is logged and the server exits, based on the idea that the configuration should be valid at startup. Exiting to the operating system allows nanny scripts to detect the problem. If \fBretry\-on\-startup\fP is set to \fBtrue\fP, the server starts reconnection attempts even at server startup or on reconfigure events, and honors the action specified in the \fBon\-fail\fP parameter. .sp Finally, the credentials of the account under which the server will access the database should be set: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqhosts\-database\(dq: { \(dquser\(dq: \(dquser\-name\(dq, \(dqpassword\(dq: \(dq1234\(dq, ... }, ... } .EE .UNINDENT .UNINDENT .sp If there is no password to the account, set the password to the empty string \fB\(dq\(dq\fP\&. (This is the default.) .sp The multiple\-storage extension uses a similar syntax; a configuration is placed into a \fBhosts\-databases\fP list instead of into a \fBhosts\-database\fP entry, as in: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqhosts\-databases\(dq: [ { \(dqtype\(dq: \(dqmysql\(dq, ... }, ... ], ... } .EE .UNINDENT .UNINDENT .sp If the same host is configured both in\-file and in\-database, Kea does not issue a warning, as it would if both were specified in the same data source. Instead, the host configured in\-file has priority over the one configured in\-database. .SS Using Read\-Only Databases for Host Reservations With DHCPv4 .sp In some deployments, the user whose name is specified in the database backend configuration may not have write privileges to the database. This is often required by the policy within a given network to secure the data from being unintentionally modified. In many cases administrators have deployed inventory databases, which contain substantially more information about the hosts than just the static reservations assigned to them. The inventory database can be used to create a view of a Kea hosts database and such a view is often read\-only. .sp Kea host\-database backends operate with an implicit configuration to both read from and write to the database. If the user does not have write access to the host database, the backend will fail to start and the server will refuse to start (or reconfigure). However, if access to a read\-only host database is required for retrieving reservations for clients and/or assigning specific addresses and options, it is possible to explicitly configure Kea to start in \(dqread\-only\(dq mode. This is controlled by the \fBreadonly\fP boolean parameter as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqhosts\-database\(dq: { \(dqreadonly\(dq: true, ... }, ... } .EE .UNINDENT .UNINDENT .sp Setting this parameter to \fBfalse\fP configures the database backend to operate in \(dqread\-write\(dq mode, which is also the default configuration if the parameter is not specified. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The \fBreadonly\fP parameter is only supported for MySQL and PostgreSQL databases. .UNINDENT .UNINDENT .sp Since Kea.2.7.4, the libdhcp_mysql.so hook library must be loaded in order to store host reservations in the MySQL Host Database Backend. Specify the lease backend hook library location: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqhooks\-libraries\(dq: [ { // the MySQL host backend hook library required for host storage. \(dqlibrary\(dq: \(dq/opt/lib/kea/hooks/libdhcp_mysql.so\(dq }, ... ], ... } .EE .UNINDENT .UNINDENT .sp Since Kea.2.7.4, the libdhcp_pgsql.so hook library must be loaded in order to store host reservations in the PostgreSQL Host Database Backend. Specify the lease backend hook library location. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqhooks\-libraries\(dq: [ { // the PostgreSQL host backend hook library required for host storage. \(dqlibrary\(dq: \(dq/opt/lib/kea/hooks/libdhcp_pgsql.so\(dq }, ... ], ... } .EE .UNINDENT .UNINDENT .SS Tuning Database Timeouts for Hosts Storage .sp See \fI\%Tuning Database Timeouts\fP\&. .SS Interface Configuration .sp The DHCPv4 server must be configured to listen on specific network interfaces. The simplest network interface configuration tells the server to listen on all available interfaces: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqinterfaces\-config\(dq: { \(dqinterfaces\(dq: [ \(dq*\(dq ] }, ... } .EE .UNINDENT .UNINDENT .sp The asterisk plays the role of a wildcard and means \(dqlisten on all interfaces.\(dq However, it is usually a good idea to explicitly specify interface names: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqinterfaces\-config\(dq: { \(dqinterfaces\(dq: [ \(dqeth1\(dq, \(dqeth3\(dq ] }, ... } .EE .UNINDENT .UNINDENT .sp It is possible to use an interface wildcard (*) concurrently with explicit interface names: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqinterfaces\-config\(dq: { \(dqinterfaces\(dq: [ \(dqeth1\(dq, \(dqeth3\(dq, \(dq*\(dq ] }, ... } .EE .UNINDENT .UNINDENT .sp This format should only be used when it is desired to temporarily override a list of interface names and listen on all interfaces. .sp Some deployments of DHCP servers require that the servers listen on interfaces with multiple IPv4 addresses configured. In these situations, the address to use can be selected by appending an IPv4 address to the interface name in the following manner: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqinterfaces\-config\(dq: { \(dqinterfaces\(dq: [ \(dqeth1/10.0.0.1\(dq, \(dqeth3/192.0.2.3\(dq ] }, ... } .EE .UNINDENT .UNINDENT .sp Should the server be required to listen on multiple IPv4 addresses assigned to the same interface, multiple addresses can be specified for an interface as in the example below: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqinterfaces\-config\(dq: { \(dqinterfaces\(dq: [ \(dqeth1/10.0.0.1\(dq, \(dqeth1/10.0.0.2\(dq ] }, ... } .EE .UNINDENT .UNINDENT .sp Alternatively, if the server should listen on all addresses for the particular interface, an interface name without any address should be specified. .sp Kea supports responding to directly connected clients which do not have an address configured. This requires the server to inject the hardware address of the destination into the data\-link layer of the packet being sent to the client. The DHCPv4 server uses raw sockets to achieve this, and builds the entire IP/UDP stack for the outgoing packets. The downside of raw socket use, however, is that incoming and outgoing packets bypass the firewalls (e.g. iptables). .sp Handling traffic on multiple IPv4 addresses assigned to the same interface can be a challenge, as raw sockets are bound to the interface. When the DHCP server is configured to use the raw socket on an interface to receive DHCP traffic, advanced packet filtering techniques (e.g. the BPF) must be used to receive unicast traffic on the desired addresses assigned to the interface. Whether clients use the raw socket or the UDP socket depends on whether they are directly connected (raw socket) or relayed (either raw or UDP socket). .sp Therefore, in deployments where the server does not need to provision the directly connected clients and only receives the unicast packets from the relay agents, the Kea server should be configured to use UDP sockets instead of raw sockets. The following configuration demonstrates how this can be achieved: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqinterfaces\-config\(dq: { \(dqinterfaces\(dq: [ \(dqeth1\(dq, \(dqeth3\(dq ], \(dqdhcp\-socket\-type\(dq: \(dqudp\(dq }, ... } .EE .UNINDENT .UNINDENT .sp The \fBdhcp\-socket\-type\fP parameter specifies that the IP/UDP sockets will be opened on all interfaces on which the server listens, i.e. \(dqeth1\(dq and \(dqeth3\(dq in this example. If \fBdhcp\-socket\-type\fP is set to \fBraw\fP, it configures the server to use raw sockets instead. If the \fBdhcp\-socket\-type\fP value is not specified, the default value \fBraw\fP is used. .sp Using UDP sockets automatically disables the reception of broadcast packets from directly connected clients. This effectively means that UDP sockets can be used for relayed traffic only. When using raw sockets, both the traffic from the directly connected clients and the relayed traffic are handled. .sp Caution should be taken when configuring the server to open multiple raw sockets on the interface with several IPv4 addresses assigned. If the directly connected client sends the message to the broadcast address, all sockets on this link will receive this message and multiple responses will be sent to the client. Therefore, the configuration with multiple IPv4 addresses assigned to the interface should not be used when the directly connected clients are operating on that link. To use a single address on such an interface, the \(dqinterface\-name/address\(dq notation should be used. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Specifying the value \fBraw\fP as the socket type does not guarantee that raw sockets will be used! The use of raw sockets to handle traffic from the directly connected clients is currently supported on Linux and BSD systems only. If raw sockets are not supported on the particular OS in use, the server issues a warning and fall back to using IP/UDP sockets. .UNINDENT .UNINDENT .sp In a typical environment, the DHCP server is expected to send back a response on the same network interface on which the query was received. This is the default behavior. However, in some deployments it is desired that the outbound (response) packets be sent as regular traffic and the outbound interface be determined by the routing tables. This kind of asymmetric traffic is uncommon, but valid. Kea supports a parameter called \fBoutbound\-interface\fP that controls this behavior. It supports two values: the first one, \fBsame\-as\-inbound\fP, tells Kea to send back the response on the same interface where the query packet was received. This is the default behavior. The second parameter, \fBuse\-routing\fP, tells Kea to send regular UDP packets and let the kernel\(aqs routing table determine the most appropriate interface. This only works when \fBdhcp\-socket\-type\fP is set to \fBudp\fP\&. An example configuration looks as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqinterfaces\-config\(dq: { \(dqinterfaces\(dq: [ \(dqeth1\(dq, \(dqeth3\(dq ], \(dqdhcp\-socket\-type\(dq: \(dqudp\(dq, \(dqoutbound\-interface\(dq: \(dquse\-routing\(dq }, ... } .EE .UNINDENT .UNINDENT .sp Interfaces are re\-detected at each reconfiguration. This behavior can be disabled by setting the \fBre\-detect\fP value to \fBfalse\fP, for instance: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqinterfaces\-config\(dq: { \(dqinterfaces\(dq: [ \(dqeth1\(dq, \(dqeth3\(dq ], \(dqre\-detect\(dq: false }, ... } .EE .UNINDENT .UNINDENT .sp Note that interfaces are not re\-detected during \fI\%config\-test\fP\&. .sp Usually loopback interfaces (e.g. the \fBlo\fP or \fBlo0\fP interface) are not configured, but if a loopback interface is explicitly configured and IP/UDP sockets are specified, the loopback interface is accepted. .sp For example, this setup can be used to run Kea in a FreeBSD jail having only a loopback interface, to service a relayed DHCP request: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqinterfaces\-config\(dq: { \(dqinterfaces\(dq: [ \(dqlo0\(dq ], \(dqdhcp\-socket\-type\(dq: \(dqudp\(dq }, ... } .EE .UNINDENT .UNINDENT .sp Kea binds the service sockets for each interface on startup. If another process is already using a port, then Kea logs the message and suppresses an error. DHCP service runs, but it is unavailable on some interfaces. .sp The \(dqservice\-sockets\-require\-all\(dq option makes Kea require all sockets to be successfully bound. If any opening fails, Kea interrupts the initialization and exits with a non\-zero status. (Default is false). .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqinterfaces\-config\(dq: { \(dqinterfaces\(dq: [ \(dqeth1\(dq, \(dqeth3\(dq ], \(dqservice\-sockets\-require\-all\(dq: true }, ... } .EE .UNINDENT .UNINDENT .sp Sometimes, immediate interruption isn\(aqt a good choice. The port can be unavailable only temporary. In this case, retrying the opening may resolve the problem. Kea provides two options to specify the retrying: \fBservice\-sockets\-max\-retries\fP and \fBservice\-sockets\-retry\-wait\-time\fP\&. .sp The first defines a maximal number of retries that Kea makes to open a socket. The zero value (default) means that the Kea doesn\(aqt retry the process. .sp The second defines a wait time (in milliseconds) between attempts. The default value is 5000 (5 seconds). .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqinterfaces\-config\(dq: { \(dqinterfaces\(dq: [ \(dqeth1\(dq, \(dqeth3\(dq ], \(dqservice\-sockets\-max\-retries\(dq: 5, \(dqservice\-sockets\-retry\-wait\-time\(dq: 5000 }, ... } .EE .UNINDENT .UNINDENT .sp If \(dqservice\-sockets\-max\-retries\(dq is non\-zero and \(dqservice\-sockets\-require\-all\(dq is false, then Kea retries the opening (if needed) but does not fail if any socket is still not opened. .SS Issues With Unicast Responses to DHCPINFORM .sp The use of UDP sockets has certain benefits in deployments where the server receives only relayed traffic; these benefits are mentioned in \fI\%Interface Configuration\fP\&. From the administrator\(aqs perspective it is often desirable to configure the system\(aqs firewall to filter out unwanted traffic, and the use of UDP sockets facilitates this. However, the administrator must also be aware of the implications related to filtering certain types of traffic, as it may impair the DHCP server\(aqs operation. .sp In this section we focus on the case when the server receives the DHCPINFORM message from the client via a relay. According to \X'tty: link https://tools.ietf.org/html/rfc2131'\fI\%RFC 2131\fP\X'tty: link', the server should unicast the DHCPACK response to the address carried in the \fBciaddr\fP field. When the UDP socket is in use, the DHCP server relies on the low\-level functions of an operating system to build the data link, IP, and UDP layers of the outgoing message. Typically, the OS first uses ARP to obtain the client\(aqs link\-layer address to be inserted into the frame\(aqs header, if the address is not cached from a previous transaction that the client had with the server. When the ARP exchange is successful, the DHCP message can be unicast to the client, using the obtained address. .sp Some system administrators block ARP messages in their network, which causes issues for the server when it responds to the DHCPINFORM messages because the server is unable to send the DHCPACK if the preceding ARP communication fails. Since the OS is entirely responsible for the ARP communication and then sending the DHCP packet over the wire, the DHCP server has no means to determine that the ARP exchange failed and the DHCP response message was dropped. Thus, the server does not log any error messages when the outgoing DHCP response is dropped. At the same time, all hooks pertaining to the packet\-sending operation will be called, even though the message never reaches its destination. .sp Note that the issue described in this section is not observed when raw sockets are in use, because, in this case, the DHCP server builds all the layers of the outgoing message on its own and does not use ARP. Instead, it inserts the value carried in the \fBchaddr\fP field of the DHCPINFORM message into the link layer. .sp Server administrators willing to support DHCPINFORM messages via relays should not block ARP traffic in their networks, or should use raw sockets instead of UDP sockets. .SS IPv4 Subnet Identifier .sp The subnet identifier (subnet ID) is a unique number associated with a particular subnet. In principle, it is used to associate clients\(aq leases with their respective subnets. The server configuration must contain unique and stable identifiers for all subnets. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Subnet IDs must be greater than zero and less than 4294967295. .UNINDENT .UNINDENT .sp The following configuration assigns the specified subnet identifier to a newly configured subnet: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqsubnet4\(dq: [ { \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq, \(dqid\(dq: 1024, ... } ] } .EE .UNINDENT .UNINDENT .SS IPv4 Subnet Prefix .sp The subnet prefix is the second way to identify a subnet. Kea can accept non\-canonical subnet addresses; for instance, this configuration is accepted: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqsubnet4\(dq: [ { \(dqsubnet\(dq: \(dq192.0.2.1/24\(dq, ... } ] } .EE .UNINDENT .UNINDENT .sp This works even if there is another subnet with the \(dq192.0.2.0/24\(dq prefix; only the textual form of subnets are compared to avoid duplicates. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Abuse of this feature can lead to incorrect subnet selection (see \fI\%How the DHCPv4 Server Selects a Subnet for the Client\fP). .UNINDENT .UNINDENT .SS Configuration of IPv4 Address Pools .sp The main role of a DHCPv4 server is address assignment. For this, the server must be configured with at least one subnet and one pool of dynamic addresses to be managed. For example, assume that the server is connected to a network segment that uses the 192.0.2.0/24 prefix. The administrator of that network decides that addresses from the range 192.0.2.10 to 192.0.2.20 are going to be managed by the DHCPv4 server. Such a configuration can be achieved in the following way: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqsubnet4\(dq: [ { \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.2.10 \- 192.0.2.20\(dq } ], ... } ] } .EE .UNINDENT .UNINDENT .sp Note that \fBsubnet\fP is defined as a simple string, but the \fBpools\fP parameter is actually a list of pools; for this reason, the pool definition is enclosed in square brackets, even though only one range of addresses is specified. .sp Each \fBpool\fP is a structure that contains the parameters that describe a single pool. Currently there is only one parameter, \fBpool\fP, which gives the range of addresses in the pool. .sp It is possible to define more than one pool in a subnet; continuing the previous example, further assume that 192.0.2.64/26 should also be managed by the server. It could be written as 192.0.2.64 to 192.0.2.127, or it can be expressed more simply as 192.0.2.64/26. Both formats are supported by \fBDhcp4\fP and can be mixed in the pool list. For example, the following pools could be defined: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqsubnet4\(dq: [ { \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.2.10\-192.0.2.20\(dq }, { \(dqpool\(dq: \(dq192.0.2.64/26\(dq } ], ... } ], ... } .EE .UNINDENT .UNINDENT .sp White space in pool definitions is ignored, so spaces before and after the hyphen are optional. They can be used to improve readability. .sp The number of pools is not limited, but for performance reasons it is recommended to use as few as possible. .sp The server may be configured to serve more than one subnet. To add a second subnet, use a command similar to the following: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqsubnet4\(dq: [ { \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.2.1 \- 192.0.2.200\(dq } ], ... }, { \(dqsubnet\(dq: \(dq192.0.3.0/24\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.3.100 \- 192.0.3.200\(dq } ], ... }, { \(dqsubnet\(dq: \(dq192.0.4.0/24\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.4.1 \- 192.0.4.254\(dq } ], ... } ] } .EE .UNINDENT .UNINDENT .sp When configuring a DHCPv4 server using prefix/length notation, please pay attention to the boundary values. When specifying that the server can use a given pool, it is also able to allocate the first (typically a network address) and the last (typically a broadcast address) address from that pool. In the aforementioned example of pool 192.0.3.0/24, both the 192.0.3.0 and 192.0.3.255 addresses may be assigned as well. This may be invalid in some network configurations. To avoid this, use the \fBmin\-max\fP notation. .sp In a subnet whose prefix length is less than 24, users may wish to exclude all addresses ending in .0 and .255 from being dynamically allocated. For instance, in the subnet 10.0.0.0/8, an administrator may wish to exclude 10.x.y.0 and 10.x.y.255 for all values of x and y, even though only 10.0.0.0 and 10.255.255.255 must be excluded according to RFC standards. The \fBexclude\-first\-last\-24\fP configuration compatibility flag (\fI\%Kea DHCPv4 Compatibility Configuration Parameters\fP) does this automatically, rather than requiring explicit configuration of many pools or reservations for fake hosts. When \fBtrue\fP, it applies only to subnets of prefix length 24 or smaller, i.e. larger address space; the default is \fBfalse\fP\&. .sp In this case, \(dqexclude\(dq means to skip these addresses in the free address pickup routine of the allocation engine; if a client explicitly requests or has a host reservation for an address in .0 or .255, it will get it. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Here are some liberties and limits to the values that subnets and pools can take in unusual Kea configurations: .TS box center; l|l|l. T{ Kea configuration case T} T{ Allowed T} T{ Comment T} _ T{ Overlapping subnets T} T{ Yes T} T{ Administrator should consider how clients are matched to these subnets. T} _ T{ Overlapping pools in one subnet T} T{ No T} T{ Startup error: DHCP4_PARSER_FAIL T} _ T{ Overlapping address pools in different subnets T} T{ Yes T} T{ Specifying the same address pool in different subnets can be used as an equivalent of the global address pool. In that case, the server can assign addresses from the same range regardless of the client\(aqs subnet. If an address from such a pool is assigned to a client in one subnet, the same address will be renewed for this client if it moves to another subnet. Another client in a different subnet will not be assigned an address already assigned to the client in any of the subnets. T} _ T{ Pools not matching the subnet prefix T} T{ No T} T{ Startup error: DHCP4_PARSER_FAIL T} .TE .UNINDENT .UNINDENT .SS Sending T1 (Option 58) and T2 (Option 59) .sp According to \X'tty: link https://tools.ietf.org/html/rfc2131'\fI\%RFC 2131\fP\X'tty: link', servers should send values for T1 and T2 that are 50% and 87.5% of the lease lifetime, respectively. By default, \fI\%kea\-dhcp4\fP does not send either value; it can be configured to send values that are either specified explicitly or that are calculated as percentages of the lease time. The server\(aqs behavior is governed by a combination of configuration parameters, two of which have already been mentioned. To send specific, fixed values use the following two parameters: .INDENT 0.0 .IP \(bu 2 \fBrenew\-timer\fP \- specifies the value of T1 in seconds. .IP \(bu 2 \fBrebind\-timer\fP \- specifies the value of T2 in seconds. .UNINDENT .sp The server only sends T2 if it is less than the valid lease time. T1 is only sent if T2 is being sent and T1 is less than T2; or T2 is not being sent and T1 is less than the valid lease time. .sp Calculating the values is controlled by the following three parameters. .INDENT 0.0 .IP \(bu 2 \fBcalculate\-tee\-times\fP \- when true, T1 and T2 are calculated as percentages of the valid lease time. It defaults to false. .IP \(bu 2 \fBt1\-percent\fP \- the percentage of the valid lease time to use for T1. It is expressed as a real number between 0.0 and 1.0 and must be less than \fBt2\-percent\fP\&. The default value is 0.50, per RFC 2131. .IP \(bu 2 \fBt2\-percent\fP \- the percentage of the valid lease time to use for T2. It is expressed as a real number between 0.0 and 1.0 and must be greater than \fBt1\-percent\fP\&. The default value is .875, per RFC 2131. .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 In the event that both explicit values are specified and \fBcalculate\-tee\-times\fP is true, the server will use the explicit values. Administrators with a setup where some subnets or shared\-networks use explicit values and some use calculated values must not define the explicit values at any level higher than where they will be used. Inheriting them from too high a scope, such as global, will cause them to have explicit values at every level underneath (shared\-networks and subnets), effectively disabling calculated values. .UNINDENT .UNINDENT .SS Standard DHCPv4 Options .sp One of the major features of the DHCPv4 server is the ability to provide configuration options to clients. Most of the options are sent by the server only if the client explicitly requests them using the Parameter Request List option. Those that do not require inclusion in the Parameter Request List option are commonly used options, e.g. \(dqDomain Server\(dq, and options which require special behavior, e.g. \(dqClient FQDN\(dq, which is returned to the client if the client has included this option in its message to the server. .sp \fI\%List of standard DHCPv4 options configurable by an administrator\fP comprises the list of the standard DHCPv4 options whose values can be configured using the configuration structures described in this section. This table excludes the options which require special processing and thus cannot be configured with fixed values. The last column of the table indicates which options can be sent by the server even when they are not requested in the Parameter Request List option, and those which are sent only when explicitly requested. .sp The following example shows how to configure the addresses of DNS servers, which is one of the most frequently used options. Options specified in this way are considered global and apply to all configured subnets. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqdomain\-name\-servers\(dq, \(dqcode\(dq: 6, \(dqspace\(dq: \(dqdhcp4\(dq, \(dqcsv\-format\(dq: true, \(dqdata\(dq: \(dq192.0.2.1, 192.0.2.2\(dq }, ... ] } .EE .UNINDENT .UNINDENT .sp Note that either \fBname\fP or \fBcode\fP is required; there is no need to specify both. \fBspace\fP has a default value of \fBdhcp4\fP, so this can be skipped as well if a regular (not encapsulated) DHCPv4 option is defined. Finally, \fBcsv\-format\fP defaults to \fBtrue\fP, so it too can be skipped, unless the option value is specified as a hexadecimal string. Therefore, the above example can be simplified to: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqdomain\-name\-servers\(dq, \(dqdata\(dq: \(dq192.0.2.1, 192.0.2.2\(dq }, ... ] } .EE .UNINDENT .UNINDENT .sp Defined options are added to the response when the client requests them, with a few exceptions which are always added. To enforce the addition of a particular option, set the \fBalways\-send\fP flag to \fBtrue\fP as in: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqdomain\-name\-servers\(dq, \(dqdata\(dq: \(dq192.0.2.1, 192.0.2.2\(dq, \(dqalways\-send\(dq: true }, ... ] } .EE .UNINDENT .UNINDENT .sp The effect is the same as if the client added the option code in the Parameter Request List option (or its equivalent for vendor options): .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqdomain\-name\-servers\(dq, \(dqdata\(dq: \(dq192.0.2.1, 192.0.2.2\(dq, \(dqalways\-send\(dq: true }, ... ], \(dqsubnet4\(dq: [ { \(dqsubnet\(dq: \(dq192.0.3.0/24\(dq, \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqdomain\-name\-servers\(dq, \(dqdata\(dq: \(dq192.0.3.1, 192.0.3.2\(dq }, ... ], ... }, ... ], ... } .EE .UNINDENT .UNINDENT .sp In the example above, the \fBdomain\-name\-servers\fP option respects the global \fBalways\-send\fP flag and is always added to responses, but for subnet \fB192.0.3.0/24\fP, the value is taken from the subnet\-level option data specification. .sp Contrary to \fBalways\-send\fP, if the \fBnever\-send\fP flag is set to \fBtrue\fP for a particular option, the server does not add it to the response. The effect is the same as if the client removed the option code in the Parameter Request List option (or its equivalent for vendor options): .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqdomain\-name\-servers\(dq, \(dqdata\(dq: \(dq192.0.2.1, 192.0.2.2\(dq }, ... ], \(dqsubnet4\(dq: [ { \(dqsubnet\(dq: \(dq192.0.3.0/24\(dq, \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqdomain\-name\-servers\(dq, \(dqnever\-send\(dq: true }, ... ], ... }, ... ], ... } .EE .UNINDENT .UNINDENT .sp In the example above, the \fBdomain\-name\-servers\fP option is never added to responses on subnet \fB192.0.3.0/24\fP\&. \fBnever\-send\fP has precedence over \fBalways\-send\fP, so if both are \fBtrue\fP the option is not added. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The \fBalways\-send\fP and \fBnever\-send\fP flags are sticky, meaning they do not follow the usual configuration inheritance rules. Instead, if they are enabled at least once along the configuration inheritance chain, they are applied \- even if they are disabled in other places which would normally receive a higher priority. For instance, if one of the flags is enabled in the global scope, but disabled at the subnet level, it is enabled, disregarding the subnet\-level setting. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The \fBnever\-send\fP flag is less powerful than \fI\%libdhcp_flex_option.so\fP; for instance, it has no effect on options managed by the server itself. Both \fBalways\-send\fP and \fBnever\-send\fP have no effect on options which cannot be requested, for instance from a custom space. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Beginning with Kea 2.7.4, option inclusion can also be controlled through option class\-tagging, see \fI\%Option Class\-Tagging\fP .UNINDENT .UNINDENT .sp The \fBname\fP parameter specifies the option name. For a list of currently supported names, see \fI\%List of standard DHCPv4 options configurable by an administrator\fP below. The \fBcode\fP parameter specifies the option code, which must match one of the values from that list. The next line specifies the option space, which must always be set to \fBdhcp4\fP as these are standard DHCPv4 options. For other option spaces, including custom option spaces, see \fI\%Nested DHCPv4 Options (Custom Option Spaces)\fP\&. The next line specifies the format in which the data will be entered; use of CSV (comma\-separated values) is recommended. The sixth line gives the actual value to be sent to clients. The data parameter is specified as normal text, with values separated by commas if more than one value is allowed. .sp Options can also be configured as hexadecimal values. If \fBcsv\-format\fP is set to \fBfalse\fP, option data must be specified as a hexadecimal string. The following commands configure the \fBdomain\-name\-servers\fP option for all subnets with the following addresses: 192.0.3.1 and 192.0.3.2. Note that \fBcsv\-format\fP is set to \fBfalse\fP\&. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqdomain\-name\-servers\(dq, \(dqcode\(dq: 6, \(dqspace\(dq: \(dqdhcp4\(dq, \(dqcsv\-format\(dq: false, \(dqdata\(dq: \(dqC0 00 03 01 C0 00 03 02\(dq }, ... ], ... } .EE .UNINDENT .UNINDENT .sp Kea supports the following formats when specifying hexadecimal data: .INDENT 0.0 .IP \(bu 2 \fBDelimited octets\fP \- one or more octets separated by either colons or spaces (\(dq:\(dq or \(dq \(dq). While each octet may contain one or two digits, we strongly recommend always using two digits. Valid examples are \(dqab:cd:ef\(dq and \(dqab cd ef\(dq. .IP \(bu 2 \fBString of digits\fP \- a continuous string of hexadecimal digits with or without a \(dq0x\(dq prefix. Valid examples are \(dq0xabcdef\(dq and \(dqabcdef\(dq. .UNINDENT .sp Care should be taken to use proper encoding when using hexadecimal format; Kea\(aqs ability to validate data correctness in hexadecimal is limited. .sp It is also possible to specify data for binary options as a single\-quoted text string within double quotes as shown (note that \fBcsv\-format\fP must be set to \fBfalse\fP): .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dquser\-class\(dq, \(dqcode\(dq: 77, \(dqspace\(dq: \(dqdhcp4\(dq, \(dqcsv\-format\(dq: false, \(dqdata\(dq: \(dq\(aqconvert this text to binary\(aq\(dq }, ... ], ... } .EE .UNINDENT .UNINDENT .sp Most of the parameters in the \fBoption\-data\fP structure are optional and can be omitted in some circumstances, as discussed in \fI\%Unspecified Parameters for DHCPv4 Option Configuration\fP\&. .sp It is possible to specify or override options on a per\-subnet basis. If clients connected to most subnets are expected to get the same values of a given option, administrators should use global options. On the other hand, if different values are used in each subnet, it does not make sense to specify global option values; rather, only subnet\-specific ones should be set. .sp The following commands override the global DNS servers option for a particular subnet, setting a single DNS server with address 192.0.2.3: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqsubnet4\(dq: [ { \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqdomain\-name\-servers\(dq, \(dqcode\(dq: 6, \(dqspace\(dq: \(dqdhcp4\(dq, \(dqcsv\-format\(dq: true, \(dqdata\(dq: \(dq192.0.2.3\(dq }, ... ], ... }, ... ], ... } .EE .UNINDENT .UNINDENT .sp In some cases it is useful to associate some options with an address pool from which a client is assigned a lease. Pool\-specific option values override subnet\-specific and global option values; it is not possible to prioritize assignment of pool\-specific options via the order of pool declarations in the server configuration. .sp The following configuration snippet demonstrates how to specify the DNS servers option, which is assigned to a client only if the client obtains an address from the given pool: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqsubnet4\(dq: [ { \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.2.1 \- 192.0.2.200\(dq, \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqdomain\-name\-servers\(dq, \(dqdata\(dq: \(dq192.0.2.3\(dq }, ... ], ... }, ... ], ... }, ... ], ... } .EE .UNINDENT .UNINDENT .sp Options can also be specified in class or host\-reservation scope. The current Kea options precedence order is (from most important to least): host reservation, pool, subnet, shared network, class, global. .sp When a data field is a string and that string contains the comma (\fB,\fP; U+002C) character, the comma must be escaped with two backslashes (\fB\e\e,\fP; U+005C). This double escape is required because both the routine splitting of CSV data into fields and JSON use the same escape character; a single escape (\fB\e,\fP) would make the JSON invalid. For example, the string \(dqfoo,bar\(dq must be represented as: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqsubnet4\(dq: [ { \(dqpools\(dq: [ { \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqboot\-file\-name\(dq, \(dqdata\(dq: \(dqfoo\e\e,bar\(dq } ] }, ... ], ... }, ... ], ... } .EE .UNINDENT .UNINDENT .sp Some options are designated as arrays, which means that more than one value is allowed. For example, the option \fBtime\-servers\fP allows the specification of more than one IPv4 address, enabling clients to obtain the addresses of multiple NTP servers. .sp \fI\%Custom DHCPv4 Options\fP describes the configuration syntax to create custom option definitions (formats). Creation of custom definitions for standard options is generally not permitted, even if the definition being created matches the actual option format defined in the RFCs. However, there is an exception to this rule for standard options for which Kea currently does not provide a definition. To use such options, a server administrator must create a definition as described in \fI\%Custom DHCPv4 Options\fP in the \fBdhcp4\fP option space. This definition should match the option format described in the relevant RFC, but the configuration mechanism allows any option format as there is currently no way to validate it. .sp The currently supported standard DHCPv4 options are listed in the table below. \(dqName\(dq and \(dqCode\(dq are the values that should be used as a name/code in the option\-data structures. \(dqType\(dq designates the format of the data; the meanings of the various types are given in \fI\%List of standard DHCP option types\fP\&. .SS List of standard DHCPv4 options configurable by an administrator .TS box center; l|l|l|l|l. T{ Name T} T{ Code T} T{ Type T} T{ Array? T} T{ Returned if not requested? T} _ T{ time\-offset T} T{ 2 T} T{ int32 T} T{ false T} T{ false T} _ T{ routers T} T{ 3 T} T{ ipv4\-address T} T{ true T} T{ true T} _ T{ time\-servers T} T{ 4 T} T{ ipv4\-address T} T{ true T} T{ false T} _ T{ name\-servers T} T{ 5 T} T{ ipv4\-address T} T{ true T} T{ false T} _ T{ domain\-name\-servers T} T{ 6 T} T{ ipv4\-address T} T{ true T} T{ true T} _ T{ log\-servers T} T{ 7 T} T{ ipv4\-address T} T{ true T} T{ false T} _ T{ cookie\-servers T} T{ 8 T} T{ ipv4\-address T} T{ true T} T{ false T} _ T{ lpr\-servers T} T{ 9 T} T{ ipv4\-address T} T{ true T} T{ false T} _ T{ impress\-servers T} T{ 10 T} T{ ipv4\-address T} T{ true T} T{ false T} _ T{ resource\-location\-servers T} T{ 11 T} T{ ipv4\-address T} T{ true T} T{ false T} _ T{ boot\-size T} T{ 13 T} T{ uint16 T} T{ false T} T{ false T} _ T{ merit\-dump T} T{ 14 T} T{ string T} T{ false T} T{ false T} _ T{ domain\-name T} T{ 15 T} T{ fqdn T} T{ false T} T{ true T} _ T{ swap\-server T} T{ 16 T} T{ ipv4\-address T} T{ false T} T{ false T} _ T{ root\-path T} T{ 17 T} T{ string T} T{ false T} T{ false T} _ T{ extensions\-path T} T{ 18 T} T{ string T} T{ false T} T{ false T} _ T{ ip\-forwarding T} T{ 19 T} T{ boolean T} T{ false T} T{ false T} _ T{ non\-local\-source\-routing T} T{ 20 T} T{ boolean T} T{ false T} T{ false T} _ T{ policy\-filter T} T{ 21 T} T{ ipv4\-address T} T{ true T} T{ false T} _ T{ max\-dgram\-reassembly T} T{ 22 T} T{ uint16 T} T{ false T} T{ false T} _ T{ default\-ip\-ttl T} T{ 23 T} T{ uint8 T} T{ false T} T{ false T} _ T{ path\-mtu\-aging\-timeout T} T{ 24 T} T{ uint32 T} T{ false T} T{ false T} _ T{ path\-mtu\-plateau\-table T} T{ 25 T} T{ uint16 T} T{ true T} T{ false T} _ T{ interface\-mtu T} T{ 26 T} T{ uint16 T} T{ false T} T{ false T} _ T{ all\-subnets\-local T} T{ 27 T} T{ boolean T} T{ false T} T{ false T} _ T{ broadcast\-address T} T{ 28 T} T{ ipv4\-address T} T{ false T} T{ false T} _ T{ perform\-mask\-discovery T} T{ 29 T} T{ boolean T} T{ false T} T{ false T} _ T{ mask\-supplier T} T{ 30 T} T{ boolean T} T{ false T} T{ false T} _ T{ router\-discovery T} T{ 31 T} T{ boolean T} T{ false T} T{ false T} _ T{ router\-solicitation\-address T} T{ 32 T} T{ ipv4\-address T} T{ false T} T{ false T} _ T{ static\-routes T} T{ 33 T} T{ ipv4\-address T} T{ true T} T{ false T} _ T{ trailer\-encapsulation T} T{ 34 T} T{ boolean T} T{ false T} T{ false T} _ T{ arp\-cache\-timeout T} T{ 35 T} T{ uint32 T} T{ false T} T{ false T} _ T{ ieee802\-3\-encapsulation T} T{ 36 T} T{ boolean T} T{ false T} T{ false T} _ T{ default\-tcp\-ttl T} T{ 37 T} T{ uint8 T} T{ false T} T{ false T} _ T{ tcp\-keepalive\-interval T} T{ 38 T} T{ uint32 T} T{ false T} T{ false T} _ T{ tcp\-keepalive\-garbage T} T{ 39 T} T{ boolean T} T{ false T} T{ false T} _ T{ nis\-domain T} T{ 40 T} T{ string T} T{ false T} T{ false T} _ T{ nis\-servers T} T{ 41 T} T{ ipv4\-address T} T{ true T} T{ false T} _ T{ ntp\-servers T} T{ 42 T} T{ ipv4\-address T} T{ true T} T{ false T} _ T{ vendor\-encapsulated\-options T} T{ 43 T} T{ empty T} T{ false T} T{ false T} _ T{ netbios\-name\-servers T} T{ 44 T} T{ ipv4\-address T} T{ true T} T{ false T} _ T{ netbios\-dd\-server T} T{ 45 T} T{ ipv4\-address T} T{ true T} T{ false T} _ T{ netbios\-node\-type T} T{ 46 T} T{ uint8 T} T{ false T} T{ false T} _ T{ netbios\-scope T} T{ 47 T} T{ string T} T{ false T} T{ false T} _ T{ font\-servers T} T{ 48 T} T{ ipv4\-address T} T{ true T} T{ false T} _ T{ x\-display\-manager T} T{ 49 T} T{ ipv4\-address T} T{ true T} T{ false T} _ T{ dhcp\-option\-overload T} T{ 52 T} T{ uint8 T} T{ false T} T{ false T} _ T{ dhcp\-server\-identifier T} T{ 54 T} T{ ipv4\-address T} T{ false T} T{ true T} _ T{ dhcp\-message T} T{ 56 T} T{ string T} T{ false T} T{ false T} _ T{ dhcp\-max\-message\-size T} T{ 57 T} T{ uint16 T} T{ false T} T{ false T} _ T{ vendor\-class\-identifier T} T{ 60 T} T{ string T} T{ false T} T{ false T} _ T{ nwip\-domain\-name T} T{ 62 T} T{ string T} T{ false T} T{ false T} _ T{ nwip\-suboptions T} T{ 63 T} T{ binary T} T{ false T} T{ false T} _ T{ nisplus\-domain\-name T} T{ 64 T} T{ string T} T{ false T} T{ false T} _ T{ nisplus\-servers T} T{ 65 T} T{ ipv4\-address T} T{ true T} T{ false T} _ T{ tftp\-server\-name T} T{ 66 T} T{ string T} T{ false T} T{ false T} _ T{ boot\-file\-name T} T{ 67 T} T{ string T} T{ false T} T{ false T} _ T{ mobile\-ip\-home\-agent T} T{ 68 T} T{ ipv4\-address T} T{ true T} T{ false T} _ T{ smtp\-server T} T{ 69 T} T{ ipv4\-address T} T{ true T} T{ false T} _ T{ pop\-server T} T{ 70 T} T{ ipv4\-address T} T{ true T} T{ false T} _ T{ nntp\-server T} T{ 71 T} T{ ipv4\-address T} T{ true T} T{ false T} _ T{ www\-server T} T{ 72 T} T{ ipv4\-address T} T{ true T} T{ false T} _ T{ finger\-server T} T{ 73 T} T{ ipv4\-address T} T{ true T} T{ false T} _ T{ irc\-server T} T{ 74 T} T{ ipv4\-address T} T{ true T} T{ false T} _ T{ streettalk\-server T} T{ 75 T} T{ ipv4\-address T} T{ true T} T{ false T} _ T{ streettalk\-directory\-assistance\-server T} T{ 76 T} T{ ipv4\-address T} T{ true T} T{ false T} _ T{ user\-class T} T{ 77 T} T{ binary T} T{ false T} T{ false T} _ T{ slp\-directory\-agent T} T{ 78 T} T{ record (boolean, ipv4\-address) T} T{ true T} T{ false T} _ T{ slp\-service\-scope T} T{ 79 T} T{ record (boolean, string) T} T{ false T} T{ false T} _ T{ nds\-servers T} T{ 85 T} T{ ipv4\-address T} T{ true T} T{ false T} _ T{ nds\-tree\-name T} T{ 86 T} T{ string T} T{ false T} T{ false T} _ T{ nds\-context T} T{ 87 T} T{ string T} T{ false T} T{ false T} _ T{ bcms\-controller\-names T} T{ 88 T} T{ fqdn T} T{ true T} T{ false T} _ T{ bcms\-controller\-address T} T{ 89 T} T{ ipv4\-address T} T{ true T} T{ false T} _ T{ client\-system T} T{ 93 T} T{ uint16 T} T{ true T} T{ false T} _ T{ client\-ndi T} T{ 94 T} T{ record (uint8, uint8, uint8) T} T{ false T} T{ false T} _ T{ uuid\-guid T} T{ 97 T} T{ record (uint8, binary) T} T{ false T} T{ false T} _ T{ uap\-servers T} T{ 98 T} T{ string T} T{ false T} T{ false T} _ T{ geoconf\-civic T} T{ 99 T} T{ binary T} T{ false T} T{ false T} _ T{ pcode T} T{ 100 T} T{ string T} T{ false T} T{ false T} _ T{ tcode T} T{ 101 T} T{ string T} T{ false T} T{ false T} _ T{ v6\-only\-preferred T} T{ 108 T} T{ uint32 T} T{ false T} T{ false T} _ T{ netinfo\-server\-address T} T{ 112 T} T{ ipv4\-address T} T{ true T} T{ false T} _ T{ netinfo\-server\-tag T} T{ 113 T} T{ string T} T{ false T} T{ false T} _ T{ v4\-captive\-portal T} T{ 114 T} T{ string T} T{ false T} T{ false T} _ T{ auto\-config T} T{ 116 T} T{ uint8 T} T{ false T} T{ false T} _ T{ name\-service\-search T} T{ 117 T} T{ uint16 T} T{ true T} T{ false T} _ T{ domain\-search T} T{ 119 T} T{ fqdn T} T{ true T} T{ false T} _ T{ classless\-static\-route T} T{ 121 T} T{ internal T} T{ false T} T{ false T} _ T{ cablelabs\-client\-conf T} T{ 122 T} T{ empty T} T{ false T} T{ false T} _ T{ vivco\-suboptions T} T{ 124 T} T{ record (uint32, binary) T} T{ false T} T{ false T} _ T{ vivso\-suboptions T} T{ 125 T} T{ uint32 T} T{ false T} T{ false T} _ T{ pana\-agent T} T{ 136 T} T{ ipv4\-address T} T{ true T} T{ false T} _ T{ v4\-lost T} T{ 137 T} T{ fqdn T} T{ false T} T{ false T} _ T{ capwap\-ac\-v4 T} T{ 138 T} T{ ipv4\-address T} T{ true T} T{ false T} _ T{ sip\-ua\-cs\-domains T} T{ 141 T} T{ fqdn T} T{ true T} T{ false T} _ T{ v4\-sztp\-redirect T} T{ 143 T} T{ tuple T} T{ true T} T{ false T} _ T{ rdnss\-selection T} T{ 146 T} T{ record (uint8, ipv4\-address, ipv4\-address, fqdn) T} T{ true T} T{ false T} _ T{ v4\-portparams T} T{ 159 T} T{ record (uint8, psid) T} T{ false T} T{ false T} _ T{ v4\-dnr T} T{ 162 T} T{ record (uint16, uint16, uint8, fqdn, binary) T} T{ false T} T{ false T} _ T{ option\-6rd T} T{ 212 T} T{ record (uint8, uint8, ipv6\-address, ipv4\-address) T} T{ true T} T{ false T} _ T{ v4\-access\-domain T} T{ 213 T} T{ fqdn T} T{ false T} T{ false T} .TE .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The \fBdefault\-url\fP option was replaced with \fBv4\-captive\-portal\fP in Kea 2.1.2, as introduced by \X'tty: link https://tools.ietf.org/html/rfc8910'\fI\%RFC 8910\fP\X'tty: link'\&. The new option has exactly the same format as the old one. The general perception is that \fBdefault\-url\fP was seldom used. Migrating users should replace \fBdefault\-url\fP with \fBv4\-captive\-portal\fP in their configurations. .UNINDENT .UNINDENT .sp Kea also supports other options than those listed above; the following options are returned by the Kea engine itself and in general should not be configured manually. .SS List of standard DHCPv4 options managed by Kea on its own and not directly configurable by an administrator .TS box center; l|l|l|l. T{ Name T} T{ Code T} T{ Type T} T{ Description T} _ T{ subnet\-mask T} T{ 1 T} T{ ipv4\-address T} T{ calculated automatically, based on subnet definition. T} _ T{ host\-name T} T{ 12 T} T{ string T} T{ sent by client, generally governed by the DNS configuration. T} _ T{ dhcp\-requested\-address T} T{ 50 T} T{ ipv4\-address T} T{ may be sent by the client and the server should not set it. T} _ T{ dhcp\-lease\-time T} T{ 51 T} T{ uint32 T} T{ set automatically based on the \fBvalid\-lifetime\fP parameter. T} _ T{ dhcp\-message\-type T} T{ 53 T} T{ string T} T{ sent by clients and servers. Set by the Kea engine depending on the situation and should never be configured explicitly. T} _ T{ dhcp\-parameter\-request\-list T} T{ 55 T} T{ uint8 array T} T{ sent by clients and should never be sent by the server. T} _ T{ dhcp\-renewal\-time T} T{ 58 T} T{ uint32 T} T{ governed by \fBrenew\-timer\fP parameter. T} _ T{ dhcp\-rebinding\-time T} T{ 59 T} T{ uint32 T} T{ governed by \fBrebind\-timer\fP parameter. T} _ T{ dhcp\-client\-identifier T} T{ 61 T} T{ binary T} T{ sent by client, echoed back with the value sent by the client. T} _ T{ fqdn T} T{ 81 T} T{ record (uint8, uint8, uint8, fqdn) T} T{ part of the DDNS and D2 configuration. T} _ T{ dhcp\-agent\-options T} T{ 82 T} T{ empty T} T{ sent by the relay agent. This is an empty container option; see RAI option detail later in this section. T} _ T{ authenticate T} T{ 90 T} T{ binary T} T{ sent by client, Kea does not yet validate it. T} _ T{ client\-last\-transaction\-time T} T{ 91 T} T{ uint32 T} T{ sent by client, server does not set it. T} _ T{ associated\-ip T} T{ 92 T} T{ ipv4\-address array T} T{ sent by client, server responds with list of addresses. T} _ T{ subnet\-selection T} T{ 118 T} T{ ipv4\-address T} T{ if present in client\(aqs messages, will be used in the subnet selection process. T} _ T{ status\-code T} T{ 151 T} T{ record (uint8, string) T} T{ set by server in bulk leasequery responses. T} _ T{ base\-time T} T{ 152 T} T{ uint32 T} T{ set by server in bulk leasequery responses. T} _ T{ start\-time\-of\-state T} T{ 153 T} T{ uint32 T} T{ set by server in bulk leasequery responses. T} _ T{ query\-start\-time T} T{ 154 T} T{ uint32 T} T{ set by requestor during bulk leasequery. T} _ T{ query\-end\-time T} T{ 155 T} T{ uint32 T} T{ set by requestor during bulk leasequery. T} _ T{ dhcp\-state T} T{ 156 T} T{ uint8 T} T{ set by server in bulk leasequery responses. T} _ T{ data\-source T} T{ 157 T} T{ uint8 T} T{ set by server in bulk leasequery responses. T} .TE .sp The following table lists all option types used in the previous two tables with a description of what values are accepted for them. .SS List of standard DHCP option types .TS box center; l|l. T{ Name T} T{ Meaning T} _ T{ binary T} T{ An arbitrary string of bytes, specified as a set of hexadecimal digits. T} _ T{ boolean T} T{ A boolean value with allowed values true or false. T} _ T{ empty T} T{ No value; data is carried in sub\-options. T} _ T{ fqdn T} T{ Fully qualified domain name (e.g. www.example.com). T} _ T{ ipv4\-address T} T{ IPv4 address in the usual dotted\-decimal notation (e.g. 192.0.2.1). T} _ T{ ipv6\-address T} T{ IPv6 address in the usual colon notation (e.g. 2001:db8::1). T} _ T{ ipv6\-prefix T} T{ IPv6 prefix and prefix length specified using CIDR notation, e.g. 2001:db8:1::/64. This data type is used to represent an 8\-bit field conveying a prefix length and the variable length prefix value. T} _ T{ psid T} T{ PSID and PSID length separated by a slash, e.g. 3/4 specifies PSID=3 and PSID length=4. In the wire format it is represented by an 8\-bit field carrying PSID length (in this case equal to 4) and the 16\-bits\-long PSID value field (in this case equal to \(dq0011000000000000b\(dq using binary notation). Allowed values for a PSID length are 0 to 16. See \X'tty: link https://tools.ietf.org/html/rfc7597'\fI\%RFC 7597\fP\X'tty: link' for details about the PSID wire representation. T} _ T{ record T} T{ Structured data that may be comprised of any types (except \(dqrecord\(dq and \(dqempty\(dq). The array flag applies to the last field only. T} _ T{ string T} T{ Any text. Please note that Kea silently discards any terminating/trailing nulls from the end of \(dqstring\(dq options when unpacking received packets. This is in keeping with \X'tty: link https://tools.ietf.org/html/rfc2132#section-2'\fI\%RFC 2132, Section 2\fP\X'tty: link'\&. T} _ T{ tuple T} T{ A length field encoded as an 8\-bit or 16\-bit unsigned integer followed by a string of this length. Typically, for DHCPv4, the length is 8\-bit, and for DHCPv6, it is 16\-bit. However, there are exceptions to that rule. E.g. for the DHCPv4 SZTP Redirect Option, bootstrap\-server\-list is encoded as a list of tuples where the URI\-length in each tuple is a 16\-bit unsigned integer. T} _ T{ uint8 T} T{ An 8\-bit unsigned integer with allowed values 0 to 255. T} _ T{ uint16 T} T{ A 16\-bit unsigned integer with allowed values 0 to 65535. T} _ T{ uint32 T} T{ A 32\-bit unsigned integer with allowed values 0 to 4294967295. T} _ T{ int8 T} T{ An 8\-bit signed integer with allowed values \-128 to 127. T} _ T{ int16 T} T{ A 16\-bit signed integer with allowed values \-32768 to 32767. T} _ T{ int32 T} T{ A 32\-bit signed integer with allowed values \-2147483648 to 2147483647. T} .TE .sp Kea also supports the Relay Agent Information (RAI, defined in \X'tty: link https://tools.ietf.org/html/rfc3046'\fI\%RFC 3046\fP\X'tty: link') option, sometimes referred to as the relay option, agent option, or simply option 82. The option itself is just a container and does not convey any information on its own. The following table contains a list of RAI sub\-options that Kea can understand. The RAI and its sub\-options are inserted by the relay agent and received by Kea; there is no need for Kea to be configured with those options. Kea\(aqs classification and flexible ID features in host reservations can be used to process those and other options not listed in the table below. .SS List of RAI sub\-options that Kea can understand .TS box center; l|l|l. T{ Name T} T{ Code T} T{ Comment T} _ T{ circuit\-id T} T{ 1 T} T{ Used when host\-reservation\-identifiers is set to \fIcircuit\-id\fP\&. T} _ T{ remote\-id T} T{ 2 T} T{ Can be used with flex\-id to identify hosts. T} _ T{ link\-selection T} T{ 5 T} T{ If present, used to select the appropriate subnet. T} _ T{ subscriber\-id T} T{ 6 T} T{ Can be used with flex\-id to identify hosts. T} _ T{ server\-id\-override T} T{ 11 T} T{ If sent by the relay, Kea accepts it as the \fIserver\-id\fP\&. T} _ T{ relay\-id T} T{ 12 T} T{ Identifies the relay T} _ T{ relay\-port T} T{ 19 T} T{ If sent by the relay, Kea sends back its responses to this port. T} .TE .sp All other RAI sub\-options (including those not listed here) can be used in client classification to classify incoming packets to specific classes, and/or by \fI\%libdhcp_flex_id.so\fP to construct a unique device identifier. For more information about expressions used in client classification and flexible identifiers, see \fI\%Client Classification\fP\&. The RAI sub\-options can be referenced using \fBrelay4[option\-code].hex\fP; for example, to classify packets based on the \fBremote\-id\fP (sub\-option code 2), one would use \fBrelay4[2].hex\fP\&. An example client class that includes all packets with a specific \fBremote\-id\fP value would look as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqremote\-id\-1020304\(dq, \(dqtest\(dq: \(dqrelay4[2].hex == 0x01020304\(dq, ... } ], ... } .EE .UNINDENT .UNINDENT .sp Classes may be used to segregate traffic into a relatively small number of groups, which then can be used to select specific subnets, pools and extra options, and more. If per\-host behavior is necessary, using host reservations with flexible identifiers is strongly recommended. .SS CableLabs Client Conf Suboptions .sp CableLabs client conf option (\(dqcablelabs\-client\-conf\(dq code 122) is a container of suboptions in the \(dqcablelabs\-client\-conf\(dq space listed in the table below. .SS List of CableLabs Client Conf sub\-options that Kea can understand .TS box center; l|l|l. T{ Name T} T{ Code T} T{ Format T} _ T{ tsp\-primary\-server T} T{ 1 T} T{ IPv4 address T} _ T{ tsp\-secondary\-server T} T{ 2 T} T{ IPv4 address T} _ T{ tsp\-as\-parameters T} T{ 4 T} T{ record of 3 uint32\(aqs T} _ T{ tsp\-ap\-parameters T} T{ 5 T} T{ record of 3 uint32\(aqs T} _ T{ tsp\-realm T} T{ 6 T} T{ Fully Qualified Domain Name T} _ T{ tsp\-use\-tgt T} T{ 7 T} T{ boolean T} _ T{ tsp\-provisioning\-timer T} T{ 8 T} T{ uint8 T} _ T{ tsp\-sct T} T{ 9 T} T{ uint16 T} _ T{ kdc\-server T} T{ 10 T} T{ array of IPv4 addresses T} .TE .sp These suboptions are defined in \X'tty: link https://tools.ietf.org/html/rfc3495'\fI\%RFC 3495\fP\X'tty: link' including its errata which clarifies the realm format, \X'tty: link https://tools.ietf.org/html/rfc3594'\fI\%RFC 3594\fP\X'tty: link' and \X'tty: link https://tools.ietf.org/html/rfc3634'\fI\%RFC 3634\fP\X'tty: link'\&. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The suboption 3 carries the TSP provisioning server address as an either IPv4 address or a FQDN. This can\(aqt be defined in Kea so no standard suboption is defined for the code 3 leaving the choice to configure its content as a binary value, or if it is used only as an IPv4 address or a FQDN to define it as a record of an \fBuint8\fP (set to 0) and \fBipv4\-address\fP, or a record of an \fBuint8\fP (set to 1) and a \fBfqdn\fP, allowing the use of CSV formatted data. .UNINDENT .UNINDENT .SS Custom DHCPv4 Options .sp Kea supports custom (non\-standard) DHCPv4 options. Let\(aqs say that we want to define a new DHCPv4 option called \fBfoo\fP, which will have code 222 and will convey a single, unsigned, 32\-bit integer value. Such an option can be defined by putting the following entry in the configuration file: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqoption\-def\(dq: [ { \(dqname\(dq: \(dqfoo\(dq, \(dqcode\(dq: 222, \(dqtype\(dq: \(dquint32\(dq, \(dqarray\(dq: false, \(dqrecord\-types\(dq: \(dq\(dq, \(dqspace\(dq: \(dqdhcp4\(dq, \(dqencapsulate\(dq: \(dq\(dq }, ... ], ... } .EE .UNINDENT .UNINDENT .sp The \fBfalse\fP value of the \fBarray\fP parameter determines that the option does NOT comprise an array of \fBuint32\fP values but is, instead, a single value. Two other parameters have been left blank: \fBrecord\-types\fP and \fBencapsulate\fP\&. The former specifies the comma\-separated list of option data fields, if the option comprises a record of data fields. The \fBrecord\-types\fP value should be non\-empty if \fBtype\fP is set to \(dqrecord\(dq; otherwise it must be left blank. The latter parameter specifies the name of the option space being encapsulated by the particular option. If the particular option does not encapsulate any option space, the parameter should be left blank. Note that the \fBoption\-def\fP configuration statement only defines the format of an option and does not set its value(s). .sp The \fBname\fP, \fBcode\fP, and \fBtype\fP parameters are required; all others are optional. The \fBarray\fP parameter\(aqs default value is \fBfalse\fP\&. The \fBrecord\-types\fP and \fBencapsulate\fP parameters\(aq default values are blank (\fB\(dq\(dq\fP). The default \fBspace\fP is \fBdhcp4\fP\&. .sp Once the new option format is defined, its value is set in the same way as for a standard option. For example, the following commands set a global value that applies to all subnets. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqfoo\(dq, \(dqcode\(dq: 222, \(dqspace\(dq: \(dqdhcp4\(dq, \(dqcsv\-format\(dq: true, \(dqdata\(dq: \(dq12345\(dq }, ... ], ... } .EE .UNINDENT .UNINDENT .sp New options can take more complex forms than the simple use of primitives (uint8, string, ipv4\-address, etc.); it is possible to define an option comprising a number of existing primitives. .sp For example, say we want to define a new option that will consist of an IPv4 address, followed by an unsigned 16\-bit integer, followed by a boolean value, followed by a text string. Such an option could be defined in the following way: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqoption\-def\(dq: [ { \(dqname\(dq: \(dqbar\(dq, \(dqcode\(dq: 223, \(dqspace\(dq: \(dqdhcp4\(dq, \(dqtype\(dq: \(dqrecord\(dq, \(dqarray\(dq: false, \(dqrecord\-types\(dq: \(dqipv4\-address, uint16, boolean, string\(dq, \(dqencapsulate\(dq: \(dq\(dq }, ... ], ... } .EE .UNINDENT .UNINDENT .sp The \fBtype\fP parameter is set to \fB\(dqrecord\(dq\fP to indicate that the option contains multiple values of different types. These types are given as a comma\-separated list in the \fBrecord\-types\fP field and should be ones from those listed in \fI\%List of standard DHCP option types\fP\&. .sp The option\(aqs values are set in an \fBoption\-data\fP statement as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqbar\(dq, \(dqspace\(dq: \(dqdhcp4\(dq, \(dqcode\(dq: 223, \(dqcsv\-format\(dq: true, \(dqdata\(dq: \(dq192.0.2.100, 123, true, Hello World\(dq } ], ... } .EE .UNINDENT .UNINDENT .sp The \fBcsv\-format\fP parameter is set to \fBtrue\fP to indicate that the \fBdata\fP field comprises a comma\-separated list of values. The values in \fBdata\fP must correspond to the types set in the \fBrecord\-types\fP field of the option definition. .sp When \fBarray\fP is set to \fBtrue\fP and \fBtype\fP is set to \fB\(dqrecord\(dq\fP, the last field is an array, i.e. it can contain more than one value, as in: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqoption\-def\(dq: [ { \(dqname\(dq: \(dqbar\(dq, \(dqcode\(dq: 223, \(dqspace\(dq: \(dqdhcp4\(dq, \(dqtype\(dq: \(dqrecord\(dq, \(dqarray\(dq: true, \(dqrecord\-types\(dq: \(dqipv4\-address, uint16\(dq, \(dqencapsulate\(dq: \(dq\(dq }, ... ], ... } .EE .UNINDENT .UNINDENT .sp The new option content is one IPv4 address followed by one or more 16\-bit unsigned integers. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 In general, boolean values are specified as \fBtrue\fP or \fBfalse\fP, without quotes. Some specific boolean parameters may also accept \fB\(dqtrue\(dq\fP, \fB\(dqfalse\(dq\fP, \fB0\fP, \fB1\fP, \fB\(dq0\(dq\fP, and \fB\(dq1\(dq\fP\&. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Numbers can be specified in decimal or hexadecimal format. The hexadecimal format can be either plain (e.g. abcd) or prefixed with 0x (e.g. 0xabcd). .UNINDENT .UNINDENT .SS DHCPv4 Private Options .sp Options with a code between 224 and 254 are reserved for private use. They can be defined at the global scope or at the client\-class local scope; this allows option definitions to be used depending on context, and option data to be set accordingly. For instance, to configure an old PXEClient vendor: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqpxeclient\(dq, \(dqtest\(dq: \(dqoption[vendor\-class\-identifier].text == \(aqPXEClient\(aq\(dq, \(dqoption\-def\(dq: [ { \(dqname\(dq: \(dqconfigfile\(dq, \(dqcode\(dq: 209, \(dqtype\(dq: \(dqstring\(dq } ], ... }, ... ], ... } .EE .UNINDENT .UNINDENT .sp As the Vendor\-Specific Information (VSI) option (code 43) has a vendor\-specific format, i.e. can carry either raw binary value or sub\-options, this mechanism is also available for this option. .sp In the following example taken from a real configuration, two vendor classes use option 43 for different and incompatible purposes: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqoption\-def\(dq: [ { \(dqname\(dq: \(dqcookie\(dq, \(dqcode\(dq: 1, \(dqtype\(dq: \(dqstring\(dq, \(dqspace\(dq: \(dqAPC\(dq }, { \(dqname\(dq: \(dqmtftp\-ip\(dq, \(dqcode\(dq: 1, \(dqtype\(dq: \(dqipv4\-address\(dq, \(dqspace\(dq: \(dqPXE\(dq }, ... ], \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqAPC\(dq, \(dqtest\(dq: \(dqoption[vendor\-class\-identifier].text == \(aqAPC\(aq\(dq, \(dqoption\-def\(dq: [ { \(dqname\(dq: \(dqvendor\-encapsulated\-options\(dq, \(dqtype\(dq: \(dqempty\(dq, \(dqencapsulate\(dq: \(dqAPC\(dq } ], \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqcookie\(dq, \(dqspace\(dq: \(dqAPC\(dq, \(dqdata\(dq: \(dq1APC\(dq }, { \(dqname\(dq: \(dqvendor\-encapsulated\-options\(dq }, ... ], ... }, { \(dqname\(dq: \(dqPXE\(dq, \(dqtest\(dq: \(dqoption[vendor\-class\-identifier].text == \(aqPXE\(aq\(dq, \(dqoption\-def\(dq: [ { \(dqname\(dq: \(dqvendor\-encapsulated\-options\(dq, \(dqtype\(dq: \(dqempty\(dq, \(dqencapsulate\(dq: \(dqPXE\(dq } ], \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqmtftp\-ip\(dq, \(dqspace\(dq: \(dqPXE\(dq, \(dqdata\(dq: \(dq0.0.0.0\(dq }, { \(dqname\(dq: \(dqvendor\-encapsulated\-options\(dq }, ... ], ... }, ... ], ... } .EE .UNINDENT .UNINDENT .sp The definition used to decode a VSI option is: .INDENT 0.0 .IP 1. 3 The local definition of a client class the incoming packet belongs to; .IP 2. 3 If none, the global definition; .IP 3. 3 If none, the last\-resort definition described in the next section, \fI\%DHCPv4 Vendor\-Specific Options\fP (backward\-compatible with previous Kea versions). .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 This last\-resort definition for the Vendor\-Specific Information option (code 43) is not compatible with a raw binary value. When there are known cases where a raw binary value will be used, a client class must be defined with both a classification expression matching these cases and an option definition for the VSI option with a binary type and no encapsulation. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 By default, in the Vendor\-Specific Information option (code 43), sub\-option code 0 and 255 mean PAD and END respectively, according to \X'tty: link https://tools.ietf.org/html/rfc2132'\fI\%RFC 2132\fP\X'tty: link'\&. In other words, the sub\-option code values of 0 and 255 are reserved. Kea does, however, allow users to define sub\-option codes from 0 to 255. If sub\-options with codes 0 and/or 255 are defined, bytes with that value are no longer treated as a PAD or an END, but as the sub\-option code when parsing a VSI option in an incoming query. .sp Option 43 input processing (also called unpacking) is deferred so that it happens after classification. This means clients cannot be classified using option 43 sub\-options. The definition used to unpack option 43 is determined as follows: .INDENT 0.0 .IP \(bu 2 If defined at the global scope, this definition is used. .IP \(bu 2 If defined at client class scope and the packet belongs to this class, the client class definition is used. .IP \(bu 2 If not defined at global scope nor in a client class to which the packet belongs, the built\-in last resort definition is used. This definition only says the sub\-option space is \fB\(dqvendor\-encapsulated\-options\-space\(dq\fP\&. .UNINDENT .sp The output definition selection is a bit simpler: .INDENT 0.0 .IP \(bu 2 If the packet belongs to a client class which defines the option 43, use this definition. .IP \(bu 2 If defined at the global scope, use this definition. .IP \(bu 2 Otherwise, use the built\-in last\-resort definition. .UNINDENT .sp Since they use a specific/per vendor option space, sub\-options are defined at the global scope. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Option definitions in client classes are allowed only for this limited option set (codes 43 and from 224 to 254), and only for DHCPv4. .UNINDENT .UNINDENT .SS DHCPv4 Vendor\-Specific Options .sp Currently there are two option spaces defined for \fI\%kea\-dhcp4\fP: \fBdhcp4\fP (for the top\-level DHCPv4 options) and \fB\(dqvendor\-encapsulated\-options\-space\(dq\fP, which is empty by default but in which options can be defined. Those options are carried in the Vendor\-Specific Information option (code 43). The following examples show how to define an option \fBfoo\fP with code 1 that comprises an IPv4 address, an unsigned 16\-bit integer, and a string. The \fBfoo\fP option is conveyed in a Vendor\-Specific Information option. .sp The first step is to define the format of the option: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqoption\-def\(dq: [ { \(dqname\(dq: \(dqfoo\(dq, \(dqcode\(dq: 1, \(dqspace\(dq: \(dqvendor\-encapsulated\-options\-space\(dq, \(dqtype\(dq: \(dqrecord\(dq, \(dqarray\(dq: false, \(dqrecord\-types\(dq: \(dqipv4\-address, uint16, string\(dq, \(dqencapsulate\(dq: \(dq\(dq } ], ... } .EE .UNINDENT .UNINDENT .sp Note that the option space is set to \fB\(dqvendor\-encapsulated\-options\-space\(dq\fP\&. Once the option format is defined, the next step is to define actual values for that option: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqfoo\(dq, \(dqspace\(dq: \(dqvendor\-encapsulated\-options\-space\(dq, \(dqcode\(dq: 1, \(dqcsv\-format\(dq: true, \(dqdata\(dq: \(dq192.0.2.3, 123, Hello World\(dq } ], ... } .EE .UNINDENT .UNINDENT .sp In this example, we also include the Vendor\-Specific Information option, which conveys our sub\-option \fBfoo\fP\&. This is required; otherwise, the option will not be included in messages sent to the client. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqvendor\-encapsulated\-options\(dq } ], ... } .EE .UNINDENT .UNINDENT .sp Alternatively, the option can be specified using its code. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqoption\-data\(dq: [ { \(dqcode\(dq: 43 } ], ... } .EE .UNINDENT .UNINDENT .sp Another popular option that is often somewhat imprecisely called the \(dqvendor option\(dq is option 125. Its proper name is the \(dqvendor\-independent vendor\-specific information option\(dq or \(dqvivso\(dq. The idea behind vivso options is that each vendor has its own unique set of options with their own custom formats. The vendor is identified by a 32\-bit unsigned integer called \fBenterprise\-number\fP or \fBvendor\-id\fP\&. .sp The standard spaces defined in Kea and their options are: .INDENT 0.0 .IP \(bu 2 \fBvendor\-4491\fP: Cable Television Laboratories, Inc. for DOCSIS3 options: .UNINDENT .TS box center; l|l|l. T{ option code T} T{ option name T} T{ option description T} _ T{ 1 T} T{ oro T} T{ ORO (or Option Request Option), used by clients to request a list of options they are interested in. T} _ T{ 2 T} T{ tftp\-servers T} T{ a list of IPv4 addresses of TFTP servers to be used by the cable modem T} .TE .sp In Kea, each vendor is represented by its own vendor space. Since there are hundreds of vendors and they sometimes use different option definitions for different hardware, it is impossible for Kea to support them all natively. Fortunately, it is easy to define support for new vendor options. As an example, the Genexis home gateway device requires the vivso 125 option to be sent with a sub\-option 2 that contains a string with the TFTP server URL. To support such a device, three steps are needed: first, establish option definitions that explain how the option is supposed to be formed; second, define option values; and third, tell Kea when to send those specific options, via client classification. .sp An example snippet of a configuration could look similar to the following: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { // First, we need to define that the sub\-option 2 in vivso option for // vendor\-id 25167 has a specific format (it\(aqs a plain string in this example). // After this definition, we can specify values for option tftp. \(dqoption\-def\(dq: [ { // We define a short name, so the option can be referenced by name. // The option has code 2 and resides within vendor space 25167. // Its data is a plain string. \(dqname\(dq: \(dqtftp\(dq, \(dqcode\(dq: 2, \(dqspace\(dq: \(dqvendor\-25167\(dq, \(dqtype\(dq: \(dqstring\(dq } ], \(dqclient\-classes\(dq: [ { // We now need to tell Kea how to recognize when to use vendor space 25167. // Usually we can use a simple expression, such as checking if the device // sent a vivso option with specific vendor\-id, e.g. \(dqvendor[4491].exists\(dq. // Unfortunately, Genexis is a bit unusual in this aspect, because it // doesn\(aqt send vivso. In this case we need to look into the vendor class // (option code 60) and see if there\(aqs a specific string that identifies // the device. Alternatively, one can make use of the automated \(gaVENDOR_CLASS_\(ga // client class and replace \(dqname\(dq and \(dqtest\(dq with \(ga\(dqname\(dq: \(dqVENDOR_CLASS_HMC1000\(dq\(ga // and no test expression. \(dqname\(dq: \(dqcpe_genexis\(dq, \(dqtest\(dq: \(dqsubstring(option[60].hex,0,7) == \(aqHMC1000\(aq\(dq, // Once the device is recognized, we want to send two options: // the vivso option with vendor\-id set to 25167, and a sub\-option 2. \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqvivso\-suboptions\(dq, \(dqdata\(dq: \(dq25167\(dq }, // The sub\-option 2 value is defined as any other option. However, // we want to send this sub\-option 2, even when the client didn\(aqt // explicitly request it (often there is no way to do that for // vendor options). Therefore we use always\-send to force Kea // to always send this option when 25167 vendor space is involved. { \(dqname\(dq: \(dqtftp\(dq, \(dqspace\(dq: \(dqvendor\-25167\(dq, \(dqdata\(dq: \(dqtftp://192.0.2.1/genexis/HMC1000.v1.3.0\-R.img\(dq, \(dqalways\-send\(dq: true } ] } ] } .EE .UNINDENT .UNINDENT .sp By default, Kea sends back only those options that are requested by a client, unless there are protocol rules that tell the DHCP server to always send an option. This approach works nicely in most cases and avoids problems with clients refusing responses with options they do not understand. However, the situation with vendor options is more complex, as they are not requested the same way as other options, are not well\-documented in official RFCs, or vary by vendor. .sp Some vendors (such as DOCSIS, identified by vendor option 4491) have a mechanism to request specific vendor options and Kea is able to honor those (sub\-option 1). Unfortunately, for many other vendors, such as Genexis (25167, discussed above), Kea does not have such a mechanism, so it cannot send any sub\-options on its own. To solve this issue, we devised the concept of persistent options. Kea can be told to always send options, even if the client did not request them. This can be achieved by adding \fB\(dqalways\-send\(dq: true\fP to the option data entry. Note that in this particular case an option is defined in vendor space 25167. With \fBalways\-send\fP enabled, the option is sent every time there is a need to deal with vendor space 25167. .sp This is also how \fI\%kea\-dhcp4\fP can be configured to send multiple vendor options from different vendors, along with each of their specific vendor IDs. If these options need to be sent by the server regardless of whether the client specified any enterprise number, \fB\(dqalways\-send\(dq: true\fP must be configured for the suboptions that will be included in the \fBvivso\-suboptions\fP option (code 125). .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqoption\-data\(dq: [ # Typically DHCPv4 clients will send a Parameter Request List option (code 55) for # vivso\-suboptions (code 125), and that is enough for Kea to understand that it needs to # send the option. These options still need to be defined in the configuration, one per # each vendor, but they don\(aqt need \(dqalways\-send\(dq enabled in that case. For misbehaving # clients that do not explicitly request it, one may alternatively set \(dqalways\-send\(dq # to true for them as well. This is referring to the following two entries in option\-data. { \(dqname\(dq: \(dqvivso\-suboptions\(dq, \(dqspace\(dq: \(dqdhcp4\(dq, \(dqdata\(dq: \(dq2234\(dq }, { \(dqname\(dq: \(dqvivso\-suboptions\(dq, \(dqspace\(dq: \(dqdhcp4\(dq, \(dqdata\(dq: \(dq3561\(dq }, { \(dqalways\-send\(dq: true, \(dqdata\(dq: \(dqtagged\(dq, \(dqname\(dq: \(dqtag\(dq, \(dqspace\(dq: \(dqvendor\-2234\(dq }, { \(dqalways\-send\(dq: true, \(dqdata\(dq: \(dqhttps://example.com:1234/path\(dq, \(dqname\(dq: \(dqurl\(dq, \(dqspace\(dq: \(dqvendor\-3561\(dq } ], \(dqoption\-def\(dq: [ { \(dqcode\(dq: 22, \(dqname\(dq: \(dqtag\(dq, \(dqspace\(dq: \(dqvendor\-2234\(dq, \(dqtype\(dq: \(dqstring\(dq }, { \(dqcode\(dq: 11, \(dqname\(dq: \(dqurl\(dq, \(dqspace\(dq: \(dqvendor\-3561\(dq, \(dqtype\(dq: \(dqstring\(dq } ] } .EE .UNINDENT .UNINDENT .sp Another possibility is to redefine the option; see \fI\%DHCPv4 Private Options\fP\&. .sp Kea comes with several example configuration files. Some of them showcase how to configure options 60 and 43. See \fBdoc/examples/kea4/vendor\-specific.json\fP and \fBdoc/examples/kea4/vivso.json\fP in the Kea sources. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 \fI\%kea\-dhcp4\fP is able to recognize multiple Vendor Class Identifier options (code 60) with different vendor IDs in the client requests, and to send multiple vivso options (code 125) in the responses, one for each vendor. .sp \fI\%kea\-dhcp4\fP honors DOCSIS sub\-option 1 (ORO) and adds only requested options if this sub\-option is present in the client request. .sp Currently only one vendor is supported for the \fBvivco\-suboptions\fP (code 124) option. Specifying multiple enterprise numbers within a single option instance or multiple options with different enterprise numbers is not supported. .UNINDENT .UNINDENT .SS Nested DHCPv4 Options (Custom Option Spaces) .sp It is sometimes useful to define a completely new option space, such as when a user creates a new option in the standard option space (\fBdhcp4\fP) and wants this option to convey sub\-options. Since they are in a separate space, sub\-option codes have a separate numbering scheme and may overlap with the codes of standard options. .sp Note that the creation of a new option space is not required when defining sub\-options for a standard option, because one is created by default if the standard option is meant to convey any sub\-options (see \fI\%DHCPv4 Vendor\-Specific Options\fP). .sp If we want a DHCPv4 option called \fBcontainer\fP with code 222, that conveys two sub\-options with codes 1 and 2, we first need to define the new sub\-options: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqoption\-def\(dq: [ { \(dqname\(dq: \(dqsubopt1\(dq, \(dqcode\(dq: 1, \(dqspace\(dq: \(dqisc\(dq, \(dqtype\(dq: \(dqipv4\-address\(dq, \(dqrecord\-types\(dq: \(dq\(dq, \(dqarray\(dq: false, \(dqencapsulate\(dq: \(dq\(dq }, { \(dqname\(dq: \(dqsubopt2\(dq, \(dqcode\(dq: 2, \(dqspace\(dq: \(dqisc\(dq, \(dqtype\(dq: \(dqstring\(dq, \(dqrecord\-types\(dq: \(dq\(dq, \(dqarray\(dq: false, \(dqencapsulate\(dq: \(dq\(dq } ], ... } .EE .UNINDENT .UNINDENT .sp Note that we have defined the options to belong to a new option space (in this case, \fB\(dqisc\(dq\fP). .sp The next step is to define a regular DHCPv4 option with the desired code and specify that it should include options from the new option space: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqoption\-def\(dq: [ { \(dqname\(dq: \(dqcontainer\(dq, \(dqcode\(dq: 222, \(dqspace\(dq: \(dqdhcp4\(dq, \(dqtype\(dq: \(dqempty\(dq, \(dqarray\(dq: false, \(dqrecord\-types\(dq: \(dq\(dq, \(dqencapsulate\(dq: \(dqisc\(dq }, ... ], ... } .EE .UNINDENT .UNINDENT .sp The name of the option space in which the sub\-options are defined is set in the \fBencapsulate\fP field. The \fBtype\fP field is set to \fB\(dqempty\(dq\fP, to indicate that this option does not carry any data other than sub\-options. .sp Finally, we can set values for the new options: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp4\(dq: { \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqsubopt1\(dq, \(dqcode\(dq: 1, \(dqspace\(dq: \(dqisc\(dq, \(dqdata\(dq: \(dq192.0.2.3\(dq }, { \(dqname\(dq: \(dqsubopt2\(dq, \(dqcode\(dq: 2, \(dqspace\(dq: \(dqisc\(dq, \(dqdata\(dq: \(dqHello world\(dq }, { \(dqname\(dq: \(dqcontainer\(dq, \(dqcode\(dq: 222, \(dqspace\(dq: \(dqdhcp4\(dq } ] } } .EE .UNINDENT .UNINDENT .sp It is possible to create an option which carries some data in addition to the sub\-options defined in the encapsulated option space. For example, if the \fBcontainer\fP option from the previous example were required to carry a uint16 value as well as the sub\-options, the \fBtype\fP value would have to be set to \fB\(dquint16\(dq\fP in the option definition. (Such an option would then have the following data structure: DHCP header, uint16 value, sub\-options.) The value specified with the \fBdata\fP parameter — which should be a valid integer enclosed in quotes, e.g. \fB\(dq123\(dq\fP — would then be assigned to the \fBuint16\fP field in the \fBcontainer\fP option. .SS Unspecified Parameters for DHCPv4 Option Configuration .sp In many cases it is not required to specify all parameters for an option configuration, and the default values can be used. However, it is important to understand the implications of not specifying some of them, as it may result in configuration errors. The list below explains the behavior of the server when a particular parameter is not explicitly specified: .INDENT 0.0 .IP \(bu 2 \fBname\fP \- the server requires either an option name or an option code to identify an option. If this parameter is unspecified, the option code must be specified. .IP \(bu 2 \fBcode\fP \- the server requires either an option name or an option code to identify an option; this parameter may be left unspecified if the \fBname\fP parameter is specified. However, this also requires that the particular option have a definition (either as a standard option or an administrator\-created definition for the option using an \fBoption\-def\fP structure), as the option definition associates an option with a particular name. It is possible to configure an option for which there is no definition (unspecified option format). Configuration of such options requires the use of the option code. .IP \(bu 2 \fBspace\fP \- if the option space is unspecified it defaults to \fBdhcp4\fP, which is an option space holding standard DHCPv4 options. .IP \(bu 2 \fBdata\fP \- if the option data is unspecified it defaults to an empty value. The empty value is mostly used for the options which have no payload (boolean options), but it is legal to specify empty values for some options which carry variable\-length data and for which the specification allows a length of 0. For such options, the data parameter may be omitted in the configuration. .IP \(bu 2 \fBcsv\-format\fP \- if this value is not specified, the server assumes that the option data is specified as a list of comma\-separated values to be assigned to individual fields of the DHCP option. .UNINDENT .SS Support for Long Options .sp The \fI\%kea\-dhcp4\fP server partially supports long options (RFC 3396). Since Kea 2.1.6, the server accepts configuring long options and sub\-options (longer than 255 bytes). The options and sub\-options are stored internally in their unwrapped form and they can be processed as usual using the parser language. On send, the server splits long options and sub\-options into multiple options and sub\-options, using the respective option code. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqoption\-def\(dq: [ { \(dqarray\(dq: false, \(dqcode\(dq: 240, \(dqencapsulate\(dq: \(dq\(dq, \(dqname\(dq: \(dqmy\-option\(dq, \(dqspace\(dq: \(dqdhcp4\(dq, \(dqtype\(dq: \(dqstring\(dq } ], \(dqsubnet4\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq, \(dqreservations\(dq: [ { \(dqhw\-address\(dq: \(dqaa:bb:cc:dd:ee:ff\(dq, \(dqoption\-data\(dq: [ { \(dqalways\-send\(dq: false, \(dqcode\(dq: 240, \(dqname\(dq: \(dqmy\-option\(dq, \(dqcsv\-format\(dq: true, \(dqdata\(dq: \(dqdata \e \-00010203040506070809\-00010203040506070809\-00010203040506070809\-00010203040506070809 \e \-00010203040506070809\-00010203040506070809\-00010203040506070809\-00010203040506070809 \e \-00010203040506070809\-00010203040506070809\-00010203040506070809\-00010203040506070809 \e \-data\(dq, \(dqspace\(dq: \(dqdhcp4\(dq } ] } ] } ], \&... } .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 In the example above, the data has been wrapped into several lines for clarity, but Kea does not support wrapping in the configuration file. .UNINDENT .UNINDENT .sp This example illustrates configuring a custom long option (exceeding 255 octets) in a reservation. When sending a response, the server splits this option into two options, each with the code 240. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Currently the server does not support storing long options in databases, either via host reservations or the configuration backend. .UNINDENT .UNINDENT .sp The server is also able to receive packets with split options (options using the same option code) and to fuse the data chunks into one option. This is also supported for sub\-options if each sub\-option data chunk also contains the sub\-option code and sub\-option length. .SS Support for IPv6\-Only Preferred Option .sp The \fBv6\-only\-preferred\fP (code 108) option is handled in a specific way described in \X'tty: link https://tools.ietf.org/html/rfc8925'\fI\%RFC 8925\fP\X'tty: link' by \fI\%kea\-dhcp4\fP when it is configured in a subnet or a shared network: when the client requests the option (i.e. puts the 108 code in the DHCP parameter request list option) and the subnet or shared network is selected the 0.0.0.0 address is offered and the option returned in the response. .SS Stateless Configuration of DHCPv4 Clients .sp The DHCPv4 server supports stateless client configuration, whereby the client has an IP address configured (e.g. using manual configuration) and only contacts the server to obtain other configuration parameters, such as addresses of DNS servers. To obtain the stateless configuration parameters, the client sends the DHCPINFORM message to the server with the \fBciaddr\fP set to the address that the client is currently using. The server unicasts the DHCPACK message to the client that includes the stateless configuration (\(dqyiaddr\(dq not set). .sp The server responds to the DHCPINFORM when the client is associated with a subnet defined in the server\(aqs configuration. An example subnet configuration looks like this: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqsubnet4\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq, \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqdomain\-name\-servers\(dq, \(dqcode\(dq: 6, \(dqdata\(dq: \(dq192.0.2.200,192.0.2.201\(dq, \(dqcsv\-format\(dq: true, \(dqspace\(dq: \(dqdhcp4\(dq } ] } ] } .EE .UNINDENT .UNINDENT .sp This subnet specifies the single option which will be included in the DHCPACK message to the client in response to DHCPINFORM. The subnet definition does not require the address pool configuration if it will be used solely for stateless configuration. .sp This server will associate the subnet with the client if one of the following conditions is met: .INDENT 0.0 .IP \(bu 2 The DHCPINFORM is relayed and the \fBgiaddr\fP matches the configured subnet. .IP \(bu 2 The DHCPINFORM is unicast from the client and the \fBciaddr\fP matches the configured subnet. .IP \(bu 2 The DHCPINFORM is unicast from the client and the \fBciaddr\fP is not set, but the source address of the IP packet matches the configured subnet. .IP \(bu 2 The DHCPINFORM is not relayed and the IP address on the interface on which the message is received matches the configured subnet. .UNINDENT .SS Client Classification in DHCPv4 .sp The DHCPv4 server includes support for client classification. For a deeper discussion of the classification process, see \fI\%Client Classification\fP\&. .sp In certain cases it is useful to configure the server to differentiate between DHCP client types and treat them accordingly. Client classification can be used to modify the behavior of almost any part of DHCP message processing. Kea currently offers client classification via private options and option 43 deferred unpacking; subnet selection; pool selection; assignment of different options; and, for cable modems, specific options for use with the TFTP server address and the boot file field. .sp Kea can be instructed to limit access to given subnets based on class information. This is particularly useful for cases where two types of devices share the same link and are expected to be served from two different subnets. The primary use case for such a scenario is cable networks, where there are two classes of devices: the cable modem itself, which should be handed a lease from subnet A; and all other devices behind the modem, which should get leases from subnet B. That segregation is essential to prevent overly curious end\-users from playing with their cable modems. For details on how to set up class restrictions on subnets, see \fI\%Configuring Subnets With Class Information\fP\&. .sp When subnets belong to a shared network, the classification applies to subnet selection but not to pools; that is, a pool in a subnet limited to a particular class can still be used by clients which do not belong to the class, if the pool they are expected to use is exhausted. The limit on access based on class information is also available at the pool level within a subnet: see \fI\%Configuring Pools With Class Information\fP\&. This is useful when segregating clients belonging to the same subnet into different address ranges. .sp In a similar way, a pool can be constrained to serve only known clients, i.e. clients which have a reservation, using the built\-in \fBKNOWN\fP or \fBUNKNOWN\fP classes. Addresses can be assigned to registered clients without giving a different address per reservation: for instance, when there are not enough available addresses. The determination whether there is a reservation for a given client is made after a subnet is selected, so it is not possible to use \fBKNOWN\fP/\fBUNKNOWN\fP classes to select a shared network or a subnet. .sp The process of classification is conducted in five steps. The first step is to assess an incoming packet and assign it to zero or more classes. The second step is to choose a subnet, possibly based on the class information. When the incoming packet is in the special class \fBDROP\fP, it is dropped and a debug message logged. The next step is to evaluate class expressions depending on the built\-in \fBKNOWN\fP/\fBUNKNOWN\fP classes after host reservation lookup, using them for pool selection and assigning classes from host reservations. The list of required classes is then built and each class of the list has its expression evaluated; when it returns \fBtrue\fP, the packet is added as a member of the class. The last step is to assign options, again possibly based on the class information. More complete and detailed information is available in \fI\%Client Classification\fP\&. .sp There are two main methods of classification. The first is automatic and relies on examining the values in the vendor class options or the existence of a host reservation. Information from these options is extracted, and a class name is constructed from it and added to the class list for the packet. The second method specifies an expression that is evaluated for each packet. If the result is \fBtrue\fP, the packet is a member of the class. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The new \fBearly\-global\-reservations\-lookup\fP global parameter flag enables a lookup for global reservations before the subnet selection phase. This lookup is similar to the general lookup described above with two differences: .INDENT 0.0 .IP \(bu 2 the lookup is limited to global host reservations .IP \(bu 2 the \fBUNKNOWN\fP class is never set .UNINDENT .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Care should be taken with client classification, as it is easy for clients that do not meet class criteria to be denied all service. .UNINDENT .UNINDENT .SS Setting Fixed Fields in Classification .sp It is possible to specify that clients belonging to a particular class should receive packets with specific values in certain fixed fields. In particular, three fixed fields are supported: \fBnext\-server\fP (conveys an IPv4 address, which is set in the \fBsiaddr\fP field), \fBserver\-hostname\fP (conveys a server hostname, can be up to 64 bytes long, and is sent in the \fBsname\fP field) and \fBboot\-file\-name\fP (conveys the configuration file, can be up to 128 bytes long, and is sent using the \fBfile\fP field). .sp Obviously, there are many ways to assign clients to specific classes, but for PXE clients the client architecture type option (code 93) seems to be particularly suited to make the distinction. The following example checks whether the client identifies itself as a PXE device with architecture EFI x86\-64, and sets several fields if it does. See \X'tty: link https://tools.ietf.org/html/rfc4578#section-2.1'\fI\%Section 2.1 of RFC 4578\fP\X'tty: link') or the client documentation for specific values. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqipxe_efi_x64\(dq, \(dqtest\(dq: \(dqoption[93].hex == 0x0009\(dq, \(dqnext\-server\(dq: \(dq192.0.2.254\(dq, \(dqserver\-hostname\(dq: \(dqhal9000\(dq, \(dqboot\-file\-name\(dq: \(dq/dev/null\(dq }, ... ], ... } .EE .UNINDENT .UNINDENT .sp If an incoming packet is matched to multiple classes, then the value used for each field will come from the first class that specifies the field, in the order the classes are assigned to the packet. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The classes are ordered as specified in the configuration. .UNINDENT .UNINDENT .SS Using Vendor Class Information in Classification .sp The server checks whether an incoming packet includes the vendor class identifier option (60). If it does, the content of that option is prepended with \fBVENDOR_CLASS_\fP, and it is interpreted as a class. For example, modern cable modems send this option with value \fBdocsis3.0\fP, so the packet belongs to the class \fBVENDOR_CLASS_docsis3.0\fP\&. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Certain special actions for clients in \fBVENDOR_CLASS_docsis3.0\fP can be achieved by defining \fBVENDOR_CLASS_docsis3.0\fP and setting its \fBnext\-server\fP and \fBboot\-file\-name\fP values appropriately. .UNINDENT .UNINDENT .sp This example shows a configuration using an automatically generated \fBVENDOR_CLASS_\fP class. The administrator of the network has decided that addresses from the range 192.0.2.10 to 192.0.2.20 are going to be managed by the Dhcp4 server and only clients belonging to the DOCSIS 3.0 client class are allowed to use that pool. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqsubnet4\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.2.10 \- 192.0.2.20\(dq } ], \(dqclient\-classes\(dq: [ \(dqVENDOR_CLASS_docsis3.0\(dq ] } ], ... } .EE .UNINDENT .UNINDENT .SS Defining and Using Custom Classes .sp The following example shows how to configure a class using an expression and a subnet using that class. This configuration defines the class named \fBClient_foo\fP\&. It is comprised of all clients whose client IDs (option 61) start with the string \fBfoo\fP\&. Members of this class will be given addresses from 192.0.2.10 to 192.0.2.20 and the addresses of their DNS servers set to 192.0.2.1 and 192.0.2.2. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqClient_foo\(dq, \(dqtest\(dq: \(dqsubstring(option[61].hex,0,3) == \(aqfoo\(aq\(dq, \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqdomain\-name\-servers\(dq, \(dqcode\(dq: 6, \(dqspace\(dq: \(dqdhcp4\(dq, \(dqcsv\-format\(dq: true, \(dqdata\(dq: \(dq192.0.2.1, 192.0.2.2\(dq } ] }, ... ], \(dqsubnet4\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.2.10 \- 192.0.2.20\(dq } ], \(dqclient\-classes\(dq: [ \(dqClient_foo\(dq ] }, ... ], ... } .EE .UNINDENT .UNINDENT .SS Additional Classification .sp In some cases it is useful to limit the scope of a class to a pool, subnet, or shared network. There are two parameters which are used to limit the scope of the class by instructing the server to evaluate test expressions when required. .sp The \fBevaluate\-additional\-classes\fP, which takes a list of class names and is valid in pool, subnet, and shared network scope. Classes in these lists are marked as additional and evaluated after selection of this specific pool/subnet/shared network and before output\-option processing. .sp The second one is the per\-class \fBonly\-in\-additional\-list\fP flag, which is \fBfalse\fP by default. When it is set to \fBtrue\fP, the test expression of the class is not evaluated at the reception of the incoming packet but later, and only if the class is present in an \fBevaluate\-additional\-classes\fP list. .sp In this example, a class is assigned to the incoming packet when the specified subnet is used: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqClient_foo\(dq, \(dqtest\(dq: \(dqmember(\(aqALL\(aq)\(dq, \(dqonly\-in\-additional\-list\(dq: true }, ... ], \(dqsubnet4\(dq: [ { \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.2.10 \- 192.0.2.20\(dq } ], \(dqevaluate\-additional\-classes\(dq: [ \(dqClient_foo\(dq ], ... }, ... ], ... } .EE .UNINDENT .UNINDENT .sp Additional evaluation can be used to express complex dependencies like subnet membership. It can also be used to reverse the precedence; if \fBoption\-data\fP is set in a subnet, it takes precedence over \fBoption\-data\fP in a class. If \fBoption\-data\fP is moved to a required class and required in the subnet, a class evaluated earlier may take precedence. .sp Additional evaluation is also available at shared network and pool levels. The order in which additional classes are considered is: pool, subnet, and shared network, i.e. in the same order from the way in which \fBoption\-data\fP is processed. .sp Since Kea version 2.7.4 additional classes configured without a test expression are unconditionally added, i.e. they are considered to always be evaluated to \fBtrue\fP\&. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Because additional evaluation occurs after lease assignment, parameters that would otherwise impact lease life times (e.g. \fBvalid\-lifetime\fP, \fBoffer\-lifetime\fP) will have no effect when specified in a class that also sets \fBonly\-in\-additional\-list\fP true. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 As of Kea version 2.7.4, \fBonly\-if\-required\fP and \fBrequire\-client\-classes\fP have been renamed to \fBonly\-in\-additional\-list\fP and \fBevaluate\-additional\-classes\fP respectivley. The original names will still be accepted as input to allow users to migrate but will eventually be rejected. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Vendor\-Identifying Vendor Options are a special case: for all other options an option is identified by its code point, but \fBvivco\-suboptions\fP (124) and \fBvivso\-suboptions\fP (125) are identified by the pair of code point and vendor identifier. This has no visible effect for \fBvivso\-suboptions\fP, whose value is the vendor identifier, but it is different for \fBvivco\-suboptions\fP, where the value is a record with the vendor identifier and a binary value. For instance, in: .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqvivco\-suboptions\(dq, \(dqalways\-send\(dq: true, \(dqdata\(dq: \(dq1234, 03666f6f\(dq }, { \(dqname\(dq: \(dqvivco\-suboptions\(dq, \(dqalways\-send\(dq: true, \(dqdata\(dq: \(dq5678, 03626172\(dq }, ... ], ... } .EE .UNINDENT .UNINDENT .sp The first \fBoption\-data\fP entry does not hide the second one, because the vendor identifiers (1234 and 5678) are different: the responses will carry two instances of the \fBvivco\-suboptions\fP option, each for a different vendor. .SS DDNS for DHCPv4 .sp As mentioned earlier, \fI\%kea\-dhcp4\fP can be configured to generate requests to the DHCP\-DDNS server, \fI\%kea\-dhcp\-ddns\fP, (referred to herein as \(dqD2\(dq) to update DNS entries. These requests are known as NameChangeRequests or NCRs. Each NCR contains the following information: .INDENT 0.0 .IP 1. 3 Whether it is a request to add (update) or remove DNS entries. .IP 2. 3 Whether the change requests forward DNS updates (A records), reverse DNS updates (PTR records), or both. .IP 3. 3 The Fully Qualified Domain Name (FQDN), lease address, and DHCID (information identifying the client associated with the FQDN). .UNINDENT .sp DDNS\-related parameters are split into two groups: .INDENT 0.0 .IP 1. 3 Connectivity Parameters .INDENT 3.0 .INDENT 3.5 These are parameters which specify where and how \fI\%kea\-dhcp4\fP connects to and communicates with D2. These parameters can only be specified within the top\-level \fBdhcp\-ddns\fP section in the \fI\%kea\-dhcp4\fP configuration. The connectivity parameters are listed below: .INDENT 0.0 .IP \(bu 2 \fBenable\-updates\fP .IP \(bu 2 \fBserver\-ip\fP .IP \(bu 2 \fBserver\-port\fP .IP \(bu 2 \fBsender\-ip\fP .IP \(bu 2 \fBsender\-port\fP .IP \(bu 2 \fBmax\-queue\-size\fP .IP \(bu 2 \fBncr\-protocol\fP .IP \(bu 2 \fBncr\-format\fP .UNINDENT .UNINDENT .UNINDENT .IP 2. 3 Behavioral Parameters .INDENT 3.0 .INDENT 3.5 These parameters influence behavior such as how client host names and FQDN options are handled. They have been moved out of the \fBdhcp\-ddns\fP section so that they may be specified at the global, shared\-network, subnet, and/or pool levels. Furthermore, they are inherited downward from global to shared\-network to subnet to pool. In other words, if a parameter is not specified at a given level, the value for that level comes from the level above it. The behavioral parameters are as follows: .INDENT 0.0 .IP \(bu 2 \fBddns\-send\-updates\fP .IP \(bu 2 \fBddns\-override\-no\-update\fP .IP \(bu 2 \fBddns\-override\-client\-update\fP .IP \(bu 2 \fBddns\-replace\-client\-name\fP .IP \(bu 2 \fBddns\-generated\-prefix\fP .IP \(bu 2 \fBddns\-qualifying\-suffix\fP .IP \(bu 2 \fBddns\-update\-on\-renew\fP .IP \(bu 2 \fBddns\-conflict\-resolution\-mode\fP .IP \(bu 2 \fBddns\-ttl\fP .IP \(bu 2 \fBddns\-ttl\-percent\fP .IP \(bu 2 \fBddns\-ttl\-min\fP .IP \(bu 2 \fBddns\-ttl\-max\fP .IP \(bu 2 \fBhostname\-char\-set\fP .IP \(bu 2 \fBhostname\-char\-replacement\fP .UNINDENT .UNINDENT .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Kea 2.7.6 added support for these parameters to the pool level. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Behavioral parameters that affect the FQDN are in effect even if both \fBenable\-updates\fP and \fBddns\-send\-updates\fP are \fBfalse\fP, to support environments in which clients are responsible for their own DNS updates. This applies to \fBddns\-replace\-client\-name\fP, \fBddns\-generated\-prefix\fP, \fBddns\-qualifying\-suffix\fP, \fBhostname\-char\-set\fP, and \fBhostname\-char\-replacement\fP\&. .UNINDENT .UNINDENT .sp The default configuration and values would appear as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqdhcp\-ddns\(dq: { // Connectivity parameters \(dqenable\-updates\(dq: false, \(dqserver\-ip\(dq: \(dq127.0.0.1\(dq, \(dqserver\-port\(dq:53001, \(dqsender\-ip\(dq:\(dq\(dq, \(dqsender\-port\(dq:0, \(dqmax\-queue\-size\(dq:1024, \(dqncr\-protocol\(dq:\(dqUDP\(dq, \(dqncr\-format\(dq:\(dqJSON\(dq }, // Behavioral parameters (global) \(dqddns\-send\-updates\(dq: true, \(dqddns\-override\-no\-update\(dq: false, \(dqddns\-override\-client\-update\(dq: false, \(dqddns\-replace\-client\-name\(dq: \(dqnever\(dq, \(dqddns\-generated\-prefix\(dq: \(dqmyhost\(dq, \(dqddns\-qualifying\-suffix\(dq: \(dq\(dq, \(dqddns\-update\-on\-renew\(dq: false, \(dqddns\-conflict\-resolution\-mode\(dq: \(dqcheck\-with\-dhcid\(dq, \(dqhostname\-char\-set\(dq: \(dq\(dq, \(dqhostname\-char\-replacement\(dq: \(dq\(dq, ... } .EE .UNINDENT .UNINDENT .sp There are two parameters which determine whether \fI\%kea\-dhcp4\fP can generate DDNS requests to D2: the existing \fBdhcp\-ddns:enable\-updates\fP parameter, which now only controls whether \fI\%kea\-dhcp4\fP connects to D2; and the new behavioral parameter, \fBddns\-send\-updates\fP, which determines whether DDNS updates are enabled at a given level (i.e. global, shared\-network, or subnet). The following table shows how the two parameters function together: .SS Enabling and disabling DDNS updates .TS box center; l|l|l. T{ dhcp\-ddns: enable\-updates T} T{ Global ddns\-send\-updates T} T{ Outcome T} _ T{ false (default) T} T{ false T} T{ no updates at any scope T} _ T{ false T} T{ true (default) T} T{ no updates at any scope T} _ T{ true T} T{ false T} T{ updates only at scopes with a local value of \fBtrue\fP for \fBddns\-enable\-updates\fP T} _ T{ true T} T{ true T} T{ updates at all scopes except those with a local value of \fBfalse\fP for \fBddns\-enable\-updates\fP T} .TE .sp Kea 1.9.1 added two new parameters; the first is \fBddns\-update\-on\-renew\fP\&. Normally, when leases are renewed, the server only updates DNS if the DNS information for the lease (e.g. FQDN, DNS update direction flags) has changed. Setting \fBddns\-update\-on\-renew\fP to \fBtrue\fP instructs the server to always update the DNS information when a lease is renewed, even if its DNS information has not changed. This allows Kea to \(dqself\-heal\(dq if it was previously unable to add DNS entries or they were somehow lost by the DNS server. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Setting \fBddns\-update\-on\-renew\fP to \fBtrue\fP may impact performance, especially for servers with numerous clients that renew often. .UNINDENT .UNINDENT .sp The second parameter added in Kea 1.9.1 is \fBddns\-use\-conflict\-resolution\fP\&. This boolean parameter was passed through to D2 and enabled or disabled conflict resolution as described in \X'tty: link https://tools.ietf.org/html/rfc4703'\fI\%RFC 4703\fP\X'tty: link'\&. Beginning with Kea 2.5.0, it is deprecated and replaced by \fBddns\-conflict\-resolution\-mode\fP, which offers four modes of conflict resolution\-related behavior: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fBcheck\-with\-dhcid\fP \- This mode, the default, instructs D2 to carry out RFC 4703\-compliant conflict resolution. Existing DNS entries may only be overwritten if they have a DHCID record and it matches the client\(aqs DHCID. This is equivalent to \fBddns\-use\-conflict\-resolution\fP: \fBtrue\fP; .IP \(bu 2 \fBno\-check\-with\-dhcid\fP \- Existing DNS entries may be overwritten by any client, whether those entries include a DHCID record or not. The new entries will include a DHCID record for the client to whom they belong. This is equivalent to \fBddns\-use\-conflict\-resolution\fP: \fBfalse\fP; .IP \(bu 2 \fBcheck\-exists\-with\-dhcid\fP \- Existing DNS entries may only be overwritten if they have a DHCID record. The DHCID record need not match the client\(aqs DHCID. This mode provides a way to protect static DNS entries (those that do not have a DHCID record) while allowing dynamic entries (those that do have a DHCID record) to be overwritten by any client. This behavior was not supported prior to Kea 2.4.0. .IP \(bu 2 \fBno\-check\-without\-dhcid\fP \- Existing DNS entries may be overwritten by any client; new entries will not include DHCID records. This behavior was not supported prior to Kea 2.4.0. .UNINDENT .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 For backward compatibility, \fBddns\-use\-conflict\-resolution\fP is still accepted in JSON configuration. The server replaces the value internally with \fBddns\-conflict\-resolution\-mode\fP and an appropriate value: \fBcheck\-with\-dhcid\fP for \fBtrue\fP and \fBno\-check\-with\-dhcid\fP for \fBfalse\fP\&. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Setting \fBddns\-conflict\-resolution\-mode\fP to any value other than \fBcheck\-with\-dhcid\fP disables the overwrite safeguards that the rules of conflict resolution (from \X'tty: link https://tools.ietf.org/html/rfc4703'\fI\%RFC 4703\fP\X'tty: link') are intended to prevent. This means that existing entries for an FQDN or an IP address made for Client\-A can be deleted or replaced by entries for Client\-B. Furthermore, there are two scenarios by which entries for multiple clients for the same key (e.g. FQDN or IP) can be created. .sp 1. Client\-B uses the same FQDN as Client\-A but a different IP address. In this case, the forward DNS entries (A and DHCID RRs) for Client\-A will be deleted as they match the FQDN, and new entries for Client\-B will be added. The reverse DNS entries (PTR and DHCID RRs) for Client\-A, however, will not be deleted as they belong to a different IP address, while new entries for Client\-B will still be added. .sp 2. Client\-B uses the same IP address as Client\-A but a different FQDN. In this case, the reverse DNS entries (PTR and DHCID RRs) for Client\-A will be deleted as they match the IP address, and new entries for Client\-B will be added. The forward DNS entries (A and DHCID RRs) for Client\-A, however, will not be deleted, as they belong to a different FQDN, while new entries for Client\-B will still be added. .sp Disabling conflict resolution should be done only after careful review of specific use cases. The best way to avoid unwanted DNS entries is to always ensure that lease changes are processed through Kea, whether they are released, expire, or are deleted via the \fI\%lease4\-del\fP command, prior to reassigning either FQDNs or IP addresses. Doing so causes \fI\%kea\-dhcp4\fP to generate DNS removal requests to D2. .UNINDENT .UNINDENT .sp The DNS entries Kea creates contain a value for TTL (time to live). By default, the \fI\%kea\-dhcp4\fP server calculates that value based on \X'tty: link https://tools.ietf.org/html/rfc4702#section-5'\fI\%RFC 4702, Section 5\fP\X'tty: link', which suggests that the TTL value be 1/3 of the lease\(aqs lifetime, with a minimum value of 10 minutes. There are four optional parameters which may be used to influence the TTL calculation: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fBddns\-ttl\fP \- If specified and greater than 0 use it as the value of TTL unconditionally. It is specified in seconds. By default it is unspecified. .IP \(bu 2 \fBddns\-ttl\-percent\fP \- If specified and greater than zero use it as the percentage of the lease life time otherwise use 1/3 (per RFC 4702) of the lease life time. It is specified as a decimal percentage (e.g. 0.75, 0.50) and is unspecified by default. .IP \(bu 2 \fBddns\-ttl\-min\fP \- If specified and greater than 0 use it the minimum otherwise use a minimum of 600 seconds (per RFC 4702). If the calculated TTL is less than the minimum return the minimum. It is specified in seconds. By default it is unspecified. .IP \(bu 2 \fBddns\-ttl\-max\fP \- If specified and greater than zero limit the calculated TTL to its value. It is specified in seconds. By default it is unspecified. .UNINDENT .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 A value of zero for any of the TTL parameters can be used to suppress (i.e. \(dqunspecify\(dq) the value of that parameter inherited from a higher scope. .UNINDENT .UNINDENT .SS DHCP\-DDNS Server Connectivity .sp For NCRs to reach the D2 server, \fI\%kea\-dhcp4\fP must be able to communicate with it. \fI\%kea\-dhcp4\fP uses the following configuration parameters to control this communication: .INDENT 0.0 .IP \(bu 2 \fBenable\-updates\fP \- Enables connectivity to \fI\%kea\-dhcp\-ddns\fP such that DDNS updates can be constructed and sent. It must be \fBtrue\fP for NCRs to be generated and sent to D2. It defaults to \fBfalse\fP\&. .IP \(bu 2 \fBserver\-ip\fP \- This is the IP address on which D2 listens for requests. The default is the local loopback interface at address 127.0.0.1. Either an IPv4 or IPv6 address may be specified. .IP \(bu 2 \fBserver\-port\fP \- This is the port on which D2 listens for requests. The default value is \fB53001\fP\&. .IP \(bu 2 \fBsender\-ip\fP \- This is the IP address which \fI\%kea\-dhcp4\fP uses to send requests to D2. The default value is blank, which instructs \fI\%kea\-dhcp4\fP to select a suitable address. .IP \(bu 2 \fBsender\-port\fP \- This is the port which \fI\%kea\-dhcp4\fP uses to send requests to D2. The default value of \fB0\fP instructs \fI\%kea\-dhcp4\fP to select a suitable port. .IP \(bu 2 \fBmax\-queue\-size\fP \- This is the maximum number of requests allowed to queue while waiting to be sent to D2. This value guards against requests accumulating uncontrollably if they are being generated faster than they can be delivered. If the number of requests queued for transmission reaches this value, DDNS updating is turned off until the queue backlog has been sufficiently reduced. The intent is to allow the \fI\%kea\-dhcp4\fP server to continue lease operations without running the risk that its memory usage grows without limit. The default value is \fB1024\fP\&. .IP \(bu 2 \fBncr\-protocol\fP \- This specifies the socket protocol to use when sending requests to D2. Currently only UDP is supported. .IP \(bu 2 \fBncr\-format\fP \- This specifies the packet format to use when sending requests to D2. Currently only JSON format is supported. .UNINDENT .sp By default, \fI\%kea\-dhcp\-ddns\fP is assumed to be running on the same machine as \fI\%kea\-dhcp4\fP, and all of the default values mentioned above should be sufficient. If, however, D2 has been configured to listen on a different address or port, these values must be altered accordingly. For example, if D2 has been configured to listen on 192.168.1.10 port 900, the following configuration is required: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqdhcp\-ddns\(dq: { \(dqserver\-ip\(dq: \(dq192.168.1.10\(dq, \(dqserver\-port\(dq: 900, ... }, ... } .EE .UNINDENT .UNINDENT .SS When Does the \fI\%kea\-dhcp4\fP Server Generate a DDNS Request? .sp The \fI\%kea\-dhcp4\fP server follows the behavior prescribed for DHCP servers in \X'tty: link https://tools.ietf.org/html/rfc4702'\fI\%RFC 4702\fP\X'tty: link'\&. It is important to keep in mind that \fI\%kea\-dhcp4\fP makes the initial decision of when and what to update and forwards that information to D2 in the form of NCRs. Carrying out the actual DNS updates and dealing with such things as conflict resolution are within the purview of D2 itself (see \fI\%The DHCP\-DDNS Server\fP). This section describes when \fI\%kea\-dhcp4\fP generates NCRs and the configuration parameters that can be used to influence this decision. It assumes that both the connectivity parameter \fBenable\-updates\fP and the behavioral parameter \fBddns\-send\-updates\fP, are \fBtrue\fP\&. .sp In general, \fI\%kea\-dhcp4\fP generates DDNS update requests when: .INDENT 0.0 .IP 1. 3 A new lease is granted in response to a DHCPREQUEST; .IP 2. 3 An existing lease is renewed but the FQDN associated with it has changed; or .IP 3. 3 An existing lease is released in response to a DHCPRELEASE. .UNINDENT .sp In the second case, lease renewal, two DDNS requests are issued: one request to remove entries for the previous FQDN, and a second request to add entries for the new FQDN. In the third case, a lease release \- a single DDNS request \- to remove its entries is made. .sp As for the first case, the decisions involved when granting a new lease are more complex. When a new lease is granted, \fI\%kea\-dhcp4\fP generates a DDNS update request if the DHCPREQUEST contains either the FQDN option (code 81) or the Host Name option (code 12). If both are present, the server uses the FQDN option. By default, \fI\%kea\-dhcp4\fP respects the FQDN N and S flags specified by the client as shown in the following table: .SS Default FQDN flag behavior .TS box center; l|l|l|l. T{ Client Flags:N\-S T} T{ Client Intent T} T{ Server Response T} T{ Server Flags:N\-S\-O T} _ T{ 0\-0 T} T{ Client wants to do forward updates, server should do reverse updates T} T{ Server generates reverse\-only request T} T{ 1\-0\-0 T} _ T{ 0\-1 T} T{ Server should do both forward and reverse updates T} T{ Server generates request to update both directions T} T{ 0\-1\-0 T} _ T{ 1\-0 T} T{ Client wants no updates done T} T{ Server does not generate a request T} T{ 1\-0\-0 T} .TE .sp The first row in the table above represents \(dqclient delegation.\(dq Here the DHCP client states that it intends to do the forward DNS updates and the server should do the reverse updates. By default, \fI\%kea\-dhcp4\fP honors the client\(aqs wishes and generates a DDNS request to the D2 server to update only reverse DNS data. The parameter \fBddns\-override\-client\-update\fP can be used to instruct the server to override client delegation requests. When this parameter is \fBtrue\fP, \fI\%kea\-dhcp4\fP disregards requests for client delegation and generates a DDNS request to update both forward and reverse DNS data. In this case, the N\-S\-O flags in the server\(aqs response to the client will be 0\-1\-1 respectively. .sp (Note that the flag combination N=1, S=1 is prohibited according to \X'tty: link https://tools.ietf.org/html/rfc4702'\fI\%RFC 4702\fP\X'tty: link'\&. If such a combination is received from the client, the packet is dropped by \fI\%kea\-dhcp4\fP\&.) .sp To override client delegation, set the following values in the configuration file: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqddns\-override\-client\-update\(dq: true, ... } .EE .UNINDENT .UNINDENT .sp The third row in the table above describes the case in which the client requests that no DNS updates be done. The parameter \fBddns\-override\-no\-update\fP can be used to instruct the server to disregard the client\(aqs wishes. When this parameter is \fBtrue\fP, \fI\%kea\-dhcp4\fP generates DDNS update requests to \fI\%kea\-dhcp\-ddns\fP even if the client requests that no updates be done. The N\-S\-O flags in the server\(aqs response to the client will be 0\-1\-1. .sp To override client delegation, issue the following commands: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqddns\-override\-no\-update\(dq: true, ... } .EE .UNINDENT .UNINDENT .sp The \fI\%kea\-dhcp4\fP server always generates DDNS update requests if the client request only contains the Host Name option. In addition, it includes an FQDN option in the response to the client with the FQDN N\-S\-O flags set to 0\-1\-0, respectively. The domain name portion of the FQDN option is the name submitted to D2 in the DDNS update request. .SS \fI\%kea\-dhcp4\fP Name Generation for DDNS Update Requests .sp Each NameChangeRequest must of course include the fully qualified domain name whose DNS entries are to be affected. \fI\%kea\-dhcp4\fP can be configured to supply a portion or all of that name, based on what it receives from the client in the DHCPREQUEST. .sp The default rules for constructing the FQDN that will be used for DNS entries are: .INDENT 0.0 .IP 1. 3 If the DHCPREQUEST contains the client FQDN option, take the candidate name from there; otherwise, take it from the Host Name option. .IP 2. 3 If the candidate name is a partial (i.e. unqualified) name, then add a configurable suffix to the name and use the result as the FQDN. .IP 3. 3 If the candidate name provided is empty, generate an FQDN using a configurable prefix and suffix. .IP 4. 3 If the client provides neither option, then take no DNS action. .UNINDENT .sp These rules can be amended by setting the \fBddns\-replace\-client\-name\fP parameter, which provides the following modes of behavior: .INDENT 0.0 .IP \(bu 2 \fBnever\fP \- use the name the client sent. If the client sent no name, do not generate one. This is the default mode. .IP \(bu 2 \fBalways\fP \- replace the name the client sent. If the client sent no name, generate one for the client. .IP \(bu 2 \fBwhen\-present\fP \- replace the name the client sent. If the client sent no name, do not generate one. .IP \(bu 2 \fBwhen\-not\-present\fP \- use the name the client sent. If the client sent no name, generate one for the client. .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 In early versions of Kea, this parameter was a boolean and permitted only values of \fBtrue\fP and \fBfalse\fP\&. Boolean values have been deprecated and are no longer accepted. Administrators currently using booleans must replace them with the desired mode name. A value of \fBtrue\fP maps to \fBwhen\-present\fP, while \fBfalse\fP maps to \fBnever\fP\&. .UNINDENT .UNINDENT .sp For example, to instruct \fI\%kea\-dhcp4\fP to always generate the FQDN for a client, set the parameter \fBddns\-replace\-client\-name\fP to \fBalways\fP as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqddns\-replace\-client\-name\(dq: \(dqalways\(dq, ... } .EE .UNINDENT .UNINDENT .sp The prefix used in the generation of an FQDN is specified by the \fBddns\-generated\-prefix\fP parameter. The default value is \(dqmyhost\(dq. To alter its value, simply set it to the desired string: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqddns\-generated\-prefix\(dq: \(dqanother.host\(dq, ... } .EE .UNINDENT .UNINDENT .sp The suffix used when generating an FQDN, or when qualifying a partial name, is specified by the \fBddns\-qualifying\-suffix\fP parameter. It is strongly recommended that the user supply a value for the qualifying suffix when DDNS updates are enabled. For obvious reasons, we cannot supply a meaningful default. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqddns\-qualifying\-suffix\(dq: \(dqfoo.example.org\(dq, ... } .EE .UNINDENT .UNINDENT .sp When qualifying a partial name, \fI\%kea\-dhcp4\fP constructs the name in the format: .sp \fB[candidate\-name].[ddns\-qualifying\-suffix].\fP .sp where \fBcandidate\-name\fP is the partial name supplied in the DHCPREQUEST. For example, if the FQDN domain name value is \(dqsome\-computer\(dq and the \fBddns\-qualifying\-suffix\fP is \(dqexample.com\(dq, the generated FQDN is: .sp \fBsome\-computer.example.com.\fP .sp When generating the entire name, \fI\%kea\-dhcp4\fP constructs the name in the format: .sp \fB[ddns\-generated\-prefix]\-[address\-text].[ddns\-qualifying\-suffix].\fP .sp where \fBaddress\-text\fP is simply the lease IP address converted to a hyphenated string. For example, if the lease address is 172.16.1.10, the qualifying suffix is \(dqexample.com\(dq, and the default value is used for \fBddns\-generated\-prefix\fP, the generated FQDN is: .sp \fBmyhost\-172\-16\-1\-10.example.com.\fP .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 When the client sends the host name option, \fBkea\-dhcp4\fP never adds a dot to the host name in the returned option. It will only end with a dot if the client sent it already qualified and ending with a dot. When the client sends the FQDN option, the FQDN returned in the response will always end with a dot. .UNINDENT .UNINDENT .SS Sanitizing Client Host Name and FQDN Names .sp Some DHCP clients may provide values in the Host Name option (option code 12) or FQDN option (option code 81) that contain undesirable characters. It is possible to configure \fI\%kea\-dhcp4\fP to sanitize these values. The most typical use case is ensuring that only characters that are permitted by RFC 1035 be included: A\-Z, a\-z, 0\-9, and \(dq\-\(dq. This may be accomplished with the following two parameters: .INDENT 0.0 .IP \(bu 2 \fBhostname\-char\-set\fP \- a regular expression describing the invalid character set. This can be any valid, regular expression using POSIX extended expression syntax. Embedded nulls (0x00) are always considered an invalid character to be replaced (or omitted). The default is \fB\(dq[^A\-Za\-z0\-9.\-]\(dq\fP\&. This matches any character that is not a letter, digit, dot, hyphen, or null. .IP \(bu 2 \fBhostname\-char\-replacement\fP \- a string of zero or more characters with which to replace each invalid character in the host name. An empty string causes invalid characters to be OMITTED rather than replaced. The default is \fB\(dq\(dq\fP\&. .UNINDENT .sp The following configuration replaces anything other than a letter, digit, dot, or hyphen with the letter \(dqx\(dq: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqhostname\-char\-set\(dq: \(dq[^A\-Za\-z0\-9.\-]\(dq, \(dqhostname\-char\-replacement\(dq: \(dqx\(dq, ... } .EE .UNINDENT .UNINDENT .sp Thus, a client\-supplied value of \(dqmyhost\-$[123.org\(dq would become \(dqmyhost\-xx123.org\(dq. Sanitizing is performed only on the portion of the name supplied by the client, and it is performed before applying a qualifying suffix (if one is defined and needed). .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Name sanitizing is meant to catch the more common cases of invalid characters through a relatively simple character\-replacement scheme. It is difficult to devise a scheme that works well in all cases, for both Host Name and FQDN options. Administrators who find they have clients with odd corner cases of character combinations that cannot be readily handled with this mechanism should consider writing a hook that can carry out sufficiently complex logic to address their needs. .sp If clients include domain names in the Host Name option and the administrator wants these preserved, they need to make sure that the dot, \(dq.\(dq, is considered a valid character by the \fBhostname\-char\-set\fP expression, such as this: \fB\(dq[^A\-Za\-z0\-9.\-]\(dq\fP\&. This does not affect dots in FQDN Option values. When scrubbing FQDNs, dots are treated as delimiters and used to separate the option value into individual domain labels that are scrubbed and then re\-assembled. .sp If clients are sending values that differ only by characters considered as invalid by the \fBhostname\-char\-set\fP, be aware that scrubbing them will yield identical values. In such cases, DDNS conflict rules will permit only one of them to register the name. .sp Finally, given the latitude clients have in the values they send, it is virtually impossible to guarantee that a combination of these two parameters will always yield a name that is valid for use in DNS. For example, using an empty value for \fBhostname\-char\-replacement\fP could yield an empty domain label within a name, if that label consists only of invalid characters. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 It is possible to specify \fBhostname\-char\-set\fP and/or \fBhostname\-char\-replacement\fP at the global scope. .sp The Kea hook library \fI\%libdhcp_ddns_tuning.so\fP provides the ability for both \fI\%kea\-dhcp4\fP and \fI\%kea\-dhcp6\fP to generate host names procedurally based on an expression, to skip DDNS updates on a per\-client basis, or to fine\-tune various DNS update aspects. Please refer to the \fI\%libdhcp_ddns_tuning.so: DDNS Tuning\fP documentation for the configuration options. .UNINDENT .UNINDENT .SS Next Server (\fBsiaddr\fP) .sp In some cases, clients want to obtain configuration from a TFTP server. Although there is a dedicated option for it, some devices may use the \fBsiaddr\fP field in the DHCPv4 packet for that purpose. That specific field can be configured using the \fBnext\-server\fP directive. It is possible to define it in the global scope or for a given subnet only. If both are defined, the subnet value takes precedence. The value in the subnet can be set to \(dq0.0.0.0\(dq, which means that \fBnext\-server\fP should not be sent. It can also be set to an empty string, which is equivalent to it not being defined at all; that is, it uses the global value. .sp The \fBserver\-hostname\fP (which conveys a server hostname, can be up to 64 bytes long, and is in the \fBsname\fP field) and \fBboot\-file\-name\fP (which conveys the configuration file, can be up to 128 bytes long, and is sent using the \fBfile\fP field) directives are handled the same way as \fBnext\-server\fP\&. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqnext\-server\(dq: \(dq192.0.2.123\(dq, \(dqboot\-file\-name\(dq: \(dq/dev/null\(dq, \(dqsubnet4\(dq: [ { \(dqnext\-server\(dq: \(dq192.0.2.234\(dq, \(dqserver\-hostname\(dq: \(dqsome\-name.example.org\(dq, \(dqboot\-file\-name\(dq: \(dqbootfile.efi\(dq, ... } ], ... } .EE .UNINDENT .UNINDENT .SS Echoing Client\-ID (RFC 6842) .sp The original DHCPv4 specification (\X'tty: link https://tools.ietf.org/html/rfc2131'\fI\%RFC 2131\fP\X'tty: link') states that the DHCPv4 server must not send back client\-id options when responding to clients. However, in some cases that results in confused clients that do not have a MAC address or client\-id; see \X'tty: link https://tools.ietf.org/html/rfc6842'\fI\%RFC 6842\fP\X'tty: link' for details. That behavior changed with the publication of \X'tty: link https://tools.ietf.org/html/rfc6842'\fI\%RFC 6842\fP\X'tty: link', which updated \X'tty: link https://tools.ietf.org/html/rfc2131'\fI\%RFC 2131\fP\X'tty: link'\&. That update states that the server must send the client\-id if the client sent it, and that is Kea\(aqs default behavior. However, in some cases older devices that do not support \X'tty: link https://tools.ietf.org/html/rfc6842'\fI\%RFC 6842\fP\X'tty: link' may refuse to accept responses that include the client\-id option. To enable backward compatibility, an optional configuration parameter has been introduced. To configure it, use the following configuration statement: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqecho\-client\-id\(dq: false, ... } .EE .UNINDENT .UNINDENT .SS Using Client Identifier and Hardware Address .sp The DHCP server must be able to identify the client from which it receives the message and distinguish it from other clients. There are many reasons why this identification is required; the most important ones are: .INDENT 0.0 .IP \(bu 2 When the client contacts the server to allocate a new lease, the server must store the client identification information in the lease database as a search key. .IP \(bu 2 When the client tries to renew or release the existing lease, the server must be able to find the existing lease entry in the database for this client, using the client identification information as a search key. .IP \(bu 2 Some configurations use static reservations for the IP addresses and other configuration information. The server\(aqs administrator uses client identification information to create these static assignments. .IP \(bu 2 In dual\-stack networks there is often a need to correlate the lease information stored in DHCPv4 and DHCPv6 servers for a particular host. Using common identification information by the DHCPv4 and DHCPv6 clients allows the network administrator to achieve this correlation and better administer the network. Beginning with release 2.1.2, Kea supports DHCPv6 DUIDs embedded within DHCPv4 Client Identifier options as described in \X'tty: link https://tools.ietf.org/html/rfc4361'\fI\%RFC 4361\fP\X'tty: link'\&. .UNINDENT .sp DHCPv4 uses two distinct identifiers which are placed by the client in the queries sent to the server and copied by the server to its responses to the client: \fBchaddr\fP and \fBclient\-identifier\fP\&. The former was introduced as a part of the BOOTP specification and it is also used by DHCP to carry the hardware address of the interface used to send the query to the server (MAC address for the Ethernet). The latter is carried in the client\-identifier option, introduced in \X'tty: link https://tools.ietf.org/html/rfc2132'\fI\%RFC 2132\fP\X'tty: link'\&. .sp \X'tty: link https://tools.ietf.org/html/rfc2131'\fI\%RFC 2131\fP\X'tty: link' indicates that the server may use both of these identifiers to identify the client but the client identifier, if present, takes precedence over \fBchaddr\fP\&. One of the reasons for this is that the client identifier is independent from the hardware used by the client to communicate with the server. For example, if the client obtained the lease using one network card and then the network card is moved to another host, the server will wrongly identify this host as the one which obtained the lease. Moreover, \X'tty: link https://tools.ietf.org/html/rfc4361'\fI\%RFC 4361\fP\X'tty: link' gives the recommendation to use a DUID (see \X'tty: link https://tools.ietf.org/html/rfc8415'\fI\%RFC 8415\fP\X'tty: link', the DHCPv6 specification) carried as a client identifier when dual\-stack networks are in use to provide consistent identification information for the client, regardless of the type of protocol it is using. Kea adheres to these specifications, and the client identifier by default takes precedence over the value carried in the \fBchaddr\fP field when the server searches, creates, updates, or removes the client\(aqs lease. .sp When the server receives a DHCPDISCOVER or DHCPREQUEST message from the client, it tries to find out if the client already has a lease in the database; if it does, the server hands out that lease rather than allocates a new one. Each lease in the lease database is associated with the client identifier and/or \fBchaddr\fP\&. The server first uses the client identifier (if present) to search for the lease; if one is found, the server treats this lease as belonging to the client, even if the current \fBchaddr\fP and the \fBchaddr\fP associated with the lease do not match. This facilitates the scenario when the network card on the client system has been replaced and thus the new MAC address appears in the messages sent by the DHCP client. If the server fails to find the lease using the client identifier, it performs another lookup using the \fBchaddr\fP\&. If this lookup returns no result, the client is considered to not have a lease and a new lease is created. .sp A common problem reported by network operators is that poor client implementations do not use stable client identifiers, instead generating a new client identifier each time the client connects to the network. Another well\-known case is when the client changes its client identifier during the multi\-stage boot process (PXE). In such cases, the MAC address of the client\(aqs interface remains stable, and using the \fBchaddr\fP field to identify the client guarantees that the particular system is considered to be the same client, even though its client identifier changes. .sp To address this problem, Kea includes a configuration option which enables client identification using \fBchaddr\fP only. This instructs the server to ignore the client identifier during lease lookups and allocations for a particular subnet. Consider the following simplified server configuration: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp4\(dq: { \(dqmatch\-client\-id\(dq: true, \(dqsubnet4\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq192.0.10.0/24\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.2.23\-192.0.2.87\(dq } ], \(dqmatch\-client\-id\(dq: false }, { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq10.0.0.0/8\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq10.0.0.23\-10.0.2.99\(dq } ] } ] } } .EE .UNINDENT .UNINDENT .sp The \fBmatch\-client\-id\fP parameter is a boolean value which controls this behavior. The default value of \fBtrue\fP indicates that the server will use the client identifier for lease lookups and \fBchaddr\fP if the first lookup returns no results. \fBfalse\fP means that the server will only use the \fBchaddr\fP to search for the client\(aqs lease. Whether the DHCID for DNS updates is generated from the client identifier or \fBchaddr\fP is controlled through the same parameter. .sp The \fBmatch\-client\-id\fP parameter may appear both in the global configuration scope and/or under any subnet declaration. In the example shown above, the effective value of the \fBmatch\-client\-id\fP will be \fBfalse\fP for the subnet 192.0.10.0/24, because the subnet\-specific setting of the parameter overrides the global value of the parameter. The effective value of the \fBmatch\-client\-id\fP for the subnet 10.0.0.0/8 will be set to \fBtrue\fP, because the subnet declaration lacks this parameter and the global setting is by default used for this subnet. In fact, the global entry for this parameter could be omitted in this case, because \fBtrue\fP is the default value. .sp It is important to understand what happens when the client obtains its lease for one setting of the \fBmatch\-client\-id\fP and then renews it when the setting has been changed. First, consider the case when the client obtains the lease and the \fBmatch\-client\-id\fP is set to \fBtrue\fP\&. The server stores the lease information, including the client identifier (if supplied) and \fBchaddr\fP, in the lease database. When the setting is changed and the client renews the lease, the server will determine that it should use the \fBchaddr\fP to search for the existing lease. If the client has not changed its MAC address, the server should successfully find the existing lease. The client identifier associated with the returned lease will be ignored and the client will be allowed to use this lease. When the lease is renewed only the \fBchaddr\fP will be recorded for this lease, according to the new server setting. .sp In the second case, the client has the lease with only a \fBchaddr\fP value recorded. When the \fBmatch\-client\-id\fP setting is changed to \fBtrue\fP, the server will first try to use the client identifier to find the existing client\(aqs lease. This will return no results because the client identifier was not recorded for this lease. The server will then use the \fBchaddr\fP and the lease will be found. If the lease appears to have no client identifier recorded, the server will assume that this lease belongs to the client and that it was created with the previous setting of the \fBmatch\-client\-id\fP\&. However, if the lease contains a client identifier which is different from the client identifier used by the client, the lease will be assumed to belong to another client and a new lease will be allocated. .sp For a more visual representation of how Kea recognizes the same client, please refer to \fI\%How Kea Recognizes the Same Client In Different DHCP Messages\fP\&. .SS Authoritative DHCPv4 Server Behavior .sp The original DHCPv4 specification (\X'tty: link https://tools.ietf.org/html/rfc2131'\fI\%RFC 2131\fP\X'tty: link') states that if a client requests an address in the INIT\-REBOOT state of which the server has no knowledge, the server must remain silent, except if the server knows that the client has requested an IP address from the wrong network. By default, Kea follows the behavior of the ISC \fBdhcpd\fP daemon instead of the specification and also remains silent if the client requests an IP address from the wrong network, because configuration information about a given network segment is not known to be correct. Kea only rejects a client\(aqs DHCPREQUEST with a DHCPNAK message if it already has a lease for the client with a different IP address. Administrators can override this behavior through the boolean \fBauthoritative\fP (\fBfalse\fP by default) setting. .sp In authoritative mode, \fBauthoritative\fP set to \fBtrue\fP, Kea always rejects INIT\-REBOOT requests from unknown clients with DHCPNAK messages. The \fBauthoritative\fP setting can be specified in global, shared\-network, and subnet configuration scope and is automatically inherited from the parent scope, if not specified. All subnets in a shared\-network must have the same \fBauthoritative\fP setting. .SS DHCPv4\-over\-DHCPv6: DHCPv4 Side .sp The support of DHCPv4\-over\-DHCPv6 transport is described in \X'tty: link https://tools.ietf.org/html/rfc7341'\fI\%RFC 7341\fP\X'tty: link' and is implemented using cooperating DHCPv4 and DHCPv6 servers. This section is about the configuration of the DHCPv4 side (the DHCPv6 side is described in \fI\%DHCPv4\-over\-DHCPv6: DHCPv6 Side\fP). .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The DHCPv4\-over\-DHCPv6 details of the inter\-process communication may change; for instance, the support of port relay (RFC 8357) introduced an incompatible change. Both the DHCPv4 and DHCPv6 sides should be running the same version of Kea. .UNINDENT .UNINDENT .sp The \fBdhcp4o6\-port\fP global parameter specifies the first of the two consecutive ports of the UDP sockets used for the communication between the DHCPv6 and DHCPv4 servers. The DHCPv4 server is bound to ::1 on \fBport\fP + 1 and connected to ::1 on \fBport\fP\&. .sp With DHCPv4\-over\-DHCPv6, the DHCPv4 server does not have access to several of the identifiers it would normally use to select a subnet. To address this issue, three new configuration entries are available; the presence of any of these allows the subnet to be used with DHCPv4\-over\-DHCPv6. These entries are: .INDENT 0.0 .IP \(bu 2 \fB4o6\-subnet\fP: takes a prefix (i.e., an IPv6 address followed by a slash and a prefix length) which is matched against the source address. .IP \(bu 2 \fB4o6\-interface\-id\fP: takes a relay interface ID option value. .IP \(bu 2 \fB4o6\-interface\fP: takes an interface name which is matched against the incoming interface name. .UNINDENT .sp ISC tested the following configuration: .INDENT 0.0 .INDENT 3.5 .sp .EX { # DHCPv4 conf \(dqDhcp4\(dq: { \(dqinterfaces\-config\(dq: { \(dqinterfaces\(dq: [ \(dqeno33554984\(dq ] }, \(dqlease\-database\(dq: { \(dqtype\(dq: \(dqmemfile\(dq, \(dqname\(dq: \(dqleases4\(dq }, \(dqvalid\-lifetime\(dq: 4000, \(dqsubnet4\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq10.10.10.0/24\(dq, \(dq4o6\-interface\(dq: \(dqeno33554984\(dq, \(dq4o6\-subnet\(dq: \(dq2001:db8:1:1::/64\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq10.10.10.100 \- 10.10.10.199\(dq } ] } ], \(dqdhcp4o6\-port\(dq: 786, \(dqloggers\(dq: [ { \(dqname\(dq: \(dqkea\-dhcp4\(dq, \(dqoutput\-options\(dq: [ { \(dqoutput\(dq: \(dqkea\-dhcp4.log\(dq } ], \(dqseverity\(dq: \(dqDEBUG\(dq, \(dqdebuglevel\(dq: 0 } ] } } .EE .UNINDENT .UNINDENT .SS Sanity Checks in DHCPv4 .sp An important aspect of a well\-running DHCP system is an assurance that the data remains consistent; however, in some cases it may be convenient to tolerate certain inconsistent data. For example, a network administrator who temporarily removes a subnet from a configuration would not want all the leases associated with it to disappear from the lease database. Kea has a mechanism to implement sanity checks for situations like this. .sp Kea supports a configuration scope called \fBsanity\-checks\fP\&. A parameter, called \fBlease\-checks\fP, governs the verification carried out when a new lease is loaded from a lease file. This mechanism permits Kea to attempt to correct inconsistent data. .sp Every subnet has a \fBsubnet\-id\fP value; this is how Kea internally identifies subnets. Each lease has a \fBsubnet\-id\fP parameter as well, which identifies the subnet it belongs to. However, if the configuration has changed, it is possible that a lease could exist with a \fBsubnet\-id\fP but without any subnet that matches it. Also, it is possible that the subnet\(aqs configuration has changed and the \fBsubnet\-id\fP now belongs to a subnet that does not match the lease. .sp Kea\(aqs corrective algorithm first checks to see if there is a subnet with the \fBsubnet\-id\fP specified by the lease. If there is, it verifies whether the lease belongs to that subnet. If not, depending on the \fBlease\-checks\fP setting, the lease is discarded, a warning is displayed, or a new subnet is selected for the lease that matches it topologically. .sp There are five levels which are supported: .INDENT 0.0 .IP \(bu 2 \fBnone\fP \- do no special checks; accept the lease as is. .IP \(bu 2 \fBwarn\fP \- if problems are detected display a warning, but accept the lease data anyway. This is the default value. .IP \(bu 2 \fBfix\fP \- if a data inconsistency is discovered, try to correct it. If the correction is not successful, insert the incorrect data anyway. .IP \(bu 2 \fBfix\-del\fP \- if a data inconsistency is discovered, try to correct it. If the correction is not successful, reject the lease. This setting ensures the data\(aqs correctness, but some incorrect data may be lost. Use with care. .IP \(bu 2 \fBdel\fP \- if any inconsistency is detected, reject the lease. This is the strictest mode; use with care. .UNINDENT .sp This feature is currently implemented for the memfile backend. The sanity check applies to the lease database in memory, not to the lease file, i.e. inconsistent leases stay in the lease file. .sp An example configuration that sets this parameter looks as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqsanity\-checks\(dq: { \(dqlease\-checks\(dq: \(dqfix\-del\(dq }, ... } .EE .UNINDENT .UNINDENT .SS Storing Extended Lease Information .sp To support such features as DHCP Leasequery (\X'tty: link https://tools.ietf.org/html/rfc4388'\fI\%RFC 4388\fP\X'tty: link') and stash agent options (\fI\%Stash Agent Options\fP), additional information must be stored with each lease. Because the amount of information for each lease has ramifications in terms of performance and system resource consumption, storage of this additional information is configurable through the \fBstore\-extended\-info\fP parameter. It defaults to \fBfalse\fP and may be set at the global, shared\-network, and subnet levels. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqstore\-extended\-info\(dq: true, ... } .EE .UNINDENT .UNINDENT .sp When set to \fBtrue\fP, information relevant to the DHCPREQUEST asking for the lease is added into the lease\(aqs user context as a map element labeled \(dqISC\(dq. When the DHCPREQUEST received contains the option (DHCP Option 82), the map contains the \fBrelay\-agent\-info\fP map with the content option (DHCP Option 82) in the \fBsub\-options\fP entry and, when present, the \fBremote\-id\fP and \fBrelay\-id\fP options. Since DHCPREQUESTs sent as renewals are not likely to contain this information, the values taken from the last DHCPREQUEST that did contain it are retained on the lease. The lease\(aqs user context looks something like this: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqISC\(dq: { \(dqrelay\-agent\-info\(dq: { \(dqsub\-options\(dq: \(dq0x0104AABBCCDD\(dq } } } .EE .UNINDENT .UNINDENT .sp Or with remote and relay sub\-options: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqISC\(dq: { \(dqrelay\-agent\-info\(dq: { \(dqsub\-options\(dq: \(dq0x02030102030C03AABBCC\(dq, \(dqremote\-id\(dq: \(dq03010203\(dq, \(dqrelay\-id\(dq: \(dqAABBCC\(dq } } } .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 It is possible that other hook libraries are already using \fBuser\-context\fP\&. Enabling \fBstore\-extended\-info\fP should not interfere with any other \fBuser\-context\fP content, as long as it does not also use an element labeled \(dqISC\(dq. In other words, \fBuser\-context\fP is intended to be a flexible container serving multiple purposes. As long as no other purpose also writes an \(dqISC\(dq element to \fBuser\-context\fP there should not be a conflict. .UNINDENT .UNINDENT .sp Extended lease information is also subject to configurable sanity checking. The parameter in the \fBsanity\-checks\fP scope is named \fBextended\-info\-checks\fP and supports these levels: .INDENT 0.0 .IP \(bu 2 \fBnone\fP \- do no check nor upgrade. This level should be used only when extended info is not used at all or when no badly formatted extended info, including using the old format, is expected. .IP \(bu 2 \fBfix\fP \- fix some common inconsistencies and upgrade extended info using the old format to the new one. It is the default level and is convenient when the Leasequery hook library is not loaded. .IP \(bu 2 \fBstrict\fP \- fix all inconsistencies which have an impact on the (Bulk) Leasequery hook library. .IP \(bu 2 \fBpedantic\fP \- enforce full conformance to the format produced by the Kea code; for instance, no extra entries are allowed with the exception of \fBcomment\fP\&. .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 This feature is currently implemented only for the memfile backend. The sanity check applies to the lease database in memory, not to the lease file, i.e. inconsistent leases stay in the lease file. .UNINDENT .UNINDENT .SS Stash Agent Options .sp This global parameter was added in version 2.5.8 to mirror a feature that was previously available in ISC DHCP. When the \fBstash\-agent\-options\fP parameter is \fBtrue\fP, the server records the relay agent information options sent during the client\(aqs initial DHCPREQUEST message (when the client was in the SELECTING state) and behaves as if those options are included in all subsequent DHCPREQUEST messages sent in the RENEWING state. This works around a problem with relay agent information options, which do not usually appear in DHCPREQUEST messages sent by the client in the RENEWING state; such messages are unicast directly to the server and are not sent through a relay agent. .sp The default is \fBfalse\fP\&. .SS Multi\-Threading Settings .sp The Kea server can be configured to process packets in parallel using multiple threads. These settings can be found under the \fBmulti\-threading\fP structure and are represented by: .INDENT 0.0 .IP \(bu 2 \fBenable\-multi\-threading\fP \- use multiple threads to process packets in parallel. The default is \fBtrue\fP\&. .IP \(bu 2 \fBthread\-pool\-size\fP \- specify the number of threads to process packets in parallel. It may be set to \fB0\fP (auto\-detect), or any positive number that explicitly sets the thread count. The default is \fB0\fP\&. .IP \(bu 2 \fBpacket\-queue\-size\fP \- specify the size of the queue used by the thread pool to process packets. It may be set to \fB0\fP (unlimited), or any positive number that explicitly sets the queue size. The default is \fB64\fP\&. .UNINDENT .sp An example configuration that sets these parameters looks as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqmulti\-threading\(dq: { \(dqenable\-multi\-threading\(dq: true, \(dqthread\-pool\-size\(dq: 4, \(dqpacket\-queue\-size\(dq: 16 }, ... } .EE .UNINDENT .UNINDENT .SS Multi\-Threading Settings With Different Database Backends .sp The Kea DHCPv4 server is benchmarked by ISC to determine which settings give the best performance. Although this section describes our results, they are merely recommendations and are very dependent on the particular hardware used for benchmarking. We strongly advise that administrators run their own performance benchmarks. .sp A full report of performance results for the latest stable Kea version can be found \X'tty: link https://reports.kea.isc.org/'\fI\%here\fP\X'tty: link'\&. This includes hardware and benchmark scenario descriptions, as well as current results. .sp After enabling multi\-threading, the number of threads is set by the \fBthread\-pool\-size\fP parameter. Results from our experiments show that the best settings for \fI\%kea\-dhcp4\fP are: .INDENT 0.0 .IP \(bu 2 \fBthread\-pool\-size\fP: 4 when using \fBmemfile\fP for storing leases. .IP \(bu 2 \fBthread\-pool\-size\fP: 12 or more when using \fBmysql\fP for storing leases. .IP \(bu 2 \fBthread\-pool\-size\fP: 8 when using \fBpostgresql\fP\&. .UNINDENT .sp Another very important parameter is \fBpacket\-queue\-size\fP; in our benchmarks we used it as a multiplier of \fBthread\-pool\-size\fP\&. The actual setting strongly depends on \fBthread\-pool\-size\fP\&. .sp We saw the best results in our benchmarks with the following settings: .INDENT 0.0 .IP \(bu 2 \fBpacket\-queue\-size\fP: 7 * \fBthread\-pool\-size\fP when using \fBmemfile\fP for storing leases; in our case it was 7 * 4 = 28. This means that at any given time, up to 28 packets could be queued. .IP \(bu 2 \fBpacket\-queue\-size\fP: 66 * \fBthread\-pool\-size\fP when using \fBmysql\fP for storing leases; in our case it was 66 * 12 = 792. This means that up to 792 packets could be queued. .IP \(bu 2 \fBpacket\-queue\-size\fP: 11 * \fBthread\-pool\-size\fP when using \fBpostgresql\fP for storing leases; in our case it was 11 * 8 = 88. .UNINDENT .SS IPv6\-Only Preferred Networks .sp \X'tty: link https://tools.ietf.org/html/rfc8925'\fI\%RFC 8925\fP\X'tty: link', recently published by the IETF, specifies a DHCPv4 option to indicate that a host supports an IPv6\-only mode and is willing to forgo obtaining an IPv4 address if the network provides IPv6 connectivity. The general idea is that a network administrator can enable this option to signal to compatible dual\-stack devices that IPv6 connectivity is available and they can shut down their IPv4 stack. The new option \fBv6\-only\-preferred\fP content is a 32\-bit unsigned integer and specifies for how long the device should disable its stack. The value is expressed in seconds. .sp The RFC mentions the \fBV6ONLY_WAIT\fP timer. This is implemented in Kea by setting the value of the \fBv6\-only\-preferred\fP option. This follows the usual practice of setting options; the option value can be specified on the pool, subnet, shared network, or global levels, or even via host reservations. .sp There is no special processing involved; it follows the standard Kea option processing regime. The option is not sent back unless the client explicitly requests it. For example, to enable the option for the whole subnet, the following configuration can be used: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqsubnet4\(dq: [ { \(dqid\(dq: 1, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.2.1 \- 192.0.2.200\(dq } ], \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq, \(dqoption\-data\(dq: [ { // This will make the v6\-only capable devices to disable their // v4 stack for half an hour and then try again \(dqname\(dq: \(dqv6\-only\-preferred\(dq, \(dqdata\(dq: \(dq1800\(dq } ] } ], \&... } .EE .UNINDENT .UNINDENT .SS Lease Caching .sp Clients that attempt multiple renewals in a short period can cause the server to update and write to the database frequently, resulting in a performance impact on the server. The cache parameters instruct the DHCP server to avoid updating leases too frequently, thus avoiding this behavior. Instead, the server assigns the same lease (i.e. reuses it) with no modifications except for CLTT (Client Last Transmission Time), which does not require disk operations. .sp The two parameters are the \fBcache\-threshold\fP double and the \fBcache\-max\-age\fP integer. These parameters can be configured at the global, shared\-network, and subnet levels. The subnet level has precedence over the shared\-network level, while the global level is used as a last resort. For example: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqsubnet4\(dq: [ { \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.2.1 \- 192.0.2.200\(dq } ], \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq, \(dqcache\-threshold\(dq: .25, \(dqcache\-max\-age\(dq: 600, \(dqvalid\-lifetime\(dq: 2000, ... } ], \&... } .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Beginning with Kea 2.7.8, the default value for \fBcache\-threshold\fP is 0.25 while \fBcache\-max\-age\fP is left unspecified. This means that lease caching is enabled by default. It may be disabled at the desired scope either by setting \fBcache\-threshold\fP to 0.0 or setting \fBcache\-max\-age\fP to 0. .UNINDENT .UNINDENT .sp When an already\-assigned lease can fulfill a client query: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 any important change, e.g. for DDNS parameter, hostname, or valid lifetime reduction, makes the lease not reusable. .IP \(bu 2 lease age, i.e. the difference between the creation or last modification time and the current time, is computed (elapsed duration). .IP \(bu 2 if \fBcache\-max\-age\fP is explicitly configured, it is compared with the lease age; leases that are too old are not reusable. This means that the value 0 for \fBcache\-max\-age\fP disables the lease cache feature. .IP \(bu 2 if \fBcache\-threshold\fP is explicitly configured and is between 0.0 and 1.0, it expresses the percentage of the lease valid lifetime which is allowed for the lease age. Values below and including 0.0 and values greater than 1.0 disable the lease cache feature. .UNINDENT .UNINDENT .UNINDENT .sp In our example, a lease with a valid lifetime of 2000 seconds can be reused if it was committed less than 500 seconds ago. With a lifetime of 3000 seconds, a maximum age of 600 seconds applies. .sp In outbound client responses (e.g. DHCPACK messages), the \fBdhcp\-lease\-time\fP option is set to the reusable valid lifetime, i.e. the expiration date does not change. Other options based on the valid lifetime e.g. \fBdhcp\-renewal\-time\fP and \fBdhcp\-rebinding\-time\fP, also depend on the reusable lifetime. .SS Temporary Allocation on DHCPDISCOVER .sp By default, \fI\%kea\-dhcp4\fP does not allocate or store a lease when offering an address to a client in response to a DHCPDISCOVER. In general, \fI\%kea\-dhcp4\fP can fulfill client demands faster by deferring lease allocation and storage until it receives DHCPREQUESTs for them. The \fBoffer\-lifetime\fP parameter in \fI\%kea\-dhcp4\fP (when not zero) instructs the server to allocate and persist a lease when generating a DHCPOFFER. In addition: .INDENT 0.0 .IP \(bu 2 The persisted lease\(aqs lifetime is equal to \fBoffer\-lifetime\fP (in seconds). .IP \(bu 2 The lifetime sent to the client in the DHCPOFFER via option 51 is still based on \fBvalid\-lifetime\fP\&. This avoids issues with clients that may reject offers whose lifetimes they perceive as too short. .IP \(bu 2 DDNS updates are not performed. As with the default behavior, those updates occur on DHCPREQUEST. .IP \(bu 2 Updates are not sent to HA peers. .IP \(bu 2 Assigned lease statistics are incremented. .IP \(bu 2 Expiration processing and reclamation behave just as they do for leases allocated during DHCPREQUEST processing. .IP \(bu 2 Lease caching, if enabled, is honored. .IP \(bu 2 In sites running multiple instances of \fI\%kea\-dhcp4\fP against a single, shared lease store, races for given address values are lost during DHCPDISCOVER processing rather than during DHCPREQUEST processing. Servers that lose the race for the address simply do not respond to the client, rather than NAK them. The client in turn simply retries its DHCPDISCOVER. This should reduce the amount of traffic such conflicts incur. .IP \(bu 2 Clients repeating DHCPDISCOVERs are offered the same address each time. .UNINDENT .sp An example subnet configuration is shown below: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqsubnet4\(dq: [ { \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.2.1 \- 192.0.2.200\(dq } ], \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq, \(dqoffer\-lifetime\(dq: 60, \(dqvalid\-lifetime\(dq: 2000, ... } ], \&... } .EE .UNINDENT .UNINDENT .sp Here \fBoffer\-lifetime\fP has been configured to be 60 seconds, with a \fBvalid\-lifetime\fP of 2000 seconds. This instructs \fI\%kea\-dhcp4\fP to persist leases for 60 seconds when sending them back in DHCPOFFERs, and then extend them to 2000 seconds when clients DHCPREQUEST them. .sp The value, which defaults to 0, is supported at the global, shared\-network, subnet, and class levels. Choosing an appropriate value for \fBoffer\-lifetime\fP is extremely site\-dependent, but a value between 60 and 120 seconds is a reasonable starting point. .SS DNR (Discovery of Network\-designated Resolvers) Options for DHCPv4 .sp The Discovery of Network\-designated Resolvers, or DNR option, was introduced in \X'tty: link https://tools.ietf.org/html/rfc9463'\fI\%RFC 9463\fP\X'tty: link' as a way to communicate location of DNS resolvers available over means other than the classic DNS over UDP over port 53. As of spring 2024, the supported technologies are DoT (DNS\-over\-TLS), DoH (DNS\-over\-HTTPS), and DoQ (DNS\-over\-QUIC), but the option was designed to be extensible to accommodate other protocols in the future. .sp The DHCPv4 option and its corresponding DHCPv6 options are almost exactly the same, with the exception of cardinality: only one DHCPv4 option is allowed, while multiple options are allowed for DHCPv6. To be able to convey multiple entries, the DHCPv4 DNR is an array that allows multiple DNS instances. Each instance is logically equal to one DHCPv6 option; the only difference is that it uses IPv4 rather than IPv6 addresses. DNR DHCPv4 options allow more than one DNR instance to be configured, and the DNR instances are separated with the \(dqpipe\(dq (\fB0x7C\fP) character. .sp For a detailed example of how to configure the DNR option, see \fI\%DNR (Discovery of Network\-designated Resolvers) Options for DHCPv6\fP\&. .sp For each DNR instance, comma\-delimited fields must be provided in the following order: .INDENT 0.0 .IP \(bu 2 Service Priority (mandatory), .IP \(bu 2 ADN FQDN (mandatory), .IP \(bu 2 IP address(es) (optional; if more than one, they must be separated by spaces) .IP \(bu 2 SvcParams as a set of key=value pairs (optional; if more than one \- they must be separated by spaces) To provide more than one \fBalpn\-id\fP, separate them with double backslash\-escaped commas as in the example below). .UNINDENT .sp Example usage: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqname\(dq: \(dqv4\-dnr\(dq, // 2 DNR Instances: // \- Service priority 2, ADN, resolver IPv4 address and Service Parameters // \- Service priority 3, ADN \- this is ADN\-only mode as per RFC 9463 3.1.6 \(dqdata\(dq: \(dq2, resolver.example., 10.0.5.6, alpn=dot\e\e,doq port=8530 | 3, fooexp.resolver.example.\(dq } .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 If \(dqcomma\(dq or \(dqpipe\(dq characters are used as text rather than as field delimiters, they must be escaped with double backslashes (\fB\e\e,\fP or \fB\e\e|\fP). Escaped commas must be used when configuring more than one \fBALPN\fP protocol, to separate them. The \(dqpipe\(dq (\fB0x7C\fP) character can be used in the \fBdohpath\fP service parameter, as it is allowed in a URI. .UNINDENT .UNINDENT .sp Examples for DNR DHCPv4 options are provided in the Kea sources, in \fIall\-options.json\fP in the \fIdoc/examples/kea4\fP directory. .SS Host Reservations in DHCPv4 .sp There are many cases where it is useful to provide a configuration on a per\-host basis. The most obvious one is to reserve a specific, static address for exclusive use by a given client (host); the returning client receives the same address from the server every time, and other clients generally do not receive that address. Host reservations are also convenient when a host has specific requirements, e.g. a printer that needs additional DHCP options. Yet another possible use case is to define unique names for hosts. .sp There may be cases when a new reservation has been made for a client for an address currently in use by another client. We call this situation a \(dqconflict.\(dq These conflicts get resolved automatically over time, as described in subsequent sections. Once a conflict is resolved, the correct client will receive the reserved configuration when it renews. .sp Host reservations are defined as parameters for each subnet. Each host must have its own unique identifier, such as the hardware/MAC address. There is an optional \fBreservations\fP array in the \fBsubnet4\fP structure; each element in that array is a structure that holds information about reservations for a single host. In particular, the structure has an identifier that uniquely identifies a host. In the DHCPv4 context, the identifier is usually a hardware or MAC address. In most cases an IP address will be specified. It is also possible to specify a hostname, host\-specific options, or fields carried within the DHCPv4 message such as \fBsiaddr\fP, \fBsname\fP, or \fBfile\fP\&. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The reserved address must be within the subnet. .UNINDENT .UNINDENT .sp The following example shows how to reserve addresses for specific hosts in a subnet: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqsubnet4\(dq: [ { \(dqid\(dq: 1, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.2.1 \- 192.0.2.200\(dq } ], \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq, \(dqinterface\(dq: \(dqeth0\(dq, \(dqreservations\(dq: [ { \(dqhw\-address\(dq: \(dq1a:1b:1c:1d:1e:1f\(dq, \(dqip\-address\(dq: \(dq192.0.2.202\(dq }, { \(dqduid\(dq: \(dq0a:0b:0c:0d:0e:0f\(dq, \(dqip\-address\(dq: \(dq192.0.2.100\(dq, \(dqhostname\(dq: \(dqalice\-laptop\(dq }, { \(dqcircuit\-id\(dq: \(dq\(aqcharter950\(aq\(dq, \(dqip\-address\(dq: \(dq192.0.2.203\(dq }, { \(dqclient\-id\(dq: \(dq01:11:22:33:44:55:66\(dq, \(dqip\-address\(dq: \(dq192.0.2.204\(dq } ] } ], \&... } .EE .UNINDENT .UNINDENT .sp The first entry reserves the 192.0.2.202 address for the client that uses a MAC address of 1a:1b:1c:1d:1e:1f. The second entry reserves the address 192.0.2.100 and the hostname of \(dqalice\-laptop\(dq for the client using a DUID 0a:0b:0c:0d:0e:0f. (If DNS updates are planned, it is strongly recommended that the hostnames be unique.) The third example reserves address 192.0.3.203 for a client whose request would be relayed by a relay agent that inserts a \fBcircuit\-id\fP option with the value \(dqcharter950\(dq. The fourth entry reserves address 192.0.2.204 for a client that uses a client identifier with value 01:11:22:33:44:55:66. .sp The above example is used for illustrational purposes only; in actual deployments it is recommended to use as few types as possible (preferably just one). See \fI\%Fine\-Tuning DHCPv4 Host Reservation\fP for a detailed discussion of this point. .sp Making a reservation for a mobile host that may visit multiple subnets requires a separate host definition in each subnet that host is expected to visit. It is not possible to define multiple host definitions with the same hardware address in a single subnet. Multiple host definitions with the same hardware address are valid if each is in a different subnet. .sp Adding host reservations incurs a performance penalty. In principle, when a server that does not support host reservation responds to a query, it needs to check whether there is a lease for a given address being considered for allocation or renewal. The server that does support host reservation has to perform additional checks: not only whether the address is currently used (i.e., if there is a lease for it), but also whether the address could be used by someone else (i.e., if there is a reservation for it). That additional check incurs extra overhead. .SS Address Reservation Types .sp In a typical Kea scenario there is an IPv4 subnet defined, e.g. 192.0.2.0/24, with a certain part of it dedicated for dynamic allocation by the DHCPv4 server. That dynamic part is referred to as a dynamic pool or simply a pool. In principle, a host reservation can reserve any address that belongs to the subnet. The reservations that specify addresses that belong to configured pools are called \(dqin\-pool reservations.\(dq In contrast, those that do not belong to dynamic pools are called \(dqout\-of\-pool reservations.\(dq There is no formal difference in the reservation syntax and both reservation types are handled uniformly. .sp Kea supports global host reservations. These are reservations that are specified at the global level within the configuration and that do not belong to any specific subnet. Kea still matches inbound client packets to a subnet as before, but when the subnet\(aqs reservation mode is set to \(dqglobal\(dq, Kea looks for host reservations only among the global reservations defined. Typically, such reservations would be used to reserve hostnames for clients which may move from one subnet to another. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Global reservations, while useful in certain circumstances, have aspects that must be given due consideration when using them. Please see \fI\%Conflicts in DHCPv4 Reservations\fP for more details. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Since Kea 1.9.1, reservation mode has been replaced by three boolean flags, \fBreservations\-global\fP, \fBreservations\-in\-subnet\fP, and \fBreservations\-out\-of\-pool\fP, which allow the configuration of host reservations both globally and in a subnet. In such cases a subnet host reservation has preference over a global reservation when both exist for the same client. .UNINDENT .UNINDENT .SS Conflicts in DHCPv4 Reservations .sp As reservations and lease information are stored separately, conflicts may arise. Consider the following series of events: the server has configured the dynamic pool of addresses from the range of 192.0.2.10 to 192.0.2.20. Host A requests an address and gets 192.0.2.10. Now the system administrator decides to reserve address 192.0.2.10 for Host B. In general, reserving an address that is currently assigned to someone else is not recommended, but there are valid use cases where such an operation is warranted. .sp The server now has a conflict to resolve. If Host B boots up and requests an address, the server cannot immediately assign the reserved address 192.0.2.10. A naive approach would to be immediately remove the existing lease for Host A and create a new one for Host B. That would not solve the problem, though, because as soon as Host B gets the address, it will detect that the address is already in use (by Host A) and will send a DHCPDECLINE message. Therefore, in this situation, the server has to temporarily assign a different address from the dynamic pool (not matching what has been reserved) to Host B. .sp When Host A renews its address, the server will discover that the address being renewed is now reserved for another host \- Host B. The server will inform Host A that it is no longer allowed to use it by sending a DHCPNAK message. The server will not remove the lease, though, as there\(aqs a small chance that the DHCPNAK will not be delivered if the network is lossy. If that happens, the client will not receive any responses, so it will retransmit its DHCPREQUEST packet. Once the DHCPNAK is received by Host A, it will revert to server discovery and will eventually get a different address. Besides allocating a new lease, the server will also remove the old one. As a result, address 192.0.2.10 will become free. .sp When Host B tries to renew its temporarily assigned address, the server will detect that it has a valid lease, but will note that there is a reservation for a different address. The server will send DHCPNAK to inform Host B that its address is no longer usable, but will keep its lease (again, the DHCPNAK may be lost, so the server will keep it until the client returns for a new address). Host B will revert to the server discovery phase and will eventually send a DHCPREQUEST message. This time the server will find that there is a reservation for that host and that the reserved address 192.0.2.10 is not used, so it will be granted. It will also remove the lease for the temporarily assigned address that Host B previously obtained. .sp This recovery will succeed, even if other hosts attempt to get the reserved address. If Host C requests the address 192.0.2.10 after the reservation is made, the server will either offer a different address (when responding to DHCPDISCOVER) or send DHCPNAK (when responding to DHCPREQUEST). .sp This mechanism allows the server to fully recover from a case where reservations conflict with existing leases; however, this procedure takes roughly as long as the value set for \fBrenew\-timer\fP\&. The best way to avoid such a recovery is not to define new reservations that conflict with existing leases. Another recommendation is to use out\-of\-pool reservations; if the reserved address does not belong to a pool, there is no way that other clients can get it. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The conflict\-resolution mechanism does not work for global reservations. Although the global address reservations feature may be useful in certain settings, it is generally recommended not to use global reservations for addresses. Administrators who do choose to use global reservations must manually ensure that the reserved addresses are not in dynamic pools. .UNINDENT .UNINDENT .SS Reserving a Hostname .sp When the reservation for a client includes the \fBhostname\fP, the server returns this hostname to the client in the Client FQDN or Hostname option. The server responds with the Client FQDN option only if the client has included the Client FQDN option in its message to the server. The server responds with the Hostname option if the client included the Hostname option in its message to the server, or if the client requested the Hostname option using the Parameter Request List option. The server returns the Hostname option even if it is not configured to perform DNS updates. The reserved hostname always takes precedence over the hostname supplied by the client or the autogenerated (from the IPv4 address) hostname. .sp The server qualifies the reserved hostname with the value of the \fBddns\-qualifying\-suffix\fP parameter. For example, the following subnet configuration: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqsubnet4\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq10.0.0.0/24\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq10.0.0.10\-10.0.0.100\(dq } ], \(dqddns\-qualifying\-suffix\(dq: \(dqexample.isc.org.\(dq, \(dqreservations\(dq: [ { \(dqhw\-address\(dq: \(dqaa:bb:cc:dd:ee:ff\(dq, \(dqhostname\(dq: \(dqalice\-laptop\(dq } ] } ], \(dqdhcp\-ddns\(dq: { \(dqenable\-updates\(dq: true } } .EE .UNINDENT .UNINDENT .sp will result in the \(dqalice\-laptop.example.isc.org.\(dq hostname being assigned to the client using the MAC address \(dqaa:bb:cc:dd:ee:ff\(dq. If the \fBddns\-qualifying\-suffix\fP is not specified, the default (empty) value will be used, and in this case the value specified as a \fBhostname\fP will be treated as a fully qualified name. Thus, by leaving the \fBddns\-qualifying\-suffix\fP empty it is possible to qualify hostnames for different clients with different domain names: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqsubnet4\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq10.0.0.0/24\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq10.0.0.10\-10.0.0.100\(dq } ], \(dqreservations\(dq: [ { \(dqhw\-address\(dq: \(dqaa:bb:cc:dd:ee:ff\(dq, \(dqhostname\(dq: \(dqalice\-laptop.isc.org.\(dq }, { \(dqhw\-address\(dq: \(dq12:34:56:78:99:AA\(dq, \(dqhostname\(dq: \(dqmark\-desktop.example.org.\(dq } ] } ], \(dqdhcp\-ddns\(dq: { \(dqenable\-updates\(dq: true } } .EE .UNINDENT .UNINDENT .sp The above example results in the assignment of the \(dqalice\-laptop.isc.org.\(dq hostname to the client using the MAC address \(dqaa:bb:cc:dd:ee:ff\(dq, and the hostname \(dqmark\-desktop.example.org.\(dq to the client using the MAC address \(dq12:34:56:78:99:AA\(dq. .SS Including Specific DHCPv4 Options in Reservations .sp Kea offers the ability to specify options on a per\-host basis. These options follow the same rules as any other options. These can be standard options (see \fI\%Standard DHCPv4 Options\fP), custom options (see \fI\%Custom DHCPv4 Options\fP), or vendor\-specific options (see \fI\%DHCPv4 Vendor\-Specific Options\fP). The following example demonstrates how standard options can be defined: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqsubnet4\(dq: [ { \(dqreservations\(dq: [ { \(dqhw\-address\(dq: \(dqaa:bb:cc:dd:ee:ff\(dq, \(dqip\-address\(dq: \(dq192.0.2.1\(dq, \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqcookie\-servers\(dq, \(dqdata\(dq: \(dq10.1.1.202,10.1.1.203\(dq }, { \(dqname\(dq: \(dqlog\-servers\(dq, \(dqdata\(dq: \(dq10.1.1.200,10.1.1.201\(dq } ] } ], ... } ], ... } .EE .UNINDENT .UNINDENT .sp Vendor\-specific options can be reserved in a similar manner: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqsubnet4\(dq: [ { \(dqreservations\(dq: [ { \(dqhw\-address\(dq: \(dqaa:bb:cc:dd:ee:ff\(dq, \(dqip\-address\(dq: \(dq10.0.0.7\(dq, \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqvivso\-suboptions\(dq, \(dqdata\(dq: \(dq4491\(dq }, { \(dqname\(dq: \(dqtftp\-servers\(dq, \(dqspace\(dq: \(dqvendor\-4491\(dq, \(dqdata\(dq: \(dq10.1.1.202,10.1.1.203\(dq } ] } ], ... } ], ... } .EE .UNINDENT .UNINDENT .sp Options defined at the host level have the highest priority. In other words, if there are options defined with the same type on the global, subnet, class, and host levels, the host\-specific values are used. .SS Reserving Next Server, Server Hostname, and Boot File Name .sp BOOTP/DHCPv4 messages include \(dqsiaddr\(dq, \(dqsname\(dq, and \(dqfile\(dq fields. Even though DHCPv4 includes corresponding options, such as option 66 and option 67, some clients may not support these options. For this reason, server administrators often use the \(dqsiaddr\(dq, \(dqsname\(dq, and \(dqfile\(dq fields instead. .sp With Kea, it is possible to make static reservations for these DHCPv4 message fields: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqsubnet4\(dq: [ { \(dqreservations\(dq: [ { \(dqhw\-address\(dq: \(dqaa:bb:cc:dd:ee:ff\(dq, \(dqnext\-server\(dq: \(dq10.1.1.2\(dq, \(dqserver\-hostname\(dq: \(dqserver\-hostname.example.org\(dq, \(dqboot\-file\-name\(dq: \(dq/usr/local/share/kea/bootfile.efi\(dq } ], ... } ], ... } .EE .UNINDENT .UNINDENT .sp Note that those parameters can be specified in combination with other parameters for a reservation, such as a reserved IPv4 address. These parameters are optional; a subset of them can be specified, or all of them can be omitted. .SS Reserving Client Classes in DHCPv4 .sp \fI\%Using Expressions in Classification\fP explains how to configure the server to assign classes to a client, based on the content of the options that this client sends to the server. Host reservation mechanisms also allow for the static assignment of classes to clients. The definitions of these classes are placed in the Kea configuration file or a database. The following configuration snippet shows how to specify that a client belongs to the classes \fBreserved\-class1\fP and \fBreserved\-class2\fP\&. Those classes are associated with specific options sent to the clients which belong to them. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqreserved\-class1\(dq, \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqrouters\(dq, \(dqdata\(dq: \(dq10.0.0.200\(dq } ] }, { \(dqname\(dq: \(dqreserved\-class2\(dq, \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqdomain\-name\-servers\(dq, \(dqdata\(dq: \(dq10.0.0.201\(dq } ] } ], \(dqsubnet4\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq10.0.0.0/24\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq10.0.0.10\-10.0.0.100\(dq } ], \(dqreservations\(dq: [ { \(dqhw\-address\(dq: \(dqaa:bb:cc:dd:ee:ff\(dq, \(dqclient\-classes\(dq: [ \(dqreserved\-class1\(dq, \(dqreserved\-class2\(dq ] } ] } ] } .EE .UNINDENT .UNINDENT .sp In some cases the host reservations can be used in conjunction with client classes specified within the Kea configuration. In particular, when a host reservation exists for a client within a given subnet, the \(dqKNOWN\(dq built\-in class is assigned to the client. Conversely, when there is no static assignment for the client, the \(dqUNKNOWN\(dq class is assigned to the client. Class expressions within the Kea configuration file can refer to \(dqKNOWN\(dq or \(dqUNKNOWN\(dq classes using the \(dqmember\(dq operator. For example: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqdependent\-class\(dq, \(dqtest\(dq: \(dqmember(\(aqKNOWN\(aq)\(dq, \(dqonly\-in\-additional\-list\(dq: true } ] } .EE .UNINDENT .UNINDENT .sp The \fBonly\-in\-additional\-list\fP parameter is needed here to force evaluation of the class after the lease has been allocated, and thus the reserved class has been also assigned. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The classes specified in non\-global host reservations are assigned to the processed packet after all classes with the \fBonly\-in\-additional\-list\fP parameter set to \fBfalse\fP have been evaluated. This means that these classes must not depend on the statically assigned classes from the host reservations. If such a dependency is needed, the \fBonly\-in\-additional\-list\fP parameter must be set to \fBtrue\fP for the dependent classes. Such classes are evaluated after the static classes have been assigned to the packet. This, however, imposes additional configuration overhead, because all classes marked as \fBonly\-in\-additional\-list\fP must be listed in the \fBevaluate\-additional\-classes\fP list for every subnet where they are used. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Client classes specified within the Kea configuration file may depend on the classes specified within the global host reservations. In such a case the \fBonly\-in\-additional\-list\fP parameter is not needed. Refer to \fI\%Pool Selection with Client Class Reservations\fP and \fI\%Subnet Selection with Client Class Reservations\fP for specific use cases. .UNINDENT .UNINDENT .SS Storing Host Reservations in MySQL or PostgreSQL .sp Kea can store host reservations in MySQL or PostgreSQL. See \fI\%Hosts Storage\fP for information on how to configure Kea to use reservations stored in MySQL or PostgreSQL. Kea provides a dedicated hook for managing reservations in a database; section \fI\%libdhcp_host_cmds.so: Host Commands\fP provides detailed information. The \X'tty: link https://gitlab.isc.org/isc-projects/kea/wikis/designs/commands#23-host-reservations-hr-management'\fI\%Kea wiki\fP\X'tty: link' provides some examples of how to conduct common host reservation operations. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 In Kea, the maximum length of an option specified per\-host\-reservation is arbitrarily set to 4096 bytes. .UNINDENT .UNINDENT .SS Fine\-Tuning DHCPv4 Host Reservation .sp The host reservation capability introduces additional restrictions for the allocation engine (the component of Kea that selects an address for a client) during lease selection and renewal. In particular, three major checks are necessary. First, when selecting a new lease, it is not sufficient for a candidate lease to simply not be in use by another DHCP client; it also must not be reserved for another client. Similarly, when renewing a lease, an additional check must be performed to see whether the address being renewed is reserved for another client. Finally, when a host renews an address, the server must check whether there is a reservation for this host, which would mean the existing (dynamically allocated) address should be revoked and the reserved one be used instead. .sp Some of those checks may be unnecessary in certain deployments, and not performing them may improve performance. The Kea server provides the \fBreservations\-global\fP, \fBreservations\-in\-subnet\fP and \fBreservations\-out\-of\-pool\fP configuration parameters to select the types of reservations allowed for a particular subnet. Each reservation type has different constraints for the checks to be performed by the server when allocating or renewing a lease for the client. .sp Configuration flags are: .INDENT 0.0 .IP \(bu 2 \fBreservations\-in\-subnet\fP \- when set to \fBtrue\fP, it enables in\-pool host reservation types. This setting is the default value, and is the safest and most flexible. However, as all checks are conducted, it is also the slowest. It does not check against global reservations. This flag defaults to \fBtrue\fP\&. .IP \(bu 2 \fBreservations\-out\-of\-pool\fP \- when set to \fBtrue\fP, it allows only out\-of\-pool host reservations. In this case the server assumes that all host reservations are for addresses that do not belong to the dynamic pool. Therefore, it can skip the reservation checks when dealing with in\-pool addresses, thus improving performance. Do not use this mode if any reservations use in\-pool addresses. Caution is advised when using this setting; Kea does not sanity\-check the reservations against \fBreservations\-out\-of\-pool\fP and misconfiguration may cause problems. This flag defaults to \fBfalse\fP\&. .IP \(bu 2 \fBreservations\-global\fP \- allows global host reservations. With this setting in place, the server searches for reservations for a client among the defined global reservations. If an address is specified, the server skips the reservation checks carried out in other modes, thus improving performance. Caution is advised when using this setting; Kea does not sanity\-check the reservations when \fBreservations\-global\fP is set to \fBtrue\fP, and misconfiguration may cause problems. This flag defaults to \fBfalse\fP\&. .UNINDENT .INDENT 0.0 .TP .B Note: setting all flags to \fBfalse\fP disables host reservation support. As there are no reservations, the server skips all checks. Any reservations defined are completely ignored. As checks are skipped, the server may operate faster in this mode. .UNINDENT .sp Since Kea 1.9.1 the \fBreservations\-global\fP, \fBreservations\-in\-subnet\fP and \fBreservations\-out\-of\-pool\fP flags are suported. .sp The \fBreservations\-global\fP, \fBreservations\-in\-subnet\fP and \fBreservations\-out\-of\-pool\fP parameters can be specified at: .INDENT 0.0 .IP \(bu 2 global level: \fB\&.Dhcp4[\(dqreservations\-global\(dq]\fP (lowest priority: gets overridden by all others) .IP \(bu 2 subnet level: \fB\&.Dhcp4.subnet4[][\(dqreservations\-in\-subnet\(dq]\fP (low priority) .IP \(bu 2 shared\-network level: \fB\&.Dhcp4[\(dqshared\-networks\(dq][][\(dqreservations\-out\-of\-pool\(dq]\fP (high priority) .IP \(bu 2 shared\-network subnet\-level: \fB\&.Dhcp4[\(dqshared\-networks\(dq][].subnet4[][\(dqreservations\-out\-of\-pool\(dq]\fP (highest priority: overrides all others) .UNINDENT .sp To decide which flags to use, the following decision diagram may be useful: .INDENT 0.0 .INDENT 3.5 .sp .EX O | v +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ | Is per\-host configuration needed, such as | | reserving specific addresses, | | assigning specific options or | | assigning packets to specific classes on per\-device basis? | +\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ | | no| yes| | | +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ | | | For all given hosts, | +\-\-> \(dqdisabled\(dq +\-\->+ can the reserved resources | | be used in all configured subnets? | +\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-+ | | +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ |no |yes | Is | | | | at least one reservation +<\-\-+ \(dqglobal\(dq <\-\-+ | used to reserve addresses? | +\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-+ | | no| yes| +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ | | | Is high leases\-per\-second | +\-\-> \(dqout\-of\-pool\(dq +\-\->+ performance or efficient | ^ | resource usage | | | (CPU ticks, RAM usage, | | | database roundtrips) | | | important to your setup? | | +\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-+ | | | | yes| no| | | | | +\-\-\-\-\-\-\-\-\-\-\-\-\-+ | | | | | | +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ | | | | Can it be guaranteed | | | +\-\->+ that the reserved | | | | addresses | | | | aren\(aqt part of the | | | | pools configured | | | | in the respective | | | | subnet? | | | +\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-+ | | | | | | yes| no| | | | | V +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ +\-\-> \(dqin\-subnet\(dq .EE .UNINDENT .UNINDENT .sp An example configuration that disables reservations looks as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp4\(dq: { \(dqsubnet4\(dq: [ { \(dqid\(dq: 1, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.2.10\-192.0.2.100\(dq } ], \(dqreservations\-global\(dq: false, \(dqreservations\-in\-subnet\(dq: false, \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq } ] } } .EE .UNINDENT .UNINDENT .sp An example configuration using global reservations is shown below: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp4\(dq: { \(dqreservations\-global\(dq: true, \(dqreservations\(dq: [ { \(dqhostname\(dq: \(dqhost\-one\(dq, \(dqhw\-address\(dq: \(dq01:bb:cc:dd:ee:ff\(dq }, { \(dqhostname\(dq: \(dqhost\-two\(dq, \(dqhw\-address\(dq: \(dq02:bb:cc:dd:ee:ff\(dq } ], \(dqsubnet4\(dq: [ { \(dqid\(dq: 1, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.2.10\-192.0.2.100\(dq } ], \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq } ] } } .EE .UNINDENT .UNINDENT .sp The meaning of the reservation flags are: .INDENT 0.0 .IP \(bu 2 \fBreservations\-global\fP: fetch global reservations. .IP \(bu 2 \fBreservations\-in\-subnet\fP: fetch subnet reservations. For a shared network this includes all subnet members of the shared network. .IP \(bu 2 \fBreservations\-out\-of\-pool\fP: this makes sense only when the \fBreservations\-in\-subnet\fP flag is \fBtrue\fP\&. When \fBreservations\-out\-of\-pool\fP is \fBtrue\fP, the server assumes that all host reservations are for addresses that do not belong to the dynamic pool. Therefore, it can skip the reservation checks when dealing with in\-pool addresses, thus improving performance. The server will not assign reserved addresses that are inside the dynamic pools to the respective clients. This also means that the addresses matching the respective reservations from inside the dynamic pools (if any) can be dynamically assigned to any client. .UNINDENT .sp The \fBdisabled\fP configuration corresponds to: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp4\(dq: { \(dqreservations\-global\(dq: false, \(dqreservations\-in\-subnet\(dq: false } } .EE .UNINDENT .UNINDENT .sp The \fBglobal\(ga\(gaconfiguration using \(ga\(gareservations\-global\fP corresponds to: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp4\(dq: { \(dqreservations\-global\(dq: true, \(dqreservations\-in\-subnet\(dq: false } } .EE .UNINDENT .UNINDENT .sp The \fBout\-of\-pool\fP configuration using \fBreservations\-out\-of\-pool\fP corresponds to: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp4\(dq: { \(dqreservations\-global\(dq: false, \(dqreservations\-in\-subnet\(dq: true, \(dqreservations\-out\-of\-pool\(dq: true } } .EE .UNINDENT .UNINDENT .sp And the \fBin\-subnet\fP configuration using \fBreservations\-in\-subnet\fP corresponds to: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp4\(dq: { \(dqreservations\-global\(dq: false, \(dqreservations\-in\-subnet\(dq: true, \(dqreservations\-out\-of\-pool\(dq: false } } .EE .UNINDENT .UNINDENT .sp To activate both \fBglobal\fP and \fBin\-subnet\fP, the following combination can be used: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp4\(dq: { \(dqreservations\-global\(dq: true, \(dqreservations\-in\-subnet\(dq: true, \(dqreservations\-out\-of\-pool\(dq: false } } .EE .UNINDENT .UNINDENT .sp To activate both \fBglobal\fP and \fBout\-of\-pool\fP, the following combination can be used: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp4\(dq: { \(dqreservations\-global\(dq: true, \(dqreservations\-in\-subnet\(dq: true, \(dqreservations\-out\-of\-pool\(dq: true } } .EE .UNINDENT .UNINDENT .sp Enabling \fBout\-of\-pool\fP and disabling \fBin\-subnet\fP at the same time is not recommended because \fBout\-of\-pool\fP applies to host reservations in a subnet, which are fetched only when the \fBin\-subnet\fP flag is \fBtrue\fP\&. .sp The parameter can be specified at the global, subnet, and shared\-network levels. .sp An example configuration that disables reservations looks as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp4\(dq: { \(dqsubnet4\(dq: [ { \(dqreservations\-global\(dq: false, \(dqreservations\-in\-subnet\(dq: false, \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq, \(dqid\(dq: 1 } ] } } .EE .UNINDENT .UNINDENT .sp An example configuration using global reservations is shown below: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp4\(dq: { \(dqreservations\(dq: [ { \(dqhostname\(dq: \(dqhost\-one\(dq, \(dqhw\-address\(dq: \(dq01:bb:cc:dd:ee:ff\(dq }, { \(dqhostname\(dq: \(dqhost\-two\(dq, \(dqhw\-address\(dq: \(dq02:bb:cc:dd:ee:ff\(dq } ], \(dqreservations\-global\(dq: true, \(dqreservations\-in\-subnet\(dq: false, \(dqsubnet4\(dq: [ { \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.2.10\-192.0.2.100\(dq } ], \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq, \(dqid\(dq: 1 } ] } } .EE .UNINDENT .UNINDENT .sp For more details regarding global reservations, see \fI\%Global Reservations in DHCPv4\fP\&. .sp Another aspect of host reservations is the different types of identifiers. Kea currently supports four types of identifiers: \fBhw\-address\fP, \fBduid\fP, \fBclient\-id\fP, and \fBcircuit\-id\fP\&. This is beneficial from a usability perspective; however, there is one drawback. For each incoming packet, Kea has to extract each identifier type and then query the database to see if there is a reservation by this particular identifier. If nothing is found, the next identifier is extracted and the next query is issued. This process continues until either a reservation is found or all identifier types have been checked. Over time, with an increasing number of supported identifier types, Kea would become slower and slower. .sp To address this problem, a parameter called \fBhost\-reservation\-identifiers\fP is available. It takes a list of identifier types as a parameter. Kea checks only those identifier types enumerated in \fBhost\-reservation\-identifiers\fP\&. From a performance perspective, the number of identifier types should be kept to a minimum, ideally one. If the deployment uses several reservation types, please enumerate them from most\- to least\-frequently used, as this increases the chances of Kea finding the reservation using the fewest queries. An example of a \fBhost\-reservation\-identifiers\fP configuration looks as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqhost\-reservation\-identifiers\(dq: [ \(dqcircuit\-id\(dq, \(dqhw\-address\(dq, \(dqduid\(dq, \(dqclient\-id\(dq ], \(dqsubnet4\(dq: [ { \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq, ... } ], \&... } .EE .UNINDENT .UNINDENT .sp If not specified, the default value is: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqhost\-reservation\-identifiers\(dq: [ \(dqhw\-address\(dq, \(dqduid\(dq, \(dqcircuit\-id\(dq, \(dqclient\-id\(dq ] .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 As soon as a host reservation is found, the search is stopped; when a client has two host reservations using different enabled identifier types, the first is always returned and the second ignored. In other words, this is usually a configuration error. In those rare cases when having two reservations for the same host makes sense, the one to be used can be specified by ordering the list of identifier types in \fBhost\-reservation\-identifiers\fP\&. .UNINDENT .UNINDENT .SS Global Reservations in DHCPv4 .sp In some deployments, such as mobile networks, clients can roam within the network and certain parameters must be specified regardless of the client\(aqs current location. To meet such a need, Kea offers a global reservation mechanism. The idea behind it is that regular host reservations are tied to specific subnets, by using a specific subnet ID. Kea can specify a global reservation that can be used in every subnet that has global reservations enabled. .sp This feature can be used to assign certain parameters, such as hostname or other dedicated, host\-specific options. It can also be used to assign addresses. .sp An address assigned via global host reservation must be feasible for the subnet the server selects for the client. In other words, the address must lie within the subnet; otherwise, it is ignored and the server will attempt to dynamically allocate an address. If the selected subnet belongs to a shared network, the server checks for feasibility against the subnet\(aqs siblings, selecting the first in\-range subnet. If no such subnet exists, the server falls back to dynamically allocating the address. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Prior to release 2.3.5, the server did not perform feasibility checks on globally reserved addresses, which allowed the server to be configured to hand out nonsensical leases for arbitrary address values. Later versions of Kea perform these checks. .UNINDENT .UNINDENT .sp To use global host reservations, a configuration similar to the following can be used: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { # This specifies global reservations. # They will apply to all subnets that # have global reservations enabled. \(dqreservations\(dq: [ { \(dqhw\-address\(dq: \(dqaa:bb:cc:dd:ee:ff\(dq, \(dqhostname\(dq: \(dqhw\-host\-dynamic\(dq }, { \(dqhw\-address\(dq: \(dq01:02:03:04:05:06\(dq, \(dqhostname\(dq: \(dqhw\-host\-fixed\(dq, # Use of IP addresses in global reservations is risky. # If used outside of a matching subnet, such as 192.0.1.0/24, # it will result in a broken configuration being handed # to the client. \(dqip\-address\(dq: \(dq192.0.1.77\(dq }, { \(dqduid\(dq: \(dq01:02:03:04:05\(dq, \(dqhostname\(dq: \(dqduid\-host\(dq }, { \(dqcircuit\-id\(dq: \(dq\(aqcharter950\(aq\(dq, \(dqhostname\(dq: \(dqcircuit\-id\-host\(dq }, { \(dqclient\-id\(dq: \(dq01:11:22:33:44:55:66\(dq, \(dqhostname\(dq: \(dqclient\-id\-host\(dq } ], \(dqvalid\-lifetime\(dq: 600, \(dqsubnet4\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq10.0.0.0/24\(dq, # Specify if the server should look up global reservations. \(dqreservations\-global\(dq: true, # Specify if the server should look up in\-subnet reservations. \(dqreservations\-in\-subnet\(dq: false, # Specify if the server can assume that all reserved addresses # are out\-of\-pool. It can be ignored because \(dqreservations\-in\-subnet\(dq # is false. # \(dqreservations\-out\-of\-pool\(dq: false, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq10.0.0.10\-10.0.0.100\(dq } ] } ] } .EE .UNINDENT .UNINDENT .sp When using database backends, the global host reservations are distinguished from regular reservations by using a \fBsubnet\-id\fP value of 0. .SS Pool Selection with Client Class Reservations .sp Client classes can be specified in the Kea configuration file and/or via host reservations. The classes specified in the Kea configuration file are evaluated immediately after receiving the DHCP packet and therefore can be used to influence subnet selection using the \fBclient\-classes\fP parameter specified in the subnet scope. The classes specified within the host reservations are fetched and assigned to the packet after the server has already selected a subnet for the client. This means that the client class specified within a host reservation cannot be used to influence subnet assignment for this client, unless the subnet belongs to a shared network. If the subnet belongs to a shared network, the server may dynamically change the subnet assignment while trying to allocate a lease. If the subnet does not belong to a shared network, the subnet is not changed once selected. .sp If the subnet does not belong to a shared network, it is possible to use host reservation\-based client classification to select a pool within the subnet as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp4\(dq: { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqreserved_class\(dq }, { \(dqname\(dq: \(dqunreserved_class\(dq, \(dqtest\(dq: \(dqnot member(\(aqreserved_class\(aq)\(dq } ], \(dqsubnet4\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq, \(dqreservations\(dq: [ { \(dqhw\-address\(dq: \(dqaa:bb:cc:dd:ee:fe\(dq, \(dqclient\-classes\(dq: [ \(dqunreserved_class\(dq ] } ], \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.2.10 \- 192.0.2.20\(dq, \(dqclient\-classes\(dq: [ \(dqunreserved_class\(dq ] }, { \(dqpool\(dq: \(dq192.0.2.30 \- 192.0.2.40\(dq, \(dqclient\-classes\(dq: [ \(dqreserved_class\(dq ] }, { \(dqpool\(dq: \(dq192.0.2.50 \- 192.0.2.60\(dq } ] } ] } } .EE .UNINDENT .UNINDENT .sp \fBreserved_class\fP is declared without the \fBtest\fP parameter because it may only be assigned to a client via the host reservation mechanism. The second class, \fBunreserved_class\fP, is assigned to clients which do not belong to \fBreserved_class\fP\&. .sp The first pool in the subnet is used for clients not having such a reservation. The second pool is only used for clients having a reservation for \fBreserved_class\fP\&. The third pool is an unrestricted pool for any clients, comprising of both \fBreserved_class\fP clients and \fBunreserved_class\fP\&. .sp The configuration snippet includes one host reservation which causes the client with the MAC address \fBaa:bb:cc:dd:ee:fe\fP to be assigned to \fBreserved_class\fP\&. Thus, this client will be given an IP address from the second address pool. .sp Reservations defined on a subnet that belongs to a shared network are not visible to an otherwise matching client, so they cannot be used to select pools, nor subnets for that matter. .SS Subnet Selection with Client Class Reservations .sp There is one specific use case when subnet selection may be influenced by client classes specified within host reservations: when the client belongs to a shared network. In such a case it is possible to use classification to select a subnet within this shared network. Consider the following example: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp4\(dq: { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqreserved_class\(dq }, { \(dqname\(dq: \(dqunreserved_class\(dq, \(dqtest\(dq: \(dqnot member(\(aqreserved_class\(aq)\(dq } ], \(dqreservations\(dq: [ { \(dqhw\-address\(dq: \(dqaa:bb:cc:dd:ee:fe\(dq, \(dqclient\-classes\(dq: [ \(dqreserved_class\(dq ] } ], \(dqreservations\-global\(dq: true, \(dqreservations\-in\-subnet\(dq: false, \(dqshared\-networks\(dq: [ { \(dqname\(dq: \(dqnet\(dq, \(dqsubnet4\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.2.10\-192.0.2.20\(dq, \(dqclient\-classes\(dq: [ \(dqunreserved_class\(dq ] }, { \(dqpool\(dq: \(dq192.0.2.30\-192.0.2.40\(dq, \(dqclient\-classes\(dq: [ \(dqunreserved_class\(dq ] } ] }, { \(dqid\(dq: 2, \(dqsubnet\(dq: \(dq192.0.3.0/24\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.3.10\-192.0.3.20\(dq, \(dqclient\-classes\(dq: [ \(dqreserved_class\(dq ] }, { \(dqpool\(dq: \(dq192.0.3.30\-192.0.3.40\(dq, \(dqclient\-classes\(dq: [ \(dqreserved_class\(dq ] } ] }, { \(dqid\(dq: 3, \(dqsubnet\(dq: \(dq192.0.4.0/24\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.4.10\-192.0.4.20\(dq }, { \(dqpool\(dq: \(dq192.0.4.30\-192.0.4.40\(dq } ] } ] } ] } } .EE .UNINDENT .UNINDENT .sp This is similar to the example described in \fI\%Pool Selection with Client Class Reservations\fP\&. This time, however, there are three subnets, of which the first two have a pool associated with a different class each. .sp The clients that do not have a reservation for \fBreserved_class\fP are assigned an address from the first subnet and when that is filled from the third subnet. Clients with a reservation for \fBreserved_class\fP are assigned an address from the second subnet and when that is filled from the third subnet. .sp The subnets must belong to the same shared network. .sp For a subnet to be restricted to a certain class, or skipped, all of the pools inside that subnet must be guarded by \fBreserved_class\fP or \fBunreserved_class\fP respectively. .sp In addition, the reservation for the client class must be specified at the global scope (global reservation) and \fBreservations\-global\fP must be set to \fBtrue\fP\&. .sp In the example above, the \fBclient\-classes\fP configuration parameter could also be specified at the subnet level rather than the pool level, and would yield the same effect. .sp If the subnets were defined outside shared networks, and \fBclient\-classes\fP were specified at the subnet level, then \fBearly\-global\-reservations\-lookup\fP would also need to be enabled in order for subnet selection to work. .SS Multiple Reservations for the Same IP .sp Host reservations were designed to preclude the creation of multiple reservations for the same IP address within a particular subnet, to avoid having two different clients compete for the same address. When using the default settings, the server returns a configuration error when it finds two or more reservations for the same IP address within a subnet in the Kea configuration file. \fI\%libdhcp_host_cmds.so\fP returns an error in response to the \fI\%reservation\-add\fP command when it detects that the reservation exists in the database for the IP address for which the new reservation is being added. .sp In some deployments a single host can select one of several network interfaces to communicate with the DHCP server, and the server must assign the same IP address to the host regardless of the interface used. Since each interface is assigned a different MAC address, it implies that several host reservations must be created to associate all of the MAC addresses present on this host with IP addresses. Using different IP addresses for each interface is impractical and is considered a waste of the IPv4 address space, especially since the host typically uses only one interface for communication with the server, hence only one IP address is in use. .sp This causes a need to create multiple host reservations for a single IP address within a subnet; this is supported since the Kea 1.9.1 release as an optional mode of operation, enabled with the \fBip\-reservations\-unique\fP global parameter. .sp \fBip\-reservations\-unique\fP is a boolean parameter that defaults to \fBtrue\fP, which forbids the specification of more than one reservation for the same IP address within a given subnet. Setting this parameter to \fBfalse\fP allows such reservations to be created both in the Kea configuration file and in the host database backend, via \fI\%libdhcp_host_cmds.so\fP\&. .sp Setting \fBip\-reservations\-unique\fP to \fBfalse\fP when using memfile, MySQL, or PostgreSQL is supported. This setting is not supported when using Host Cache (see \fI\%libdhcp_host_cache.so: Host Cache Reservations for Improved Performance\fP) or the RADIUS backend (see \fI\%libdhcp_radius.so: RADIUS Server Support\fP). These reservation backends do not support multiple reservations for the same IP; if either of these hooks is loaded and \fBip\-reservations\-unique\fP is set to \fBfalse\fP, then a configuration error is emitted and the server fails to start. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 When \fBip\-reservations\-unique\fP is set to \fBtrue\fP (the default value), the server ensures that IP reservations are unique for a subnet within a single host backend and/or Kea configuration file. It does not guarantee that the reservations are unique across multiple backends. On server startup, only IP reservations defined in the Kea configuration file are checked for uniqueness. .UNINDENT .UNINDENT .sp The following is an example configuration with two reservations for the same IP address but different MAC addresses: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqip\-reservations\-unique\(dq: false, \(dqsubnet4\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq, \(dqreservations\(dq: [ { \(dqhw\-address\(dq: \(dq1a:1b:1c:1d:1e:1f\(dq, \(dqip\-address\(dq: \(dq192.0.2.11\(dq }, { \(dqhw\-address\(dq: \(dq2a:2b:2c:2d:2e:2f\(dq, \(dqip\-address\(dq: \(dq192.0.2.11\(dq } ] } ] } .EE .UNINDENT .UNINDENT .sp It is possible to control the \fBip\-reservations\-unique\fP parameter via the \fI\%Configuration Backend in DHCPv4\fP\&. If the new setting of this parameter conflicts with the currently used backends (i.e. backends do not support the new setting), the new setting is ignored and a warning log message is generated. The backends continue to use the default setting, expecting that IP reservations are unique within each subnet. To allow the creation of non\-unique IP reservations, the administrator must remove the backends which lack support for them from the configuration file. .sp Administrators must be careful when they have been using multiple reservations for the same IP address and later decide to return to the default mode in which this is no longer allowed. They must make sure that at most one reservation for a given IP address exists within a subnet, prior to switching back to the default mode. If such duplicates are left in the configuration file, the server reports a configuration error. Leaving such reservations in the host databases does not cause configuration errors but may lead to lease allocation errors during the server\(aqs operation, when it unexpectedly finds multiple reservations for the same IP address. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Currently, the Kea server does not verify whether multiple reservations for the same IP address exist in MySQL and/or PostgreSQL host databases when \fBip\-reservations\-unique\fP is updated from \fBfalse\fP to \fBtrue\fP\&. This may cause issues with lease allocations. The administrator must ensure that there is at most one reservation for each IP address within each subnet, prior to the configuration update. .UNINDENT .UNINDENT .sp The \fBreservations\-lookup\-first\fP is a boolean parameter which controls whether host reservations lookup should be performed before lease lookup. This parameter has effect only when multi\-threading is disabled. When multi\-threading is enabled, host reservations lookup is always performed first to avoid lease\-lookup resource locking. The \fBreservations\-lookup\-first\fP parameter defaults to \fBfalse\fP when multi\-threading is disabled. .SS Host Reservations as Basic Access Control .sp It is possible to define a host reservation that contains just an identifier, without any address, options, or values. In some deployments this is useful, as the hosts that have a reservation belong to the KNOWN class while others do not. This can be used as a basic access control mechanism. .sp The following example demonstrates this concept. It indicates a single IPv4 subnet and all clients will get an address from it. However, only known clients (those that have reservations) will get their default router configured. Empty reservations, i.e. reservations that only have the identification criterion, can be useful as a way of making the clients known. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqKNOWN\(dq, \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqrouters\(dq, \(dqdata\(dq: \(dq192.0.2.250\(dq } ] } ], \(dqreservations\(dq: [ // Clients on this list will be added to the KNOWN class. { \(dqhw\-address\(dq: \(dqaa:bb:cc:dd:ee:fe\(dq }, { \(dqhw\-address\(dq: \(dq11:22:33:44:55:66\(dq } ], \(dqreservations\-in\-subnet\(dq: true, \(dqsubnet4\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.2.1\-192.0.2.200\(dq } ] } ] } .EE .UNINDENT .UNINDENT .sp This concept can be extended further. A good real\-life scenario might be a situation where some customers of an ISP have not paid their bills. A new class can be defined to use an alternative default router that, instead of relaying traffic, redirects those customers to a captive portal urging them to bring their accounts up to date. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqblocked\(dq, \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqrouters\(dq, \(dqdata\(dq: \(dq192.0.2.251\(dq } ] } ], \(dqreservations\(dq: [ // Clients on this list will be added to the KNOWN class. Some // will also be added to the blocked class. { \(dqhw\-address\(dq: \(dqaa:bb:cc:dd:ee:fe\(dq, \(dqclient\-classes\(dq: [ \(dqblocked\(dq ] }, { \(dqhw\-address\(dq: \(dq11:22:33:44:55:66\(dq } ], \(dqreservations\-in\-subnet\(dq: true, \(dqsubnet4\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.2.1\-192.0.2.200\(dq } ], \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqrouters\(dq, \(dqdata\(dq: \(dq192.0.2.250\(dq } ] } ] } .EE .UNINDENT .UNINDENT .SS Shared Networks in DHCPv4 .sp DHCP servers use subnet information in two ways. It is used to both determine the point of attachment, i.e. where the client is connected to the network, and to group information pertaining to a specific location in the network. Sometimes it is useful to have more than one logical IP subnet deployed on the same physical link. Understanding that two or more subnets are used on the same link requires additional logic in the DHCP server. This capability is called \(dqshared networks\(dq in Kea, and sometimes also \(dqshared subnets\(dq; in Microsoft\(aqs nomenclature it is called \(dqmultinet.\(dq .sp There are many cases where the shared networks feature is useful; here we explain just a handful of the most common ones. The first and by far most common use case is an existing IPv4 network that has grown and is running out of available address space. Rather than migrating all devices to a new, larger subnet, it is easier to simply configure additional subnets on top of the existing one. Sometimes, due to address space fragmentation (e.g. only many disjointed /24s are available), this is the only choice. Also, configuring additional subnets has the advantage of not disrupting the operation of existing devices. .sp Another very frequent use case comes from cable networks. There are two types of devices in cable networks: cable modems and the end\-user devices behind them. It is a common practice to use different subnets for cable modems to prevent users from tinkering with them. In this case, the distinction is based on the type of device, rather than on address\-space exhaustion. .sp A client connected to a shared network may be assigned an address from any of the pools defined within the subnets belonging to the shared network. Internally, the server selects one of the subnets belonging to a shared network and tries to allocate an address from this subnet. If the server is unable to allocate an address from the selected subnet (e.g., due to address\-pool exhaustion), it uses another subnet from the same shared network and tries to allocate an address from this subnet. The server typically allocates all addresses available in a given subnet before it starts allocating addresses from other subnets belonging to the same shared network. However, in certain situations the client can be allocated an address from another subnet before the address pools in the first subnet get exhausted; this sometimes occurs when the client provides a hint that belongs to another subnet, or the client has reservations in a subnet other than the default. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Deployments should not assume that Kea waits until it has allocated all the addresses from the first subnet in a shared network before allocating addresses from other subnets. .UNINDENT .UNINDENT .sp To define a shared network, an additional configuration scope is introduced: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp4\(dq: { \(dqshared\-networks\(dq: [ { # Name of the shared network. It may be an arbitrary string # and it must be unique among all shared networks. \(dqname\(dq: \(dqmy\-secret\-lair\-level\-1\(dq, # The subnet selector can be specified at the shared\-network level. # Subnets from this shared network will be selected for directly # connected clients sending requests to the server\(aqs \(dqeth0\(dq interface. \(dqinterface\(dq: \(dqeth0\(dq, # This starts a list of subnets in this shared network. # There are two subnets in this example. \(dqsubnet4\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq10.0.0.0/8\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq10.0.0.1 \- 10.0.0.99\(dq } ] }, { \(dqid\(dq: 2, \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.2.100 \- 192.0.2.199\(dq } ] } ] } ], # end of shared\-networks # It is likely that in the network there will be a mix of regular, # \(dqplain\(dq subnets and shared networks. It is perfectly valid to mix # them in the same configuration file. # # This is a regular subnet. It is not part of any shared network. \(dqsubnet4\(dq: [ { \(dqid\(dq: 3, \(dqsubnet\(dq: \(dq192.0.3.0/24\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.3.1 \- 192.0.3.200\(dq } ], \(dqinterface\(dq: \(dqeth1\(dq } ] } } .EE .UNINDENT .UNINDENT .sp As demonstrated in the example, it is possible to mix shared and regular (\(dqplain\(dq) subnets. Each shared network must have a unique name. This is similar to the ID for subnets, but gives administrators more flexibility. It is used for logging, but also internally for identifying shared networks. .sp In principle it makes sense to define only shared networks that consist of two or more subnets. However, for testing purposes, an empty subnet or a network with just a single subnet is allowed. This is not a recommended practice in production networks, as the shared network logic requires additional processing and thus lowers the server\(aqs performance. To avoid unnecessary performance degradation, shared subnets should only be defined when required by the deployment. .sp Shared networks provide the ability to specify many parameters in the shared network scope that apply to all subnets within it. If necessary, it is possible to specify a parameter in the shared\-network scope and then override its value in the subnet scope. For example: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqshared\-networks\(dq: [ { \(dqname\(dq: \(dqlab\-network3\(dq, \(dqinterface\(dq: \(dqeth0\(dq, # This applies to all subnets in this shared network, unless # values are overridden on subnet scope. \(dqvalid\-lifetime\(dq: 600, # This option is made available to all subnets in this shared # network. \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqlog\-servers\(dq, \(dqdata\(dq: \(dq1.2.3.4\(dq } ], \(dqsubnet4\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq10.0.0.0/8\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq10.0.0.1 \- 10.0.0.99\(dq } ], # This particular subnet uses different values. \(dqvalid\-lifetime\(dq: 1200, \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqlog\-servers\(dq, \(dqdata\(dq: \(dq10.0.0.254\(dq }, { \(dqname\(dq: \(dqrouters\(dq, \(dqdata\(dq: \(dq10.0.0.254\(dq } ] }, { \(dqid\(dq: 2, \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.2.100 \- 192.0.2.199\(dq } ], # This subnet does not specify its own valid\-lifetime value, # so it is inherited from shared network scope. \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqrouters\(dq, \(dqdata\(dq: \(dq192.0.2.1\(dq } ] } ] } ], ... } .EE .UNINDENT .UNINDENT .sp In this example, there is a \fBlog\-servers\fP option defined that is available to clients in both subnets in this shared network. Also, the valid lifetime is set to 10 minutes (600s). However, the first subnet overrides some of the values (the valid lifetime is 20 minutes, there is a different IP address for \fBlog\-servers\fP), but also adds its own option (the router address). Assuming a client asking for router and \fBlog\-servers\fP options is assigned a lease from this subnet, it will get a lease for 20 minutes and a \fBlog\-servers\fP and routers value of 10.0.0.254. If the same client is assigned to the second subnet, it will get a 10\-minute lease, a \fBlog\-servers\fP value of 1.2.3.4, and routers set to 192.0.2.1. .SS Local and Relayed Traffic in Shared Networks .sp It is possible to specify an interface name at the shared\-network level, to tell the server that this specific shared network is reachable directly (not via relays) using the local network interface. As all subnets in a shared network are expected to be used on the same physical link, it is a configuration error to attempt to define a shared network using subnets that are reachable over different interfaces. In other words, all subnets within the shared network must have the same value for the \fBinterface\fP parameter. The following configuration is an example of what \fBNOT\fP to do: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqshared\-networks\(dq: [ { \(dqname\(dq: \(dqoffice\-floor\-2\(dq, \(dqsubnet4\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq10.0.0.0/8\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq10.0.0.1 \- 10.0.0.99\(dq } ], \(dqinterface\(dq: \(dqeth0\(dq }, { \(dqid\(dq: 2, \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.2.100 \- 192.0.2.199\(dq } ], # Specifying the different interface name is a configuration # error. This value should rather be \(dqeth0\(dq or the interface # name in the other subnet should be \(dqeth1\(dq. \(dqinterface\(dq: \(dqeth1\(dq } ] } ], \&... } .EE .UNINDENT .UNINDENT .sp To minimize the chance of configuration errors, it is often more convenient to simply specify the interface name once, at the shared\-network level, as shown in the example below. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqshared\-networks\(dq: [ { \(dqname\(dq: \(dqoffice\-floor\-2\(dq, # This tells Kea that the whole shared network is reachable over a # local interface. This applies to all subnets in this network. \(dqinterface\(dq: \(dqeth0\(dq, \(dqsubnet4\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq10.0.0.0/8\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq10.0.0.1 \- 10.0.0.99\(dq } ] }, { \(dqid\(dq: 2, \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.2.100 \- 192.0.2.199\(dq } ] } ] } ], \&... } .EE .UNINDENT .UNINDENT .sp With relayed traffic, subnets are typically selected using the relay agents\(aq addresses. If the subnets are used independently (not grouped within a shared network), a different relay address can be specified for each of these subnets. When multiple subnets belong to a shared network they must be selected via the same relay address and, similarly to the case of the local traffic described above, it is a configuration error to specify different relay addresses for the respective subnets in the shared network. The following configuration is another example of what \fBNOT\fP to do: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqshared\-networks\(dq: [ { \(dqname\(dq: \(dqkakapo\(dq, \(dqsubnet4\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq192.0.2.0/26\(dq, \(dqrelay\(dq: { \(dqip\-addresses\(dq: [ \(dq192.1.1.1\(dq ] }, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.2.63 \- 192.0.2.63\(dq } ] }, { \(dqid\(dq: 2, \(dqsubnet\(dq: \(dq10.0.0.0/24\(dq, \(dqrelay\(dq: { # Specifying a different relay address for this # subnet is a configuration error. In this case # it should be 192.1.1.1 or the relay address # in the previous subnet should be 192.2.2.2. \(dqip\-addresses\(dq: [ \(dq192.2.2.2\(dq ] }, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq10.0.0.16 \- 10.0.0.16\(dq } ] } ] } ], \&... } .EE .UNINDENT .UNINDENT .sp Again, it is better to specify the relay address at the shared\-network level; this value will be inherited by all subnets belonging to the shared network. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqshared\-networks\(dq: [ { \(dqname\(dq: \(dqkakapo\(dq, \(dqrelay\(dq: { # This relay address is inherited by both subnets. \(dqip\-addresses\(dq: [ \(dq192.1.1.1\(dq ] }, \(dqsubnet4\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq192.0.2.0/26\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.2.63 \- 192.0.2.63\(dq } ] }, { \(dqid\(dq: 2, \(dqsubnet\(dq: \(dq10.0.0.0/24\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq10.0.0.16 \- 10.0.0.16\(dq } ] } ] } ], \&... } .EE .UNINDENT .UNINDENT .sp Even though it is technically possible to configure two (or more) subnets within the shared network to use different relay addresses, this will almost always lead to a different behavior than what the user expects. In this case, the Kea server will initially select one of the subnets by matching the relay address in the client\(aqs packet with the subnet\(aqs configuration. However, it MAY end up using the other subnet (even though it does not match the relay address) if the client already has a lease in this subnet or has a host reservation in this subnet, or simply if the initially selected subnet has no more addresses available. Therefore, it is strongly recommended to always specify subnet selectors (interface or relay address) at the shared\-network level if the subnets belong to a shared network, as it is rarely useful to specify them at the subnet level and may lead to the configuration errors described above. .SS Client Classification in Shared Networks .sp Sometimes it is desirable to segregate clients into specific subnets based on certain properties. This mechanism is called client classification and is described in \fI\%Client Classification\fP\&. .sp Client classification can be applied to subnets belonging to shared networks in the same way as it is used for subnets specified outside of shared networks. It is important to understand how the server selects subnets for clients when client classification is in use, to ensure that the appropriate subnet is selected for a given client type. .sp If a subnet is associated with one or more classes, only the clients belonging to at least one of these classes may use this subnet. If there are no classes specified for a subnet, any client connected to a given shared network can use this subnet. A common mistake is to assume that a subnet that includes a client class is preferred over subnets without client classes. .sp The \fBclient\-classes\fP parameter may be specified at the shared network, subnet, and/or pool scopes. If specified for a shared network, clients must belong to at least one of the classes specified for that network to be considered for subnets within that network. If specified for a subnet, clients must belong to at least one of the classes specified for that subnet to be considered for any of that subnet\(aqs pools or host reservations. If specified for a pool, clients must belong to at least one of the classes specified for that pool to be given a lease from that pool. .sp Consider the following example: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqb\-devices\(dq, \(dqtest\(dq: \(dqoption[93].hex == 0x0002\(dq } ], \(dqshared\-networks\(dq: [ { \(dqname\(dq: \(dqgalah\(dq, \(dqinterface\(dq: \(dqeth0\(dq, \(dqsubnet4\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq192.0.2.0/26\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.2.1 \- 192.0.2.63\(dq } ] }, { \(dqid\(dq: 2, \(dqsubnet\(dq: \(dq10.0.0.0/24\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq10.0.0.2 \- 10.0.0.250\(dq } ], \(dqclient\-classes\(dq: [ \(dqb\-devices\(dq ] } ] } ] } .EE .UNINDENT .UNINDENT .sp If the client belongs to the \(dqb\-devices\(dq class (because it includes option 93 with a value of 0x0002), that does not guarantee that the subnet 10.0.0.0/24 will be used (or preferred) for this client. The server can use either of the two subnets, because the subnet 192.0.2.0/26 is also allowed for this client. The client classification used in this case should be perceived as a way to restrict access to certain subnets, rather than as a way to express subnet preference. For example, if the client does not belong to the \(dqb\-devices\(dq class, it may only use the subnet 192.0.2.0/26 and will never use the subnet 10.0.0.0/24. .sp A typical use case for client classification is in a cable network, where cable modems should use one subnet and other devices should use another subnet within the same shared network. In this case it is necessary to apply classification on all subnets. The following example defines two classes of devices, and the subnet selection is made based on option 93 values. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqa\-devices\(dq, \(dqtest\(dq: \(dqoption[93].hex == 0x0001\(dq }, { \(dqname\(dq: \(dqb\-devices\(dq, \(dqtest\(dq: \(dqoption[93].hex == 0x0002\(dq } ], \(dqshared\-networks\(dq: [ { \(dqname\(dq: \(dqgalah\(dq, \(dqinterface\(dq: \(dqeth0\(dq, \(dqsubnet4\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq192.0.2.0/26\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.2.1 \- 192.0.2.63\(dq } ], \(dqclient\-classes\(dq: [ \(dqa\-devices\(dq ] }, { \(dqid\(dq: 2, \(dqsubnet\(dq: \(dq10.0.0.0/24\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq10.0.0.2 \- 10.0.0.250\(dq } ], \(dqclient\-classes\(dq: [ \(dqb\-devices\(dq ] } ] } ] } .EE .UNINDENT .UNINDENT .sp In this example each class has its own restriction. Only clients that belong to class \(dqa\-devices\(dq are able to use subnet 192.0.2.0/26 and only clients belonging to \(dqb\-devices\(dq are able to use subnet 10.0.0.0/24. Care should be taken not to define too\-restrictive classification rules, as clients that are unable to use any subnets will be refused service. However, this may be a desired outcome if one wishes to provide service only to clients with known properties (e.g. only VoIP phones allowed on a given link). .sp It is possible to achieve an effect similar to the one presented in this section without the use of shared networks. If the subnets are placed in the global subnets scope, rather than in the shared network, the server will still use classification rules to pick the right subnet for a given class of devices. The major benefit of placing subnets within the shared network is that common parameters for the logically grouped subnets can be specified once in the shared\-network scope, e.g. the \fBinterface\fP or \fBrelay\fP parameter. All subnets belonging to this shared network will inherit those parameters. .SS Host Reservations in Shared Networks .sp Subnets that are part of a shared network allow host reservations, similar to regular subnets: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqshared\-networks\(dq: [ { \(dqname\(dq: \(dqfrog\(dq, \(dqinterface\(dq: \(dqeth0\(dq, \(dqsubnet4\(dq: [ { \(dqsubnet\(dq: \(dq192.0.2.0/26\(dq, \(dqid\(dq: 100, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.2.1 \- 192.0.2.63\(dq } ], \(dqreservations\(dq: [ { \(dqhw\-address\(dq: \(dqaa:bb:cc:dd:ee:ff\(dq, \(dqip\-address\(dq: \(dq192.0.2.28\(dq } ] }, { \(dqsubnet\(dq: \(dq10.0.0.0/24\(dq, \(dqid\(dq: 101, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq10.0.0.1 \- 10.0.0.254\(dq } ], \(dqreservations\(dq: [ { \(dqhw\-address\(dq: \(dq11:22:33:44:55:66\(dq, \(dqip\-address\(dq: \(dq10.0.0.29\(dq } ] } ] } ] } .EE .UNINDENT .UNINDENT .sp It is worth noting that Kea conducts additional checks when processing a packet if shared networks are defined. First, instead of simply checking whether there is a reservation for a given client in its initially selected subnet, Kea looks through all subnets in a shared network for a reservation. This is one of the reasons why defining a shared network may impact performance. If there is a reservation for a client in any subnet, that particular subnet is selected for the client. Although it is technically not an error, it is considered bad practice to define reservations for the same host in multiple subnets belonging to the same shared network. .sp While not strictly mandatory, it is strongly recommended to use explicit \(dqid\(dq values for subnets if database storage will be used for host reservations. If an ID is not specified, the values for it are auto\-generated, i.e. Kea assigns increasing integer values starting from 1. Thus, the auto\-generated IDs are not stable across configuration changes. .SS Server Identifier in DHCPv4 .sp The DHCPv4 protocol uses a \(dqserver identifier\(dq to allow clients to discriminate between several servers present on the same link; this value is an IPv4 address of the server. The server chooses the IPv4 address of the interface on which the message from the client (or relay) has been received. A single server instance uses multiple server identifiers if it is receiving queries on multiple interfaces. .sp It is possible to override the default server identifier values by specifying the \fBdhcp\-server\-identifier\fP option. This option configuration is only supported at the subnet, shared network, client class, and global levels. It must not be specified at the host\-reservation level. When configuring the \fBdhcp\-server\-identifier\fP option at client\-class level, the class must not set the \fBonly\-in\-additional\-list\fP flag, because this class would not be evaluated before the server determines if the received DHCP message should be accepted for processing. Such classes are evaluated after subnet selection. See \fI\%Additional Classification\fP for details. .sp The following example demonstrates how to override the server identifier for a subnet: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqsubnet4\(dq: [ { \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq, \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqdhcp\-server\-identifier\(dq, \(dqdata\(dq: \(dq10.2.5.76\(dq } ], ... } ], \&... } .EE .UNINDENT .UNINDENT .SS How the DHCPv4 Server Selects a Subnet for the Client .sp The DHCPv4 server differentiates among directly connected clients, clients trying to renew leases, and clients sending their messages through relays. For directly connected clients, the server checks the configuration for the interface on which the message has been received and, if the server configuration does not match any configured subnet, the message is discarded. .sp An optional interface parameter is available within a subnet definition to designate that a given subnet is local, i.e. reachable directly over the specified interface. For example, a server that is intended to serve a local subnet over eth0 may be configured as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqsubnet4\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.2.100 \- 192.0.2.199\(dq } ], \(dqinterface\(dq: \(dqeth0\(dq } ], ... } .EE .UNINDENT .UNINDENT .sp Assuming that the server\(aqs interface is configured with the IPv4 address 192.0.2.3, the server only processes messages received through this interface from a directly connected client if there is a subnet configured to which this IPv4 address belongs, such as 192.0.2.0/24. The server uses this subnet to assign an IPv4 address for the client. .sp The rule above does not apply when the client unicasts its message, i.e. is trying to renew its lease; such a message is accepted through any interface. The renewing client sets \fBciaddr\fP to the currently used IPv4 address, and the server uses this address to select the subnet for the client (in particular, to extend the lease using this address). .sp If the message is relayed it is accepted through any interface. The \fBgiaddr\fP set by the relay agent is used to select the subnet for the client. .sp It is also possible to specify a relay IPv4 address for a given subnet. It can be used to match incoming packets into a subnet in uncommon configurations, e.g. shared networks. See \fI\%Using a Specific Relay Agent for a Subnet\fP for details. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The subnet selection mechanism described in this section is based on the assumption that client classification is not used. The classification mechanism alters the way in which a subnet is selected for the client, depending on the classes to which the client belongs. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 When the selected subnet is a member of a shared network, the whole shared network is selected. .UNINDENT .UNINDENT .SS Using a Specific Relay Agent for a Subnet .sp A relay must have an interface connected to the link on which the clients are being configured. Typically the relay has an IPv4 address configured on that interface, which belongs to the subnet from which the server assigns addresses. Normally, the server is able to use the IPv4 address inserted by the relay (in the \fBgiaddr\fP field of the DHCPv4 packet) to select the appropriate subnet. .sp However, that is not always the case. In certain uncommon — but valid — deployments, the relay address may not match the subnet. This usually means that there is more than one subnet allocated for a given link. The two most common examples of this are long\-lasting network renumbering (where both old and new address spaces are still being used) and a cable network. In a cable network, both cable modems and the devices behind them are physically connected to the same link, yet they use distinct addressing. In such a case, the DHCPv4 server needs additional information (the IPv4 address of the relay) to properly select an appropriate subnet. .sp The following example assumes that there is a subnet 192.0.2.0/24 that is accessible via a relay that uses 10.0.0.1 as its IPv4 address. The server is able to select this subnet for any incoming packets that come from a relay that has an address in the 192.0.2.0/24 subnet. It also selects that subnet for a relay with address 10.0.0.1. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp4\(dq: { \(dqsubnet4\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.2.10 \- 192.0.2.20\(dq } ], \(dqrelay\(dq: { \(dqip\-addresses\(dq: [ \(dq10.0.0.1\(dq ] } } ] } } .EE .UNINDENT .UNINDENT .sp If \fBrelay\fP is specified, the \fBip\-addresses\fP parameter within it is mandatory. The \fBip\-addresses\fP parameter supports specifying a list of addresses. .SS Segregating IPv4 Clients in a Cable Network .sp In certain cases, it is useful to mix relay address information (introduced in \fI\%Using a Specific Relay Agent for a Subnet\fP) with client classification (explained in \fI\%Client Classification\fP). One specific example is in a cable network, where modems typically get addresses from a different subnet than all the devices connected behind them. .sp Let us assume that there is one Cable Modem Termination System (CMTS) with one CM MAC (a physical link that modems are connected to). We want the modems to get addresses from the 10.1.1.0/24 subnet, while everything connected behind the modems should get addresses from the 192.0.2.0/24 subnet. The CMTS that acts as a relay uses address 10.1.1.1. The following configuration can serve that situation: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqsubnet4\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq10.1.1.0/24\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq10.1.1.2 \- 10.1.1.20\(dq } ], \(dqclient\-classes\(dq: [ \(dqdocsis3.0\(dq ], \(dqrelay\(dq: { \(dqip\-addresses\(dq: [ \(dq10.1.1.1\(dq ] } }, { \(dqid\(dq: 2, \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.2.10 \- 192.0.2.20\(dq } ], \(dqrelay\(dq: { \(dqip\-addresses\(dq: [ \(dq10.1.1.1\(dq ] } } ], ... } .EE .UNINDENT .UNINDENT .SS Duplicate Addresses (DHCPDECLINE Support) .sp The DHCPv4 server is configured with a certain pool of addresses that it is expected to hand out to DHCPv4 clients. It is assumed that the server is authoritative and has complete jurisdiction over those addresses. However, for various reasons such as misconfiguration or a faulty client implementation that retains its address beyond the valid lifetime, there may be devices connected that use those addresses without the server\(aqs approval or knowledge. .sp Such an unwelcome event can be detected by legitimate clients (using ARP or ICMP Echo Request mechanisms) and reported to the DHCPv4 server using a DHCPDECLINE message. The server does a sanity check (to see whether the client declining an address really was supposed to use it) and then conducts a clean\-up operation. Any DNS entries related to that address are removed, the event is logged, and hooks are triggered. After that is complete, the address is marked as declined (which indicates that it is used by an unknown entity and thus not available for assignment) and a probation time is set on it. Unless otherwise configured, the probation period lasts 24 hours; after that time, the server will recover the lease (i.e. put it back into the available state) and the address will be available for assignment again. It should be noted that if the underlying issue of a misconfigured device is not resolved, the duplicate\-address scenario will repeat. If reconfigured correctly, this mechanism provides an opportunity to recover from such an event automatically, without any system administrator intervention. .sp To configure the decline probation period to a value other than the default, the following syntax can be used: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqdecline\-probation\-period\(dq: 3600, \(dqsubnet4\(dq: [ { ... }, ... ], ... } .EE .UNINDENT .UNINDENT .sp The parameter is expressed in seconds, so the example above instructs the server to recycle declined leases after one hour. .sp There are several statistics and hook points associated with the decline handling procedure. The \fBlease4_decline\fP hook point is triggered after the incoming DHCPDECLINE message has been sanitized and the server is about to decline the lease. The \fBdeclined\-addresses\fP statistic is increased after the hook returns (both the global and subnet\-specific variants). (See \fI\%Statistics in the DHCPv4 Server\fP and \fI\%Hook Libraries\fP for more details on DHCPv4 statistics and Kea hook points.) .sp Once the probation time elapses, the declined lease is recovered using the standard expired\-lease reclamation procedure, with several additional steps. In particular, both \fBdeclined\-addresses\fP statistics (global and subnet\-specific) are decreased. At the same time, \fBreclaimed\-declined\-addresses\fP statistics (again in two variants, global and subnet\-specific) are increased. .sp A note about statistics: The Kea server does not decrease the \fBassigned\-addresses\fP statistics when a DHCPDECLINE is received and processed successfully. While technically a declined address is no longer assigned, the primary usage of the \fBassigned\-addresses\fP statistic is to monitor pool utilization. Most people would forget to include \fBdeclined\-addresses\fP in the calculation, and would simply use \fBassigned\-addresses\fP/\fBtotal\-addresses\fP\&. This would cause a bias towards under\-representing pool utilization. As this has a potential to cause serious confusion, ISC decided not to decrease \fBassigned\-addresses\fP immediately after receiving DHCPDECLINE, but to do it later when Kea recovers the address back to the available pool. .SS Statistics in the DHCPv4 Server .sp The DHCPv4 server supports the following statistics: .SS DHCPv4 statistics .TS box center; l|l|l. T{ Statistic T} T{ Data Type T} T{ Description T} _ T{ pkt4\-received T} T{ integer T} T{ Number of DHCPv4 packets received. This includes all packets: valid, bogus, corrupted, rejected, etc. This statistic is expected to grow rapidly. T} _ T{ pkt4\-discover\-received T} T{ integer T} T{ Number of DHCPDISCOVER packets received. This statistic is expected to grow; its increase means that clients that just booted started their configuration process and their initial packets reached the Kea server. T} _ T{ pkt4\-offer\-received T} T{ integer T} T{ Number of DHCPOFFER packets received. This statistic is expected to remain zero at all times, as DHCPOFFER packets are sent by the server and the server is never expected to receive them. A non\-zero value indicates an error. One likely cause would be a misbehaving relay agent that incorrectly forwards DHCPOFFER messages towards the server, rather than back to the clients. T} _ T{ pkt4\-request\-received T} T{ integer T} T{ Number of DHCPREQUEST packets received. This statistic is expected to grow. Its increase means that clients that just booted received the server\(aqs response (DHCPOFFER) and accepted it, and are now requesting an address (DHCPREQUEST). T} _ T{ pkt4\-ack\-received T} T{ integer T} T{ Number of DHCPACK packets received. This statistic is expected to remain zero at all times, as DHCPACK packets are sent by the server and the server is never expected to receive them. A non\-zero value indicates an error. One likely cause would be a misbehaving relay agent that incorrectly forwards DHCPACK messages towards the server, rather than back to the clients. T} _ T{ pkt4\-nak\-received T} T{ integer T} T{ Number of DHCPNAK packets received. This statistic is expected to remain zero at all times, as DHCPNAK packets are sent by the server and the server is never expected to receive them. A non\-zero value indicates an error. One likely cause would be a misbehaving relay agent that incorrectly forwards DHCPNAK messages towards the server, rather than back to the clients. T} _ T{ pkt4\-release\-received T} T{ integer T} T{ Number of DHCPRELEASE packets received. This statistic is expected to grow. Its increase means that clients that had an address are shutting down or ceasing to use their addresses. T} _ T{ pkt4\-decline\-received T} T{ integer T} T{ Number of DHCPDECLINE packets received. This statistic is expected to remain close to zero. Its increase means that a client leased an address, but discovered that the address is currently used by an unknown device elsewhere in the network. T} _ T{ pkt4\-inform\-received T} T{ integer T} T{ Number of DHCPINFORM packets received. This statistic is expected to grow. Its increase means that there are clients that either do not need an address or already have an address and are interested only in getting additional configuration parameters. T} _ T{ pkt4\-unknown\-received T} T{ integer T} T{ Number of packets received of an unknown type. A non\-zero value of this statistic indicates that the server received a packet that it was not able to recognize, either with an unsupported type or possibly malformed (without a message\-type option). T} _ T{ pkt4\-sent T} T{ integer T} T{ Number of DHCPv4 packets sent. This statistic is expected to grow every time the server transmits a packet. In general, it should roughly match \fBpkt4\-received\fP, as most incoming packets cause the server to respond. There are exceptions (e.g. DHCPRELEASE), so do not worry if it is less than pkt4\-received. T} _ T{ pkt4\-offer\-sent T} T{ integer T} T{ Number of DHCPOFFER packets sent. This statistic is expected to grow in most cases after a DHCPDISCOVER is processed. There are certain uncommon but valid cases where incoming DHCPDISCOVER packets are dropped, but in general this statistic is expected to be close to \fBpkt4\-discover\-received\fP\&. T} _ T{ pkt4\-ack\-sent T} T{ integer T} T{ Number of DHCPACK packets sent. This statistic is expected to grow in most cases after a DHCPREQUEST is processed; there are certain cases where DHCPNAK is sent instead. In general, the sum of \fBpkt4\-ack\-sent\fP and \fBpkt4\-nak\-sent\fP should be close to \fBpkt4\-request\-received\fP\&. T} _ T{ pkt4\-nak\-sent T} T{ integer T} T{ Number of DHCPNAK packets sent. This statistic is expected to grow when the server chooses not to honor the address requested by a client. In general, the sum of \fBpkt4\-ack\-sent\fP and \fBpkt4\-nak\-sent\fP should be close to \fBpkt4\-request\-received\fP\&. T} _ T{ pkt4\-parse\-failed T} T{ integer T} T{ Number of incoming packets that could not be parsed. A non\-zero value of this statistic indicates that the server received a malformed or truncated packet. This may indicate problems in the network, faulty clients, or a bug in the server. T} _ T{ pkt4\-receive\-drop T} T{ integer T} T{ Number of incoming packets that were dropped. The exact reason for dropping packets is logged, but the most common reasons may be that an unacceptable packet type was received, direct responses are forbidden, or the server ID sent by the client does not match the server\(aqs server ID. T} _ T{ subnet[id].total\-addresses T} T{ integer T} T{ Total number of addresses available for DHCPv4 management for a given subnet; in other words, this is the count of all addresses in all configured pools. This statistic changes only during configuration updates. It does not take into account any addresses that may be reserved due to host reservation. The \fIid\fP is the the subnet ID of a given subnet. This statistic is exposed for each subnet separately, and is reset during a reconfiguration event. T} _ T{ subnet[id].pool[pid].total\-addresses T} T{ integer T} T{ Total number of addresses available for DHCPv4 management for a given subnet pool; in other words, this is the count of all addresses in configured subnet pool. This statistic changes only during configuration updates. It does not take into account any addresses that may be reserved due to host reservation. The \fIid\fP is the subnet ID of a given subnet. The \fIpid\fP is the pool ID of a given pool. This statistic is exposed for each subnet pool separately, and is reset during a reconfiguration event. T} _ T{ cumulative\-assigned\-addresses T} T{ integer T} T{ Cumulative number of addresses that have been assigned since server startup. It is incremented each time an address is assigned and is not reset when the server is reconfigured. T} _ T{ subnet[id].cumulative\-assigned\-addresses T} T{ integer T} T{ Cumulative number of assigned addresses in a given subnet. It increases every time a new lease is allocated (as a result of receiving a DHCPREQUEST message) and never decreases. The \fIid\fP is the subnet ID of the subnet. This statistic is exposed for each subnet separately, and is reset during a reconfiguration event. T} _ T{ subnet[id].pool[pid].cumulative\-assigned\-addresses T} T{ integer T} T{ Cumulative number of assigned addresses in a given subnet pool. It increases every time a new lease is allocated (as a result of receiving a DHCPREQUEST message) and never decreases. The \fIid\fP is the subnet ID of the subnet. The \fIpid\fP is the pool ID of the pool. This statistic is exposed for each subnet pool separately, and is reset during a reconfiguration event. T} _ T{ subnet[id].assigned\-addresses T} T{ integer T} T{ Number of assigned addresses in a given subnet. It increases every time a new lease is allocated (as a result of receiving a DHCPREQUEST message) and decreases every time a lease is released (a DHCPRELEASE message is received) or expires. The \fIid\fP is the subnet ID of the subnet. This statistic is exposed for each subnet separately, and is reset during a reconfiguration event. T} _ T{ subnet[id].pool[pid].assigned\-addresses T} T{ integer T} T{ Number of assigned addresses in a given subnet pool. It increases every time a new lease is allocated (as a result of receiving a DHCPREQUEST message) and decreases every time a lease is released (a DHCPRELEASE message is received) or expires. The \fIid\fP is the subnet ID of the subnet. The \fIpid\fP is the pool ID of the pool. This statistic is exposed for each subnet pool separately, and is reset during a reconfiguration event. T} _ T{ reclaimed\-leases T} T{ integer T} T{ Number of expired leases that have been reclaimed since server startup. It is incremented each time an expired lease is reclaimed and never decreases. It can be used as a long\-term indicator of how many actual leases have been reclaimed. This is a global statistic that covers all subnets. T} _ T{ subnet[id].reclaimed\-leases T} T{ integer T} T{ Number of expired leases associated with a given subnet that have been reclaimed since server startup. It is incremented each time an expired lease is reclaimed. The \fIid\fP is the subnet ID of a given subnet. This statistic is exposed for each subnet separately. T} _ T{ subnet[id].pool[pid].reclaimed\-leases T} T{ integer T} T{ Number of expired leases associated with a given subnet pool that have been reclaimed since server startup. It is incremented each time an expired lease is reclaimed. The \fIid\fP is the subnet ID of a given subnet. The \fIpid\fP is the pool ID of the pool. This statistic is exposed for each subnet pool separately. T} _ T{ declined\-addresses T} T{ integer T} T{ Number of IPv4 addresses that are currently declined; a count of the number of leases currently unavailable. Once a lease is recovered, this statistic is decreased; ideally, this statistic should be zero. If this statistic is non\-zero or increasing, a network administrator should investigate whether there is a misbehaving device in the network. This is a global statistic that covers all subnets. T} _ T{ subnet[id].declined\-addresses T} T{ integer T} T{ Number of IPv4 addresses that are currently declined in a given subnet; a count of the number of leases currently unavailable. Once a lease is recovered, this statistic is decreased; ideally, this statistic should be zero. If this statistic is non\-zero or increasing, a network administrator should investigate whether there is a misbehaving device in the network. The \fIid\fP is the subnet ID of a given subnet. This statistic is exposed for each subnet separately. T} _ T{ subnet[id].pool[pid].declined\-addresses T} T{ integer T} T{ Number of IPv4 addresses that are currently declined in a given subnet pool; a count of the number of leases currently unavailable. Once a lease is recovered, this statistic is decreased; ideally, this statistic should be zero. If this statistic is non\-zero or increasing, a network administrator should investigate whether there is a misbehaving device in the network. The \fIid\fP is the subnet ID of a given subnet. The \fIpid\fP is the pool ID of the pool. This statistic is exposed for each subnet pool separately. T} _ T{ reclaimed\-declined\-addresses T} T{ integer T} T{ Number of IPv4 addresses that were declined, but have now been recovered. Unlike \fBdeclined\-addresses\fP, this statistic never decreases. It can be used as a long\-term indicator of how many actual valid declines were processed and recovered from. This is a global statistic that covers all subnets. T} _ T{ subnet[id].reclaimed\-declined\-addresses T} T{ integer T} T{ Number of IPv4 addresses that were declined, but have now been recovered. Unlike \fBdeclined\-addresses\fP, this statistic never decreases. It can be used as a long\-term indicator of how many actual valid declines were processed and recovered from. The \fIid\fP is the subnet ID of a given subnet. This statistic is exposed for each subnet separately. T} _ T{ subnet[id].pool[pid].reclaimed\-declined\-addresses T} T{ integer T} T{ Number of IPv4 addresses that were declined, but have now been recovered. Unlike \fBdeclined\-addresses\fP, this statistic never decreases. It can be used as a long\-term indicator of how many actual valid declines were processed and recovered from. The \fIid\fP is the subnet ID of a given subnet. The \fIpid\fP is the pool ID of the pool. This statistic is exposed for each subnet pool separately. T} _ T{ pkt4\-lease\-query\-received T} T{ integer T} T{ Number of IPv4 DHCPLEASEQUERY packets received. (Only exists if the Leasequery hook library is loaded.) T} _ T{ pkt4\-lease\-query\-response\-unknown\-sent T} T{ integer T} T{ Number of IPv4 DHCPLEASEUNKNOWN responses sent. (Only exists if the Leasequery hook library is loaded.) T} _ T{ pkt4\-lease\-query\-response\-unassigned\-sent T} T{ integer T} T{ Number of IPv4 DHCPLEASEUNASSIGNED responses sent. (Only exists if the Leasequery hook library is loaded.) T} _ T{ pkt4\-lease\-query\-response\-active\-sent T} T{ integer T} T{ Number of IPv4 DHCPLEASEACTIVE responses sent. (Only exists if the Leasequery hook library is loaded.) T} _ T{ v4\-allocation\-fail T} T{ integer T} T{ Number of total address allocation failures for a particular client. This consists of the number of lease allocation attempts that the server made before giving up, if it was unable to use any of the address pools. This is a global statistic that covers all subnets. T} _ T{ subnet[id].v4\-allocation\-fail T} T{ integer T} T{ Number of total address allocation failures for a particular client. This consists of the number of lease allocation attempts that the server made before giving up, if it was unable to use any of the address pools. The \fIid\fP is the subnet ID of a given subnet. This statistic is exposed for each subnet separately. T} _ T{ v4\-allocation\-fail\-shared\-network T} T{ integer T} T{ Number of address allocation failures for a particular client connected to a shared network. This is a global statistic that covers all subnets. T} _ T{ subnet[id].v4\-allocation\-fail\-shared\-network T} T{ integer T} T{ Number of address allocation failures for a particular client connected to a shared network. The \fIid\fP is the subnet ID of a given subnet. This statistic is exposed for each subnet separately. T} _ T{ v4\-allocation\-fail\-subnet T} T{ integer T} T{ Number of address allocation failures for a particular client connected to a subnet that does not belong to a shared network. This is a global statistic that covers all subnets. T} _ T{ subnet[id].v4\-allocation\-fail\-subnet T} T{ integer T} T{ Number of address allocation failures for a particular client connected to a subnet that does not belong to a shared network. The \fIid\fP is the subnet ID of a given subnet. This statistic is exposed for each subnet separately. T} _ T{ v4\-allocation\-fail\-no\-pools T} T{ integer T} T{ Number of address allocation failures because the server could not use any configured pools for a particular client. It is also possible that all of the subnets from which the server attempted to assign an address lack address pools. In this case, it should be considered misconfiguration if an operator expects that some clients should be assigned dynamic addresses. This is a global statistic that covers all subnets. T} _ T{ subnet[id].v4\-allocation\-fail\-no\-pools T} T{ integer T} T{ Number of address allocation failures because the server could not use any configured pools for a particular client. It is also possible that all of the subnets from which the server attempted to assign an address lack address pools. In this case, it should be considered misconfiguration if an operator expects that some clients should be assigned dynamic addresses. The \fIid\fP is the subnet ID of a given subnet. This statistic is exposed for each subnet separately. T} _ T{ v4\-allocation\-fail\-classes T} T{ integer T} T{ Number of address allocation failures when the client\(aqs packet belongs to one or more classes. There may be several reasons why a lease was not assigned: for example, if all pools require packets to belong to certain classes and an incoming packet does not belong to any. Another case where this information may be useful is to indicate that the pool reserved for a given class has run out of addresses. This is a global statistic that covers all subnets. T} _ T{ subnet[id].v4\-allocation\-fail\-classes T} T{ integer T} T{ Number of address allocation failures when the client\(aqs packet belongs to one or more classes. There may be several reasons why a lease was not assigned: for example, if all pools require packets to belong to certain classes and an incoming packet does not belong to any. Another case where this information may be useful is to indicate that the pool reserved for a given class has run out of addresses. The \fIid\fP is the subnet ID of a given subnet. This statistic is exposed for each subnet separately. T} _ T{ v4\-lease\-reuses T} T{ integer T} T{ Number of times an IPv4 lease had its CLTT increased in memory and its expiration time left unchanged in persistent storage, as part of the lease caching feature. This is referred to as a lease reuse. This statistic is global. T} _ T{ subnet[id].v4\-lease\-reuses T} T{ integer T} T{ Number of times an IPv4 lease had its CLTT increased in memory and its expiration time left unchanged in persistent storage, as part of the lease caching feature. This is referred to as a lease reuse. This statistic is on a per\-subnet basis. The \fIid\fP is the subnet ID of a given subnet. T} _ T{ v4\-reservation\-conflicts T} T{ integer T} T{ Number of host reservation allocation conflicts which have occurred across every subnet. When a client sends a DHCP Discover and is matched to a host reservation which is already leased to another client, this counter is increased by 1. T} _ T{ subnet[id].v4\-reservation\-conflicts T} T{ integer T} T{ Number of host reservation allocation conflicts which have occurred in a specific subnet. When a client sends a DHCP Discover and is matched to a host reservation which is already leased to another client, this counter is increased by 1. T} .TE .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The pool ID can be configured on each pool by explicitly setting the \fBpool\-id\fP parameter in the pool parameter map. If not configured, \fBpool\-id\fP defaults to 0. The statistics related to pool ID 0 refer to all the statistics of all the pools that have an unconfigured \fBpool\-id\fP\&. The pool ID does not need to be unique within the subnet or across subnets. The statistics regarding a specific pool ID within a subnet are combined with the other statistics of all other pools with the same pool ID in the respective subnet. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 This section describes DHCPv4\-specific statistics. For a general overview and usage of statistics, see \fI\%Statistics\fP\&. .UNINDENT .UNINDENT .sp The DHCPv4 server provides two global parameters to control the default sample limits of statistics: .INDENT 0.0 .IP \(bu 2 \fBstatistic\-default\-sample\-count\fP \- determines the default maximum number of samples to be kept. The special value of 0 indicates that a default maximum age should be used. .IP \(bu 2 \fBstatistic\-default\-sample\-age\fP \- determines the default maximum age, in seconds, of samples to be kept. .UNINDENT .sp For instance, to reduce the statistic\-keeping overhead, set the default maximum sample count to 1 so only one sample is kept: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqstatistic\-default\-sample\-count\(dq: 1, \(dqsubnet4\(dq: [ { ... }, ... ], ... } .EE .UNINDENT .UNINDENT .sp Statistics can be retrieved periodically to gain more insight into Kea operations. One tool that leverages that capability is ISC Stork. See \fI\%Monitoring Kea With Stork\fP for details. .SS Management API for the DHCPv4 Server .sp The management API allows the issuing of specific management commands, such as statistics retrieval, reconfiguration, or shutdown. For more details, see \fI\%Management API\fP\&. By default there are no sockets open; to instruct Kea to open a socket, the following entry in the configuration file can be used: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqcontrol\-sockets\(dq: [ { \(dqsocket\-type\(dq: \(dqunix\(dq, \(dqsocket\-name\(dq: \(dq/path/to/the/unix/socket\(dq } ], \(dqsubnet4\(dq: [ { ... }, ... ], ... } .EE .UNINDENT .UNINDENT .SS UNIX Control Socket .sp Until Kea server 2.7.2 the only supported communication channel type was the UNIX stream socket with \fBsocket\-type\fP set to \fBunix\fP and \fBsocket\-name\fP to the file path of the UNIX/LOCAL socket. .sp The length of the path specified by the \fBsocket\-name\fP parameter is restricted by the maximum length for the UNIX socket name on the administrator\(aqs operating system, i.e. the size of the \fBsun_path\fP field in the \fBsockaddr_un\fP structure, decreased by 1. This value varies on different operating systems, between 91 and 107 characters. Typical values are 107 on Linux and 103 on FreeBSD. .sp Kea supports only one \fBunix\fP control socket in the \(dqcontrol\-sockets\(dq list. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 As of Kea 2.7.9, control sockets may only reside in the directory determined during compilation as \fB\(dq[kea\-install\-dir]/var/run/kea\(dq\fP, which must also have \fB0750\fP access rights. This path may be overridden at startup by setting the environment variable \fBKEA_CONTROL_SOCKET_DIR\fP to the desired path. If a path other than this value is used in \fBsocket\-name\fP, Kea will emit an error and refuse to start or, if already running, log an unrecoverable error. For ease of use in simply omit the path component from \fBsocket\-name\fP\&. .UNINDENT .UNINDENT .sp Communication over the control channel is conducted using JSON structures. See the \X'tty: link https://reports.kea.isc.org/dev_guide/d2/d96/ctrlSocket.html'\fI\%Control Channel section in the Kea Developer\(aqs Guide\fP\X'tty: link' for more details. .sp The DHCPv4 server supports the following operational commands: .INDENT 0.0 .IP \(bu 2 \fI\%build\-report\fP .IP \(bu 2 \fI\%config\-get\fP .IP \(bu 2 \fI\%config\-hash\-get\fP .IP \(bu 2 \fI\%config\-reload\fP .IP \(bu 2 \fI\%config\-set\fP .IP \(bu 2 \fI\%config\-test\fP .IP \(bu 2 \fI\%config\-write\fP .IP \(bu 2 \fI\%dhcp\-disable\fP .IP \(bu 2 \fI\%dhcp\-enable\fP .IP \(bu 2 \fI\%leases\-reclaim\fP .IP \(bu 2 \fI\%list\-commands\fP .IP \(bu 2 \fI\%shutdown\fP .IP \(bu 2 \fI\%status\-get\fP .IP \(bu 2 \fI\%version\-get\fP .UNINDENT .sp as described in \fI\%Commands Supported by Both the DHCPv4 and DHCPv6 Servers\fP\&. In addition, it supports the following statistics\-related commands: .INDENT 0.0 .IP \(bu 2 \fI\%statistic\-get\fP .IP \(bu 2 \fI\%statistic\-reset\fP .IP \(bu 2 \fI\%statistic\-remove\fP .IP \(bu 2 \fI\%statistic\-get\fP\-all .IP \(bu 2 \fI\%statistic\-reset\fP\-all .IP \(bu 2 \fI\%statistic\-remove\fP\-all .IP \(bu 2 \fI\%statistic\-sample\-age\-set\fP .IP \(bu 2 \fI\%statistic\-sample\-age\-set\fP\-all .IP \(bu 2 \fI\%statistic\-sample\-count\-set\fP .IP \(bu 2 \fI\%statistic\-sample\-count\-set\fP\-all .UNINDENT .sp as described in \fI\%Commands for Manipulating Statistics\fP\&. .SS HTTP/HTTPS Control Socket .sp The \fBsocket\-type\fP must be \fBhttp\fP or \fBhttps\fP (when the type is \fBhttps\fP TLS is required). The \fBsocket\-address\fP (default \fB127.0.0.1\fP) and \fBsocket\-port\fP (default 8000) specify an IP address and port to which the HTTP service will be bound. .sp Since Kea 2.7.5 the \fBhttp\-headers\fP parameter specifies a list of extra HTTP headers to add to HTTP responses. .sp The \fBtrust\-anchor\fP, \fBcert\-file\fP, \fBkey\-file\fP, and \fBcert\-required\fP parameters specify the TLS setup for HTTP, i.e. HTTPS. If these parameters are not specified, HTTP is used. The TLS/HTTPS support in Kea is described in \fI\%TLS/HTTPS Support\fP\&. .sp Basic HTTP authentication protects against unauthorized uses of the control agent by local users. For protection against remote attackers, HTTPS and reverse proxy of \fI\%Secure Connections\fP provide stronger security. .sp The authentication is described in the \fBauthentication\fP block with the mandatory \fBtype\fP parameter, which selects the authentication. Currently only the basic HTTP authentication (type basic) is supported. .sp The \fBrealm\fP authentication parameter (default \fBkea\-dhcpv4\-server\fP is used for error messages when the basic HTTP authentication is required but the client is not authorized. .sp When the \fBclients\fP authentication list is configured and not empty, basic HTTP authentication is required. Each element of the list specifies a user ID and a password. The user ID is mandatory, must not be empty, and must not contain the colon (:) character. The password is optional; when it is not specified an empty password is used. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The basic HTTP authentication user ID and password are encoded in UTF\-8, but the current Kea JSON syntax only supports the Latin\-1 (i.e. 0x00..0xff) Unicode subset. .UNINDENT .UNINDENT .sp To avoid exposing the user ID and/or the associated password, these values can be read from files. The syntax is extended by: .INDENT 0.0 .IP \(bu 2 The \fBdirectory\fP authentication parameter, which handles the common part of file paths. The default value is the empty string. .IP \(bu 2 The \fBpassword\-file\fP client parameter, which, alongside the \fBdirectory\fP parameter, specifies the path of a file that can contain the password, or when no user ID is given, the whole basic HTTP authentication secret. .IP \(bu 2 The \fBuser\-file\fP client parameter, which, with the \fBdirectory\fP parameter, specifies the path of a file where the user ID can be read. .UNINDENT .sp Since Kea\-2.7.6 Kea supports multiple HTTP/HTTPS connections. Both IPv4 and IPv6 addresses can be used. The server will issue an error when changing the socket type from HTTP to HTTPS or from HTTPS to HTTP using the same address and port. This action is not allowed as it might introduce a security issue accidentally caused by a user mistake. A different address or port must be specified when using the \(dqconfig\-set\(dq command to switch from HTTP to HTTPS or from HTTPS to HTTP. The same applies when modyfying the configuration file and then running \(dqconfig\-reload\(dq command. .sp When files are used, they are read when the configuration is loaded, to detect configuration errors as soon as possible. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqcontrol\-sockets\(dq: [ { \(dqsocket\-type\(dq: \(dqhttps\(dq, \(dqsocket\-address\(dq: \(dq10.20.30.40\(dq, \(dqsocket\-port\(dq: 8004, \(dqhttp\-headers\(dq: [ { \(dqname\(dq: \(dqStrict\-Transport\-Security\(dq, \(dqvalue\(dq: \(dqmax\-age=31536000\(dq } ], \(dqtrust\-anchor\(dq: \(dq/path/to/the/ca\-cert.pem\(dq, \(dqcert\-file\(dq: \(dq/path/to/the/agent\-cert.pem\(dq, \(dqkey\-file\(dq: \(dq/path/to/the/agent\-key.pem\(dq, \(dqcert\-required\(dq: true, \(dqauthentication\(dq: { \(dqtype\(dq: \(dqbasic\(dq, \(dqrealm\(dq: \(dqkea\-dhcpv4\-server\(dq, \(dqclients\(dq: [ { \(dquser\(dq: \(dqadmin\(dq, \(dqpassword\(dq: \(dq1234\(dq } ] } }, { \(dqsocket\-type\(dq: \(dqhttp\(dq, \(dqsocket\-address\(dq: \(dq2010:30:40::50\(dq, \(dqsocket\-port\(dq: 8004 } ], \(dqsubnet4\(dq: [ { ... }, ... ], ... } .EE .UNINDENT .UNINDENT .SS User Contexts in IPv4 .sp Kea allows the loading of hook libraries that can sometimes benefit from additional parameters. If such a parameter is specific to the whole library, it is typically defined as a parameter for the hook library. However, sometimes there is a need to specify parameters that are different for each pool. .sp See \fI\%Comments and User Context\fP for additional background regarding the user\-context idea. See \fI\%User Contexts in Hooks\fP for a discussion from the hooks perspective. .sp User contexts can be specified at global scope; at the shared\-network, subnet, pool, client\-class, option\-data, or definition level; and via host reservation. One other useful feature is the ability to store comments or descriptions. .sp Let\(aqs consider an imaginary case of devices that have colored LED lights. Depending on their location, they should glow red, blue, or green. It would be easy to write a hook library that would send specific values, maybe as a vendor option. However, the server has to have some way to specify that value for each pool. This need is addressed by user contexts. In essence, any user data can be specified in the user context as long as it is a valid JSON map. For example, the aforementioned case of LED devices could be configured in the following way: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqsubnet4\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.2.10 \- 192.0.2.20\(dq, # This is pool specific user context \(dquser\-context\(dq: { \(dqcolor\(dq: \(dqred\(dq } } ], # This is a subnet\-specific user context. Any type # of information can be entered here as long as it is valid JSON. \(dquser\-context\(dq: { \(dqcomment\(dq: \(dqnetwork on the second floor\(dq, \(dqlast\-modified\(dq: \(dq2017\-09\-04 13:32\(dq, \(dqdescription\(dq: \(dqyou can put anything you like here\(dq, \(dqphones\(dq: [ \(dqx1234\(dq, \(dqx2345\(dq ], \(dqdevices\-registered\(dq: 42, \(dqbilling\(dq: false } } ] } .EE .UNINDENT .UNINDENT .sp Kea does not interpret or use the user\-context information; it simply stores it and makes it available to the hook libraries. It is up to each hook library to extract that information and use it. The parser translates a \fBcomment\fP entry into a user context with the entry, which allows a comment to be attached inside the configuration itself. .SS Supported DHCP Standards .sp The following standards are currently supported in Kea: .INDENT 0.0 .IP \(bu 2 \fIBOOTP Vendor Information Extensions\fP, \X'tty: link https://tools.ietf.org/html/rfc1497'\fI\%RFC 1497\fP\X'tty: link': This requires the open source BOOTP hook to be loaded. See \fI\%libdhcp_bootp.so: Support for BOOTP Clients\fP for details. .IP \(bu 2 \fIDynamic Host Configuration Protocol\fP, \X'tty: link https://tools.ietf.org/html/rfc1531'\fI\%RFC 1531\fP\X'tty: link': This RFC is obsolete and was replaced by RFC 1541, which in turn was replaced by RFC 2131. Kea supports all three RFCs. .IP \(bu 2 \fIClarifications and Extensions for the Bootstrap Protocol\fP, \X'tty: link https://tools.ietf.org/html/rfc1532'\fI\%RFC 1532\fP\X'tty: link': This RFC has an editorial error and was quickly superseeded by RFC 1542. Kea supports them both. .IP \(bu 2 \fIDHCP Options and BOOTP Vendor Extensions\fP, \X'tty: link https://tools.ietf.org/html/rfc1533'\fI\%RFC 1533\fP\X'tty: link': This RFC is obsolete and was replaced by RFC 2132. Nevertheless, Kea supports the options defined in it. .IP \(bu 2 \fIDynamic Host Configuration Protocol\fP, \X'tty: link https://tools.ietf.org/html/rfc1541'\fI\%RFC 1541\fP\X'tty: link': This RFC is obsolete and was replaced by RFC 2131. Kea supports both. .IP \(bu 2 \fIClarifications and Extensions for the Bootstrap Protocol\fP, \X'tty: link https://tools.ietf.org/html/rfc1542'\fI\%RFC 1542\fP\X'tty: link': This RFC is supported. .IP \(bu 2 \fIDynamic Host Configuration Protocol\fP, \X'tty: link https://tools.ietf.org/html/rfc2131'\fI\%RFC 2131\fP\X'tty: link': Supported messages are DHCPDISCOVER (1), DHCPOFFER (2), DHCPREQUEST (3), DHCPRELEASE (7), DHCPINFORM (8), DHCPACK (5), and DHCPNAK(6). .IP \(bu 2 \fIDHCP Options and BOOTP Vendor Extensions\fP, \X'tty: link https://tools.ietf.org/html/rfc2132'\fI\%RFC 2132\fP\X'tty: link': Supported options are PAD (0), END(255), Message Type(53), DHCP Server Identifier (54), Domain Name (15), DNS Servers (6), IP Address Lease Time (51), Subnet Mask (1), and Routers (3). .IP \(bu 2 \fIDHCP Options for Novell Directory Services\fP, \X'tty: link https://tools.ietf.org/html/rfc2241'\fI\%RFC 2241\fP\X'tty: link': All three options are supported. .IP \(bu 2 \fIManagement of IP numbers by peg\-dhcp\fP, \X'tty: link https://tools.ietf.org/html/rfc2322'\fI\%RFC 2322\fP\X'tty: link': This RFC is supported, although additional hardware is required for full deployment. .IP \(bu 2 \fIDHCP Option for The Open Group\(aqs User Authentication Protocol\fP, \X'tty: link https://tools.ietf.org/html/rfc2485'\fI\%RFC 2485\fP\X'tty: link': The option is supported. .IP \(bu 2 \fIDHCP Option to Disable Stateless Auto\-Configuration in IPv4 Clients\fP, \X'tty: link https://tools.ietf.org/html/rfc2563'\fI\%RFC 2563\fP\X'tty: link': The option is supported. .IP \(bu 2 \fIDHCP Options for Service Location Protocol\fP, \X'tty: link https://tools.ietf.org/html/rfc2610'\fI\%RFC 2610\fP\X'tty: link': Both options are supported. .IP \(bu 2 \fIThe Name Service Search Option for DHCP\fP, \X'tty: link https://tools.ietf.org/html/rfc2937'\fI\%RFC 2937\fP\X'tty: link': The option is supported. .IP \(bu 2 \fIThe User Class Option for DHCP\fP, \X'tty: link https://tools.ietf.org/html/rfc3004'\fI\%RFC 3004\fP\X'tty: link': The user class is supported and can be used in any expression. The option\(aqs structure is not parsed and has to be referenced using hex. .IP \(bu 2 \fIThe IPv4 Subnet Selection Option for DHCP\fP, \X'tty: link https://tools.ietf.org/html/rfc3011'\fI\%RFC 3011\fP\X'tty: link': The subnet\-selection option is supported; if received in a packet, it is used in the subnet\-selection process. .IP \(bu 2 \fIDHCP Relay Agent Information Option\fP, \X'tty: link https://tools.ietf.org/html/rfc3046'\fI\%RFC 3046\fP\X'tty: link': Relay Agent Information, Circuit ID, and Remote ID options are supported. .IP \(bu 2 \fIThe DOCSIS (Data\-Over\-Cable Service Interface Specifications) Device Class DHCP (Dynamic Host Configuration Protocol) Relay Agent Information Sub\-option\fP, \X'tty: link https://tools.ietf.org/html/rfc3256'\fI\%RFC 3256\fP\X'tty: link': The DOCSIS sub\-option is supported and can be used in any expression. .IP \(bu 2 \fIEncoding Long Options in the Dynamic Host Configuration Protocol (DHCPv4)\fP, \X'tty: link https://tools.ietf.org/html/rfc3396'\fI\%RFC 3396\fP\X'tty: link': The Kea server can both receive and send long options. The long options can be configured and Kea will send them as separate instances if the payload length is longer than 255 octets. .IP \(bu 2 \fIDynamic Host Configuration Protocol (DHCP) Domain Search Option\fP, \X'tty: link https://tools.ietf.org/html/rfc3397'\fI\%RFC 3397\fP\X'tty: link': The option is supported. .IP \(bu 2 \fIThe Classless Static Route Option for Dynamic Host Configuration Protocol (DHCP) version 4\fP, \X'tty: link https://tools.ietf.org/html/rfc3442'\fI\%RFC 3442\fP\X'tty: link': The option is supported. .IP \(bu 2 \fIDynamic Host Configuration Protocol (DHCP) Option for CableLabs Client Configuration\fP, \X'tty: link https://tools.ietf.org/html/rfc3495'\fI\%RFC 3495\fP\X'tty: link': The option and its suboptions 1, 2, 4, 5, 6, 7 and 8 are supported. See \fI\%CableLabs Client Conf Suboptions\fP for details. .IP \(bu 2 \fILink Selection sub\-option for the Relay Agent Option\fP, \X'tty: link https://tools.ietf.org/html/rfc3527'\fI\%RFC 3527\fP\X'tty: link': The link selection sub\-option is supported. .IP \(bu 2 \fIPacketCable Security Ticket Control Sub\-Option for the DHCP CableLabs Client Configuration (CCC) Option\fP, \X'tty: link https://tools.ietf.org/html/rfc3594'\fI\%RFC 3594\fP\X'tty: link': The Security Ticket Control sub\-option is supported. .IP \(bu 2 \fIKey Distribution Center (KDC) Server Address Sub\-option for the Dynamic Host Configuration Protocol (DHCP) CableLabs Client Configuration (CCC) Option\fP, \X'tty: link https://tools.ietf.org/html/rfc3634'\fI\%RFC 3634\fP\X'tty: link': The Key Distribution Center IP Address sub\-option is supported. .IP \(bu 2 \fIUnused Dynamic Host Configuration Protocol (DHCP) Option Codes\fP, \X'tty: link https://tools.ietf.org/html/rfc3679'\fI\%RFC 3679\fP\X'tty: link': Kea does not support any of the old options that were obsoleted by this RFC. .IP \(bu 2 \fIVendor\-Identifying Vendor Options for Dynamic Host Configuration Protocol version 4\fP, \X'tty: link https://tools.ietf.org/html/rfc3925'\fI\%RFC 3925\fP\X'tty: link': The Vendor\-Identifying Vendor Class and Vendor\-Identifying Vendor\-Specific Information options are supported. .IP \(bu 2 \fIReclassifying Dynamic Host Configuration Protocol version 4 (DHCPv4) Options\fP, \X'tty: link https://tools.ietf.org/html/rfc3942'\fI\%RFC 3942\fP\X'tty: link': Kea supports options with codes greater than 127. .IP \(bu 2 \fISubscriber\-ID Suboption for the DHCP Relay Agent Option\fP, \X'tty: link https://tools.ietf.org/html/rfc3993'\fI\%RFC 3993\fP\X'tty: link': The Subscriber\-ID option is supported. .IP \(bu 2 \fIDynamic Host Configuration Protocol (DHCP) Options for Broadcast and Multicast Control Servers\fP, \X'tty: link https://tools.ietf.org/html/rfc4280'\fI\%RFC 4280\fP\X'tty: link': The DHCPv4 options are supported. .IP \(bu 2 \fINode\-specific Client Identifiers for Dynamic Host Configuration Protocol Version Four (DHCPv4)\fP, \X'tty: link https://datatracker.ietf.org/doc/html/rfc4361'\fI\%RFC 4361\fP\X'tty: link': The DUID in DHCPv4 is supported. .IP \(bu 2 \fIDynamic Host Configuration Protocol (DHCP) Leasequery\fP, \X'tty: link https://datatracker.ietf.org/doc/html/rfc4388'\fI\%RFC 4388\fP\X'tty: link': The server functionality is supported. This requires leasequery hook. See \fI\%libdhcp_lease_query.so: Leasequery Support\fP for details. .IP \(bu 2 \fIDynamic Host Configuration Protocol (DHCP) Options for the Intel Preboot eXecution Environment (PXE)\fP, \X'tty: link https://datatracker.ietf.org/doc/html/rfc4578'\fI\%RFC 4578\fP\X'tty: link': All three options defined are supported. .IP \(bu 2 \fIA DNS Resource Record (RR) for Encoding Dynamic Host Configuration Protocol (DHCP) Information (DHCID RR)\fP, \X'tty: link https://tools.ietf.org/html/rfc4701'\fI\%RFC 4701\fP\X'tty: link': The DHCPv4 server supports DHCID records. The DHCP\-DDNS server must be running to add, update, and/or delete DHCID records. .IP \(bu 2 \fIThe Dynamic Host Configuration Protocol (DHCP) Client Fully Qualified Domain Name (FQDN) Option\fP, \X'tty: link https://tools.ietf.org/html/rfc4702'\fI\%RFC 4702\fP\X'tty: link': The Kea server is able to handle the Client FQDN option. Also, it is able to use the \fI\%kea\-dhcp\-ddns\fP component to initiate appropriate DNS Update operations. .IP \(bu 2 \fIResolution of Fully Qualified Domain Name (FQDN) Conflicts among Dynamic Host Configuration Protocol (DHCP) Clients\fP, \X'tty: link https://tools.ietf.org/html/rfc4703'\fI\%RFC 4703\fP\X'tty: link': The DHCPv6 server uses a DHCP\-DDNS server to resolve conflicts. .IP \(bu 2 \fITimezone Options for DHCP\fP: \X'tty: link https://tools.ietf.org/html/rfc4833'\fI\%RFC 4833\fP\X'tty: link': Both DHCPv4 options are supported. .IP \(bu 2 \fIThe Dynamic Host Configuration Protocol Version 4 (DHCPv4) Relay Agent Flags Suboption\fP: \X'tty: link https://tools.ietf.org/html/rfc5010'\fI\%RFC 5010\fP\X'tty: link': The Relay Agent Flags sub\-option is understood by Kea and can be used in an expression. .IP \(bu 2 \fIServer Identifier Override sub\-option for the Relay Agent Option\fP, \X'tty: link https://tools.ietf.org/html/rfc5107'\fI\%RFC 5107\fP\X'tty: link': The server identifier override sub\-option is supported. The implementation is not complete according to the RFC, because the server does not store the RAI, but the functionality handles expected use cases. .IP \(bu 2 \fIDHCP Options for Protocol for Carrying Authentication for Network Access (PANA) Authentication Agents\fP: \X'tty: link https://tools.ietf.org/html/rfc5192'\fI\%RFC 5192\fP\X'tty: link': The PANA option is supported. .IP \(bu 2 \fIDiscovering Location\-to\-Service Translation (LoST) Servers Using the Dynamic Host Configuration Protocol (DHCP)\fP: \X'tty: link https://tools.ietf.org/html/rfc5223'\fI\%RFC 5223\fP\X'tty: link': The LOST option is supported. .IP \(bu 2 \fIControl And Provisioning of Wireless Access Points (CAPWAP) Access Controller DHCP Option\fP: \X'tty: link https://tools.ietf.org/html/rfc5417'\fI\%RFC 5417\fP\X'tty: link': The CAPWAP for IPv4 option is supported. .IP \(bu 2 \fIDHCPv4 Lease Query by Relay Agent Remote ID\fP, \X'tty: link https://tools.ietf.org/html/rfc6148'\fI\%RFC 6148\fP\X'tty: link': The leasequery by remote\-id is supported. This requires leasequery hook. See \fI\%libdhcp_lease_query.so: Leasequery Support\fP for details. .IP \(bu 2 \fIClient Identifier Option in DHCP Server Replies\fP, \X'tty: link https://tools.ietf.org/html/rfc6842'\fI\%RFC 6842\fP\X'tty: link': The server by default sends back the \fBclient\-id\fP option. That capability can be disabled. See \fI\%Echoing Client\-ID (RFC 6842)\fP for details. .IP \(bu 2 \fIThe DHCPv4 Relay Agent Identifier Sub\-Option\fP, \X'tty: link https://tools.ietf.org/html/rfc6925'\fI\%RFC 6925\fP\X'tty: link': The relay\-id option is supported and can be used in all features that are using expressions (client classification, flex\-id reservations, etc.). .IP \(bu 2 \fIDHCPv4 Bulk Leasequery\fP, \X'tty: link https://tools.ietf.org/html/rfc6926'\fI\%RFC 6926\fP\X'tty: link': The server functionality (TCP connections, new query types, multiple responses, etc.) is supported. This requires leasequery hook. See \fI\%libdhcp_lease_query.so: Leasequery Support\fP for details. .IP \(bu 2 \fIGeneralized UDP Source Port for the DHCP Relay Agent Option\fP, \X'tty: link https://tools.ietf.org/html/rfc8357'\fI\%RFC 8357\fP\X'tty: link': The Kea server handles the Relay Agent Information Source Port sub\-option in a received message, remembers the UDP port, and sends back a reply to the same relay agent using this UDP port. .IP \(bu 2 \fICaptive\-Portal Identification in DHCP and Router Advertisements (RAs)\fP, \X'tty: link https://tools.ietf.org/html/rfc8910'\fI\%RFC 8910\fP\X'tty: link': The Kea server can configure both v4 and v6 versions of the captive portal options. .IP \(bu 2 \fIIPv6\-Only Preferred Option for DHCPv4\fP, \X'tty: link https://tools.ietf.org/html/rfc8925'\fI\%RFC 8925\fP\X'tty: link': The Kea server is able to designate its pools and subnets as IPv6\-Only Preferred and send back the \fBv6\-only\-preferred\fP option to clients that requested it. .IP \(bu 2 \fIDHCP and Router Advertisement Options for the Discovery of Network\-designated Resolvers (DNR)\fP, \X'tty: link https://tools.ietf.org/html/rfc9463'\fI\%RFC 9463\fP\X'tty: link'\&. The Kea server supports the DNR option. .UNINDENT .SS Known RFC Violations .sp In principle, Kea aspires to be a reference implementation and aims to implement 100% of the RFC standards. However, in some cases there are practical aspects that prevent Kea from completely adhering to the text of all RFC documents. .INDENT 0.0 .IP \(bu 2 \X'tty: link https://tools.ietf.org/html/rfc2131'\fI\%RFC 2131\fP\X'tty: link', page 30, says that if the incoming DHCPREQUEST packet has no \(dqrequested IP address\(dq option and \fBciaddr\fP is not set, the server is supposed to respond with NAK. However, broken clients exist that will always send a DHCPREQUEST without those options indicated. In that event, Kea accepts the DHCPREQUEST, assigns an address, and responds with an ACK. .IP \(bu 2 \X'tty: link https://tools.ietf.org/html/rfc2131'\fI\%RFC 2131\fP\X'tty: link', table 5, says that messages of type DHCPDECLINE or DHCPRELEASE must have the server identifier set and should be dropped if that option is missing. However, ISC DHCP does not enforce this, presumably as a compatibility effort for broken clients, and the Kea team decided to follow suit. .UNINDENT .SS DHCPv4 Server Limitations .sp These are the current known limitations of the Kea DHCPv4 server software. Most of them are reflections of the current stage of development and should be treated as “not yet implemented,” rather than as actual limitations. However, some of them are implications of the design choices made. Those are clearly marked as such. .INDENT 0.0 .IP \(bu 2 On the Linux and BSD system families, DHCP messages are sent and received over raw sockets (using LPF and BPF) and all packet headers (including data link layer, IP, and UDP headers) are created and parsed by Kea, rather than by the system kernel. Currently, Kea can only parse the data\-link layer headers with a format adhering to the IEEE 802.3 standard, and assumes this data\-link\-layer header format for all interfaces. Thus, Kea does not work on interfaces which use different data\-link\-layer header formats (e.g. Infiniband). .UNINDENT .SS Kea DHCPv4 Server Examples .sp A collection of simple\-to\-use examples for the DHCPv4 component of Kea is available with the source files, located in the \fBdoc/examples/kea4\fP directory. .SS Configuration Backend in DHCPv4 .sp In the \fI\%Kea Configuration Backend\fP section we have described the Configuration Backend (CB) feature, its applicability, and its limitations. This section focuses on the usage of the CB with the Kea DHCPv4 server. It lists the supported parameters, describes limitations, and gives examples of DHCPv4 server configurations to take advantage of the CB. Please also refer to the corresponding section \fI\%Configuration Backend in DHCPv6\fP for DHCPv6\-specific usage of the CB. .SS Supported Parameters .sp The ultimate goal for the CB is to serve as a central configuration repository for one or multiple Kea servers connected to a database. In currently supported Kea versions, only a subset of the DHCPv4 server parameters can be configured in the database. All other parameters must be specified in the JSON configuration file, if required. .sp All supported parameters can be configured via \fI\%libdhcp_cb_cmds.so\fP\&. The general rule is that scalar global parameters are set using \fI\%remote\-global\-parameter4\-set\fP; shared\-network\-specific parameters are set using \fI\%remote\-network4\-set\fP; and subnet\-level and pool\-level parameters are set using \fI\%remote\-subnet4\-set\fP\&. Whenever there is an exception to this general rule, it is highlighted in the table. Non\-scalar global parameters have dedicated commands; for example, the global DHCPv4 options (\fBoption\-data\fP) are modified using \fI\%remote\-option4\-global\-set\fP\&. Client classes, together with class\-specific option definitions and DHCPv4 options, are configured using the \fI\%remote\-class4\-set\fP command. .sp The \fI\%Configuration Sharing and Server Tags\fP section explains the concept of shareable and non\-shareable configuration elements and the limitations for sharing them between multiple servers. In the DHCP configuration (both DHCPv4 and DHCPv6), the shareable configuration elements are subnets and shared networks. Thus, they can be explicitly associated with multiple server tags. The global parameters, option definitions, and global options are non\-shareable and can be associated with only one server tag. This rule does not apply to the configuration elements associated with \fBall\fP servers. Any configuration element associated with \fBall\fP servers (using the \fBall\fP keyword as a server tag) is used by all servers connecting to the configuration database. .sp The following table lists DHCPv4\-specific parameters supported by the configuration backend, with an indication of the level of the hierarchy at which it is currently supported. .SS List of DHCPv4 parameters supported by the configuration backend .TS box center; l|l|l|l|l|l. T{ Parameter T} T{ Global T} T{ Client Class T} T{ Shared Network T} T{ Subnet T} T{ Pool T} _ T{ 4o6\-interface T} T{ n/a T} T{ n/a T} T{ n/a T} T{ yes T} T{ n/a T} _ T{ 4o6\-interface\-id T} T{ n/a T} T{ n/a T} T{ n/a T} T{ yes T} T{ n/a T} _ T{ 4o6\-subnet T} T{ n/a T} T{ n/a T} T{ n/a T} T{ yes T} T{ n/a T} _ T{ allocator T} T{ yes T} T{ n/a T} T{ yes T} T{ yes T} T{ n/a T} _ T{ boot\-file\-name T} T{ yes T} T{ yes T} T{ yes T} T{ yes T} T{ n/a T} _ T{ cache\-max\-age T} T{ yes T} T{ n/a T} T{ no T} T{ no T} T{ n/a T} _ T{ cache\-threshold T} T{ yes T} T{ n/a T} T{ no T} T{ no T} T{ n/a T} _ T{ calculate\-tee\-times T} T{ yes T} T{ n/a T} T{ yes T} T{ yes T} T{ n/a T} _ T{ client\-class T} T{ n/a T} T{ n/a T} T{ yes T} T{ yes T} T{ yes T} _ T{ ddns\-send\-update T} T{ yes T} T{ n/a T} T{ yes T} T{ yes T} T{ n/a T} _ T{ ddns\-override\-no\-update T} T{ yes T} T{ n/a T} T{ yes T} T{ yes T} T{ n/a T} _ T{ ddns\-override\-client\-update T} T{ yes T} T{ n/a T} T{ yes T} T{ yes T} T{ n/a T} _ T{ ddns\-replace\-client\-name T} T{ yes T} T{ n/a T} T{ yes T} T{ yes T} T{ n/a T} _ T{ ddns\-generated\-prefix T} T{ yes T} T{ n/a T} T{ yes T} T{ yes T} T{ n/a T} _ T{ ddns\-qualifying\-suffix T} T{ yes T} T{ n/a T} T{ yes T} T{ yes T} T{ n/a T} _ T{ decline\-probation\-period T} T{ yes T} T{ n/a T} T{ n/a T} T{ n/a T} T{ n/a T} _ T{ dhcp4o6\-port T} T{ yes T} T{ n/a T} T{ n/a T} T{ n/a T} T{ n/a T} _ T{ echo\-client\-id T} T{ yes T} T{ n/a T} T{ n/a T} T{ n/a T} T{ n/a T} _ T{ hostname\-char\-set T} T{ yes T} T{ n/a T} T{ yes T} T{ yes T} T{ n/a T} _ T{ hostname\-char\-replacement T} T{ yes T} T{ n/a T} T{ yes T} T{ yes T} T{ n/a T} _ T{ interface T} T{ n/a T} T{ n/a T} T{ yes T} T{ yes T} T{ n/a T} _ T{ match\-client\-id T} T{ yes T} T{ n/a T} T{ yes T} T{ yes T} T{ n/a T} _ T{ min\-valid\-lifetime T} T{ yes T} T{ yes T} T{ yes T} T{ yes T} T{ n/a T} _ T{ max\-valid\-lifetime T} T{ yes T} T{ yes T} T{ yes T} T{ yes T} T{ n/a T} _ T{ next\-server T} T{ yes T} T{ yes T} T{ yes T} T{ yes T} T{ n/a T} _ T{ option\-data T} T{ yes (via remote\-option4\-global\-set) T} T{ yes T} T{ yes T} T{ yes T} T{ yes T} _ T{ option\-def T} T{ yes (via remote\-option\-def4\-set) T} T{ yes T} T{ n/a T} T{ n/a T} T{ n/a T} _ T{ rebind\-timer T} T{ yes T} T{ n/a T} T{ yes T} T{ yes T} T{ n/a T} _ T{ renew\-timer T} T{ yes T} T{ n/a T} T{ yes T} T{ yes T} T{ n/a T} _ T{ server\-hostname T} T{ yes T} T{ yes T} T{ yes T} T{ yes T} T{ n/a T} _ T{ valid\-lifetime T} T{ yes T} T{ yes T} T{ yes T} T{ yes T} T{ n/a T} _ T{ relay T} T{ n/a T} T{ n/a T} T{ yes T} T{ yes T} T{ n/a T} _ T{ require\-client\-classes T} T{ no T} T{ n/a T} T{ yes T} T{ yes T} T{ yes T} _ T{ evaluate\-additional\-classes T} T{ no T} T{ n/a T} T{ yes T} T{ yes T} T{ yes T} _ T{ reservations\-global T} T{ yes T} T{ n/a T} T{ yes T} T{ yes T} T{ n/a T} _ T{ reservations\-in\-subnet T} T{ yes T} T{ n/a T} T{ yes T} T{ yes T} T{ n/a T} _ T{ reservations\-out\-of\-pool T} T{ yes T} T{ n/a T} T{ yes T} T{ yes T} T{ n/a T} _ T{ t1\-percent T} T{ yes T} T{ n/a T} T{ yes T} T{ yes T} T{ n/a T} _ T{ t2\-percent T} T{ yes T} T{ n/a T} T{ yes T} T{ yes T} T{ n/a T} .TE .INDENT 0.0 .IP \(bu 2 \fByes\fP \- indicates that the parameter is supported at the given level of the hierarchy and can be configured via the configuration backend. .IP \(bu 2 \fBno\fP \- indicates that a parameter is supported at the given level of the hierarchy but cannot be configured via the configuration backend. .IP \(bu 2 \fBn/a\fP \- indicates that a given parameter is not applicable at the particular level of the hierarchy or that the server does not support the parameter at that level. .UNINDENT .sp Some scalar parameters contained by top\-level global maps are supported by the configuration backend. .SS List of DHCPv4 map parameters supported by the configuration backend .TS box center; l|l|l. T{ Parameter name (flat naming format) T} T{ Global map T} T{ Parameter name T} _ T{ compatibility.ignore\-dhcp\-server\-identifier T} T{ compatibility T} T{ ignore\-dhcp\-server\-identifier T} _ T{ compatibility.ignore\-rai\-link\-selection T} T{ compatibility T} T{ ignore\-rai\-link\-selection T} _ T{ compatibility.lenient\-option\-parsing T} T{ compatibility T} T{ lenient\-option\-parsing T} _ T{ compatibility.exclude\-first\-last\-24 T} T{ compatibility T} T{ exclude\-first\-last\-24 T} _ T{ dhcp\-ddns.enable\-updates T} T{ dhcp\-ddns T} T{ enable\-updates T} _ T{ dhcp\-ddns.max\-queue\-size T} T{ dhcp\-ddns T} T{ max\-queue\-size T} _ T{ dhcp\-ddns.ncr\-format T} T{ dhcp\-ddns T} T{ ncr\-format T} _ T{ dhcp\-ddns.ncr\-protocol T} T{ dhcp\-ddns T} T{ ncr\-protocol T} _ T{ dhcp\-ddns.sender\-ip T} T{ dhcp\-ddns T} T{ sender\-ip T} _ T{ dhcp\-ddns.sender\-port T} T{ dhcp\-ddns T} T{ sender\-port T} _ T{ dhcp\-ddns.server\-ip T} T{ dhcp\-ddns T} T{ server\-ip T} _ T{ dhcp\-ddns.server\-port T} T{ dhcp\-ddns T} T{ server\-port T} _ T{ expired\-leases\-processing.flush\-reclaimed\-timer\-wait\-time T} T{ expired\-leases\-processing T} T{ flush\-reclaimed\-timer\-wait\-time T} _ T{ expired\-leases\-processing.hold\-reclaimed\-time T} T{ expired\-leases\-processing T} T{ hold\-reclaimed\-time T} _ T{ expired\-leases\-processing.max\-reclaim\-leases T} T{ expired\-leases\-processing T} T{ max\-reclaim\-leases T} _ T{ expired\-leases\-processing.max\-reclaim\-time T} T{ expired\-leases\-processing T} T{ max\-reclaim\-time T} _ T{ expired\-leases\-processing.reclaim\-timer\-wait\-time T} T{ expired\-leases\-processing T} T{ reclaim\-timer\-wait\-time T} _ T{ expired\-leases\-processing.unwarned\-reclaim\-cycles T} T{ expired\-leases\-processing T} T{ unwarned\-reclaim\-cycles T} _ T{ multi\-threading.enable\-multi\-threading T} T{ multi\-threading T} T{ enable\-multi\-threading T} _ T{ multi\-threading.thread\-pool\-size T} T{ multi\-threading T} T{ thread\-pool\-size T} _ T{ multi\-threading.packet\-queue\-size T} T{ multi\-threading T} T{ packet\-queue\-size T} _ T{ sanity\-checks.lease\-checks T} T{ sanity\-checks T} T{ lease\-checks T} _ T{ sanity\-checks.extended\-info\-checks T} T{ sanity\-checks T} T{ extended\-info\-checks T} _ T{ dhcp\-queue\-control.enable\-queue T} T{ dhcp\-queue\-control T} T{ enable\-queue T} _ T{ dhcp\-queue\-control.queue\-type T} T{ dhcp\-queue\-control T} T{ queue\-type T} _ T{ dhcp\-queue\-control.capacity T} T{ dhcp\-queue\-control T} T{ capacity T} .TE .SS Enabling the Configuration Backend .sp Consider the following configuration snippet, which uses a MySQL configuration database: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp4\(dq: { \(dqserver\-tag\(dq: \(dqmy DHCPv4 server\(dq, \(dqconfig\-control\(dq: { \(dqconfig\-databases\(dq: [ { \(dqtype\(dq: \(dqmysql\(dq, \(dqname\(dq: \(dqkea\(dq, \(dquser\(dq: \(dqkea\(dq, \(dqpassword\(dq: \(dq1234\(dq, \(dqhost\(dq: \(dq192.0.2.1\(dq, \(dqport\(dq: 3302 } ], \(dqconfig\-fetch\-wait\-time\(dq: 20 }, \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dq/usr/local/lib/kea/hooks/libdhcp_mysql.so\(dq }, { \(dqlibrary\(dq: \(dq/usr/local/lib/kea/hooks/libdhcp_cb_cmds.so\(dq } ] } } .EE .UNINDENT .UNINDENT .sp The following snippet illustrates the use of a PostgreSQL database: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp4\(dq: { \(dqserver\-tag\(dq: \(dqmy DHCPv4 server\(dq, \(dqconfig\-control\(dq: { \(dqconfig\-databases\(dq: [ { \(dqtype\(dq: \(dqpostgresql\(dq, \(dqname\(dq: \(dqkea\(dq, \(dquser\(dq: \(dqkea\(dq, \(dqpassword\(dq: \(dq1234\(dq, \(dqhost\(dq: \(dq192.0.2.1\(dq, \(dqport\(dq: 3302 } ], \(dqconfig\-fetch\-wait\-time\(dq: 20 }, \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dq/usr/local/lib/kea/hooks/libdhcp_pgsql.so\(dq }, { \(dqlibrary\(dq: \(dq/usr/local/lib/kea/hooks/libdhcp_cb_cmds.so\(dq } ] } } .EE .UNINDENT .UNINDENT .sp The \fBconfig\-control\fP map contains two parameters. \fBconfig\-databases\fP is a list that contains one element, which includes the database type, its location, and the credentials to be used to connect to this database. (Note that the parameters specified here correspond to the database specification for the lease database backend and hosts database backend.) Currently only one database connection can be specified on the \fBconfig\-databases\fP list. The server connects to this database during startup or reconfiguration, and fetches the configuration available for this server from the database. This configuration is merged into the configuration read from the configuration file. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Whenever there is a conflict between the parameters specified in the configuration file and the database, the parameters from the database take precedence. We strongly recommend avoiding the duplication of parameters in the file and the database, but this recommendation is not enforced by the Kea servers. In particular, if the subnets\(aq configuration is sourced from the database, we recommend that all subnets be specified in the database and that no subnets be specified in the configuration file. It is possible to specify the subnets in both places, but the subnets in the configuration file with overlapping IDs and/or prefixes with the subnets from the database will be superseded by those from the database. .UNINDENT .UNINDENT .sp Once the Kea server is configured, it starts periodically polling the database for configuration changes. The polling frequency is controlled by the \fBconfig\-fetch\-wait\-time\fP parameter, expressed in seconds; it is the period between the time when the server completed its last poll (and possibly the local configuration update) and the time when it will begin polling again. In the example above, this period is set to 20 seconds. This means that after adding a new configuration into the database (e.g. adding a new subnet), it will take up to 20 seconds (plus the time needed to fetch and apply the new configuration) before the server starts using this subnet. The lower the \fBconfig\-fetch\-wait\-time\fP value, the shorter the time for the server to react to incremental configuration updates in the database. On the other hand, polling the database too frequently may impact the DHCP server\(aqs performance, because the server needs to make at least one query to the database to discover any pending configuration updates. The default value of \fBconfig\-fetch\-wait\-time\fP is 30 seconds. .sp The \fI\%config\-backend\-pull\fP command can be used to force the server to immediately poll any configuration changes from the database and avoid waiting for the next fetch cycle. .sp In the configuration examples above, two hook libraries are loaded. The first is a library which implements the configuration backend for a specific database type: \fI\%libdhcp_mysql.so\fP provides support for MySQL and \fI\%libdhcp_pgsql.so\fP provides support for PostgreSQL. The library loaded must match the database \fBtype\fP specified within the \fBconfig\-control\fP parameter; otherwise an error is logged when the server attempts to load its configuration, and the load fails. .sp The second hook library, \fI\%libdhcp_cb_cmds.so\fP, is optional. It should be loaded when the Kea server instance is to be used to manage the configuration in the database. See the \fI\%libdhcp_cb_cmds.so: Configuration Backend Commands\fP section for details. .SS Kea DHCPv4 Compatibility Configuration Parameters .sp ISC\(aqs intention is for Kea to follow the RFC documents to promote better standards compliance. However, many buggy DHCP implementations already exist that cannot be easily fixed or upgraded. Therefore, Kea provides an easy\-to\-use compatibility mode for broken or non\-compliant clients. For that purpose, the compatibility option must be enabled to permit uncommon practices: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp4\(dq: { \(dqcompatibility\(dq: { } } } .EE .UNINDENT .UNINDENT .SS Lenient Option Parsing .sp By default, tuple fields defined in custom options are parsed as a set of length\-value pairs. .sp With \fB\(dqlenient\-option\-parsing\(dq: true\fP, if a length ever exceeded the rest of the option\(aqs buffer, previous versions of Kea returned a log message \fBunable to parse the opaque data tuple, the buffer length is x, but the tuple length is y\fP with \fBx < y\fP; this no longer occurs. Instead, the value is considered to be the rest of the buffer, or in terms of the log message above, the tuple length \fBy\fP becomes \fBx\fP\&. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp4\(dq: { \(dqcompatibility\(dq: { \(dqlenient\-option\-parsing\(dq: true } } } .EE .UNINDENT .UNINDENT .sp Starting with Kea version 2.5.8, this parsing is extended to silently ignore FQDN (81) options with some invalid domain names. .SS Ignore DHCP Server Identifier .sp With \fB\(dqignore\-dhcp\-server\-identifier\(dq: true\fP, the server does not check the address in the DHCP Server Identifier option, i.e. whether a query is sent to this server or another one (and in the second case dropping the query). .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp4\(dq: { \(dqcompatibility\(dq: { \(dqignore\-dhcp\-server\-identifier\(dq: true } } } .EE .UNINDENT .UNINDENT .SS Ignore RAI Link Selection .sp With \fB\(dqignore\-rai\-link\-selection\(dq: true\fP, Relay Agent Information Link Selection sub\-option data is not used for subnet selection. In this case, normal logic drives the subnet selection, instead of attempting to use the subnet specified by the sub\-option. This option is not RFC\-compliant and is set to \fBfalse\fP by default. Setting this option to \fBtrue\fP can help with subnet selection in certain scenarios; for example, when DHCP relays do not allow the administrator to specify which sub\-options are included in the Relay Agent Information option, and include incorrect Link Selection information. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp4\(dq: { \(dqcompatibility\(dq: { \(dqignore\-rai\-link\-selection\(dq: true } } } .EE .UNINDENT .UNINDENT .SS Exclude First Last Addresses in /24 Subnets or Larger .sp The \fBexclude\-first\-last\-24\fP compatibility flag is described in \fI\%Configuration of IPv4 Address Pools\fP (when true .0 and .255 addresses are excluded from subnets with prefix length less than or equal to 24). .SS Address Allocation Strategies in DHCPv4 .sp A DHCP server follows a complicated algorithm to select an IPv4 address for a client. It prefers assigning specific addresses requested by the client and the addresses for which the client has reservations. .sp If the client requests no particular address and has no reservations, or other clients are already using any requested addresses, the server must find another available address within the configured pools. A server function called an \(dqallocator\(dq is responsible in Kea for finding an available address in such a case. .sp The Kea DHCPv4 server provides configuration parameters to select different allocators at the global, shared\-network, and subnet levels. Consider the following example: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp4\(dq: { \(dqallocator\(dq: \(dqrandom\(dq, \(dqsubnet4\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq10.0.0.0/8\(dq, \(dqallocator\(dq: \(dqiterative\(dq }, { \(dqid\(dq: 2, \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq } ] } } .EE .UNINDENT .UNINDENT .sp This allocator overrides the default iterative allocation strategy at the global level and selects the random allocation instead. The random allocation will be used for the subnet with ID 2, while the iterative allocation will be used for the subnet with ID 1. .sp The following sections describe the supported allocators and their recommended uses. .SS Allocators Comparison .sp In the table below, we briefly compare the supported allocators, all of which are described in detail in later sections. .SS Comparison of the lease allocators supported by Kea DHCPv4 .TS box center; l|l|l|l|l|l. T{ Allocator T} T{ Low Utilization Performance T} T{ High Utilization Performance T} T{ Lease Randomization T} T{ Startup/Configuration T} T{ Memory Usage T} _ T{ Iterative T} T{ very high T} T{ low T} T{ no T} T{ very fast T} T{ low T} _ T{ Random T} T{ high T} T{ low T} T{ yes T} T{ very fast T} T{ high (varying) T} _ T{ Free Lease Queue T} T{ high T} T{ high T} T{ yes T} T{ slow (depends on pool sizes) T} T{ high (varying) T} .TE .SS Iterative Allocator .sp This is the default allocator used by the Kea DHCPv4 server. It remembers the last offered address and offers this address, increased by one, to the next client. For example, it may offer addresses in this order: \fB192.0.2.10\fP, \fB192.0.2.11\fP, \fB192.0.2.12\fP, and so on. The time to find and offer the next address is very short; thus, this is the most performant allocator when pool utilization is low and there is a high probability that the next address is available. .sp The iterative allocation underperforms when multiple DHCP servers share a lease database or are connected to a cluster. The servers tend to offer and allocate the same blocks of addresses to different clients independently, which causes many allocation conflicts between the servers and retransmissions by clients. A random allocation addresses this issue by dispersing the allocation order. .SS Random Allocator .sp The random allocator uses a uniform randomization function to select offered addresses from subnet pools. It is suitable in deployments where multiple servers are connected to a shared database or a database cluster. By dispersing the offered addresses, the servers minimize the risk of allocating the same address to two different clients at the same or nearly the same time. In addition, it improves the server\(aqs resilience against attacks based on allocation predictability. .sp The random allocator is, however, slightly slower than the iterative allocator. Moreover, it increases the server\(aqs memory consumption because it must remember randomized addresses to avoid offering them repeatedly. Memory consumption grows with the number of offered addresses; in other words, larger pools and more clients increase memory consumption by random allocation. .sp The following configuration snippet shows how to select the random allocator for a subnet: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp4\(dq: { \(dqallocator\(dq: \(dqrandom\(dq, \(dqsubnet4\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq10.0.0.0/8\(dq, \(dqallocator\(dq: \(dqrandom\(dq } ] } } .EE .UNINDENT .UNINDENT .SS Free Lease Queue Allocator .sp This is a sophisticated allocator whose use should be considered in subnets with highly utilized address pools. In such cases, it can take a considerable amount of time for the iterative or random allocator to find an available address, because they must repeatedly check whether there is a valid lease for an address they will offer. The number of checks can be as high as the number of addresses in the subnet when the subnet pools are exhausted, which can have a direct negative impact on the DHCP response time for each request. .sp The Free Lease Queue (FLQ) allocator tracks lease allocations and de\-allocations and maintains a running list of available addresses for each address pool. It allows an available lease to be selected within a constant time, regardless of the subnet pools\(aq utilization. The allocator continuously updates the list of free leases by removing any allocated leases and adding released or reclaimed ones. .sp The following configuration snippet shows how to select the FLQ allocator for a subnet: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp4\(dq: { \(dqsubnet4\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq, \(dqallocator\(dq: \(dqflq\(dq } ] } } .EE .UNINDENT .UNINDENT .sp There are several considerations that the administrator should take into account before using this allocator. The FLQ allocator can heavily impact the server\(aqs startup and reconfiguration time, because the allocator has to populate the list of free leases for each subnet where it is used. These delays can be observed both during the configuration reload and when the subnets are created using \fI\%libdhcp_subnet_cmds.so\fP\&. This allocator increases memory consumption to hold the list of free leases, proportional to the total size of the address pools for which the FLQ allocator is used. Finally, lease reclamation must be enabled with a low value of the \fBreclaim\-timer\-wait\-time\fP parameter, to ensure that the server frequently collects expired leases and makes them available for allocation via the free lease queue; expired leases are not considered free by the allocator until they are reclaimed by the server. See \fI\%Lease Reclamation\fP for more details about the lease reclamation process. .sp We recommend that the FLQ allocator be selected only after careful consideration. For example, using it for a subnet with a \fB/8\fP pool may delay the server\(aqs startup by 15 seconds or more. On the other hand, the startup delay and the memory consumption increase should be acceptable for subnets with a \fB/16\fP pool or smaller. We also recommend specifying another allocator type in the global configuration settings and overriding this selection at the subnet or shared\-network level, to use the FLQ allocator only for selected subnets. That way, when a new subnet is added without an allocator specification, the global setting is used, thus avoiding unnecessary impact on the server\(aqs startup time. .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 The FLQ allocator is not suitable for use with a shared lease database (i.e., when multiple Kea servers store leases in the same database). The servers are unaware of the expired leases reclaimed by the sibling servers and never return them to their local free lease queues. As a result, the servers will not be able to offer some of the available leases to the clients. Only a server reclaiming a particular lease will be able to offer it. .UNINDENT .UNINDENT .SH THE DHCPV6 SERVER .SS Starting and Stopping the DHCPv6 Server .sp It is recommended that the Kea DHCPv6 server be started and stopped using \fI\%keactrl\fP (described in \fI\%Managing Kea with keactrl\fP); however, it is also possible to run the server directly via the \fI\%kea\-dhcp6\fP command, which accepts the following command\-line switches: .INDENT 0.0 .IP \(bu 2 \fB\-c file\fP \- specifies the configuration file. This is the only mandatory switch. .IP \(bu 2 \fB\-d\fP \- specifies whether the server logging should be switched to debug/verbose mode. In verbose mode, the logging severity and debuglevel specified in the configuration file are ignored; \(dqdebug\(dq severity and the maximum debuglevel (99) are assumed. The flag is convenient for temporarily switching the server into maximum verbosity, e.g. when debugging. .IP \(bu 2 \fB\-p server\-port\fP \- specifies the local UDP port on which the server listens. This is only useful during testing, as a DHCPv6 server listening on ports other than the standard ones is not able to handle regular DHCPv6 queries. .IP \(bu 2 \fB\-P client\-port\fP \- specifies the remote UDP port to which the server sends all responses. This is only useful during testing, as a DHCPv6 server sending responses to ports other than the standard ones is not able to handle regular DHCPv6 queries. .IP \(bu 2 \fB\-t file\fP \- specifies a configuration file to be tested. \fI\%kea\-dhcp6\fP loads it, checks it, and exits. During the test, log messages are printed to standard output and error messages to standard error. The result of the test is reported through the exit code (0 = configuration looks OK, 1 = error encountered). The check is not comprehensive; certain checks are possible only when running the server. .IP \(bu 2 \fB\-T file\fP \- specifies a configuration file to be tested. \fI\%kea\-dhcp6\fP loads it, checks it, and exits. It performs extra checks beyond what \fB\-t\fP offers, such as establishing database connections (for the lease backend, host reservations backend, configuration backend, and forensic logging backend), loading hook libraries, parsing hook\-library configurations, etc. It does not open UNIX or TCP/UDP sockets, nor does it open or rotate files, as any of these actions could interfere with a running process on the same machine. .IP \(bu 2 \fB\-v\fP \- displays the Kea version and exits. .IP \(bu 2 \fB\-V\fP \- displays the Kea extended version with additional parameters and exits. The listing includes the versions of the libraries dynamically linked to Kea. .IP \(bu 2 \fB\-W\fP \- displays the Kea configuration report and exits. The report is a copy of the \fBconfig.report\fP file produced by \fBmeson setup\fP; it is embedded in the executable binary. .sp The contents of the \fBconfig.report\fP file may also be accessed by examining certain libraries in the installation tree or in the source tree. .INDENT 2.0 .INDENT 3.5 .sp .EX # from installation using libkea\-process.so $ strings ${prefix}/lib/libkea\-process.so | sed \-n \(aqs/;;;; //p\(aq # from sources using libkea\-process.so $ strings src/lib/process/.libs/libkea\-process.so | sed \-n \(aqs/;;;; //p\(aq # from sources using libkea\-process.a $ strings src/lib/process/.libs/libkea\-process.a | sed \-n \(aqs/;;;; //p\(aq # from sources using libcfgrpt.a $ strings src/lib/process/cfgrpt/.libs/libcfgrpt.a | sed \-n \(aqs/;;;; //p\(aq .EE .UNINDENT .UNINDENT .IP \(bu 2 \fB\-X\fP \- As of Kea 3.0, disables path and permissions restrictions. The server will emit a warning at startup that sercurity restrictions have been disabled. Do not use this mode of operation without careful consideration and taking any necessary precautions. Failure to do so can expose deployments to security vulnerabilities. For more information please read section \fI\%Securing a Kea Deployment\fP\&. .UNINDENT .sp On startup, the server detects available network interfaces and attempts to open UDP sockets on all interfaces listed in the configuration file. Since the DHCPv6 server opens privileged ports, it requires root access; this daemon must be run as root. .sp During startup, the server attempts to create a PID file of the form: \fB[pidfile_dir]/[conf name].kea\-dhcp6.pid\fP, where: .INDENT 0.0 .IP \(bu 2 \fBpidfile_dir\fP \- is \fB[prefix]/[localstatedir]/run/kea\fP where \fBprefix\fP and \fBlocalstatedir\fP are the values passed into meson setup using \fB\-\-prefix\fP and \fB\-\-localstatedir\fP which default to \fB/usr/local\fP and \fBvar\fP respectively. So the whole \fBpidfile_dir\fP defaults to \fB/usr/local/var\fP\&. Note that this value may be overridden at runtime by setting the environment variable \fBKEA_PIDFILE_DIR\fP intended primarily for testing purposes. .IP \(bu 2 \fBconf name\fP: The configuration file name used to start the server, minus all preceding paths and the file extension. For example, given a pathname of \fB/usr/local/etc/kea/myconf.txt\fP, the portion used would be \fBmyconf\fP\&. .UNINDENT .sp If the file already exists and contains the PID of a live process, the server issues a \fBDHCP6_ALREADY_RUNNING\fP log message and exits. It is possible, though unlikely, that the file is a remnant of a system crash and the process to which the PID belongs is unrelated to Kea. In such a case, it would be necessary to manually delete the PID file. .sp The server can be stopped using the \fBkill\fP command. When running in a console, the server can also be shut down by pressing Ctrl\-c. Kea detects the key combination and shuts down gracefully. .sp The reconfiguration of each Kea server is triggered by the SIGHUP signal. When a server receives the SIGHUP signal it rereads its configuration file and, if the new configuration is valid, uses the new configuration. If the new configuration proves to be invalid, the server retains its current configuration; however, in some cases a fatal error message is logged indicating that the server is no longer providing any service: a working configuration must be loaded as soon as possible. .SS DHCPv6 Server Configuration .SS Introduction .sp This section explains how to configure the Kea DHCPv6 server using a configuration file. .sp Before DHCPv6 is started, its configuration file must be created. The basic configuration is as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX { # DHCPv6 configuration starts on the next line \(dqDhcp6\(dq: { # First we set up global values \(dqvalid\-lifetime\(dq: 4000, \(dqrenew\-timer\(dq: 1000, \(dqrebind\-timer\(dq: 2000, \(dqpreferred\-lifetime\(dq: 3000, # Next we set up the interfaces to be used by the server. \(dqinterfaces\-config\(dq: { \(dqinterfaces\(dq: [ \(dqeth0\(dq ] }, # And we specify the type of lease database \(dqlease\-database\(dq: { \(dqtype\(dq: \(dqmemfile\(dq, \(dqpersist\(dq: true, \(dqname\(dq: \(dq/var/lib/kea/dhcp6.leases\(dq }, # Finally, we list the subnets from which we will be leasing addresses. \(dqsubnet6\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq2001:db8:1::/64\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8:1::1\-2001:db8:1::ffff\(dq } ] } ] # DHCPv6 configuration ends with the next line } } .EE .UNINDENT .UNINDENT .sp The following paragraphs provide a brief overview of the parameters in the above example, along with their format. Subsequent sections of this chapter go into much greater detail for these and other parameters. .sp The lines starting with a hash (#) are comments and are ignored by the server; they do not impact its operation in any way. .sp The configuration starts in the first line with the initial opening curly bracket (or brace). Each configuration must contain an object specifying the configuration of the Kea module using it. In the example above, this object is called \fBDhcp6\fP\&. .sp The \fBDhcp6\fP configuration starts with the \fB\(dqDhcp6\(dq: {\fP line and ends with the corresponding closing brace (in the above example, the brace after the last comment). Everything defined between those lines is considered to be the \fBDhcp6\fP configuration. .sp In general, the order in which those parameters appear does not matter, but there are two caveats. The first one is that the configuration file must be well\-formed JSON, meaning that the parameters for any given scope must be separated by a comma, and there must not be a comma after the last parameter. When reordering a configuration file, moving a parameter to or from the last position in a given scope may also require moving the comma. The second caveat is that it is uncommon — although legal JSON — to repeat the same parameter multiple times. If that happens, the last occurrence of a given parameter in a given scope is used, while all previous instances are ignored. This is unlikely to cause any confusion as there are no real\-life reasons to keep multiple copies of the same parameter in the configuration file. .sp The first few DHCPv6 configuration elements define some global parameters. \fBvalid\-lifetime\fP defines how long the addresses (leases) given out by the server are valid; the default is for a client to be allowed to use a given address for 4000 seconds. (Note that integer numbers are specified as is, without any quotes around them.) The address will become deprecated in 3000 seconds, i.e. clients are allowed to keep old connections, but cannot use this address to create new connections. \fBrenew\-timer\fP and \fBrebind\-timer\fP are values (also in seconds) that define T1 and T2 timers, which govern when the client begins the renewal and rebind procedures. .sp The \fBinterfaces\-config\fP map specifies the network interfaces on which the server should listen to DHCP messages. The \fBinterfaces\fP parameter specifies a list of network interfaces on which the server should listen. Lists are opened and closed with square brackets, with elements separated by commas. To listen on two interfaces, the \fBinterfaces\-config\fP element should look like this: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqinterfaces\-config\(dq: { \(dqinterfaces\(dq: [ \(dqeth0\(dq, \(dqeth1\(dq ] }, \&... } .EE .UNINDENT .UNINDENT .sp The next lines define the lease database, the place where the server stores its lease information. This particular example tells the server to use memfile, which is the simplest and fastest database backend. It uses an in\-memory database and stores leases on disk in a CSV (comma\-separated values) file. This is a very simple configuration example; usually the lease database configuration is more extensive and contains additional parameters. Note that \fBlease\-database\fP is an object and opens up a new scope, using an opening brace. Its parameters (just one in this example: \fBtype\fP) follow. If there were more than one, they would be separated by commas. This scope is closed with a closing brace. As more parameters for the \fBDhcp6\fP definition follow, a trailing comma is present. .sp Finally, we need to define a list of IPv6 subnets. This is the most important DHCPv6 configuration structure, as the server uses that information to process clients\(aq requests. It defines all subnets from which the server is expected to receive DHCP requests. The subnets are specified with the \fBsubnet6\fP parameter. It is a list, so it starts and ends with square brackets. Each subnet definition in the list has several attributes associated with it, so it is a structure and is opened and closed with braces. At a minimum, a subnet definition must have at least two parameters: \fBsubnet\fP, which defines the whole subnet; and \fBpools\fP, which is a list of dynamically allocated pools that are governed by the DHCP server. .sp The example contains a single subnet. If more than one were defined, additional elements in the \fBsubnet6\fP parameter would be specified and separated by commas. For example, to define two subnets, the following syntax would be used: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqsubnet6\(dq: [ { \(dqid\(dq: 1, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8:1::/112\(dq } ], \(dqsubnet\(dq: \(dq2001:db8:1::/64\(dq }, { \(dqid\(dq: 2, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8:2::1\-2001:db8:2::ffff\(dq } ], \(dqsubnet\(dq: \(dq2001:db8:2::/64\(dq } ], \&... } .EE .UNINDENT .UNINDENT .sp Note that indentation is optional and is used for aesthetic purposes only. In some cases it may be preferable to use more compact notation. .sp After all the parameters have been specified, there are two contexts open: \fBglobal\fP and \fBDhcp6\fP; thus, two closing curly brackets must be used to close them. .SS Lease Storage .sp All leases issued by the server are stored in the lease database. There are three database backends available: memfile (the default), MySQL, PostgreSQL. .SS Memfile \- Basic Storage for Leases .sp The server is able to store lease data in different repositories. Larger deployments may elect to store leases in a database; \fI\%Lease Database Configuration\fP describes this option. In typical smaller deployments, though, the server stores lease information in a CSV file rather than a database. As well as requiring less administration, an advantage of using a file for storage is that it eliminates a dependency on third\-party database software. .sp The configuration of the memfile backend is controlled through the \fBDhcp6\fP/\fBlease\-database\fP parameters. The \fBtype\fP parameter is mandatory and specifies which storage for leases the server should use, through the \fB\(dqmemfile\(dq\fP value. The following list gives additional optional parameters that can be used to configure the memfile backend. .INDENT 0.0 .IP \(bu 2 \fBpersist\fP: controls whether the new leases and updates to existing leases are written to the file. It is strongly recommended that the value of this parameter be set to \fBtrue\fP at all times during the server\(aqs normal operation. Not writing leases to disk means that if a server is restarted (e.g. after a power failure), it will not know which addresses have been assigned. As a result, it may assign new clients addresses that are already in use. The value of \fBfalse\fP is mostly useful for performance\-testing purposes. The default value of the \fBpersist\fP parameter is \fBtrue\fP, which enables writing lease updates to the lease file. .IP \(bu 2 \fBname\fP: specifies the lease file in which new leases and lease updates are recorded. The default value for this parameter is \fB\(dq[kea\-install\-dir]/var/lib/kea/kea\-leases6.csv\(dq\fP\&. .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 As of Kea 2.7.9, lease files may only be loaded from the data directory determined during compilation: \fB\(dq[kea\-install\-dir]/var/lib/kea\(dq\fP\&. This path may be overridden at startup by setting the environment variable \fBKEA_DHCP_DATA_DIR\fP to the desired path. If a path other than this value is used in \fBname\fP, Kea will emit an error and refuse to start or, if already running, log an unrecoverable error. For ease of use in specifying a custom file name simply omit the path component from \fBname\fP\&. .UNINDENT .UNINDENT .INDENT 0.0 .IP \(bu 2 \fBlfc\-interval\fP: specifies the interval, in seconds, at which the server will perform a lease file cleanup (LFC). This removes redundant (historical) information from the lease file and effectively reduces the lease file size. The cleanup process is described in more detail later in this section. The default value of the \fBlfc\-interval\fP is \fB3600\fP\&. A value of \fB0\fP disables the LFC. .IP \(bu 2 \fBmax\-row\-errors\fP: specifies the number of row errors before the server stops attempting to load a lease file. When the server loads a lease file, it is processed row by row, each row containing a single lease. If a row is flawed and cannot be processed correctly the server logs it, discards the row, and goes on to the next row. This parameter can be used to set a limit on the number of such discards that can occur, after which the server abandons the effort and exits. The default value of \fB0\fP disables the limit and allows the server to process the entire file, regardless of how many rows are discarded. .UNINDENT .sp An example configuration of the memfile backend is presented below: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqlease\-database\(dq: { \(dqtype\(dq: \(dqmemfile\(dq, \(dqpersist\(dq: true, \(dqname\(dq: \(dqkea\-leases6.csv\(dq, \(dqlfc\-interval\(dq: 1800, \(dqmax\-row\-errors\(dq: 100 } } .EE .UNINDENT .UNINDENT .sp This configuration selects \fBkea\-leases6.csv\fP as the storage file for lease information and enables persistence (writing lease updates to this file). It also configures the backend to perform a periodic cleanup of the lease file every 1800 seconds (30 minutes) and sets the maximum number of row errors to 100. .SS Why Is Lease File Cleanup Necessary? .sp It is important to know how the lease file contents are organized to understand why the periodic lease file cleanup is needed. Every time the server updates a lease or creates a new lease for a client, the new lease information must be recorded in the lease file. For performance reasons, the server does not update the existing client\(aqs lease in the file, as this would potentially require rewriting the entire file. Instead, it simply appends the new lease information to the end of the file; the previous lease entries for the client are not removed. When the server loads leases from the lease file, e.g. at server startup, it assumes that the latest lease entry for the client is the valid one. Previous entries are discarded, meaning that the server can reconstruct accurate information about the leases even though there may be many lease entries for each client. However, storing many entries for each client results in a bloated lease file and impairs the performance of the server\(aqs startup and reconfiguration, as it needs to process a larger number of lease entries. .sp Lease file cleanup (LFC) removes all previous entries for each client and leaves only the latest ones. The interval at which the cleanup is performed is configurable, and it should be selected according to the frequency of lease renewals initiated by the clients. The more frequent the renewals, the smaller the value of \fBlfc\-interval\fP should be. Note, however, that the LFC takes time and thus it is possible (although unlikely) that, if the \fBlfc\-interval\fP is too short, a new cleanup may be started while the previous one is still running. The server would recover from this by skipping the new cleanup when it detected that the previous cleanup was still in progress, but it implies that the actual cleanups will be triggered more rarely than the configured interval. Moreover, triggering a new cleanup adds overhead to the server, which is not able to respond to new requests for a short period of time when the new cleanup process is spawned. Therefore, it is recommended that the \fBlfc\-interval\fP value be selected in a way that allows the LFC to complete the cleanup before a new cleanup is triggered. .sp Lease file cleanup is performed by a separate process (in the background) to avoid a performance impact on the server process. To avoid conflicts between two processes using the same lease files, the LFC process starts with Kea opening a new lease file; the actual LFC process operates on the lease file that is no longer used by the server. There are also other files created as a side effect of the lease file cleanup. The detailed description of the LFC process is located later in this Kea Administrator\(aqs Reference Manual: \fI\%The LFC Process\fP\&. .SS Lease Database Configuration .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Lease database access information must be configured for the DHCPv6 server, even if it has already been configured for the DHCPv4 server. The servers store their information independently, so each server can use a separate database or both servers can use the same database. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Kea requires the database timezone to match the system timezone. For more details, see \fI\%First\-Time Creation of the MySQL Database\fP and \fI\%First\-Time Creation of the PostgreSQL Database\fP\&. .UNINDENT .UNINDENT .sp Lease database configuration is controlled through the \fBDhcp6\fP/\fBlease\-database\fP parameters. The database type must be set to \fBmemfile\fP, \fBmysql\fP or \fBpostgresql\fP, e.g.: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqlease\-database\(dq: { \(dqtype\(dq: \(dqmysql\(dq, ... }, ... } .EE .UNINDENT .UNINDENT .sp Next, the name of the database to hold the leases must be set; this is the name used when the database was created (see \fI\%First\-Time Creation of the MySQL Database\fP or \fI\%First\-Time Creation of the PostgreSQL Database\fP). .sp For MySQL or PostgreSQL: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqlease\-database\(dq: { \(dqname\(dq: \(dqdatabase\-name\(dq , ... }, ... } .EE .UNINDENT .UNINDENT .sp If the database is located on a different system from the DHCPv6 server, the database host name must also be specified: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqlease\-database\(dq: { \(dqhost\(dq: \(dqremote\-host\-name\(dq, ... }, ... } .EE .UNINDENT .UNINDENT .sp Normally, the database is on the same machine as the DHCPv6 server. In this case, set the value to the empty string: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqlease\-database\(dq: { \(dqhost\(dq : \(dq\(dq, ... }, ... } .EE .UNINDENT .UNINDENT .sp Should the database use a port other than the default, it may be specified as well: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqlease\-database\(dq: { \(dqport\(dq : 12345, ... }, ... } .EE .UNINDENT .UNINDENT .sp Should the database be located on a different system, the administrator may need to specify a longer interval for the connection timeout: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqlease\-database\(dq: { \(dqconnect\-timeout\(dq : timeout\-in\-seconds, ... }, ... } .EE .UNINDENT .UNINDENT .sp The default value of five seconds should be more than adequate for local connections. If a timeout is given, though, it should be an integer greater than zero. .sp The maximum number of times the server automatically attempts to reconnect to the lease database after connectivity has been lost may be specified: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqlease\-database\(dq: { \(dqmax\-reconnect\-tries\(dq : number\-of\-tries, ... }, ... } .EE .UNINDENT .UNINDENT .sp If the server is unable to reconnect to the database after making the maximum number of attempts, the server will exit. A value of 0 (the default) disables automatic recovery and the server will exit immediately upon detecting a loss of connectivity (MySQL and PostgreSQL only). .sp The number of milliseconds the server waits between attempts to reconnect to the lease database after connectivity has been lost may also be specified: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqlease\-database\(dq: { \(dqreconnect\-wait\-time\(dq : number\-of\-milliseconds, ... }, ... } .EE .UNINDENT .UNINDENT .sp The default value for MySQL and PostgreSQL is 0, which disables automatic recovery and causes the server to exit immediately upon detecting the loss of connectivity. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqlease\-database\(dq: { \(dqon\-fail\(dq : \(dqstop\-retry\-exit\(dq, ... }, ... } .EE .UNINDENT .UNINDENT .sp The possible values are: .INDENT 0.0 .IP \(bu 2 \fBstop\-retry\-exit\fP \- disables the DHCP service while trying to automatically recover lost connections, and shuts down the server on failure after exhausting \fBmax\-reconnect\-tries\fP\&. This is the default value for the lease backend, the host backend, and the configuration backend. .IP \(bu 2 \fBserve\-retry\-exit\fP \- continues the DHCP service while trying to automatically recover lost connections, and shuts down the server on failure after exhausting \fBmax\-reconnect\-tries\fP\&. .IP \(bu 2 \fBserve\-retry\-continue\fP \- continues the DHCP service and does not shut down the server even if the recovery fails. This is the default value for forensic logging. .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Automatic reconnection to database backends is configured individually per backend; this allows users to tailor the recovery parameters to each backend they use. We suggest that users enable it either for all backends or none, so behavior is consistent. .sp Losing connectivity to a backend for which reconnection is disabled results (if configured) in the server shutting itself down. This includes cases when the lease database backend and the hosts database backend are connected to the same database instance. .sp It is highly recommended not to change the \fBstop\-retry\-exit\fP default setting for the lease manager, as it is critical for the connection to be active while processing DHCP traffic. Change this only if the server is used exclusively as a configuration tool. .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqlease\-database\(dq: { \(dqretry\-on\-startup\(dq : true, ... }, ... } .EE .UNINDENT .UNINDENT .sp During server startup, the inability to connect to any of the configured backends is considered fatal only if \fBretry\-on\-startup\fP is set to \fBfalse\fP (the default). A fatal error is logged and the server exits, based on the idea that the configuration should be valid at startup. Exiting to the operating system allows nanny scripts to detect the problem. If \fBretry\-on\-startup\fP is set to \fBtrue\fP, the server starts reconnection attempts even at server startup or on reconfigure events, and honors the action specified in the \fBon\-fail\fP parameter. .sp The host parameter is used by the MySQL and PostgreSQL backends. .sp Finally, the credentials of the account under which the server will access the database should be set: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqlease\-database\(dq: { \(dquser\(dq: \(dquser\-name\(dq, \(dqpassword\(dq: \(dq1234\(dq, ... }, ... } .EE .UNINDENT .UNINDENT .sp If there is no password to the account, set the password to the empty string \fB\(dq\(dq\fP\&. (This is the default.) .SS Tuning Database Timeouts .sp In rare cases, reading or writing to the database may hang. This can be caused by a temporary network issue, or by misconfiguration of the proxy server switching the connection between different database instances. These situations are rare, but users have reported that Kea sometimes hangs while performing database IO operations. Setting appropriate timeout values can mitigate such issues. .sp MySQL exposes two distinct connection options to configure the read and write timeouts. Kea\(aqs corresponding \fBread\-timeout\fP and \fBwrite\-timeout\fP configuration parameters specify the timeouts in seconds. For example: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqlease\-database\(dq: { \(dqread\-timeout\(dq : 10, \(dqwrite\-timeout\(dq: 20, ... }, ... } .EE .UNINDENT .UNINDENT .sp Setting these parameters to 0 is equivalent to not specifying them, and causes the Kea server to establish a connection to the database with the MySQL defaults. In this case, Kea waits indefinitely for the completion of the read and write operations. .sp MySQL versions earlier than 5.6 do not support setting timeouts for read and write operations. Moreover, the \fBread\-timeout\fP and \fBwrite\-timeout\fP parameters can only be specified for the MySQL backend; setting them for any other backend database type causes a configuration error. .sp To set a timeout in seconds for PostgreSQL, use the \fBtcp\-user\-timeout\fP parameter. For example: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqlease\-database\(dq: { \(dqtcp\-user\-timeout\(dq : 10, ... }, ... } .EE .UNINDENT .UNINDENT .sp Specifying this parameter for other backend types causes a configuration error. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The timeouts described here are only effective for TCP connections. Please note that the MySQL client library used by the Kea servers typically connects to the database via a UNIX domain socket when the \fBhost\fP parameter is \fBlocalhost\fP, but establishes a TCP connection for \fB127.0.0.1\fP\&. .UNINDENT .UNINDENT .sp Since Kea.2.7.4, the libdhcp_mysql.so hook library must be loaded in order to store leases in the MySQL Lease Database Backend. Specify the lease backend hook library location: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqhooks\-libraries\(dq: [ { // the MySQL lease backend hook library required for lease storage. \(dqlibrary\(dq: \(dq/opt/lib/kea/hooks/libdhcp_mysql.so\(dq }, ... ], ... } .EE .UNINDENT .UNINDENT .sp Since Kea.2.7.4, the libdhcp_pgsql.so hook library must be loaded in order to store leases in the PostgreSQL Lease Database Backend. Specify the lease backend hook library location. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqhooks\-libraries\(dq: [ { // the PostgreSQL lease backend hook library required for lease storage. \(dqlibrary\(dq: \(dq/opt/lib/kea/hooks/libdhcp_pgsql.so\(dq }, ... ], ... } .EE .UNINDENT .UNINDENT .SS Hosts Storage .sp Kea is also able to store information about host reservations in the database. The hosts database configuration uses the same syntax as the lease database. In fact, the Kea server opens independent connections for each purpose, be it lease or hosts information, which gives the most flexibility. Kea can keep leases and host reservations separately, but can also point to the same database. Currently the supported hosts database types are MySQL and PostgreSQL. .sp The following configuration can be used to configure a connection to MySQL: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqhosts\-database\(dq: { \(dqtype\(dq: \(dqmysql\(dq, \(dqname\(dq: \(dqkea\(dq, \(dquser\(dq: \(dqkea\(dq, \(dqpassword\(dq: \(dq1234\(dq, \(dqhost\(dq: \(dqlocalhost\(dq, \(dqport\(dq: 3306 } } .EE .UNINDENT .UNINDENT .sp Depending on the database configuration, many of the parameters may be optional. .sp Please note that usage of hosts storage is optional. A user can define all host reservations in the configuration file, and that is the recommended way if the number of reservations is small. However, when the number of reservations grows, it is more convenient to use host storage. Please note that both storage methods (the configuration file and one of the supported databases) can be used together. If hosts are defined in both places, the definitions from the configuration file are checked first and external storage is checked later, if necessary. .sp Host information can be placed in multiple stores. Operations are performed on the stores in the order they are defined in the configuration file, although this leads to a restriction in ordering in the case of a host reservation addition; read\-only stores must be configured after a (required) read\-write store, or the addition will fail. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Kea requires the database timezone to match the system timezone. For more details, see \fI\%First\-Time Creation of the MySQL Database\fP and \fI\%First\-Time Creation of the PostgreSQL Database\fP\&. .UNINDENT .UNINDENT .SS DHCPv6 Hosts Database Configuration .sp Hosts database configuration is controlled through the \fBDhcp6\fP/\fBhosts\-database\fP parameters. If enabled, the type of database must be set to \fBmysql\fP or \fBpostgresql\fP\&. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqhosts\-database\(dq: { \(dqtype\(dq: \(dqmysql\(dq, ... }, ... } .EE .UNINDENT .UNINDENT .sp Next, the name of the database to hold the reservations must be set; this is the name used when the lease database was created (see \fI\%Supported Backends\fP for instructions on how to set up the desired database type): .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqhosts\-database\(dq: { \(dqname\(dq: \(dqdatabase\-name\(dq , ... }, ... } .EE .UNINDENT .UNINDENT .sp If the database is located on a different system than the DHCPv6 server, the database host name must also be specified: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqhosts\-database\(dq: { \(dqhost\(dq: remote\-host\-name, ... }, ... } .EE .UNINDENT .UNINDENT .sp Normally, the database is on the same machine as the DHCPv6 server. In this case, set the value to the empty string: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqhosts\-database\(dq: { \(dqhost\(dq : \(dq\(dq, ... }, ... } .EE .UNINDENT .UNINDENT .sp Should the database use a port different than the default, it may be specified as well: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqhosts\-database\(dq: { \(dqport\(dq : 12345, ... }, ... } .EE .UNINDENT .UNINDENT .sp The maximum number of times the server automatically attempts to reconnect to the host database after connectivity has been lost may be specified: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqhosts\-database\(dq: { \(dqmax\-reconnect\-tries\(dq : number\-of\-tries, ... }, ... } .EE .UNINDENT .UNINDENT .sp If the server is unable to reconnect to the database after making the maximum number of attempts, the server will exit. A value of 0 (the default) disables automatic recovery and the server will exit immediately upon detecting a loss of connectivity (MySQL and PostgreSQL only). .sp The number of milliseconds the server waits between attempts to reconnect to the host database after connectivity has been lost may also be specified: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqhosts\-database\(dq: { \(dqreconnect\-wait\-time\(dq : number\-of\-milliseconds, ... }, ... } .EE .UNINDENT .UNINDENT .sp The default value for MySQL and PostgreSQL is 0, which disables automatic recovery and causes the server to exit immediately upon detecting the loss of connectivity. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqhosts\-database\(dq: { \(dqon\-fail\(dq : \(dqstop\-retry\-exit\(dq, ... }, ... } .EE .UNINDENT .UNINDENT .sp The possible values are: .INDENT 0.0 .IP \(bu 2 \fBstop\-retry\-exit\fP \- disables the DHCP service while trying to automatically recover lost connections. Shuts down the server on failure after exhausting \fBmax\-reconnect\-tries\fP\&. This is the default value for MySQL and PostgreSQL. .IP \(bu 2 \fBserve\-retry\-exit\fP \- continues the DHCP service while trying to automatically recover lost connections. Shuts down the server on failure after exhausting \fBmax\-reconnect\-tries\fP\&. .IP \(bu 2 \fBserve\-retry\-continue\fP \- continues the DHCP service and does not shut down the server even if the recovery fails. .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Automatic reconnection to database backends is configured individually per backend. This allows users to tailor the recovery parameters to each backend they use. We suggest that users enable it either for all backends or none, so behavior is consistent. .sp Losing connectivity to a backend for which reconnection is disabled results (if configured) in the server shutting itself down. This includes cases when the lease database backend and the hosts database backend are connected to the same database instance. .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqhosts\-database\(dq: { \(dqretry\-on\-startup\(dq : true, ... }, ... } .EE .UNINDENT .UNINDENT .sp During server startup, the inability to connect to any of the configured backends is considered fatal only if \fBretry\-on\-startup\fP is set to \fBfalse\fP (the default). A fatal error is logged and the server exits, based on the idea that the configuration should be valid at startup. Exiting to the operating system allows nanny scripts to detect the problem. If \fBretry\-on\-startup\fP is set to \fBtrue\fP, the server starts reconnection attempts even at server startup or on reconfigure events, and honors the action specified in the \fBon\-fail\fP parameter. .sp Finally, the credentials of the account under which the server will access the database should be set: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqhosts\-database\(dq: { \(dquser\(dq: \(dquser\-name\(dq, \(dqpassword\(dq: \(dq1234\(dq, ... }, ... } .EE .UNINDENT .UNINDENT .sp If there is no password to the account, set the password to the empty string \fB\(dq\(dq\fP\&. (This is the default.) .sp The multiple\-storage extension uses a similar syntax; a configuration is placed into a \fBhosts\-databases\fP list instead of into a \fBhosts\-database\fP entry, as in: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqhosts\-databases\(dq: [ { \(dqtype\(dq: \(dqmysql\(dq, ... }, ... ], ... } .EE .UNINDENT .UNINDENT .sp If the same host is configured both in\-file and in\-database, Kea does not issue a warning, as it would if both were specified in the same data source. Instead, the host configured in\-file has priority over the one configured in\-database. .SS Using Read\-Only Databases for Host Reservations with DHCPv6 .sp In some deployments, the user whose name is specified in the database backend configuration may not have write privileges to the database. This is often required by the policy within a given network to secure the data from being unintentionally modified. In many cases administrators have deployed inventory databases, which contain substantially more information about the hosts than just the static reservations assigned to them. The inventory database can be used to create a view of a Kea hosts database and such a view is often read\-only. .sp Kea host\-database backends operate with an implicit configuration to both read from and write to the database. If the user does not have write access to the host database, the backend will fail to start and the server will refuse to start (or reconfigure). However, if access to a read\-only host database is required for retrieving reservations for clients and/or assigning specific addresses and options, it is possible to explicitly configure Kea to start in \(dqread\-only\(dq mode. This is controlled by the \fBreadonly\fP boolean parameter as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqhosts\-database\(dq: { \(dqreadonly\(dq: true, ... }, ... } .EE .UNINDENT .UNINDENT .sp Setting this parameter to \fBfalse\fP configures the database backend to operate in \(dqread\-write\(dq mode, which is also the default configuration if the parameter is not specified. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The \fBreadonly\fP parameter is only supported for MySQL and PostgreSQL databases. .UNINDENT .UNINDENT .sp Since Kea.2.7.4, the libdhcp_mysql.so hook library must be loaded in order to store host reservations in the MySQL Host Database Backend. Specify the lease backend hook library location: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqhooks\-libraries\(dq: [ { // the MySQL host backend hook library required for host storage. \(dqlibrary\(dq: \(dq/opt/lib/kea/hooks/libdhcp_mysql.so\(dq }, ... ], ... } .EE .UNINDENT .UNINDENT .sp Since Kea.2.7.4, the libdhcp_pgsql.so hook library must be loaded in order to store host reservations in the PostgreSQL Host Database Backend. Specify the lease backend hook library location. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqhooks\-libraries\(dq: [ { // the PostgreSQL host backend hook library required for host storage. \(dqlibrary\(dq: \(dq/opt/lib/kea/hooks/libdhcp_pgsql.so\(dq }, ... ], ... } .EE .UNINDENT .UNINDENT .SS Tuning Database Timeouts for Hosts Storage .sp See \fI\%Tuning Database Timeouts\fP\&. .SS Interface Configuration .sp The DHCPv6 server must be configured to listen on specific network interfaces. The simplest network interface configuration tells the server to listen on all available interfaces: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqinterfaces\-config\(dq: { \(dqinterfaces\(dq: [ \(dq*\(dq ] }, ... } .EE .UNINDENT .UNINDENT .sp The asterisk plays the role of a wildcard and means \(dqlisten on all interfaces.\(dq However, it is usually a good idea to explicitly specify interface names: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqinterfaces\-config\(dq: { \(dqinterfaces\(dq: [ \(dqeth1\(dq, \(dqeth3\(dq ] }, ... } .EE .UNINDENT .UNINDENT .sp It is possible to use an interface wildcard (*) concurrently with explicit interface names: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqinterfaces\-config\(dq: { \(dqinterfaces\(dq: [ \(dqeth1\(dq, \(dqeth3\(dq, \(dq*\(dq ] }, ... } .EE .UNINDENT .UNINDENT .sp This format should only be used when it is desired to temporarily override a list of interface names and listen on all interfaces. .sp As with the DHCPv4 server, binding to specific addresses and disabling re\-detection of interfaces are supported. But \fBdhcp\-socket\-type\fP is not supported, because DHCPv6 uses only UDP/IPv6 sockets. The following example shows how to disable interface detection: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqinterfaces\-config\(dq: { \(dqinterfaces\(dq: [ \(dqeth1\(dq, \(dqeth3\(dq ], \(dqre\-detect\(dq: false }, ... } .EE .UNINDENT .UNINDENT .sp The loopback interfaces (i.e. the \fBlo\fP or \fBlo0\fP interface) are not configured by default, unless explicitly mentioned in the configuration. Note that Kea requires a link\-local address (which does not exist on all systems) or a specified unicast address, as in: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqinterfaces\-config\(dq: { \(dqinterfaces\(dq: [ \(dqenp0s2/2001:db8::1234:abcd\(dq ] }, ... } .EE .UNINDENT .UNINDENT .sp Kea binds the service sockets for each interface on startup. If another process is already using a port, then Kea logs the message and suppresses an error. DHCP service runs, but it is unavailable on some interfaces. .sp The \(dqservice\-sockets\-require\-all\(dq option makes Kea require all sockets to be successfully bound. If any opening fails, Kea interrupts the initialization and exits with a non\-zero status. (Default is false). .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqinterfaces\-config\(dq: { \(dqinterfaces\(dq: [ \(dqeth1\(dq, \(dqeth3\(dq ], \(dqservice\-sockets\-require\-all\(dq: true }, ... } .EE .UNINDENT .UNINDENT .sp Sometimes, immediate interruption isn\(aqt a good choice. The port can be unavailable only temporary. In this case, retrying the opening may resolve the problem. Kea provides two options to specify the retrying: \fBservice\-sockets\-max\-retries\fP and \fBservice\-sockets\-retry\-wait\-time\fP\&. .sp The first defines a maximal number of retries that Kea makes to open a socket. The zero value (default) means that the Kea doesn\(aqt retry the process. .sp The second defines a wait time (in milliseconds) between attempts. The default value is 5000 (5 seconds). .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqinterfaces\-config\(dq: { \(dqinterfaces\(dq: [ \(dqeth1\(dq, \(dqeth3\(dq ], \(dqservice\-sockets\-max\-retries\(dq: 5, \(dqservice\-sockets\-retry\-wait\-time\(dq: 5000 }, ... } .EE .UNINDENT .UNINDENT .sp If \(dqservice\-sockets\-max\-retries\(dq is non\-zero and \(dqservice\-sockets\-require\-all\(dq is false, then Kea retries the opening (if needed) but does not fail if any socket is still not opened. .SS IPv6 Subnet Identifier .sp The subnet identifier (subnet ID) is a unique number associated with a particular subnet. In principle, it is used to associate clients\(aq leases with their respective subnets. The server configuration must contain unique and stable identifiers for all subnets. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Subnet IDs must be greater than zero and less than 4294967295. .UNINDENT .UNINDENT .sp The following configuration assigns the specified subnet identifier to a newly configured subnet: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqsubnet6\(dq: [ { \(dqsubnet\(dq: \(dq2001:db8:1::/64\(dq, \(dqid\(dq: 1024, ... } ] } .EE .UNINDENT .UNINDENT .SS IPv6 Subnet Prefix .sp The subnet prefix is the second way to identify a subnet. Kea can accept non\-canonical subnet addresses; for instance, this configuration is accepted: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqsubnet6\(dq: [ { \(dqsubnet\(dq: \(dq2001:db8:1::1/64\(dq, ... } ] } .EE .UNINDENT .UNINDENT .sp This works even if there is another subnet with the \(dq2001:db8:1::/64\(dq prefix; only the textual form of subnets are compared to avoid duplicates. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Abuse of this feature can lead to incorrect subnet selection (see \fI\%IPv6 Subnet Selection\fP). .UNINDENT .UNINDENT .SS Unicast Traffic Support .sp When the DHCPv6 server starts, by default it listens to the DHCP traffic sent to multicast address ff02::1:2 on each interface that it is configured to listen on (see \fI\%Interface Configuration\fP). In some cases it is useful to configure a server to handle incoming traffic sent to global unicast addresses as well; the most common reason for this is to have relays send their traffic to the server directly. To configure the server to listen on a specific unicast address, add a slash (/) after the interface name, followed by the global unicast address on which the server should listen. The server will listen to this address in addition to normal link\-local binding and listening on the ff02::1:2 address. The sample configuration below shows how to listen on 2001:db8::1 (a global address) configured on the \fBeth1\fP interface. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqinterfaces\-config\(dq: { \(dqinterfaces\(dq: [ \(dqeth1/2001:db8::1\(dq ] }, \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqunicast\(dq, \(dqdata\(dq: \(dq2001:db8::1\(dq } ], ... } .EE .UNINDENT .UNINDENT .sp This configuration will cause the server to listen on \fBeth1\fP on the link\-local address, the multicast group (ff02::1:2), and 2001:db8::1. .sp Usually, unicast support is associated with a server unicast option which allows clients to send unicast messages to the server. The example above includes a server unicast option specification which causes the client to send messages to the specified unicast address. .sp It is possible to mix interface names, wildcards, and interface names/addresses in the list of interfaces. It is not possible, however, to specify more than one unicast address on a given interface. .sp Care should be taken to specify proper unicast addresses, as the server will attempt to bind to the addresses specified without any additional checks. This approach was selected intentionally, to allow the software to communicate over uncommon addresses if so desired. .SS Configuration of IPv6 Address Pools .sp The main role of a DHCPv6 server is address assignment. For this, the server must be configured with at least one subnet and one pool of dynamic addresses to be managed. For example, assume that the server is connected to a network segment that uses the 2001:db8:1::/64 prefix. The administrator of that network decides that addresses from the range 2001:db8:1::1 to 2001:db8:1::ffff are going to be managed by the DHCPv6 server. Such a configuration can be achieved in the following way: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqsubnet6\(dq: [ { \(dqsubnet\(dq: \(dq2001:db8:1::/64\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8:1::1\-2001:db8:1::ffff\(dq } ], ... } ] } .EE .UNINDENT .UNINDENT .sp Note that \fBsubnet\fP is defined as a simple string, but the \fBpools\fP parameter is actually a list of pools; for this reason, the pool definition is enclosed in square brackets, even though only one range of addresses is specified. .sp Each \fBpool\fP is a structure that contains the parameters that describe a single pool. Currently there is only one parameter, \fBpool\fP, which gives the range of addresses in the pool. .sp It is possible to define more than one pool in a subnet; continuing the previous example, further assume that 2001:db8:1:0:5::/80 should also be managed by the server. It could be written as 2001:db8:1:0:5:: to 2001:db8:1::5:ffff:ffff:ffff, but typing so many \fBf\fP characters is cumbersome. The pool can be expressed more simply as 2001:db8:1:0:5::/80. Both formats are supported by \fBDhcp6\fP and they can be mixed in the pool list. For example, the following pools could be defined: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqsubnet6\(dq: [ { \(dqsubnet\(dq: \(dq2001:db8:1::/64\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8:1::1\-2001:db8:1::ffff\(dq }, { \(dqpool\(dq: \(dq2001:db8:1:05::/80\(dq } ], ... } ] } .EE .UNINDENT .UNINDENT .sp White space in pool definitions is ignored, so spaces before and after the hyphen are optional. They can be used to improve readability. .sp The number of pools is not limited, but for performance reasons it is recommended to use as few as possible. .sp The server may be configured to serve more than one subnet. To add a second subnet, use a command similar to the following: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqsubnet6\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq2001:db8:1::/64\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8:1::1\-2001:db8:1::ffff\(dq } ] }, { \(dqid\(dq: 2, \(dqsubnet\(dq: \(dq2001:db8:2::/64\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8:2::/64\(dq } ] }, ... ] } .EE .UNINDENT .UNINDENT .sp In this example, we allow the server to dynamically assign all addresses available in the whole subnet. Although rather wasteful, it is certainly a valid configuration to dedicate the whole /64 subnet for that purpose. Note that the Kea server does not preallocate the leases, so there is no danger in using gigantic address pools. .sp When configuring a DHCPv6 server using prefix/length notation, please pay attention to the boundary values. When specifying that the server can use a given pool, it is also able to allocate the first (typically a network address) address from that pool. For example, for pool 2001:db8:2::/64, the 2001:db8:2:: address may be assigned as well. To avoid this, use the \fBmin\-max\fP notation. .SS Subnet and Prefix Delegation Pools .sp Subnets may also be configured to delegate prefixes, as defined in \X'tty: link https://tools.ietf.org/html/rfc8415'\fI\%RFC 8415\fP\X'tty: link', section 6.3. A subnet may have one or more prefix delegation pools. Each pool has a prefixed address, which is specified as a prefix (\fBprefix\fP) and a prefix length (\fBprefix\-len\fP), as well as a delegated prefix length (\fBdelegated\-len\fP). The delegated length must not be shorter than (i.e. it must be numerically greater than or equal to) the prefix length. If both the delegated and prefix lengths are equal, the server will be able to delegate only one prefix. The delegated prefix does not have to match the subnet prefix. .sp Below is a sample subnet configuration which enables prefix delegation for the subnet: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqsubnet6\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq2001:d8b:1::/64\(dq, \(dqpd\-pools\(dq: [ { \(dqprefix\(dq: \(dq3000:1::\(dq, \(dqprefix\-len\(dq: 64, \(dqdelegated\-len\(dq: 96 } ] } ], ... } .EE .UNINDENT .UNINDENT .SS Prefix Exclude Option .sp For each delegated prefix, the delegating router may choose to exclude a single prefix out of the delegated prefix as specified in \X'tty: link https://tools.ietf.org/html/rfc6603'\fI\%RFC 6603\fP\X'tty: link'\&. The requesting router must not assign the excluded prefix to any of its downstream interfaces. The excluded prefix is intended to be used on a link through which the delegating router exchanges DHCPv6 messages with the requesting router. The configuration example below demonstrates how to specify an excluded prefix within a prefix pool definition. The excluded prefix \fB2001:db8:1:8000:cafe:80::/72\fP will be sent to a requesting router which includes the Prefix Exclude option in the Option Request option (ORO), and which is delegated a prefix from this pool. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqsubnet6\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq2001:db8:1::/48\(dq, \(dqpd\-pools\(dq: [ { \(dqprefix\(dq: \(dq2001:db8:1:8000::\(dq, \(dqprefix\-len\(dq: 56, \(dqdelegated\-len\(dq: 64, \(dqexcluded\-prefix\(dq: \(dq2001:db8:1:8000:cafe:80::\(dq, \(dqexcluded\-prefix\-len\(dq: 72 } ] } ] } .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Here are some liberties and limits to the values that subnets and pools can take in Kea configurations that are out of the ordinary: .TS box center; l|l|l. T{ Kea configuration case T} T{ Allowed T} T{ Comment T} _ T{ Overlapping subnets T} T{ Yes T} T{ Administrator consideration needs to be given to how clients are matched to these subnets. T} _ T{ Overlapping address pools in one subnet T} T{ No T} T{ Startup error: DHCP6_PARSER_FAIL T} _ T{ Overlapping address pools in different subnets T} T{ Yes T} T{ Specifying the same address pool in different subnets can be used as an equivalent of the global address pool. In that case, the server can assign addresses from the same range regardless of the client\(aqs subnet. If an address from such a pool is assigned to a client in one subnet, the same address will be renewed for this client if it moves to another subnet. Another client in a different subnet will not be assigned an address already assigned to the client in any of the subnets. T} _ T{ Address pools that are outside the subnet they are configured under T} T{ No T} T{ Startup error: DHCP6_PARSER_FAIL T} _ T{ Overlapping prefix delegation pools in one subnet T} T{ No T} T{ Startup error: DHCP6_PARSER_FAIL T} _ T{ Overlapping prefix delegation pools in different subnets T} T{ Yes T} T{ Specifying the same prefix delegation pool in different subnets can be used as an equivalent of the global pool. In that case, the server can delegate the same prefixes regardless of the client\(aqs subnet. If a prefix from such a pool is delegated to a client in one subnet, the same prefix will be renewed for this client if it moves to another subnet. Another client in a different subnet will not be delegated a prefix already delegated to the client in any of the subnets. T} _ T{ Prefix delegation pools not matching the subnet prefix T} T{ Yes T} T{ It is common in many deployments to configure the prefix delegation pools not matching the subnet prefix, e.g. a prefix pool of 3000::/96 within the 2001:db8:1::/64 subnet. Such use cases are supported by the Kea DHCPv6 server. T} .TE .UNINDENT .UNINDENT .SS Standard DHCPv6 Options .sp One of the major features of the DHCPv6 server is the ability to provide configuration options to clients. Although there are several options that require special behavior, most options are sent by the server only if the client explicitly requests them. The following example shows how to configure the addresses of DNS servers, one of the most frequently used options. Options specified in this way are considered global and apply to all configured subnets. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqdns\-servers\(dq, \(dqcode\(dq: 23, \(dqspace\(dq: \(dqdhcp6\(dq, \(dqcsv\-format\(dq: true, \(dqdata\(dq: \(dq2001:db8::cafe, 2001:db8::babe\(dq }, ... ] } .EE .UNINDENT .UNINDENT .sp The \fBoption\-data\fP line creates a new entry in the option\-data table. This table contains information on all global options that the server is supposed to configure in all subnets. The \fBname\fP line specifies the option name. (For a complete list of currently supported names, see \fI\%List of standard DHCPv6 options configurable by an administrator\fP\&.) The next line specifies the option code, which must match one of the values from that list. The line beginning with \fBspace\fP specifies the option space, which must always be set to \fBdhcp6\fP as these are standard DHCPv6 options. For other name spaces, including custom option spaces, see \fI\%Nested DHCPv6 Options (Custom Option Spaces)\fP\&. The following line specifies the format in which the data will be entered; use of CSV (comma\-separated values) is recommended. Finally, the \fBdata\fP line gives the actual value to be sent to clients. The data parameter is specified as normal text, with values separated by commas if more than one value is allowed. .sp Options can also be configured as hexadecimal values. If \fBcsv\-format\fP is set to \fBfalse\fP, the option data must be specified as a hexadecimal string. The following commands configure the \fBdns\-servers\fP option for all subnets with the addresses 2001:db8:1::cafe and 2001:db8:1::babe. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqdns\-servers\(dq, \(dqcode\(dq: 23, \(dqspace\(dq: \(dqdhcp6\(dq, \(dqcsv\-format\(dq: false, \(dqdata\(dq: \(dq20 01 0D B8 00 01 00 00 00 00 00 00 00 00 CA FE \e 20 01 0D B8 00 01 00 00 00 00 00 00 00 00 BA BE\(dq }, ... ] } .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The value for the setting of the \fBdata\fP element is split across two lines in this example for clarity; when entering the command, the whole string should be entered on the same line. .UNINDENT .UNINDENT .sp Kea supports the following formats when specifying hexadecimal data: .INDENT 0.0 .IP \(bu 2 \fBDelimited octets\fP \- one or more octets separated by either colons or spaces (\(dq:\(dq or \(dq \(dq). While each octet may contain one or two digits, we strongly recommend always using two digits. Valid examples are \(dqab:cd:ef\(dq and \(dqab cd ef\(dq. .IP \(bu 2 \fBString of digits\fP \- a continuous string of hexadecimal digits with or without a \(dq0x\(dq prefix. Valid examples are \(dq0xabcdef\(dq and \(dqabcdef\(dq. .UNINDENT .sp Care should be taken to use proper encoding when using hexadecimal format; Kea\(aqs ability to validate data correctness in hexadecimal is limited. .sp It is also possible to specify data for binary options as a single\-quoted text string within double quotes, as shown (note that \fBcsv\-format\fP must be set to \fBfalse\fP): .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqsubscriber\-id\(dq, \(dqcode\(dq: 38, \(dqspace\(dq: \(dqdhcp6\(dq, \(dqcsv\-format\(dq: false, \(dqdata\(dq: \(dq\(aqconvert this text to binary\(aq\(dq }, ... ], ... } .EE .UNINDENT .UNINDENT .sp Most of the parameters in the \fBoption\-data\fP structure are optional and can be omitted in some circumstances, as discussed in \fI\%Unspecified Parameters for DHCPv6 Option Configuration\fP\&. Only one of \fBname\fP or \fBcode\fP is required; it is not necessary to specify both. Space has a default value of \fBdhcp6\fP, so this can be skipped as well if a regular (not encapsulated) DHCPv6 option is defined. Finally, \fBcsv\-format\fP defaults to \fBtrue\fP, so it too can be skipped, unless the option value is specified as hexstring. Therefore, the above example can be simplified to: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqdns\-servers\(dq, \(dqdata\(dq: \(dq2001:db8::cafe, 2001:db8::babe\(dq }, ... ] } .EE .UNINDENT .UNINDENT .sp Defined options are added to the response when the client requests them, as well as any options required by a protocol. An administrator can also specify that an option is always sent, even if a client did not specifically request it. To enforce the addition of a particular option, set the \fBalways\-send\fP flag to \fBtrue\fP, as in: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqdns\-servers\(dq, \(dqdata\(dq: \(dq2001:db8::cafe, 2001:db8::babe\(dq, \(dqalways\-send\(dq: true }, ... ] } .EE .UNINDENT .UNINDENT .sp The effect is the same as if the client added the option code in the Option Request Option (or its equivalent for vendor options), as in: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqdns\-servers\(dq, \(dqdata\(dq: \(dq2001:db8::cafe, 2001:db8::babe\(dq, \(dqalways\-send\(dq: true }, ... ], \(dqsubnet6\(dq: [ { \(dqsubnet\(dq: \(dq2001:db8:1::/64\(dq, \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqdns\-servers\(dq, \(dqdata\(dq: \(dq2001:db8:1::cafe, 2001:db8:1::babe\(dq }, ... ], ... }, ... ], ... } .EE .UNINDENT .UNINDENT .sp In the example above, the \fBdns\-servers\fP option respects the global \fBalways\-send\fP flag and is always added to responses, but for subnet \fB2001:db8:1::/64\fP, the value is taken from the subnet\-level option data specification. .sp Contrary to \fBalways\-send\fP, if the \fBnever\-send\fP flag is set to \fBtrue\fP for a particular option, the server does not add it to the response. The effect is the same as if the client removed the option code in the Option Request Option (or its equivalent for vendor options): .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqdns\-servers\(dq, \(dqdata\(dq: \(dq2001:db8::cafe, 2001:db8::babe\(dq }, ... ], \(dqsubnet6\(dq: [ { \(dqsubnet\(dq: \(dq2001:db8:1::/64\(dq, \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqdns\-servers\(dq, \(dqnever\-send\(dq: true }, ... ], ... }, ... ], ... } .EE .UNINDENT .UNINDENT .sp In the example above, the \fBdns\-server\fP option is never added to responses on subnet \fB2001:db8:1::/64\fP\&. \fBnever\-send\fP has precedence over \fBalways\-send\fP, so if both are \fBtrue\fP the option is not added. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The \fBalways\-send\fP and \fBnever\-send\fP flags are sticky, meaning they do not follow the usual configuration inheritance rules. Instead, if they are enabled at least once along the configuration inheritance chain, they are applied \- even if they are disabled in other places which would normally receive a higher priority. For instance, if one of the flags is enabled in the global scope, but disabled at the subnet level, it is enabled, disregarding the subnet\-level setting. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The \fBnever\-send\fP flag is less powerful than \fI\%libdhcp_flex_option.so\fP; for instance, it has no effect on options managed by the server itself. Both \fBalways\-send\fP and \fBnever\-send\fP have no effect on options which cannot be requested, for instance from a custom space. .UNINDENT .UNINDENT .sp It is possible to override options on a per\-subnet basis. If clients connected to most subnets are expected to get the same values of a given option, administrators should use global options; it is possible to override specific values for a small number of subnets. On the other hand, if different values are used in each subnet, it does not make sense to specify global option values; rather, only subnet\-specific ones should be set. .sp The following commands override the global \fBdns\-servers\fP option for a particular subnet, setting a single DNS server with address 2001:db8:1::3. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqsubnet6\(dq: [ { \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqdns\-servers\(dq, \(dqcode\(dq: 23, \(dqspace\(dq: \(dqdhcp6\(dq, \(dqcsv\-format\(dq: true, \(dqdata\(dq: \(dq2001:db8:1::3\(dq }, ... ], ... }, ... ], ... } .EE .UNINDENT .UNINDENT .sp In some cases it is useful to associate some options with an address or prefix pool from which a client is assigned a lease. Pool\-specific option values override subnet\-specific and global option values. If the client is assigned multiple leases from different pools, the server assigns options from all pools from which the leases have been obtained. However, if the particular option is specified in multiple pools from which the client obtains the leases, only one instance of this option is handed out to the client. The server\(aqs administrator must not try to prioritize assignment of pool\-specific options by trying to order pool declarations in the server configuration. .sp The following configuration snippet demonstrates how to specify the \fBdns\-servers\fP option, which will be assigned to a client only if the client obtains an address from the given pool: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqsubnet6\(dq: [ { \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8:1::100\-2001:db8:1::300\(dq, \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqdns\-servers\(dq, \(dqdata\(dq: \(dq2001:db8:1::10\(dq } ] } ] }, ... ], ... } .EE .UNINDENT .UNINDENT .sp Options can also be specified in class or host\-reservation scope. The current Kea options precedence order is (from most important to least): host reservation, pool, subnet, shared network, class, global. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Beginning with Kea 2.7.4, option inclusion can also be controlled through option class\-tagging, see \fI\%Option Class\-Tagging\fP .UNINDENT .UNINDENT .sp When a data field is a string and that string contains the comma (\fB,\fP; U+002C) character, the comma must be escaped with two backslashes (\fB\e\e,\fP; U+005C). This double escape is required because both the routine splitting of CSV data into fields and JSON use the same escape character; a single escape (\fB\e,\fP) would make the JSON invalid. For example, the string \(dqEST5EDT4,M3.2.0/02:00,M11.1.0/02:00\(dq must be represented as: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqsubnet6\(dq: [ { \(dqpools\(dq: [ { \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqnew\-posix\-timezone\(dq, \(dqdata\(dq: \(dqEST5EDT4\e\e,M3.2.0/02:00\e\e,M11.1.0/02:00\(dq } ] }, ... ], ... }, ... ], ... } .EE .UNINDENT .UNINDENT .sp Some options are designated as arrays, which means that more than one value is allowed. For example, the option \fBdns\-servers\fP allows the specification of more than one IPv6 address, enabling clients to obtain the addresses of multiple DNS servers. .sp \fI\%Custom DHCPv6 Options\fP describes the configuration syntax to create custom option definitions (formats). Creation of custom definitions for standard options is generally not permitted, even if the definition being created matches the actual option format defined in the RFCs. However, there is an exception to this rule for standard options for which Kea currently does not provide a definition. To use such options, a server administrator must create a definition as described in \fI\%Custom DHCPv6 Options\fP in the \fBdhcp6\fP option space. This definition should match the option format described in the relevant RFC, but the configuration mechanism allows any option format as there is currently no way to validate it. .sp The currently supported standard DHCPv6 options are listed in the table below. \(dqName\(dq and \(dqCode\(dq are the values that should be used as a name/code in the option\-data structures. \(dqType\(dq designates the format of the data; the meanings of the various types are given in \fI\%List of standard DHCP option types\fP\&. .SS List of standard DHCPv6 options configurable by an administrator .TS box center; l|l|l|l. T{ Name T} T{ Code T} T{ Type T} T{ Array? T} _ T{ preference T} T{ 7 T} T{ uint8 T} T{ false T} _ T{ unicast T} T{ 12 T} T{ ipv6\-address T} T{ false T} _ T{ sip\-server\-dns T} T{ 21 T} T{ fqdn T} T{ true T} _ T{ sip\-server\-addr T} T{ 22 T} T{ ipv6\-address T} T{ true T} _ T{ dns\-servers T} T{ 23 T} T{ ipv6\-address T} T{ true T} _ T{ domain\-search T} T{ 24 T} T{ fqdn T} T{ true T} _ T{ nis\-servers T} T{ 27 T} T{ ipv6\-address T} T{ true T} _ T{ nisp\-servers T} T{ 28 T} T{ ipv6\-address T} T{ true T} _ T{ nis\-domain\-name T} T{ 29 T} T{ fqdn T} T{ true T} _ T{ nisp\-domain\-name T} T{ 30 T} T{ fqdn T} T{ true T} _ T{ sntp\-servers T} T{ 31 T} T{ ipv6\-address T} T{ true T} _ T{ information\-refresh\-time T} T{ 32 T} T{ uint32 T} T{ false T} _ T{ bcmcs\-server\-dns T} T{ 33 T} T{ fqdn T} T{ true T} _ T{ bcmcs\-server\-addr T} T{ 34 T} T{ ipv6\-address T} T{ true T} _ T{ geoconf\-civic T} T{ 36 T} T{ record (uint8, uint16, binary) T} T{ false T} _ T{ remote\-id T} T{ 37 T} T{ record (uint32, binary) T} T{ false T} _ T{ subscriber\-id T} T{ 38 T} T{ binary T} T{ false T} _ T{ client\-fqdn T} T{ 39 T} T{ record (uint8, fqdn) T} T{ false T} _ T{ pana\-agent T} T{ 40 T} T{ ipv6\-address T} T{ true T} _ T{ new\-posix\-timezone T} T{ 41 T} T{ string T} T{ false T} _ T{ new\-tzdb\-timezone T} T{ 42 T} T{ string T} T{ false T} _ T{ ero T} T{ 43 T} T{ uint16 T} T{ true T} _ T{ lq\-query (1) T} T{ 44 T} T{ record (uint8, ipv6\-address) T} T{ false T} _ T{ client\-data (1) T} T{ 45 T} T{ empty T} T{ false T} _ T{ clt\-time (1) T} T{ 46 T} T{ uint32 T} T{ false T} _ T{ lq\-relay\-data (1) T} T{ 47 T} T{ record (ipv6\-address, binary) T} T{ false T} _ T{ lq\-client\-link (1) T} T{ 48 T} T{ ipv6\-address T} T{ true T} _ T{ v6\-lost T} T{ 51 T} T{ fqdn T} T{ false T} _ T{ capwap\-ac\-v6 T} T{ 52 T} T{ ipv6\-address T} T{ true T} _ T{ relay\-id T} T{ 53 T} T{ binary T} T{ false T} _ T{ ntp\-server T} T{ 56 T} T{ empty T} T{ false T} _ T{ v6\-access\-domain T} T{ 57 T} T{ fqdn T} T{ false T} _ T{ sip\-ua\-cs\-list T} T{ 58 T} T{ fqdn T} T{ true T} _ T{ bootfile\-url T} T{ 59 T} T{ string T} T{ false T} _ T{ bootfile\-param T} T{ 60 T} T{ tuple T} T{ true T} _ T{ client\-arch\-type T} T{ 61 T} T{ uint16 T} T{ true T} _ T{ nii T} T{ 62 T} T{ record (uint8, uint8, uint8) T} T{ false T} _ T{ aftr\-name T} T{ 64 T} T{ fqdn T} T{ false T} _ T{ erp\-local\-domain\-name T} T{ 65 T} T{ fqdn T} T{ false T} _ T{ rsoo T} T{ 66 T} T{ empty T} T{ false T} _ T{ pd\-exclude T} T{ 67 T} T{ binary T} T{ false T} _ T{ rdnss\-selection T} T{ 74 T} T{ record (ipv6\-address, uint8, fqdn) T} T{ true T} _ T{ client\-linklayer\-addr T} T{ 79 T} T{ binary T} T{ false T} _ T{ link\-address T} T{ 80 T} T{ ipv6\-address T} T{ false T} _ T{ solmax\-rt T} T{ 82 T} T{ uint32 T} T{ false T} _ T{ inf\-max\-rt T} T{ 83 T} T{ uint32 T} T{ false T} _ T{ dhcp4o6\-server\-addr T} T{ 88 T} T{ ipv6\-address T} T{ true T} _ T{ s46\-rule T} T{ 89 T} T{ record (uint8, uint8, uint8, ipv4\-address, ipv6\-prefix) T} T{ false T} _ T{ s46\-br T} T{ 90 T} T{ ipv6\-address T} T{ false T} _ T{ s46\-dmr T} T{ 91 T} T{ ipv6\-prefix T} T{ false T} _ T{ s46\-v4v6bind T} T{ 92 T} T{ record (ipv4\-address, ipv6\-prefix) T} T{ false T} _ T{ s46\-portparams T} T{ 93 T} T{ record(uint8, psid) T} T{ false T} _ T{ s46\-cont\-mape T} T{ 94 T} T{ empty T} T{ false T} _ T{ s46\-cont\-mapt T} T{ 95 T} T{ empty T} T{ false T} _ T{ s46\-cont\-lw T} T{ 96 T} T{ empty T} T{ false T} _ T{ v6\-captive\-portal T} T{ 103 T} T{ string T} T{ false T} _ T{ v6\-sztp\-redirect T} T{ 136 T} T{ tuple T} T{ true T} _ T{ ipv6\-address\-andsf T} T{ 143 T} T{ ipv6\-address T} T{ true T} _ T{ v6\-dnr T} T{ 144 T} T{ record (uint16, uint16, fqdn, binary) T} T{ false T} _ T{ addr\-reg\-enable T} T{ 148 T} T{ empty T} T{ false T} .TE .sp Options marked with (1) have option definitions, but the logic behind them is not implemented. That means that, technically, Kea knows how to parse them in incoming messages or how to send them if configured to do so, but not what to do with them. Since the related RFCs require certain processing, the support for those options is non\-functional. However, it may be useful in some limited lab testing; hence the definition formats are listed here. .sp Some options are more complex to configure than others. In particular, the Softwire46 family of options and Discovery of Network\-designated Resolvers (DNR) are discussed in separate sections below. .sp Kea supports more options than those listed above. The following list is mostly useful for readers who want to understand whether Kea is able to support certain options. The following options are returned by the Kea engine itself and in general should not be configured manually. .SS List of standard DHCPv6 options managed by Kea on its own and not directly configurable by an administrator .TS box center; l|l|l. T{ Name T} T{ Code T} T{ Description T} _ T{ client\-id T} T{ 1 T} T{ Sent by the client; Kea uses it to distinguish between clients. T} _ T{ server\-id T} T{ 2 T} T{ Sent by clients to request action from a specific server and by the server to identify itself. See \fI\%Server Identifier in DHCPv6\fP for details. T} _ T{ ia\-na T} T{ 3 T} T{ A container option that conveys IPv6 addresses (\fBiaddr\fP options). Kea receives and sends those options using its allocation engine. T} _ T{ ia\-ta T} T{ 4 T} T{ Conveys temporary addresses. Deprecated feature, not supported. T} _ T{ iaaddr T} T{ 5 T} T{ Conveys addresses with lifetimes in \fBia\-na\fP and \fBia\-ta\fP options. T} _ T{ oro T} T{ 6 T} T{ ORO (or Option Request Option) is used by clients to request a list of options they are interested in. Kea supports it and sends the requested options back if configured with required options. T} _ T{ elapsed\-time T} T{ 8 T} T{ Sent by clients to identify how long they have been trying to obtain a configuration. Kea uses high values sent by clients as an indicator that something is wrong; this is one of the aspects used in HA to determine if the partner is healthy or not. T} _ T{ relay\-msg T} T{ 9 T} T{ Used by relays to encapsulate the original client message. Kea uses it when sending back relayed responses to the relay agent. T} _ T{ auth T} T{ 11 T} T{ Used to pass authentication information between clients and server. The support for this option is very limited. T} _ T{ status\-code T} T{ 13 T} T{ An option that the server can attach in case of various failures, such as running out of addresses or not being configured to assign prefixes. T} _ T{ rapid\-commit T} T{ 14 T} T{ Used to signal the client\(aqs willingness to support \fBrapid\-commit\fP and the server\(aqs acceptance for this configuration. See \fI\%Rapid Commit\fP for details. T} _ T{ user\-class T} T{ 15 T} T{ Sent by the client to self\-identify the device type. Kea can use this for client classification. T} _ T{ vendor\-class T} T{ 16 T} T{ Similar to \fBuser\-class\fP, but vendor\-specific. T} _ T{ vendor\-opts T} T{ 17 T} T{ A vendor\-specific container that is used by both the client and the server to exchange vendor\-specific options. The logic behind those options varies between vendors. Vendor options are explained in \fI\%DHCPv6 Vendor\-Specific Options\fP\&. T} _ T{ interface\-id T} T{ 18 T} T{ May be inserted by the relay agent to identify the interface that the original client message was received on. Kea may be told to use this information to select specific subnets. Also, if specified, Kea echoes this option back, so the relay will know which interface to use to reach the client. T} _ T{ ia\-pd T} T{ 25 T} T{ A container for conveying Prefix Delegations (PDs)) that are being delegated to clients. See \fI\%Subnet and Prefix Delegation Pools\fP for details. T} _ T{ iaprefix T} T{ 26 T} T{ Conveys the IPv6 prefix in the \fBia\-pd\fP option. See \fI\%Subnet and Prefix Delegation Pools\fP for details. T} .TE .SS Common Softwire46 Options .sp Softwire46 options are involved in IPv4\-over\-IPv6 provisioning by means of tunneling or translation, as specified in \X'tty: link https://tools.ietf.org/html/rfc7598'\fI\%RFC 7598\fP\X'tty: link'\&. The following sections provide configuration examples of these options. .SS Softwire46 Container Options .sp Softwire46 (S46) container options group rules and optional port parameters for a specified domain. There are three container options specified in the \(dqdhcp6\(dq (top\-level) option space: the MAP\-E Container option, the MAP\-T Container option, and the S46 Lightweight 4over6 Container option. These options only contain the encapsulated options specified below; they do not include any data fields. .sp To configure the server to send a specific container option along with all encapsulated options, the container option must be included in the server configuration as shown below: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqs46\-cont\-mape\(dq } ], ... } .EE .UNINDENT .UNINDENT .sp This configuration will cause the server to include the MAP\-E Container option to the client. Use \fBs46\-cont\-mapt\fP or \fBs46\-cont\-lw\fP for the MAP\-T Container and S46 Lightweight 4over6 Container options, respectively. .sp All remaining Softwire46 options described below are included in one of the container options. Thus, they must be included in appropriate option spaces by selecting a \fBspace\fP name, which specifies the option where they are supposed to be included. .SS S46 Rule Option .sp The S46 Rule option is used to convey the Basic Mapping Rule (BMR) and Forwarding Mapping Rule (FMR). .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqspace\(dq: \(dqs46\-cont\-mape\-options\(dq, \(dqname\(dq: \(dqs46\-rule\(dq, \(dqdata\(dq: \(dq128, 0, 24, 192.0.2.0, 2001:db8:1::/64\(dq } .EE .UNINDENT .UNINDENT .sp Another possible \fBspace\fP value is \fBs46\-cont\-mapt\-options\fP\&. .sp The S46 Rule option conveys a number of parameters: .INDENT 0.0 .IP \(bu 2 \fBflags\fP \- an unsigned 8\-bit integer, with currently only the most\-significant bit specified. It denotes whether the rule can be used for forwarding (128) or not (0). .IP \(bu 2 \fBea\-len\fP \- an 8\-bit\-long Embedded Address length. Allowed values range from 0 to 48. .IP \(bu 2 \fBIPv4 prefix length\fP \- an 8\-bit\-long expression of the prefix length of the Rule IPv4 prefix specified in the \fBipv4\-prefix\fP field. Allowed values range from 0 to 32. .IP \(bu 2 \fBIPv4 prefix\fP \- a fixed\-length 32\-bit field that specifies the IPv4 prefix for the S46 rule. The bits in the prefix after a specific number of bits (defined in \fBprefix4\-len\fP) are reserved, and MUST be initialized to zero by the sender and ignored by the receiver. .IP \(bu 2 \fBIPv6 prefix\fP \- a field in prefix/length notation that specifies the IPv6 domain prefix for the S46 rule. The field is padded on the right with zero bits up to the nearest octet boundary, when \fBprefix6\-len\fP is not evenly divisible by 8. .UNINDENT .SS S46 BR Option .sp The S46 BR option is used to convey the IPv6 address of the Border Relay. This option is mandatory in the MAP\-E Container option and is not permitted in the MAP\-T and S46 Lightweight 4over6 Container options. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqspace\(dq: \(dqs46\-cont\-mape\-options\(dq, \(dqname\(dq: \(dqs46\-br\(dq, \(dqdata\(dq: \(dq2001:db8:cafe::1\(dq } .EE .UNINDENT .UNINDENT .sp Another possible \fBspace\fP value is \fBs46\-cont\-lw\-options\fP\&. .SS S46 DMR Option .sp The S46 DMR option is used to convey values for the Default Mapping Rule (DMR). This option is mandatory in the MAP\-T container option and is not permitted in the MAP\-E and S46 Lightweight 4over6 Container options. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqspace\(dq: \(dqs46\-cont\-mapt\-options\(dq, \(dqname\(dq: \(dqs46\-dmr\(dq, \(dqdata\(dq: \(dq2001:db8:cafe::/64\(dq } .EE .UNINDENT .UNINDENT .sp This option must not be included in other containers. .SS S46 IPv4/IPv6 Address Binding Option .sp The S46 IPv4/IPv6 Address Binding option may be used to specify the full or shared IPv4 address of the Customer Edge (CE). The IPv6 prefix field is used by the CE to identify the correct prefix to use for the tunnel source. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqspace\(dq: \(dqs46\-cont\-lw\(dq, \(dqname\(dq: \(dqs46\-v4v6bind\(dq, \(dqdata\(dq: \(dq192.0.2.3, 2001:db8:1:cafe::/64\(dq } .EE .UNINDENT .UNINDENT .sp This option must not be included in other containers. .SS S46 Port Parameters .sp The S46 Port Parameters option specifies optional port\-set information that may be provided to CEs. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqspace\(dq: \(dqs46\-rule\-options\(dq, \(dqname\(dq: \(dqs46\-portparams\(dq, \(dqdata\(dq: \(dq2, 3/4\(dq } .EE .UNINDENT .UNINDENT .sp Another possible \fBspace\fP value is \fBs46\-v4v6bind\fP, to include this option in the S46 IPv4/IPv6 Address Binding option. .sp Note that the second value in the example above specifies the PSID and PSID\-length fields in the format of PSID/PSID length. This is equivalent to the values of \fBPSID\-len=4\fP and \fBPSID=12288\fP conveyed in the S46 Port Parameters option. .SS DNR (Discovery of Network\-designated Resolvers) Options for DHCPv6 .sp The Discovery of Network\-designated Resolvers, or DNR option, was introduced in \X'tty: link https://tools.ietf.org/html/rfc9463'\fI\%RFC 9463\fP\X'tty: link' as a way to communicate location of DNS resolvers available over means other than the classic DNS over UDP over port 53. As of spring 2024, the supported technologies are DoT (DNS\-over\-TLS), DoH (DNS\-over\-HTTPS), and DoQ (DNS\-over\-QUIC), but the option was designed to be extensible to accommodate other protocols in the future. .sp The DNR option may be configured using convenient notation: comma\-delimited fields must be provided in the following order: .INDENT 0.0 .IP \(bu 2 Service Priority (mandatory), .IP \(bu 2 ADN FQDN (mandatory), .IP \(bu 2 IP address(es) (optional; if more than one, they must be separated by spaces) .IP \(bu 2 SvcParams as a set of key=value pairs (optional; if more than one, they must be separated by spaces) To provide more than one \fBalpn\-id\fP, separate them with double backslash\-escaped commas as in the example below). .UNINDENT .sp Let\(aqs imagine that we want to convey a DoT server operating at \fBdot1.example.org\fP (which resolves to two IPv6 addresses: \fB2001:db8::1\fP and \fB2001:db8::2\fP) on a non\-standard port 8530. An example option that would convey this information looks as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqname\(dq: \(dqv6\-dnr\(dq, // name of the option // The following fields should be specified: // \- service priority (unsigned 16\-bit integer) // \- authentication\-domain\-name (FQDN of the encrypted resolver) // \- a list of one or more IPv6 addresses // \- list of parameters in key=value format, space separated; any comma // characters in this field must be escaped with double backslashes \(dqdata\(dq: \(dq100, dot1.example.org., 2001:db8::1 2001:db8::2, alpn=dot port=8530\(dq } .EE .UNINDENT .UNINDENT .sp The above option will be encoded on\-wire as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX 00 64 \- service priority (100 in hex as unsigned 16\-bit integer) 00 12 \- length of the Authentication Domain Name (name of the resolver) FQDN (18 in hex as unsigned 16\-bit integer) 04 64 6f 74 31 07 65 78 61 6d 70 6c 65 03 6f 72 67 00 \- 18 octets of the ADN FQDN 00 20 \- 32 octets is the length of the following two IPv6 addresses 20 01 0d b8 00 00 00 00 00 00 00 00 00 00 00 01 \- 2001:db8::1 20 01 0d b8 00 00 00 00 00 00 00 00 00 00 00 02 \- 2001:db8::2 00 01 \- SvsParams begin \- this is alpn SvcParamKey 00 04 \- length of the alpn SvcParamValue field (4 octets) 03 \- length of the following alpn\-id coded on one octet 64 6f 74 \- \(dqdot\(dq \- value of the alpn 00 03 \- this is port SvcParamKey 00 02 \- length of the SvcParamValue field is 2 octets 21 52 \- the actual value is 0x2152 or 8530 in decimal .EE .UNINDENT .UNINDENT .sp The following example shows how to configure more than one \fBALPN\fP protocol in Service Parameters. The example specifies a resolver known as \fBresolver.example\fP that supports: .INDENT 0.0 .IP \(bu 2 DoT on default port 853 .IP \(bu 2 DoQ on default port 853 .IP \(bu 2 DoH at \fBhttps://resolver.example/q{?dns}\fP .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqname\(dq: \(dqv6\-dnr\(dq, // name of the option // Note the double backslash\-escaped commas in the alpn\-id list. \(dqdata\(dq: \(dq150, resolver.example., 2001:db8::1 2001:db8::2, alpn=dot\e\e,doq\e\e,h2\e\e,h3 dohpath=/q{?dns}\(dq } .EE .UNINDENT .UNINDENT .sp The above option will be encoded on\-wire as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX 00 96 \- service priority (150 in hex as unsigned 16\-bit integer) 00 12 \- length of the Authentication Domain Name (name of the resolver) FQDN (18 in hex as unsigned 16\-bit integer) 08 72 65 73 6f 6c 76 65 72 07 65 78 61 6d 70 6c 65 00 \- 18 octets of the ADN FQDN 00 20 \- 32 octets is the length of the following two IPv6 addresses 20 01 0d b8 00 00 00 00 00 00 00 00 00 00 00 01 \- 2001:db8::1 20 01 0d b8 00 00 00 00 00 00 00 00 00 00 00 02 \- 2001:db8::2 00 01 \- SvsParams begin \- this is the alpn SvcParamKey 00 0e \- length of the alpn SvcParamValue field (14 octets) 03 \- length of the following alpn\-id coded on one octet 64 6f 74 \- \(dqdot\(dq \- value of the alpn 03 \- length of the following alpn\-id coded on one octet 64 6f 71 \- \(dqdoq\(dq \- value of the alpn 02 \- length of the following alpn\-id coded on one octet 68 32 \- \(dqh2\(dq \- value of the alpn \(dqHTTP/2 over TLS\(dq 02 \- length of the following alpn\-id coded on one octet 68 33 \- \(dqh3\(dq \- value of the alpn \(dqHTTP/3\(dq 00 07 \- this is dohpath SvcParamKey 00 08 \- length of the SvcParamValue field is 8 octets 2f 71 7b 3f 64 6e 73 7d \- \(dq/q{?dns}\(dq dohpath .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 If \(dqcomma\(dq or \(dqpipe\(dq characters are used as text rather than as field delimiters, they must be escaped with double backslashes (\fB\e\e,\fP or \fB\e\e|\fP). Escaped commas must be used when configuring more than one \fBALPN\fP protocol, to separate them. The \(dqpipe\(dq (\fB0x7C\fP) character can be used in the \fBdohpath\fP service parameter, as it is allowed in a URI. .UNINDENT .UNINDENT .sp \X'tty: link https://www.rfc-editor.org/rfc/rfc9463#name-option-format'\fI\%RFC 9463\fP\X'tty: link', Section 4.1 encourages the use of the \fBALPN\fP (Application\-Layer Protocol Negotiation) SvcParam, as it is required in most cases. It defines the protocol for reaching the encrypted resolver. The most common values are \fBdot\fP, \fBdoq\fP, and \fBh2\fP (meaning HTTP/2.0 over TLS, used in DoH). .sp Per \X'tty: link https://www.rfc-editor.org/rfc/rfc9461.html#name-new-svcparamkey-dohpath'\fI\%RFC 9461\fP\X'tty: link' Section 5: if the \fBalpn\fP SvcParam indicates support for HTTP, \fBdohpath\fP MUST be present. The URI Template MUST contain a \(dqdns\(dq variable. For example, when advertising a DoH resolver available at \fBhttps://doh1.example.org/query{?dns}\fP, the \fBdohpath\fP should be set to relative URI \fB/query{?dns}\fP\&. .sp Users interested in configuring this option are encouraged to read the following materials: .INDENT 0.0 .IP \(bu 2 A very nice set of examples is available in Section 7 of \X'tty: link https://www.rfc-editor.org/rfc/rfc9461#name-examples'\fI\%RFC 9461\fP\X'tty: link'\&. .IP \(bu 2 A list of all currently defined service parameters is maintained in the \X'tty: link https://www.iana.org/assignments/dns-svcb/dns-svcb.xhtml'\fI\%IANA registry\fP\X'tty: link'\&. This specifies records that can be stored in the svcParams field of the DNR option. .IP \(bu 2 A list of currently allowed protocols in the ALPN parameter is maintained in \X'tty: link https://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml#alpn-protocol-ids'\fI\%another IANA registry\fP\X'tty: link'\&. .IP \(bu 2 \X'tty: link https://www.rfc-editor.org/rfc/rfc9463'\fI\%RFC 9463\fP\X'tty: link' provides option definitions. In terms of SvcParams, it states that \fBalpn\fP and \fBport\fP must be supported, and support for \fBdohpath\fP (used for DoH) is recommended. .IP \(bu 2 Section 2.2 of \X'tty: link https://www.rfc-editor.org/rfc/rfc9460'\fI\%RFC 9460\fP\X'tty: link' defines the on\-wire format for SvcParams. .IP \(bu 2 Sections 7.1 and 7.2 of \X'tty: link https://www.rfc-editor.org/rfc/rfc9460'\fI\%RFC 9460\fP\X'tty: link' define the on\-wire format for alpn and port. .IP \(bu 2 Section 5 of \X'tty: link https://www.rfc-editor.org/rfc/rfc9461#name-new-svcparamkey-dohpath'\fI\%RFC 9461\fP\X'tty: link' defines the on\-wire format for \fBdohpath\fP\&. .UNINDENT .sp Kea currently supports the following service parameters: .INDENT 0.0 .INDENT 3.5 .TS box center; l|l|l. T{ Name T} T{ Code T} T{ Description T} _ T{ alpn T} T{ 1 T} T{ Specifies comma\-separated protocol types (DoT, DoH, etc.) T} _ T{ port T} T{ 3 T} T{ Unsigned 16\-bit integer. Indicates a non\-standard TCP or UDP port. T} _ T{ dohpath T} T{ 7 T} T{ Mandatory for DoH. Contains URL path for the DoT resolver. T} .TE .UNINDENT .UNINDENT .sp The other currently defined service parameters mandatory (0), no\-default\-alpn (2), ipv4hint (4), ech (5), ipv6hint (6), and ohttp (8) are not usable in the DNR option. .sp Further examples are provided in Kea sources in the \fBall\-options.json\fP file in the \fBdoc/examples/kea6\fP directory. The DHCPv4 option is nearly identical, and is described in \fI\%DNR (Discovery of Network\-designated Resolvers) Options for DHCPv4\fP\&. .SS NTP Server Suboptions .sp NTP server option is a container of suboptions: ntp\-server\-address (1), ntp\-server\-multicast (2) carrying an IPv6 address, and ntp\-server\-fqdn (3) carrying a FQDN in wire format defined in the \(dqv6\-ntp\-server\-suboptions\(dq option space. Each option instance carries one and only one suboption as required by \X'tty: link https://tools.ietf.org/html/rfc5908'\fI\%RFC 5908\fP\X'tty: link'\&. .SS Custom DHCPv6 Options .sp Kea supports custom (non\-standard) DHCPv6 options. Let\(aqs say that we want to define a new DHCPv6 option called \fBfoo\fP, which will have code 100 and will convey a single, unsigned, 32\-bit integer value. Such an option can be defined by putting the following entry in the configuration file: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqoption\-def\(dq: [ { \(dqname\(dq: \(dqfoo\(dq, \(dqcode\(dq: 100, \(dqtype\(dq: \(dquint32\(dq, \(dqarray\(dq: false, \(dqrecord\-types\(dq: \(dq\(dq, \(dqspace\(dq: \(dqdhcp6\(dq, \(dqencapsulate\(dq: \(dq\(dq }, ... ], ... } .EE .UNINDENT .UNINDENT .sp The \fBfalse\fP value of the \fBarray\fP parameter determines that the option does NOT comprise an array of \fBuint32\fP values but is, instead, a single value. Two other parameters have been left blank: \fBrecord\-types\fP and \fBencapsulate\fP\&. The former specifies the comma\-separated list of option data fields, if the option comprises a record of data fields. The \fBrecord\-types\fP value should be non\-empty if \fBtype\fP is set to \fBrecord\fP; otherwise it must be left blank. The latter parameter specifies the name of the option space being encapsulated by the particular option. If the particular option does not encapsulate any option space, the parameter should be left blank. Note that the \fBoption\-def\fP configuration statement only defines the format of an option and does not set its value(s). .sp The \fBname\fP, \fBcode\fP, and \fBtype\fP parameters are required; all others are optional. The \fBarray\fP parameter\(aqs default value is \fBfalse\fP\&. The \fBrecord\-types\fP and \fBencapsulate\fP parameters\(aq default values are blank (\fB\(dq\(dq\fP). The default \fBspace\fP is \fBdhcp6\fP\&. .sp Once the new option format is defined, its value is set in the same way as for a standard option. For example, the following commands set a global value that applies to all subnets. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqfoo\(dq, \(dqcode\(dq: 100, \(dqspace\(dq: \(dqdhcp6\(dq, \(dqcsv\-format\(dq: true, \(dqdata\(dq: \(dq12345\(dq }, ... ], ... } .EE .UNINDENT .UNINDENT .sp New options can take more complex forms than the simple use of primitives (uint8, string, ipv6\-address, etc.); it is possible to define an option comprising a number of existing primitives. .sp For example, say we want to define a new option that will consist of an IPv6 address, followed by an unsigned 16\-bit integer, followed by a boolean value, followed by a text string. Such an option could be defined in the following way: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqoption\-def\(dq: [ { \(dqname\(dq: \(dqbar\(dq, \(dqcode\(dq: 101, \(dqspace\(dq: \(dqdhcp6\(dq, \(dqtype\(dq: \(dqrecord\(dq, \(dqarray\(dq: false, \(dqrecord\-types\(dq: \(dqipv6\-address, uint16, boolean, string\(dq, \(dqencapsulate\(dq: \(dq\(dq }, ... ], ... } .EE .UNINDENT .UNINDENT .sp The \fBtype\fP parameter is set to \fB\(dqrecord\(dq\fP to indicate that the option contains multiple values of different types. These types are given as a comma\-separated list in the \fBrecord\-types\fP field and should be ones from those listed in \fI\%List of standard DHCP option types\fP\&. .sp The values of the options are set in an \fBoption\-data\fP statement as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqbar\(dq, \(dqspace\(dq: \(dqdhcp6\(dq, \(dqcode\(dq: 101, \(dqcsv\-format\(dq: true, \(dqdata\(dq: \(dq2001:db8:1::10, 123, false, Hello World\(dq } ], ... } .EE .UNINDENT .UNINDENT .sp The \fBcsv\-format\fP parameter is set to \fBtrue\fP to indicate that the \fBdata\fP field comprises a comma\-separated list of values. The values in \fBdata\fP must correspond to the types set in the \fBrecord\-types\fP field of the option definition. .sp When \fBarray\fP is set to \fBtrue\fP and \fBtype\fP is set to \fB\(dqrecord\(dq\fP, the last field is an array, i.e. it can contain more than one value, as in: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqoption\-def\(dq: [ { \(dqname\(dq: \(dqbar\(dq, \(dqcode\(dq: 101, \(dqspace\(dq: \(dqdhcp6\(dq, \(dqtype\(dq: \(dqrecord\(dq, \(dqarray\(dq: true, \(dqrecord\-types\(dq: \(dqipv6\-address, uint16\(dq, \(dqencapsulate\(dq: \(dq\(dq }, ... ], ... } .EE .UNINDENT .UNINDENT .sp The new option content is one IPv6 address followed by one or more 16\-bit unsigned integers. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 In general, boolean values are specified as \fBtrue\fP or \fBfalse\fP, without quotes. Some specific boolean parameters may also accept \fB\(dqtrue\(dq\fP, \fB\(dqfalse\(dq\fP, \fB0\fP, \fB1\fP, \fB\(dq0\(dq\fP, and \fB\(dq1\(dq\fP\&. .UNINDENT .UNINDENT .SS DHCPv6 Vendor\-Specific Options .sp Vendor options in DHCPv6 are carried in the Vendor\-Specific Information option (code 17). The idea behind option 17 is that each vendor has its own unique set of options with their own custom formats. The vendor is identified by a 32\-bit unsigned integer called \fBenterprise\-number\fP or \fBvendor\-id\fP\&. .sp The standard spaces defined in Kea and their options are: .INDENT 0.0 .IP \(bu 2 \fBvendor\-2495\fP: Internet Systems Consortium, Inc. for 4o6 options: .UNINDENT .TS box center; l|l|l. T{ option code T} T{ option name T} T{ option description T} _ T{ 60000 T} T{ 4o6\-interface T} T{ the name of the 4o6 server\(aqs client\-facing interface T} _ T{ 60001 T} T{ 4o6\-source\-address T} T{ the address that the 4o6 server uses to send packets to the client T} _ T{ 60002 T} T{ 4o6\-source\-port T} T{ the port that the 4o6 server opens to send packets to the client T} .TE .INDENT 0.0 .IP \(bu 2 \fBvendor\-4491\fP: Cable Television Laboratories, Inc. for DOCSIS3 options: .UNINDENT .TS box center; l|l|l. T{ option code T} T{ option name T} T{ option description T} _ T{ 1 T} T{ oro T} T{ ORO (or Option Request Option) is used by clients to request a list of options they are interested in. T} _ T{ 2 T} T{ tftp\-servers T} T{ a list of IPv4 addresses of TFTP servers to be used by the cable modem T} .TE .sp The following examples show how to define an option \fB\(dqfoo\(dq\fP with code 1 that consists of an IPv6 address, an unsigned 16\-bit integer, and a string. The \fB\(dqfoo\(dq\fP option is conveyed in a Vendor\-Specific Information option, which comprises a single uint32 value that is set to \fB12345\fP\&. The sub\-option \fB\(dqfoo\(dq\fP follows the data field holding this value. .sp The first step is to define the format of the option: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqoption\-def\(dq: [ { \(dqname\(dq: \(dqfoo\(dq, \(dqcode\(dq: 1, \(dqspace\(dq: \(dqvendor\-12345\(dq, \(dqtype\(dq: \(dqrecord\(dq, \(dqarray\(dq: false, \(dqrecord\-types\(dq: \(dqipv6\-address, uint16, string\(dq, \(dqencapsulate\(dq: \(dq\(dq } ], ... } .EE .UNINDENT .UNINDENT .sp Note that the option space is set to \fB\(dqvendor\-12345\(dq\fP\&. Once the option format is defined, the next step is to define actual values for that option: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqfoo\(dq, \(dqspace\(dq: \(dqvendor\-12345\(dq, \(dqdata\(dq: \(dq2001:db8:1::10, 123, Hello World\(dq }, ... ], ... } .EE .UNINDENT .UNINDENT .sp We should also define a value (\fB\(dqenterprise\-number\(dq\fP) for the Vendor\-Specific Information option, to convey the option \fBfoo\fP\&. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqvendor\-opts\(dq, \(dqdata\(dq: \(dq12345\(dq }, ... ], ... } .EE .UNINDENT .UNINDENT .sp Alternatively, the option can be specified using its code. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqoption\-data\(dq: [ { \(dqcode\(dq: 17, \(dqdata\(dq: \(dq12345\(dq }, ... ], ... } .EE .UNINDENT .UNINDENT .sp A common configuration is to set the \fBalways\-send\fP flag to \fBtrue\fP, so the vendor option is sent even when the client did not specify it in the query. .sp This is also how \fI\%kea\-dhcp6\fP can be configured to send multiple vendor options from different vendors, along with each of their specific enterprise numbers. To send these options regardless of whether the client specifies an enterprise number, the server must be configured with \fB\(dqalways\-send\(dq: true\fP, including the Vendor\-Specific Information option (code 17). .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp6\(dq: { \(dqoption\-data\(dq: [ { \(dqalways\-send\(dq: true, \(dqdata\(dq: \(dqtagged\(dq, \(dqname\(dq: \(dqtag\(dq, \(dqspace\(dq: \(dqvendor\-2234\(dq }, { \(dqalways\-send\(dq: true, \(dqdata\(dq: \(dqhttps://example.com:1234/path\(dq, \(dqname\(dq: \(dqurl\(dq, \(dqspace\(dq: \(dqvendor\-3561\(dq } ], \(dqoption\-def\(dq: [ { \(dqcode\(dq: 22, \(dqname\(dq: \(dqtag\(dq, \(dqspace\(dq: \(dqvendor\-2234\(dq, \(dqtype\(dq: \(dqstring\(dq }, { \(dqcode\(dq: 11, \(dqname\(dq: \(dqurl\(dq, \(dqspace\(dq: \(dqvendor\-3561\(dq, \(dqtype\(dq: \(dqstring\(dq } ] } } .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The \fI\%kea\-dhcp6\fP server is able to recognize multiple Vendor Class options (code 16) with different enterprise numbers in the client requests, and to send multiple Vendor\-Specific Information options (code 17) in the responses, one for each vendor. .UNINDENT .UNINDENT .SS Nested DHCPv6 Options (Custom Option Spaces) .sp It is sometimes useful to define a completely new option space: for example, a user might create a new option to convey sub\-options that use a separate numbering scheme, such as sub\-options with codes 1 and 2. Those option codes conflict with standard DHCPv6 options, so a separate option space must be defined. .sp Note that the creation of a new option space is not required when defining sub\-options for a standard option, because one is created by default if the standard option is meant to convey any sub\-options (see \fI\%DHCPv6 Vendor\-Specific Options\fP). .sp If we want a DHCPv6 option called \fBcontainer\fP with code 102, that conveys two sub\-options with codes 1 and 2, we first need to define the new sub\-options: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqoption\-def\(dq: [ { \(dqname\(dq: \(dqsubopt1\(dq, \(dqcode\(dq: 1, \(dqspace\(dq: \(dqisc\(dq, \(dqtype\(dq: \(dqipv6\-address\(dq, \(dqrecord\-types\(dq: \(dq\(dq, \(dqarray\(dq: false, \(dqencapsulate\(dq: \(dq\(dq }, { \(dqname\(dq: \(dqsubopt2\(dq, \(dqcode\(dq: 2, \(dqspace\(dq: \(dqisc\(dq, \(dqtype\(dq: \(dqstring\(dq, \(dqrecord\-types\(dq: \(dq\(dq, \(dqarray\(dq: false, \(dqencapsulate\(dq: \(dq\(dq } ], ... } .EE .UNINDENT .UNINDENT .sp Note that we have defined the options to belong to a new option space (in this case, \fB\(dqisc\(dq\fP). .sp The next step is to define a regular DHCPv6 option with the desired code and specify that it should include options from the new option space: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqoption\-def\(dq: [ { \(dqname\(dq: \(dqcontainer\(dq, \(dqcode\(dq: 102, \(dqspace\(dq: \(dqdhcp6\(dq, \(dqtype\(dq: \(dqempty\(dq, \(dqarray\(dq: false, \(dqrecord\-types\(dq: \(dq\(dq, \(dqencapsulate\(dq: \(dqisc\(dq }, ... ], ... } .EE .UNINDENT .UNINDENT .sp The name of the option space in which the sub\-options are defined is set in the \fBencapsulate\fP field. The \fBtype\fP field is set to \fB\(dqempty\(dq\fP, to indicate that this option does not carry any data other than sub\-options. .sp Finally, we can set values for the new options: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp6\(dq: { \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqsubopt1\(dq, \(dqcode\(dq: 1, \(dqspace\(dq: \(dqisc\(dq, \(dqdata\(dq: \(dq2001:db8::abcd\(dq }, { \(dqname\(dq: \(dqsubopt2\(dq, \(dqcode\(dq: 2, \(dqspace\(dq: \(dqisc\(dq, \(dqdata\(dq: \(dqHello world\(dq }, { \(dqname\(dq: \(dqcontainer\(dq, \(dqcode\(dq: 102, \(dqspace\(dq: \(dqdhcp6\(dq } ] } } .EE .UNINDENT .UNINDENT .sp It is possible to create an option which carries some data in addition to the sub\-options defined in the encapsulated option space. For example, if the \fBcontainer\fP option from the previous example were required to carry a uint16 value as well as the sub\-options, the \fBtype\fP value would have to be set to \fB\(dquint16\(dq\fP in the option definition. (Such an option would then have the following data structure: DHCP header, uint16 value, sub\-options.) The value specified with the \fBdata\fP parameter — which should be a valid integer enclosed in quotes, e.g. \fB\(dq123\(dq\fP — would then be assigned to the \fBuint16\fP field in the \fBcontainer\fP option. .SS Unspecified Parameters for DHCPv6 Option Configuration .sp In many cases it is not required to specify all parameters for an option configuration, and the default values can be used. However, it is important to understand the implications of not specifying some of them, as it may result in configuration errors. The list below explains the behavior of the server when a particular parameter is not explicitly specified: .INDENT 0.0 .IP \(bu 2 \fBname\fP \- the server requires either an option name or an option code to identify an option. If this parameter is unspecified, the option code must be specified. .IP \(bu 2 \fBcode\fP \- the server requires either an option name or an option code to identify an option; this parameter may be left unspecified if the \fBname\fP parameter is specified. However, this also requires that the particular option have a definition (either as a standard option or an administrator\-created definition for the option using an \fBoption\-def\fP structure), as the option definition associates an option with a particular name. It is possible to configure an option for which there is no definition (unspecified option format). Configuration of such options requires the use of the option code. .IP \(bu 2 \fBspace\fP \- if the option space is unspecified it defaults to \fBdhcp6\fP, which is an option space holding standard DHCPv6 options. .IP \(bu 2 \fBdata\fP \- if the option data is unspecified it defaults to an empty value. The empty value is mostly used for the options which have no payload (boolean options), but it is legal to specify empty values for some options which carry variable\-length data and for which the specification allows a length of 0. For such options, the data parameter may be omitted in the configuration. .IP \(bu 2 \fBcsv\-format\fP \- if this value is not specified, the server assumes that the option data is specified as a list of comma\-separated values to be assigned to individual fields of the DHCP option. .UNINDENT .SS Controlling the Values Sent for T1 and T2 Times .sp According to RFC 8415, section 21.4, the recommended T1 and T2 values are 50% and 80% of the preferred lease time, respectively. Kea can be configured to send values that are specified explicitly or that are calculated as percentages of the preferred lease time. The server\(aqs behavior is determined by a combination of configuration parameters, of which T1 and T2 are only two. .sp The lease\(aqs preferred and valid lifetimes are expressed as triplets with minimum, default, and maximum values using configuration entries: .INDENT 0.0 .IP \(bu 2 \fBmin\-preferred\-lifetime\fP \- specifies the minimum preferred lifetime (optional). .IP \(bu 2 \fBpreferred\-lifetime\fP \- specifies the default preferred lifetime. .IP \(bu 2 \fBmax\-preferred\-lifetime\fP \- specifies the maximum preferred lifetime (optional). .IP \(bu 2 \fBmin\-valid\-lifetime\fP \- specifies the minimum valid lifetime (optional). .IP \(bu 2 \fBvalid\-lifetime\fP \- specifies the default valid lifetime. .IP \(bu 2 \fBmax\-valid\-lifetime\fP \- specifies the maximum valid lifetime (optional). .UNINDENT .sp These values may be specified within client classes. .sp When the client does not specify lifetimes, the default is used. A specified lifetime \- using the IAADDR or IAPREFIX sub\-option with non\-zero values \- uses these values when they are between the configured minimum and maximum bounds. Values outside the bounds are rounded up or down as needed. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 If the \fBpreferred\-lifetime\fP has not been explicitly specified, or if the specified value is larger than the value of \fBvalid\-lifetime\fP, the server uses the value of \fBvalid\-lifetime\fP multiplied by 0.625. .UNINDENT .UNINDENT .sp To send specific fixed values, use the following two parameters: .INDENT 0.0 .IP \(bu 2 \fBrenew\-timer\fP \- specifies the value of T1 in seconds. .IP \(bu 2 \fBrebind\-timer\fP \- specifies the value of T2 in seconds. .UNINDENT .sp Any value greater than or equal to zero may be specified for T2. T1, if specified, must be less than T2. This flexibility allows a use case where administrators want to suppress client renewals and rebinds by deferring them beyond the lifespan of the lease. This should cause the lease to expire, rather than get renewed by clients. If T1 is specified as larger than T2, T1 is silently set to zero in the outbound IA. .sp In the great majority of cases, the values should follow this rule: T1 < T2 < preferred lifetime < valid lifetime. Alternatively, both T1 and T2 values can be configured to 0, which is a signal to DHCPv6 clients that they may renew at their own discretion. However, there are known broken client implementations in use that will start renewing immediately. Administrators who plan to use T1=T2=0 values should test first and make sure their clients behave rationally. .sp In some rare cases there may be a need to disable a client\(aqs ability to renew addresses. This is undesired from a protocol perspective and should be avoided if possible. However, if necessary, administrators can configure the T1 and T2 values to be equal or greater to the valid lifetime. Be advised that this will cause clients to occasionally lose their addresses, which is generally perceived as poor service. However, there may be some rare business cases when this is desired (e.g. when it is desirable to intentionally break long\-lasting connections). .sp Calculation of the values is controlled by the following three parameters: .INDENT 0.0 .IP \(bu 2 \fBcalculate\-tee\-times\fP \- when \fBtrue\fP, T1 and T2 are calculated as percentages of the valid lease time. It defaults to \fBtrue\fP\&. .IP \(bu 2 \fBt1\-percent\fP \- the percentage of the valid lease time to use for T1. It is expressed as a real number between 0.0 and 1.0 and must be less than \fBt2\-percent\fP\&. The default value is 0.5, per RFC 8415. .IP \(bu 2 \fBt2\-percent\fP \- the percentage of the valid lease time to use for T2. It is expressed as a real number between 0.0 and 1.0 and must be greater than \fBt1\-percent\fP\&. The default value is 0.8 per RFC 8415. .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Unlike DHCPv4 the tee (T1, T2) times are always present in DHCPv6 address and prefix options. Therefore the default value for \fBcalculate\-tee\-times\fP for \fI\%kea\-dhcp6\fP is \fBtrue\fP\&. This ensures the server\(aqs default behavior will result in non\-zero tee times being sent to clients. This is to avoid the server being swamped by misbehaving clients that do not calculate it for themselves. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 If both explicit values are specified and \fBcalculate\-tee\-times\fP is \fBtrue\fP, the server will use the explicit values. Administrators with a setup where some subnets or shared\-networks use explicit values and some use calculated values must not define the explicit values at any level higher than where they will be used. Inheriting them from too high a scope, such as global, will cause them to have values at every level underneath (both shared\-networks and subnets), effectively disabling calculated values. .UNINDENT .UNINDENT .SS IPv6 Subnet Selection .sp The DHCPv6 server may receive requests from local (connected to the same subnet as the server) and remote (connected via relays) clients. As the server may have many subnet configurations defined, it must select an appropriate subnet for a given request. .sp In IPv4, the server can determine which of the configured subnets are local, as there is a reasonable expectation that the server will have a (global) IPv4 address configured on the interface. That assumption is not true in IPv6; the DHCPv6 server must be able to operate while only using link\-local addresses. Therefore, an optional \fBinterface\fP parameter is available within a subnet definition to designate that a given subnet is local, i.e. reachable directly over the specified interface. For example, a server that is intended to serve a local subnet over eth0 may be configured as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqsubnet6\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq2001:db8:beef::/48\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8:beef::/48\(dq } ], \(dqinterface\(dq: \(dqeth0\(dq } ], ... } .EE .UNINDENT .UNINDENT .SS Rapid Commit .sp The Rapid Commit option, described in \X'tty: link https://tools.ietf.org/html/rfc8415'\fI\%RFC 8415\fP\X'tty: link', is supported by the Kea DHCPv6 server. However, support is disabled by default. It can be enabled on a per\-subnet basis using the \fBrapid\-commit\fP parameter as shown below: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp6\(dq: { \(dqsubnet6\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq2001:db8:beef::/48\(dq, \(dqrapid\-commit\(dq: true, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8:beef::1\-2001:db8:beef::10\(dq } ] } ] } } .EE .UNINDENT .UNINDENT .sp This setting only affects the subnet for which \fBrapid\-commit\fP is set to \fBtrue\fP\&. For clients connected to other subnets, the server ignores the Rapid Commit option sent by the client and follows the 4\-way exchange procedure, i.e. responds with an Advertise for a Solicit containing a Rapid Commit option. .SS DHCPv6 Relays .sp A DHCPv6 server with multiple subnets defined must select the appropriate subnet when it receives a request from a client. For clients connected via relays, two mechanisms are used: .sp The first uses the \fBlinkaddr\fP field in the \fBRELAY_FORW\fP message. The name of this field is somewhat misleading in that it does not contain a link\-layer address; instead, it holds an address (typically a global address) that is used to identify a link. The DHCPv6 server checks to see whether the address belongs to a defined subnet and, if it does, that subnet is selected for the client\(aqs request. .sp The second mechanism is based on \fBinterface\-id\fP options. While forwarding a client\(aqs message, relays may insert an \fBinterface\-id\fP option into the message that identifies the interface on the relay that received the message. (Some relays allow configuration of that parameter, but it is sometimes hard\-coded and may range from the very simple [e.g. \(dqvlan100\(dq] to the very cryptic; one example seen on real hardware was \(dqISAM144|299|ipv6|nt:vp:1:110\(dq.) The server can use this information to select the appropriate subnet. The information is also returned to the relay, which then knows the interface to use to transmit the response to the client. For this to work successfully, the relay interface IDs must be unique within the network and the server configuration must match those values. .sp When configuring the DHCPv6 server, two similarly named parameters can be configured for a subnet: .INDENT 0.0 .IP \(bu 2 \fBinterface\fP \- defines which local network interface can be used to access a given subnet. .IP \(bu 2 \fBinterface\-id\fP \- specifies the content of the \fBinterface\-id\fP option used by relays to identify the interface on the relay to which the response packet is sent. .UNINDENT .sp The two are mutually exclusive; a subnet cannot be reachable both locally (direct traffic) and via relays (remote traffic). Specifying both is a configuration error and the DHCPv6 server will refuse such a configuration. .sp The following example configuration shows how to specify an \fBinterface\-id\fP with a value of \(dqvlan123\(dq: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqsubnet6\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq2001:db8:beef::/48\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8:beef::/48\(dq } ], \(dqinterface\-id\(dq: \(dqvlan123\(dq } ], ... } .EE .UNINDENT .UNINDENT .SS Relay\-Supplied Options .sp \X'tty: link https://tools.ietf.org/html/rfc6422'\fI\%RFC 6422\fP\X'tty: link' defines a mechanism called Relay\-Supplied DHCP Options. In certain cases relay agents are the only entities that may have specific information, and they can insert options when relaying messages from the client to the server. The server then does certain checks and copies those options to the response sent to the client. .sp There are certain conditions that must be met for the option to be included. First, the server must not provide the option itself; in other words, if both relay and server provide an option, the server always takes precedence. Second, the option must be RSOO\-enabled. (RSOO is the \(dqRelay Supplied Options option.\(dq) IANA maintains a list of RSOO\-enabled options \X'tty: link https://www.iana.org/assignments/dhcpv6-parameters/dhcpv6-parameters.xhtml#options-relay-supplied'\fI\%here\fP\X'tty: link'\&. However, there may be cases when system administrators want to echo other options. Kea can be instructed to treat other options as RSOO\-enabled; for example, to mark options 110, 120, and 130 as RSOO\-enabled, the following syntax should be used: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqrelay\-supplied\-options\(dq: [ \(dq110\(dq, \(dq120\(dq, \(dq130\(dq ], ... } .EE .UNINDENT .UNINDENT .sp At this time, only option 65 is RSOO\-enabled by IANA. This option will always be treated as RSOO\-enabled, so there is no need to explicitly mark it. When enabling standard options, it is also possible to use their names rather than their option code, e.g. use \fBdns\-servers\fP instead of \fB23\fP\&. See ref:\fIdhcp6\-std\-options\-list\fP for the names. In certain cases this may also work for custom options, but due to the nature of the parser code this may be unreliable and should be avoided. .SS Client Classification in DHCPv6 .sp The DHCPv6 server includes support for client classification. For a deeper discussion of the classification process, see \fI\%Client Classification\fP\&. .sp In certain cases it is useful to configure the server to differentiate between DHCP client types and treat them accordingly. Client classification can be used to modify the behavior of almost any part of DHCP message processing. Kea currently offers three mechanisms that take advantage of client classification in DHCPv6: subnet selection, address pool selection, and DHCP options assignment. .sp Kea can be instructed to limit access to given subnets based on class information. This is particularly useful for cases where two types of devices share the same link and are expected to be served from two different subnets. The primary use case for such a scenario is cable networks, where there are two classes of devices: the cable modem itself, which should be handed a lease from subnet A; and all other devices behind the modem, which should get leases from subnet B. That segregation is essential to prevent overly curious end\-users from playing with their cable modems. For details on how to set up class restrictions on subnets, see \fI\%Configuring Subnets With Class Information\fP\&. .sp When subnets belong to a shared network, the classification applies to subnet selection but not to pools; that is, a pool in a subnet limited to a particular class can still be used by clients which do not belong to the class, if the pool they are expected to use is exhausted. The limit on access based on class information is also available at the address/prefix pool level within a subnet: see \fI\%Configuring Pools With Class Information\fP\&. This is useful when segregating clients belonging to the same subnet into different address ranges. .sp In a similar way, a pool can be constrained to serve only known clients, i.e. clients which have a reservation, using the built\-in \fBKNOWN\fP or \fBUNKNOWN\fP classes. Addresses can be assigned to registered clients without giving a different address per reservation: for instance, when there are not enough available addresses. The determination whether there is a reservation for a given client is made after a subnet is selected, so it is not possible to use \fBKNOWN\fP/\fBUNKNOWN\fP classes to select a shared network or a subnet. .sp The process of classification is conducted in five steps. The first step is to assess an incoming packet and assign it to zero or more classes. The second step is to choose a subnet, possibly based on the class information. When the incoming packet is in the special class \fBDROP\fP, it is dropped and a debug message logged. The next step is to evaluate class expressions depending on the built\-in \fBKNOWN\fP/\fBUNKNOWN\fP classes after host reservation lookup, using them for pool/pd\-pool selection and assigning classes from host reservations. The list of required classes is then built and each class of the list has its expression evaluated; when it returns \fBtrue\fP, the packet is added as a member of the class. The last step is to assign options, again possibly based on the class information. More complete and detailed information is available in \fI\%Client Classification\fP\&. .sp There are two main methods of classification. The first is automatic and relies on examining the values in the vendor class options or the existence of a host reservation. Information from these options is extracted, and a class name is constructed from it and added to the class list for the packet. The second method specifies an expression that is evaluated for each packet. If the result is \fBtrue\fP, the packet is a member of the class. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The new \fBearly\-global\-reservations\-lookup\fP global parameter flag enables a lookup for global reservations before the subnet selection phase. This lookup is similar to the general lookup described above with two differences: .INDENT 0.0 .IP \(bu 2 the lookup is limited to global host reservations .IP \(bu 2 the \fBUNKNOWN\fP class is never set .UNINDENT .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Care should be taken with client classification, as it is easy for clients that do not meet class criteria to be denied all service. .UNINDENT .UNINDENT .SS Defining and Using Custom Classes .sp The following example shows how to configure a class using an expression and a subnet using that class. This configuration defines the class named \fBClient_enterprise\fP\&. It is comprised of all clients whose client identifiers start with the given hex string (which would indicate a DUID based on an enterprise id of 0xAABBCCDD). Members of this class will be given an address from 2001:db8:1::0 to 2001:db8:1::FFFF and the addresses of their DNS servers set to 2001:db8:0::1 and 2001:db8:2::1. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqClient_enterprise\(dq, \(dqtest\(dq: \(dqsubstring(option[1].hex,0,6) == 0x0002AABBCCDD\(dq, \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqdns\-servers\(dq, \(dqcode\(dq: 23, \(dqspace\(dq: \(dqdhcp6\(dq, \(dqcsv\-format\(dq: true, \(dqdata\(dq: \(dq2001:db8:0::1, 2001:db8:2::1\(dq } ] }, ... ], \(dqsubnet6\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq2001:db8:1::/64\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8:1::\-2001:db8:1::ffff\(dq } ], \(dqclient\-classes\(dq: [ \(dqClient_enterprise\(dq ] } ], ... } .EE .UNINDENT .UNINDENT .sp This example shows a configuration using an automatically generated \fBVENDOR_CLASS_\fP class. The administrator of the network has decided that addresses in the range 2001:db8:1::1 to 2001:db8:1::ffff are to be managed by the DHCPv6 server and that only clients belonging to the eRouter1.0 client class are allowed to use that pool. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqsubnet6\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq2001:db8:1::/64\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8:1::\-2001:db8:1::ffff\(dq } ], \(dqclient\-classes\(dq: [ \(dqVENDOR_CLASS_eRouter1.0\(dq ] } ], ... } .EE .UNINDENT .UNINDENT .SS Additional Classification .sp In some cases it is useful to limit the scope of a class to a pool, subnet, or shared network. There are two parameters which are used to limit the scope of the class by instructing the server to evaluate test expressions when required. .sp The \fBevaluate\-additional\-classes\fP, which takes a list of class names and is valid in pool, subnet, and shared network scope. Classes in these lists are marked as additional and evaluated after selection of this specific pool/subnet/shared network and before output\-option processing. .sp The second one is the per\-class \fBonly\-in\-additional\-list\fP flag, which is \fBfalse\fP by default. When it is set to \fBtrue\fP, the test expression of the class is not evaluated at the reception of the incoming packet but later, and only if the class is present in an \fBevaluate\-additional\-classes\fP list. .sp In this example, a class is assigned to the incoming packet when the specified subnet is used: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqClient_foo\(dq, \(dqtest\(dq: \(dqmember(\(aqALL\(aq)\(dq, \(dqonly\-in\-additional\-list\(dq: true }, ... ], \(dqsubnet6\(dq: [ { \(dqsubnet\(dq: \(dq2001:db8:1::/64\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8:1::\-2001:db8:1::ffff\(dq } ], \(dqevaluate\-additional\-classes\(dq: [ \(dqClient_foo\(dq ], ... }, ... ], ... } .EE .UNINDENT .UNINDENT .sp Additional evaluation can be used to express complex dependencies like subnet membership. It can also be used to reverse the precedence; if \fBoption\-data\fP is set in a subnet, it takes precedence over \fBoption\-data\fP in a class. If \fBoption\-data\fP is moved to a required class and required in the subnet, a class evaluated earlier may take precedence. .sp Additional evaluation is also available at shared network and pool/pd\-pool levels. The order in which additional classes are considered is: (pd\-)pool, subnet, and shared network, i.e. in the same order from the way in which \fBoption\-data\fP is processed. .sp Since Kea version 2.7.4 additional classes configured without a test expression are unconditionally added, i.e. they are considered to always be evaluated to \fBtrue\fP\&. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Because additional evaluation occurs after lease assignment, parameters that would otherwise impact lease life times (e.g. \fBvalid\-lifetime\fP, \fBpreferred\-lifetime\fP) will have no effect when specified in a class that also sets \fBonly\-in\-additional\-list\fP true. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 As of Kea version 2.7.4, \fBonly\-if\-required\fP and \fBrequire\-client\-classes\fP have been renamed to \fBonly\-in\-additional\-list\fP and \fBevaluate\-additional\-classes\fP respectivley. The original names will still be accepted as input to allow users to migrate but will eventually be rejected. .UNINDENT .UNINDENT .SS DDNS for DHCPv6 .sp As mentioned earlier, \fI\%kea\-dhcp6\fP can be configured to generate requests to the DHCP\-DDNS server, \fI\%kea\-dhcp\-ddns\fP, (referred to herein as \(dqD2\(dq) to update DNS entries. These requests are known as NameChangeRequests or NCRs. Each NCR contains the following information: .INDENT 0.0 .IP 1. 3 Whether it is a request to add (update) or remove DNS entries. .IP 2. 3 Whether the change requests forward DNS updates (AAAA records), reverse DNS updates (PTR records), or both. .IP 3. 3 The Fully Qualified Domain Name (FQDN), lease address, and DHCID (information identifying the client associated with the FQDN). .UNINDENT .sp DDNS\-related parameters are split into two groups: .INDENT 0.0 .IP 1. 3 Connectivity Parameters .INDENT 3.0 .INDENT 3.5 These are parameters which specify where and how \fI\%kea\-dhcp6\fP connects to and communicates with D2. These parameters can only be specified within the top\-level \fBdhcp\-ddns\fP section in the \fI\%kea\-dhcp6\fP configuration. The connectivity parameters are listed below: .INDENT 0.0 .IP \(bu 2 \fBenable\-updates\fP .IP \(bu 2 \fBserver\-ip\fP .IP \(bu 2 \fBserver\-port\fP .IP \(bu 2 \fBsender\-ip\fP .IP \(bu 2 \fBsender\-port\fP .IP \(bu 2 \fBmax\-queue\-size\fP .IP \(bu 2 \fBncr\-protocol\fP .IP \(bu 2 \fBncr\-format\fP .UNINDENT .UNINDENT .UNINDENT .IP 2. 3 Behavioral Parameters .INDENT 3.0 .INDENT 3.5 These parameters influence behavior such as how client host names and FQDN options are handled. They have been moved out of the \fBdhcp\-ddns\fP section so that they may be specified at the global, shared\-network, subnet and/or pool levels. Furthermore, they are inherited downward from global to shared\-network to subnet to pool. In other words, if a parameter is not specified at a given level, the value for that level comes from the level above it. The behavioral parameters are as follows: .INDENT 0.0 .IP \(bu 2 \fBddns\-send\-updates\fP .IP \(bu 2 \fBddns\-override\-no\-update\fP .IP \(bu 2 \fBddns\-override\-client\-update\fP .IP \(bu 2 \fBddns\-replace\-client\-name\fP .IP \(bu 2 \fBddns\-generated\-prefix\fP .IP \(bu 2 \fBddns\-qualifying\-suffix\fP .IP \(bu 2 \fBddns\-update\-on\-renew\fP .IP \(bu 2 \fBddns\-conflict\-resolution\-mode\fP .IP \(bu 2 \fBddns\-ttl\fP .IP \(bu 2 \fBddns\-ttl\-percent\fP .IP \(bu 2 \fBddns\-ttl\-min\fP .IP \(bu 2 \fBddns\-ttl\-max\fP .IP \(bu 2 \fBhostname\-char\-set\fP .IP \(bu 2 \fBhostname\-char\-replacement\fP .UNINDENT .UNINDENT .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Kea 2.7.6 added support for these parameters to the (address) pool level. They are not supported in pd\-pools. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Behavioral parameters that affect the FQDN are in effect even if both \fBenable\-updates\fP and \fBddns\-send\-updates\fP are \fBfalse\fP, to support environments in which clients are responsible for their own DNS updates. This applies to \fBddns\-replace\-client\-name\fP, \fBddns\-generated\-prefix\fP, \fBddns\-qualifying\-suffix\fP, \fBhostname\-char\-set\fP, and \fBhostname\-char\-replacement\fP\&. .UNINDENT .UNINDENT .sp The default configuration and values would appear as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqdhcp\-ddns\(dq: { // Connectivity parameters \(dqenable\-updates\(dq: false, \(dqserver\-ip\(dq: \(dq127.0.0.1\(dq, \(dqserver\-port\(dq:53001, \(dqsender\-ip\(dq:\(dq\(dq, \(dqsender\-port\(dq:0, \(dqmax\-queue\-size\(dq:1024, \(dqncr\-protocol\(dq:\(dqUDP\(dq, \(dqncr\-format\(dq:\(dqJSON\(dq }, // Behavioral parameters (global) \(dqddns\-send\-updates\(dq: true, \(dqddns\-override\-no\-update\(dq: false, \(dqddns\-override\-client\-update\(dq: false, \(dqddns\-replace\-client\-name\(dq: \(dqnever\(dq, \(dqddns\-generated\-prefix\(dq: \(dqmyhost\(dq, \(dqddns\-qualifying\-suffix\(dq: \(dq\(dq, \(dqddns\-update\-on\-renew\(dq: false, \(dqddns\-conflict\-resolution\-mode\(dq: \(dqcheck\-with\-dhcid\(dq, \(dqhostname\-char\-set\(dq: \(dq\(dq, \(dqhostname\-char\-replacement\(dq: \(dq\(dq, ... } .EE .UNINDENT .UNINDENT .sp There are two parameters which determine whether \fI\%kea\-dhcp6\fP can generate DDNS requests to D2: the existing \fBdhcp\-ddns:enable\-updates\fP parameter, which now only controls whether \fI\%kea\-dhcp6\fP connects to D2; and the new behavioral parameter, \fBddns\-send\-updates\fP, which determines whether DDNS updates are enabled at a given level (i.e. global, shared\-network, or subnet). The following table shows how the two parameters function together: .SS Enabling and disabling DDNS updates .TS box center; l|l|l. T{ dhcp\-ddns: enable\-updates T} T{ Global ddns\-send\-updates T} T{ Outcome T} _ T{ false (default) T} T{ false T} T{ no updates at any scope T} _ T{ false T} T{ true (default) T} T{ no updates at any scope T} _ T{ true T} T{ false T} T{ updates only at scopes with a local value of \fBtrue\fP for \fBddns\-enable\-updates\fP T} _ T{ true T} T{ true T} T{ updates at all scopes except those with a local value of \fBfalse\fP for \fBddns\-enable\-updates\fP T} .TE .sp Kea 1.9.1 added two new parameters; the first is \fBddns\-update\-on\-renew\fP\&. Normally, when leases are renewed, the server only updates DNS if the DNS information for the lease (e.g. FQDN, DNS update direction flags) has changed. Setting \fBddns\-update\-on\-renew\fP to \fBtrue\fP instructs the server to always update the DNS information when a lease is renewed, even if its DNS information has not changed. This allows Kea to \(dqself\-heal\(dq if it was previously unable to add DNS entries or they were somehow lost by the DNS server. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Setting \fBddns\-update\-on\-renew\fP to \fBtrue\fP may impact performance, especially for servers with numerous clients that renew often. .UNINDENT .UNINDENT .sp The second parameter added in Kea 1.9.1 is \fBddns\-use\-conflict\-resolution\fP\&. This boolean parameter was passed through to D2 and enabled or disabled conflict resolution as described in \X'tty: link https://tools.ietf.org/html/rfc4703'\fI\%RFC 4703\fP\X'tty: link'\&. Beginning with Kea 2.5.0, it is deprecated and replaced by \fBddns\-conflict\-resolution\-mode\fP, which offers four modes of conflict resolution\-related behavior: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fBcheck\-with\-dhcid\fP \- This mode, the default, instructs D2 to carry out RFC 4703\-compliant conflict resolution. Existing DNS entries may only be overwritten if they have a DHCID record and it matches the client\(aqs DHCID. This is equivalent to \fBddns\-use\-conflict\-resolution\fP: \fBtrue\fP; .IP \(bu 2 \fBno\-check\-with\-dhcid\fP \- Existing DNS entries may be overwritten by any client, whether those entries include a DHCID record or not. The new entries will include a DHCID record for the client to whom they belong. This is equivalent to \fBddns\-use\-conflict\-resolution\fP: \fBfalse\fP; .IP \(bu 2 \fBcheck\-exists\-with\-dhcid\fP \- Existing DNS entries may only be overwritten if they have a DHCID record. The DHCID record need not match the client\(aqs DHCID. This mode provides a way to protect static DNS entries (those that do not have a DHCID record) while allowing dynamic entries (those that do have a DHCID record) to be overwritten by any client. This behavior was not supported prior to Kea 2.4.0. .IP \(bu 2 \fBno\-check\-without\-dhcid\fP \- Existing DNS entries may be overwritten by any client; new entries will not include DHCID records. This behavior was not supported prior to Kea 2.4.0. .UNINDENT .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 For backward compatibility, \fBddns\-use\-conflict\-resolution\fP is still accepted in JSON configuration. The server replaces the value internally with \fBddns\-conflict\-resolution\-mode\fP and an appropriate value: \(ga \fBcheck\-with\-dhcid\fP for \fBtrue\fP and \fBno\-check\-with\-dhcid\fP for \fBfalse\fP\&. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Setting \fBddns\-conflict\-resolution\-mode\fP to any value other than \fBcheck\-with\-dhcid\fP disables the overwrite safeguards that the rules of conflict resolution (from \X'tty: link https://tools.ietf.org/html/rfc4703'\fI\%RFC 4703\fP\X'tty: link') are intended to prevent. This means that existing entries for an FQDN or an IP address made for Client\-A can be deleted or replaced by entries for Client\-B. Furthermore, there are two scenarios by which entries for multiple clients for the same key (e.g. FQDN or IP) can be created. .sp 1. Client\-B uses the same FQDN as Client\-A but a different IP address. In this case, the forward DNS entries (AAAA and DHCID RRs) for Client\-A will be deleted as they match the FQDN, and new entries for Client\-B will be added. The reverse DNS entries (PTR and DHCID RRs) for Client\-A, however, will not be deleted as they belong to a different IP address, while new entries for Client\-B will still be added. .sp 2. Client\-B uses the same IP address as Client\-A but a different FQDN. In this case, the reverse DNS entries (PTR and DHCID RRs) for Client\-A will be deleted as they match the IP address, and new entries for Client\-B will be added. The forward DNS entries (AAAA and DHCID RRs) for Client\-A, however, will not be deleted, as they belong to a different FQDN, while new entries for Client\-B will still be added. .sp Disabling conflict resolution should be done only after careful review of specific use cases. The best way to avoid unwanted DNS entries is to always ensure that lease changes are processed through Kea, whether they are released, expire, or are deleted via the \fI\%lease6\-del\fP command, prior to reassigning either FQDNs or IP addresses. Doing so causes \fI\%kea\-dhcp6\fP to generate DNS removal requests to D2. .UNINDENT .UNINDENT .sp The DNS entries Kea creates contain a value for TTL (time to live). By default, the \fI\%kea\-dhcp4\fP server calculates that value based on \X'tty: link https://tools.ietf.org/html/rfc4702#section-5'\fI\%RFC 4702, Section 5\fP\X'tty: link', which suggests that the TTL value be 1/3 of the lease\(aqs life time, with a minimum value of 10 minutes. There are four optional parameters which may be used to influence the TTL calculation: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fBddns\-ttl\fP \- If specified and greater than 0 use it as the value of TTL unconditionally. It is specified in seconds. By default it is unspecified. .IP \(bu 2 \fBddns\-ttl\-percent\fP \- If specified and greater than zero use it as the percentage of the lease life time otherwise use 1/3 (per RFC 4702) of the lease life time. It is specified as a decimal percentage (e.g. 0.75, 0.50) and is unspecified by default. .IP \(bu 2 \fBddns\-ttl\-min\fP \- If specified and greater than 0 use it the minimum otherwise use a minimum of 600 seconds (per RFC 4702). If the calculated TTL is less than the minimum return the minimum. It is specified in seconds. By default it is unspecified. .IP \(bu 2 \fBddns\-ttl\-max\fP \- If specified and greater than zero limit the calculated TTL to its value. It is specified in seconds. By default it is unspecified. .UNINDENT .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 A value of zero for any of the TTL parameters can be used to suppress (i.e. \(dqunspecify\(dq) the value of that parameter inherited from a higher scope. .UNINDENT .UNINDENT .SS DHCP\-DDNS Server Connectivity .sp For NCRs to reach the D2 server, \fI\%kea\-dhcp6\fP must be able to communicate with it. \fI\%kea\-dhcp6\fP uses the following configuration parameters to control this communication: .INDENT 0.0 .IP \(bu 2 \fBenable\-updates\fP \- This enables connectivity to \fI\%kea\-dhcp\-ddns\fP such that DDNS updates can be constructed and sent. It must be \fBtrue\fP for NCRs to be generated and sent to D2. It defaults to \fBfalse\fP\&. .IP \(bu 2 \fBserver\-ip\fP \- This is the IP address on which D2 listens for requests. The default is the local loopback interface at address 127.0.0.1. Either an IPv4 or IPv6 address may be specified. .IP \(bu 2 \fBserver\-port\fP \- This is the port on which D2 listens for requests. The default value is \fB53001\fP\&. .IP \(bu 2 \fBsender\-ip\fP \- This is the IP address which \fI\%kea\-dhcp6\fP uses to send requests to D2. The default value is blank, which instructs \fI\%kea\-dhcp6\fP to select a suitable address. .IP \(bu 2 \fBsender\-port\fP \- This is the port which \fI\%kea\-dhcp6\fP uses to send requests to D2. The default value of \fB0\fP instructs \fI\%kea\-dhcp6\fP to select a suitable port. .IP \(bu 2 \fBmax\-queue\-size\fP \- This is the maximum number of requests allowed to queue while waiting to be sent to D2. This value guards against requests accumulating uncontrollably if they are being generated faster than they can be delivered. If the number of requests queued for transmission reaches this value, DDNS updating is turned off until the queue backlog has been sufficiently reduced. The intent is to allow the \fI\%kea\-dhcp4\fP server to continue lease operations without running the risk that its memory usage may grow without limit. The default value is \fB1024\fP\&. .IP \(bu 2 \fBncr\-protocol\fP \- This specifies the socket protocol to use when sending requests to D2. Currently only UDP is supported. .IP \(bu 2 \fBncr\-format\fP \- This specifies the packet format to use when sending requests to D2. Currently only JSON format is supported. .UNINDENT .sp By default, \fI\%kea\-dhcp\-ddns\fP is assumed to be running on the same machine as \fI\%kea\-dhcp6\fP, and all of the default values mentioned above should be sufficient. If, however, D2 has been configured to listen on a different address or port, these values must be altered accordingly. For example, if D2 has been configured to listen on 2001:db8::5 port 900, the following configuration is required: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqdhcp\-ddns\(dq: { \(dqserver\-ip\(dq: \(dq2001:db8::5\(dq, \(dqserver\-port\(dq: 900, ... }, ... } .EE .UNINDENT .UNINDENT .SS When Does the \fI\%kea\-dhcp6\fP Server Generate a DDNS Request? .sp The \fI\%kea\-dhcp6\fP server follows the behavior prescribed for DHCP servers in \X'tty: link https://tools.ietf.org/html/rfc4704'\fI\%RFC 4704\fP\X'tty: link'\&. It is important to keep in mind that \fI\%kea\-dhcp6\fP makes the initial decision of when and what to update and forwards that information to D2 in the form of NCRs. Carrying out the actual DNS updates and dealing with such things as conflict resolution are within the purview of D2 itself (see \fI\%The DHCP\-DDNS Server\fP). This section describes when \fI\%kea\-dhcp6\fP generates NCRs and the configuration parameters that can be used to influence this decision. It assumes that both the connectivity parameter \fBenable\-updates\fP and the behavioral parameter \fBddns\-send\-updates\fP are \fBtrue\fP\&. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Currently the interface between \fI\%kea\-dhcp6\fP and D2 only supports requests which update DNS entries for a single IP address. If a lease grants more than one address, \fI\%kea\-dhcp6\fP creates the DDNS update request for only the first of these addresses. .UNINDENT .UNINDENT .sp In general, \fI\%kea\-dhcp6\fP generates DDNS update requests when: .INDENT 0.0 .IP 1. 3 A new lease is granted in response to a DHCPREQUEST; .IP 2. 3 An existing lease is renewed but the FQDN associated with it has changed; or .IP 3. 3 An existing lease is released in response to a DHCPRELEASE. .UNINDENT .sp In the second case, lease renewal, two DDNS requests are issued: one request to remove entries for the previous FQDN, and a second request to add entries for the new FQDN. In the third case, a lease release \- a single DDNS request \- to remove its entries will be made. .sp As for the first case, the decisions involved when granting a new lease are more complex. When a new lease is granted, \fI\%kea\-dhcp6\fP generates a DDNS update request only if the DHCPREQUEST contains the FQDN option (code 39). By default, \fI\%kea\-dhcp6\fP respects the FQDN N and S flags specified by the client as shown in the following table: .SS Default FQDN flag behavior .TS box center; l|l|l|l. T{ Client Flags:N\-S T} T{ Client Intent T} T{ Server Response T} T{ Server Flags:N\-S\-O T} _ T{ 0\-0 T} T{ Client wants to do forward updates, server should do reverse updates T} T{ Server generates reverse\-only request T} T{ 1\-0\-0 T} _ T{ 0\-1 T} T{ Server should do both forward and reverse updates T} T{ Server generates request to update both directions T} T{ 0\-1\-0 T} _ T{ 1\-0 T} T{ Client wants no updates done T} T{ Server does not generate a request T} T{ 1\-0\-0 T} .TE .sp The first row in the table above represents \(dqclient delegation.\(dq Here the DHCP client states that it intends to do the forward DNS updates and the server should do the reverse updates. By default, \fI\%kea\-dhcp6\fP honors the client\(aqs wishes and generates a DDNS request to the D2 server to update only reverse DNS data. The parameter \fBddns\-override\-client\-update\fP can be used to instruct the server to override client delegation requests. When this parameter is \fBtrue\fP, \fI\%kea\-dhcp6\fP disregards requests for client delegation and generates a DDNS request to update both forward and reverse DNS data. In this case, the N\-S\-O flags in the server\(aqs response to the client will be 0\-1\-1, respectively. .sp (Note that the flag combination N=1, S=1 is prohibited according to \X'tty: link https://tools.ietf.org/html/rfc4702'\fI\%RFC 4702\fP\X'tty: link'\&. If such a combination is received from the client, the packet will be dropped by \fI\%kea\-dhcp6\fP\&.) .sp To override client delegation, set the following values in the configuration file: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqddns\-override\-client\-update\(dq: true, ... } .EE .UNINDENT .UNINDENT .sp The third row in the table above describes the case in which the client requests that no DNS updates be done. The parameter \fBddns\-override\-no\-update\fP can be used to instruct the server to disregard the client\(aqs wishes. When this parameter is \fBtrue\fP, \fI\%kea\-dhcp6\fP generates DDNS update requests to \fI\%kea\-dhcp\-ddns\fP even if the client requests that no updates be done. The N\-S\-O flags in the server\(aqs response to the client will be 0\-1\-1. .sp To override client delegation, issue the following commands: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqddns\-override\-no\-update\(dq: true, ... } .EE .UNINDENT .UNINDENT .sp The \fI\%kea\-dhcp6\fP server always generates DDNS update requests if the client request only contains the Host Name option. In addition, it includes an FQDN option in the response to the client, with the FQDN N\-S\-O flags set to 0\-1\-0, respectively. The domain name portion of the FQDN option is the name submitted to D2 in the DDNS update request. .SS \fI\%kea\-dhcp6\fP Name Generation for DDNS Update Requests .sp Each NameChangeRequest must of course include the fully qualified domain name whose DNS entries are to be affected. \fI\%kea\-dhcp6\fP can be configured to supply a portion or all of that name, based on what it receives from the client in the DHCPREQUEST. .sp The default rules for constructing the FQDN that will be used for DNS entries are: .INDENT 0.0 .IP 1. 3 If the DHCPREQUEST contains the client FQDN option, take the candidate name from there. .IP 2. 3 If the candidate name is a partial (i.e. unqualified) name, then add a configurable suffix to the name and use the result as the FQDN. .IP 3. 3 If the candidate name provided is empty, generate an FQDN using a configurable prefix and suffix. .IP 4. 3 If the client provides neither option, then take no DNS action. .UNINDENT .sp These rules can be amended by setting the \fBddns\-replace\-client\-name\fP parameter, which provides the following modes of behavior: .INDENT 0.0 .IP \(bu 2 \fBnever\fP \- use the name the client sent. If the client sent no name, do not generate one. This is the default mode. .IP \(bu 2 \fBalways\fP \- replace the name the client sent. If the client sent no name, generate one for the client. .IP \(bu 2 \fBwhen\-present\fP \- replace the name the client sent. If the client sent no name, do not generate one. .IP \(bu 2 \fBwhen\-not\-present\fP \- use the name the client sent. If the client sent no name, generate one for the client. .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 In early versions of Kea, this parameter was a boolean and permitted only values of \fBtrue\fP and \fBfalse\fP\&. Boolean values have been deprecated and are no longer accepted; administrators currently using booleans must replace them with the desired mode name. A value of \fBtrue\fP maps to \fBwhen\-present\fP, while \fBfalse\fP maps to \fBnever\fP\&. .UNINDENT .UNINDENT .sp For example, to instruct \fI\%kea\-dhcp6\fP to always generate the FQDN for a client, set the parameter \fBddns\-replace\-client\-name\fP to \fBalways\fP as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqddns\-replace\-client\-name\(dq: \(dqalways\(dq, ... } .EE .UNINDENT .UNINDENT .sp The prefix used in the generation of an FQDN is specified by the \fBddns\-generated\-prefix\fP parameter. The default value is \(dqmyhost\(dq. To alter its value, simply set it to the desired string: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqddns\-generated\-prefix\(dq: \(dqanother.host\(dq, ... } .EE .UNINDENT .UNINDENT .sp The suffix used when generating an FQDN, or when qualifying a partial name, is specified by the \fBddns\-qualifying\-suffix\fP parameter. It is strongly recommended that the user supply a value for the qualifying suffix when DDNS updates are enabled. For obvious reasons, we cannot supply a meaningful default. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqddns\-qualifying\-suffix\(dq: \(dqfoo.example.org\(dq, ... } .EE .UNINDENT .UNINDENT .sp When qualifying a partial name, \fI\%kea\-dhcp6\fP constructs the name in the format: .sp \fB[candidate\-name].[ddns\-qualifying\-suffix].\fP .sp where \fBcandidate\-name\fP is the partial name supplied in the DHCPREQUEST. For example, if the FQDN domain name value is \(dqsome\-computer\(dq and the \fBddns\-qualifying\-suffix\fP is \(dqexample.com\(dq, the generated FQDN is: .sp \fBsome\-computer.example.com.\fP .sp When generating the entire name, \fI\%kea\-dhcp6\fP constructs the name in the format: .sp \fB[ddns\-generated\-prefix]\-[address\-text].[ddns\-qualifying\-suffix].\fP .sp where \fBaddress\-text\fP is simply the lease IP address converted to a hyphenated string. For example, if the lease address is 3001:1::70E, the qualifying suffix is \(dqexample.com\(dq, and the default value is used for \fBddns\-generated\-prefix\fP, the generated FQDN is: .sp \fBmyhost\-3001\-1\-\-70E.example.com.\fP .sp As of Kea 2.7.8, generated prefixes that would have ended in a hyphen will have a zero appended to the end. For example, the generated prefix for the address \(dq2001:db8:1::\(dq would be \(dqmyhost\-2001\-db8\-1\-\-0\(dq. .SS Sanitizing Client FQDN Names .sp Some DHCP clients may provide values in the name component of the FQDN option (option code 39) that contain undesirable characters. It is possible to configure \fI\%kea\-dhcp6\fP to sanitize these values. The most typical use case is ensuring that only characters that are permitted by RFC 1035 be included: A\-Z, a\-z, 0\-9, and \(dq\-\(dq. This may be accomplished with the following two parameters: .INDENT 0.0 .IP \(bu 2 \fBhostname\-char\-set\fP \- a regular expression describing the invalid character set. This can be any valid, regular expression using POSIX extended expression syntax. Embedded nulls (0x00) are always considered an invalid character to be replaced (or omitted). The default is \fB\(dq[^A\-Za\-z0\-9.\-]\(dq\fP\&. This matches any character that is not a letter, digit, dot, hyphen, or null. .IP \(bu 2 \fBhostname\-char\-replacement\fP \- a string of zero or more characters with which to replace each invalid character in the host name. An empty string causes invalid characters to be OMITTED rather than replaced. The default is \fB\(dq\(dq\fP\&. .UNINDENT .sp The following configuration replaces anything other than a letter, digit, dot, or hyphen with the letter \(dqx\(dq: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqhostname\-char\-set\(dq: \(dq[^A\-Za\-z0\-9.\-]\(dq, \(dqhostname\-char\-replacement\(dq: \(dqx\(dq, ... } .EE .UNINDENT .UNINDENT .sp Thus, a client\-supplied value of \(dqmyhost\-$[123.org\(dq would become \(dqmyhost\-xx123.org\(dq. Sanitizing is performed only on the portion of the name supplied by the client, and it is performed before applying a qualifying suffix (if one is defined and needed). .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Name sanitizing is meant to catch the more common cases of invalid characters through a relatively simple character\-replacement scheme. It is difficult to devise a scheme that works well in all cases. Administrators who find they have clients with odd corner cases of character combinations that cannot be readily handled with this mechanism should consider writing a hook that can carry out sufficiently complex logic to address their needs. .sp Make sure that the dot, \(dq.\(dq, is considered a valid character by the \fBhostname\-char\-set\fP expression, such as this: \fB\(dq[^A\-Za\-z0\-9.\-]\(dq\fP\&. When scrubbing FQDNs, dots are treated as delimiters and used to separate the option value into individual domain labels that are scrubbed and then re\-assembled. .sp If clients are sending values that differ only by characters considered as invalid by the \fBhostname\-char\-set\fP, be aware that scrubbing them will yield identical values. In such cases, DDNS conflict rules will permit only one of them to register the name. .sp Finally, given the latitude clients have in the values they send, it is virtually impossible to guarantee that a combination of these two parameters will always yield a name that is valid for use in DNS. For example, using an empty value for \fBhostname\-char\-replacement\fP could yield an empty domain label within a name, if that label consists only of invalid characters. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 It is possible to specify \fBhostname\-char\-set\fP and/or \fBhostname\-char\-replacement\fP at the global scope. .sp The Kea hook library \fI\%libdhcp_ddns_tuning.so\fP provides the ability for both \fI\%kea\-dhcp4\fP and \fI\%kea\-dhcp6\fP to generate host names procedurally based on an expression, to skip DDNS updates on a per\-client basis, or to fine\-tune various DNS update aspects. Please refer to the \fI\%libdhcp_ddns_tuning.so: DDNS Tuning\fP documentation for the configuration options. .UNINDENT .UNINDENT .SS DHCPv4\-over\-DHCPv6: DHCPv6 Side .sp The support of DHCPv4\-over\-DHCPv6 transport is described in \X'tty: link https://tools.ietf.org/html/rfc7341'\fI\%RFC 7341\fP\X'tty: link' and is implemented using cooperating DHCPv4 and DHCPv6 servers. This section is about the configuration of the DHCPv6 side (the DHCPv4 side is described in \fI\%DHCPv4\-over\-DHCPv6: DHCPv4 Side\fP). .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The DHCPv4\-over\-DHCPv6 details of the inter\-process communication may change; for instance, the support of port relay (RFC 8357) introduced an incompatible change. Both the DHCPv4 and DHCPv6 sides should be running the same version of Kea. .UNINDENT .UNINDENT .sp There is only one specific parameter for the DHCPv6 side: \fBdhcp4o6\-port\fP, which specifies the first of the two consecutive ports of the UDP sockets used for the communication between the DHCPv6 and DHCPv4 servers. The DHCPv6 server is bound to ::1 on \fBport\fP and connected to ::1 on \fBport\fP + 1. .sp Two other configuration entries are generally required: unicast traffic support (see \fI\%Unicast Traffic Support\fP) and the DHCP 4o6 server address option (name \(dqdhcp4o6\-server\-addr\(dq, code 88). .sp ISC tested the following configuration: .INDENT 0.0 .INDENT 3.5 .sp .EX { # DHCPv6 conf \(dqDhcp6\(dq: { \(dqinterfaces\-config\(dq: { \(dqinterfaces\(dq: [ \(dqeno33554984/2001:db8:1:1::1\(dq ] }, \(dqlease\-database\(dq: { \(dqtype\(dq: \(dqmemfile\(dq, \(dqname\(dq: \(dqleases6\(dq }, \(dqpreferred\-lifetime\(dq: 3000, \(dqvalid\-lifetime\(dq: 4000, \(dqrenew\-timer\(dq: 1000, \(dqrebind\-timer\(dq: 2000, \(dqsubnet6\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq2001:db8:1:1::/64\(dq, \(dqinterface\(dq: \(dqeno33554984\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8:1:1::1:0/112\(dq } ] } ], \(dqdhcp4o6\-port\(dq: 786, \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqdhcp4o6\-server\-addr\(dq, \(dqcode\(dq: 88, \(dqspace\(dq: \(dqdhcp6\(dq, \(dqcsv\-format\(dq: true, \(dqdata\(dq: \(dq2001:db8:1:1::1\(dq } ], \(dqloggers\(dq: [ { \(dqname\(dq: \(dqkea\-dhcp6\(dq, \(dqoutput\-options\(dq: [ { \(dqoutput\(dq: \(dqkea\-dhcp6.log\(dq } ], \(dqseverity\(dq: \(dqDEBUG\(dq, \(dqdebuglevel\(dq: 0 } ] } } .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Relayed DHCPv4\-QUERY DHCPv6 messages are not supported. .UNINDENT .UNINDENT .SS Sanity Checks in DHCPv6 .sp An important aspect of a well\-running DHCP system is an assurance that the data remains consistent; however, in some cases it may be convenient to tolerate certain inconsistent data. For example, a network administrator who temporarily removes a subnet from a configuration would not want all the leases associated with it to disappear from the lease database. Kea has a mechanism to implement sanity checks for situations like this. .sp Kea supports a configuration scope called \fBsanity\-checks\fP\&. A parameter, called \fBlease\-checks\fP, governs the verification carried out when a new lease is loaded from a lease file. This mechanism permits Kea to attempt to correct inconsistent data. .sp Every subnet has a \fBsubnet\-id\fP value; this is how Kea internally identifies subnets. Each lease has a \fBsubnet\-id\fP parameter as well, which identifies the subnet it belongs to. However, if the configuration has changed, it is possible that a lease could exist with a \fBsubnet\-id\fP but without any subnet that matches it. Also, it is possible that the subnet\(aqs configuration has changed and the \fBsubnet\-id\fP now belongs to a subnet that does not match the lease. .sp Kea\(aqs corrective algorithm first checks to see if there is a subnet with the \fBsubnet\-id\fP specified by the lease. If there is, it verifies whether the lease belongs to that subnet. If not, depending on the \fBlease\-checks\fP setting, the lease is discarded, a warning is displayed, or a new subnet is selected for the lease that matches it topologically. .sp Since delegated prefixes do not have to belong to a subnet in which they are offered, there is no way to implement such a mechanism for IPv6 prefixes. As such, the mechanism works for IPv6 addresses only. .sp There are five levels which are supported: .INDENT 0.0 .IP \(bu 2 \fBnone\fP \- do no special checks; accept the lease as is. .IP \(bu 2 \fBwarn\fP \- if problems are detected display a warning, but accept the lease data anyway. This is the default value. .IP \(bu 2 \fBfix\fP \- if a data inconsistency is discovered, try to correct it. If the correction is not successful, insert the incorrect data anyway. .IP \(bu 2 \fBfix\-del\fP \- if a data inconsistency is discovered, try to correct it. If the correction is not successful, reject the lease. This setting ensures the data\(aqs correctness, but some incorrect data may be lost. Use with care. .IP \(bu 2 \fBdel\fP \- if any inconsistency is detected, reject the lease. This is the strictest mode; use with care. .UNINDENT .sp This feature is currently implemented for the memfile backend. The sanity check applies to the lease database in memory, not to the lease file, i.e. inconsistent leases will stay in the lease file. .sp An example configuration that sets this parameter looks as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqsanity\-checks\(dq: { \(dqlease\-checks\(dq: \(dqfix\-del\(dq }, ... } .EE .UNINDENT .UNINDENT .SS Storing Extended Lease Information .sp To support such features as DHCPv6 Reconfigure (\X'tty: link https://tools.ietf.org/html/rfc3315'\fI\%RFC 3315\fP\X'tty: link') and Leasequery (\X'tty: link https://tools.ietf.org/html/rfc5007'\fI\%RFC 5007\fP\X'tty: link'), additional information must be stored with each lease. Because the amount of information stored for each lease has ramifications in terms of performance and system resource consumption, storage of this additional information is configurable through the \fBstore\-extended\-info\fP parameter. It defaults to \fBfalse\fP and may be set at the global, shared\-network, and subnet levels. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqstore\-extended\-info\(dq: true, ... } .EE .UNINDENT .UNINDENT .sp When set to \fBtrue\fP, information relevant to the DHCPv6 query (e.g. REQUEST, RENEW, or REBIND) asking for the lease is added into the lease\(aqs \fBuser\-context\fP as a map element labeled \(dqISC\(dq. Currently, the information contained in the map is a list of relays, one for each relay message layer that encloses the client query. The lease\(aqs \fBuser\-context\fP for a two\-hop query might look something like this (shown pretty\-printed for clarity): .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqISC\(dq: { \(dqrelay\-info\(dq: [ { \(dqhop\(dq: 3, \(dqlink\(dq: \(dq2001:db8::1\(dq, \(dqpeer\(dq: \(dq2001:db8::2\(dq }, { \(dqhop\(dq: 2, \(dqlink\(dq: \(dq2001:db8::3\(dq, \(dqoptions\(dq: \(dq0x00C800080102030405060708\(dq, \(dqpeer\(dq: \(dq2001:db8::4\(dq }, { \(dqhop\(dq: 1, \(dqlink\(dq: \(dq2001:db8::5\(dq, \(dqoptions\(dq: \(dq0x00250006010203040506003500086464646464646464\(dq, \(dqremote\-id\(dq: \(dq010203040506\(dq, \(dqrelay\-id\(dq: \(dq6464646464646464\(dq } ] } } .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Prior to Kea version 2.3.2, this entry was named \fBrelays\fP; remote and relay identifier options were not decoded. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 It is possible that other hook libraries are already using \fBuser\-context\fP\&. Enabling \fBstore\-extended\-info\fP should not interfere with any other \fBuser\-context\fP content, as long as it does not also use an element labeled \(dqISC\(dq. In other words, \fBuser\-context\fP is intended to be a flexible container serving multiple purposes. As long as no other purpose also writes an \(dqISC\(dq element to \fBuser\-context\fP there should not be a conflict. .UNINDENT .UNINDENT .sp Extended lease information is also subject to configurable sanity checking. The parameter in the \fBsanity\-checks\fP scope is named \fBextended\-info\-checks\fP and supports these levels: .INDENT 0.0 .IP \(bu 2 \fBnone\fP \- do no check nor upgrade. This level should be used only when extended info is not used at all or when no badly formatted extended info, including using the old format, is expected. .IP \(bu 2 \fBfix\fP \- fix some common inconsistencies and upgrade extended info using the old format to the new one. It is the default level and is convenient when the Leasequery hook library is not loaded. .IP \(bu 2 \fBstrict\fP \- fix all inconsistencies which have an impact on the (Bulk) Leasequery hook library. .IP \(bu 2 \fBpedantic\fP \- enforce full conformance to the format produced by the Kea code; for instance, no extra entries are allowed with the exception of \fBcomment\fP\&. .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 This feature is currently implemented only for the memfile backend. The sanity check applies to the lease database in memory, not to the lease file, i.e. inconsistent leases stay in the lease file. .UNINDENT .UNINDENT .SS Multi\-Threading Settings .sp The Kea server can be configured to process packets in parallel using multiple threads. These settings can be found under the \fBmulti\-threading\fP structure and are represented by: .INDENT 0.0 .IP \(bu 2 \fBenable\-multi\-threading\fP \- use multiple threads to process packets in parallel. The default is \fBtrue\fP\&. .IP \(bu 2 \fBthread\-pool\-size\fP \- specify the number of threads to process packets in parallel. It may be set to \fB0\fP (auto\-detect), or any positive number that explicitly sets the thread count. The default is \fB0\fP\&. .IP \(bu 2 \fBpacket\-queue\-size\fP \- specify the size of the queue used by the thread pool to process packets. It may be set to \fB0\fP (unlimited), or any positive number that explicitly sets the queue size. The default is \fB64\fP\&. .UNINDENT .sp An example configuration that sets these parameters looks as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqmulti\-threading\(dq: { \(dqenable\-multi\-threading\(dq: true, \(dqthread\-pool\-size\(dq: 4, \(dqpacket\-queue\-size\(dq: 16 }, ... } .EE .UNINDENT .UNINDENT .SS Multi\-Threading Settings With Different Database Backends .sp The Kea DHCPv6 server is benchmarked by ISC to determine which settings give the best performance. Although this section describes our results, they are merely recommendations and are very dependent on the particular hardware used for benchmarking. We strongly advise that administrators run their own performance benchmarks. .sp A full report of performance results for the latest stable Kea version can be found \X'tty: link https://reports.kea.isc.org/'\fI\%here\fP\X'tty: link'\&. This includes hardware and benchmark scenario descriptions, as well as current results. .sp After enabling multi\-threading, the number of threads is set by the \fBthread\-pool\-size\fP parameter. Results from our experiments show that the best settings for \fI\%kea\-dhcp6\fP are: .INDENT 0.0 .IP \(bu 2 \fBthread\-pool\-size\fP: 4 when using \fBmemfile\fP for storing leases. .IP \(bu 2 \fBthread\-pool\-size\fP: 12 or more when using \fBmysql\fP for storing leases. .IP \(bu 2 \fBthread\-pool\-size\fP: 6 when using \fBpostgresql\fP\&. .UNINDENT .sp Another very important parameter is \fBpacket\-queue\-size\fP; in our benchmarks we used it as a multiplier of \fBthread\-pool\-size\fP\&. The actual setting strongly depends on \fBthread\-pool\-size\fP\&. .sp We saw the best results in our benchmarks with the following settings: .INDENT 0.0 .IP \(bu 2 \fBpacket\-queue\-size\fP: 150 * \fBthread\-pool\-size\fP when using \fBmemfile\fP for storing leases; in our case it was 150 * 4 = 600. This means that at any given time, up to 600 packets could be queued. .IP \(bu 2 \fBpacket\-queue\-size\fP: 200 * \fBthread\-pool\-size\fP when using \fBmysql\fP for storing leases; in our case it was 200 * 12 = 2400. This means that up to 2400 packets could be queued. .IP \(bu 2 \fBpacket\-queue\-size\fP: 11 * \fBthread\-pool\-size\fP when using \fBpostgresql\fP for storing leases; in our case it was 11 * 6 = 66. .UNINDENT .SS Lease Caching .sp Clients that attempt multiple renewals in a short period can cause the server to update and write to the database frequently, resulting in a performance impact on the server. The cache parameters instruct the DHCP server to avoid updating leases too frequently, thus avoiding this behavior. Instead, the server assigns the same lease (i.e. reuses it) with no modifications except for CLTT (Client Last Transmission Time), which does not require disk operations. .sp The two parameters are the \fBcache\-threshold\fP double and the \fBcache\-max\-age\fP integer. These parameters can be configured at the global, shared\-network, and subnet levels. The subnet level has precedence over the shared\-network level, while the global level is used as a last resort. For example: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqsubnet6\(dq: [ { \(dqsubnet\(dq: \(dq2001:db8:1:1::/64\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8:1:1::1:0/112\(dq } ], \(dqcache\-threshold\(dq: .25, \(dqcache\-max\-age\(dq: 600, \(dqvalid\-lifetime\(dq: 2000, ... } ], \&... } .EE .UNINDENT .UNINDENT .sp When an already\-assigned lease can fulfill a client query: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 any important change, e.g. for DDNS parameter, hostname, or preferred or valid lifetime reduction, makes the lease not reusable. .IP \(bu 2 lease age, i.e. the difference between the creation or last modification time and the current time, is computed (elapsed duration). .IP \(bu 2 if \fBcache\-max\-age\fP is explicitly configured, it is compared with the lease age; leases that are too old are not reusable. This means that the value 0 for \fBcache\-max\-age\fP disables the lease cache feature. .IP \(bu 2 if \fBcache\-threshold\fP is explicitly configured and is between 0.0 and 1.0, it expresses the percentage of the lease valid lifetime which is allowed for the lease age. Values below and including 0.0 and values greater than 1.0 disable the lease cache feature. .UNINDENT .UNINDENT .UNINDENT .sp In our example, a lease with a valid lifetime of 2000 seconds can be reused if it was committed less than 500 seconds ago. With a lifetime of 3000 seconds, a maximum age of 600 seconds applies. .sp In outbound client responses (e.g. DHCPV6_REPLY messages), the used preferred and valid lifetimes are the reusable values, i.e. the expiration dates do not change. .SS Host Reservations in DHCPv6 .sp There are many cases where it is useful to provide a configuration on a per\-host basis. The most obvious one is to reserve a specific, static IPv6 address or/and prefix for exclusive use by a given client (host); the returning client receives the same address and/or prefix every time, and other clients will never get that address. Host reservations are also convenient when a host has specific requirements, e.g. a printer that needs additional DHCP options or a cable modem that needs specific parameters. Yet another possible use case is to define unique names for hosts. .sp There may be cases when a new reservation has been made for a client for an address or prefix currently in use by another client. We call this situation a \(dqconflict.\(dq These conflicts get resolved automatically over time, as described in subsequent sections. Once a conflict is resolved, the correct client will receive the reserved configuration when it renews. .sp Host reservations are defined as parameters for each subnet. Each host must be identified by either DUID or its hardware/MAC address; see \fI\%MAC/Hardware Addresses in DHCPv6\fP for details. There is an optional \fBreservations\fP array in the \fBsubnet6\fP structure; each element in that array is a structure that holds information about reservations for a single host. In particular, the structure has an identifier that uniquely identifies a host. In the DHCPv6 context, the identifier is usually a DUID, but it can also be a hardware or MAC address. One or more addresses or prefixes may also be specified, and it is possible to specify a hostname and DHCPv6 options for a given host. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The reserved address must be within the subnet. This does not apply to reserved prefixes. .UNINDENT .UNINDENT .sp The following example shows how to reserve addresses and prefixes for specific hosts: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqsubnet6\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq2001:db8:1::/48\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8:1::/80\(dq } ], \(dqpd\-pools\(dq: [ { \(dqprefix\(dq: \(dq2001:db8:1:8000::\(dq, \(dqprefix\-len\(dq: 56, \(dqdelegated\-len\(dq: 64 } ], \(dqreservations\(dq: [ { \(dqduid\(dq: \(dq01:02:03:04:05:0A:0B:0C:0D:0E\(dq, \(dqip\-addresses\(dq: [ \(dq2001:db8:1::100\(dq ] }, { \(dqhw\-address\(dq: \(dq00:01:02:03:04:05\(dq, \(dqip\-addresses\(dq: [ \(dq2001:db8:1::101\(dq, \(dq2001:db8:1::102\(dq ] }, { \(dqduid\(dq: \(dq01:02:03:04:05:06:07:08:09:0A\(dq, \(dqip\-addresses\(dq: [ \(dq2001:db8:1::103\(dq ], \(dqprefixes\(dq: [ \(dq2001:db8:2:abcd::/64\(dq ], \(dqhostname\(dq: \(dqfoo.example.com\(dq } ] } ], \&... } .EE .UNINDENT .UNINDENT .sp This example includes reservations for three different clients. The first reservation is for the address 2001:db8:1::100, for a client using DUID 01:02:03:04:05:0A:0B:0C:0D:0E. The second reservation is for two addresses, 2001:db8:1::101 and 2001:db8:1::102, for a client using MAC address 00:01:02:03:04:05. Lastly, address 2001:db8:1::103 and prefix 2001:db8:2:abcd::/64 are reserved for a client using DUID 01:02:03:04:05:06:07:08:09:0A. The last reservation also assigns a hostname to this client. .sp DHCPv6 allows a single client to lease multiple addresses and multiple prefixes at the same time. Therefore \fBip\-addresses\fP and \fBprefixes\fP are plural and are actually arrays. When the client sends multiple IA options (IA_NA or IA_PD), each reserved address or prefix is assigned to an individual IA of the appropriate type. If the number of IAs of a specific type is lower than the number of reservations of that type, the number of reserved addresses or prefixes assigned to the client is equal to the number of IA_NAs or IA_PDs sent by the client; that is, some reserved addresses or prefixes are not assigned. However, they still remain reserved for this client and the server will not assign them to any other client. If the number of IAs of a specific type sent by the client is greater than the number of reserved addresses or prefixes, the server will try to assign all reserved addresses or prefixes to the individual IAs and dynamically allocate addresses or prefixes to the remaining IAs. If the server cannot assign a reserved address or prefix because it is in use, the server will select the next reserved address or prefix and try to assign it to the client. If the server subsequently finds that there are no more reservations that can be assigned to the client at that moment, the server will try to assign leases dynamically. .sp Making a reservation for a mobile host that may visit multiple subnets requires a separate host definition in each subnet that host is expected to visit. It is not possible to define multiple host definitions with the same hardware address in a single subnet. Multiple host definitions with the same hardware address are valid if each is in a different subnet. The reservation for a given host should include only one identifier, either DUID or hardware address; defining both for the same host is considered a configuration error. .sp Adding host reservations incurs a performance penalty. In principle, when a server that does not support host reservation responds to a query, it needs to check whether there is a lease for a given address being considered for allocation or renewal. The server that does support host reservation has to perform additional checks: not only whether the address is currently used (i.e., if there is a lease for it), but also whether the address could be used by someone else (i.e., if there is a reservation for it). That additional check incurs extra overhead. .SS Address/Prefix Reservation Types .sp In a typical Kea scenario there is an IPv6 subnet defined, with a certain part of it dedicated for dynamic address allocation by the DHCPv6 server. There may be an additional address space defined for prefix delegation. Those dynamic parts are referred to as dynamic pools, address and prefix pools, or simply pools. In principle, a host reservation can reserve any address or prefix that belongs to the subnet. The reservations that specify addresses that belong to configured pools are called \(dqin\-pool reservations.\(dq In contrast, those that do not belong to dynamic pools are called \(dqout\-of\-pool reservations.\(dq There is no formal difference in the reservation syntax and both reservation types are handled uniformly. .sp Kea supports global host reservations. These are reservations that are specified at the global level within the configuration and that do not belong to any specific subnet. Kea still matches inbound client packets to a subnet as before, but when the subnet\(aqs reservation mode is set to \(dqglobal\(dq, Kea looks for host reservations only among the global reservations defined. Typically, such reservations would be used to reserve hostnames for clients which may move from one subnet to another. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Global reservations, while useful in certain circumstances, have aspects that must be given due consideration when using them. Please see \fI\%Conflicts in DHCPv6 Reservations\fP for more details. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Since Kea 1.9.1, reservation mode has been replaced by three boolean flags, \fBreservations\-global\fP, \fBreservations\-in\-subnet\fP and \fBreservations\-out\-of\-pool\fP, which allow the configuration of host reservations both globally and in a subnet. In such cases a subnet host reservation has preference over a global reservation when both exist for the same client. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Beginning with Kea 2.7.3, the host reservation syntax supports a new entry, \fBexcluded\-prefixes\fP\&. It can be used to specify prefixes the client should exclude from delegated prefixes. When present it must have the same number of elements as the \fBprefixes\fP entry. Both entries contain strings representing IPv6 prefixes. Each element of the \fBexcluded\-prefixes\fP must be either an empty string or match the prefix at the same position in \fBprefixes\fP\&. An empty \fBexcluded\-prefixes\fP list or a list with only empty strings can be omitted. An example which excludes \fB2001:db8:0:1::/64\fP from \fB2001:db8::/48\fP is shown below: .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqreservations\(dq: [ { \(dqduid\(dq: \(dq01:02:03:04:05:06:07:08:09:0A\(dq, \(dqip\-addresses\(dq: [ \(dq2001:db8:1::103\(dq ], \(dqprefixes\(dq: [ \(dq2001:db8::/48\(dq ], \(dqexcluded\-prefixes\(dq: [ \(dq2001:db8:0:1::/64\(dq ], \(dqhostname\(dq: \(dqfoo.example.com\(dq } ], \&... } .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Since host reservations have precedence over prefix pools, a reserved prefix without an excluded prefix will not add a pd\-exclude option to the prefix option even if the delegated prefix is in a configured prefix pool that does specify an excluded prefix (different from previous behavior). .UNINDENT .UNINDENT .SS Conflicts in DHCPv6 Reservations .sp As reservations and lease information are stored separately, conflicts may arise. Consider the following series of events: the server has configured the dynamic pool of addresses from the range of 2001:db8::10 to 2001:db8::20. Host A requests an address and gets 2001:db8::10. Now the system administrator decides to reserve address 2001:db8::10 for Host B. In general, reserving an address that is currently assigned to someone else is not recommended, but there are valid use cases where such an operation is warranted. .sp The server now has a conflict to resolve. If Host B boots up and requests an address, the server cannot immediately assign the reserved address 2001:db8::10. A naive approach would to be immediately remove the lease for Host A and create a new one for Host B. That would not solve the problem, though, because as soon as Host B gets the address, it will detect that the address is already in use (by Host A) and will send a DHCPDECLINE message. Therefore, in this situation, the server has to temporarily assign a different address from the dynamic pool (not matching what has been reserved) to Host B. .sp When Host A renews its address, the server will discover that the address being renewed is now reserved for someone else \- Host B. The server will remove the lease for 2001:db8::10, select a new address, and create a new lease for it. It will send two addresses in its response: the old address, with the lifetime set to 0 to explicitly indicate that it is no longer valid; and the new address, with a non\-zero lifetime. When Host B tries to renew its temporarily assigned address, the server will detect that the existing lease does not match the reservation, so it will release the current address Host B has and will create a new lease matching the reservation. As before, the server will send two addresses: the temporarily assigned one with a zero lifetime, and the new one that matches the reservation with the proper lifetime set. .sp This recovery will succeed, even if other hosts attempt to get the reserved address. If Host C requests the address 2001:db8::10 after the reservation is made, the server will propose a different address. .sp This recovery mechanism allows the server to fully recover from a case where reservations conflict with existing leases; however, this procedure takes roughly as long as the value set for \fBrenew\-timer\fP\&. The best way to avoid such a recovery is not to define new reservations that conflict with existing leases. Another recommendation is to use out\-of\-pool reservations; if the reserved address does not belong to a pool, there is no way that other clients can get it. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The conflict\-resolution mechanism does not work for global reservations. Although the global address reservations feature may be useful in certain settings, it is generally recommended not to use global reservations for addresses. Administrators who do choose to use global reservations must manually ensure that the reserved addresses are not in dynamic pools. .UNINDENT .UNINDENT .SS Reserving a Hostname .sp When the reservation for a client includes the \fBhostname\fP, the server assigns this hostname to the client and sends it back in the Client FQDN option, if the client included the Client FQDN option in its message to the server. The reserved hostname always takes precedence over the hostname supplied by the client (via the FQDN option) or the autogenerated (from the IPv6 address) hostname. .sp The server qualifies the reserved hostname with the value of the \fBddns\-qualifying\-suffix\fP parameter. For example, the following subnet configuration: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqsubnet6\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq2001:db8:1::/48\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8:1::/80\(dq } ], \(dqddns\-qualifying\-suffix\(dq: \(dqexample.isc.org.\(dq, \(dqreservations\(dq: [ { \(dqduid\(dq: \(dq01:02:03:04:05:0A:0B:0C:0D:0E\(dq, \(dqip\-addresses\(dq: [ \(dq2001:db8:1::100\(dq ], \(dqhostname\(dq: \(dqalice\-laptop\(dq } ] } ], \(dqdhcp\-ddns\(dq: { \(dqenable\-updates\(dq: true }, \&... } .EE .UNINDENT .UNINDENT .sp will result the \(dqalice\-laptop.example.isc.org.\(dq hostname being assigned to the client using the DUID \(dq01:02:03:04:05:0A:0B:0C:0D:0E\(dq. If the \fBddns\-qualifying\-suffix\fP is not specified, the default (empty) value will be used, and in this case the value specified as a \fBhostname\fP will be treated as a fully qualified name. Thus, by leaving the \fBddns\-qualifying\-suffix\fP empty it is possible to qualify hostnames for different clients with different domain names: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqsubnet6\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq2001:db8:1::/48\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8:1::/80\(dq } ], \(dqreservations\(dq: [ { \(dqduid\(dq: \(dq01:02:03:04:05:0A:0B:0C:0D:0E\(dq, \(dqip\-addresses\(dq: [ \(dq2001:db8:1::100\(dq ], \(dqhostname\(dq: \(dqmark\-desktop.example.org.\(dq } ] } ], \(dqdhcp\-ddns\(dq: { \(dqenable\-updates\(dq: true } } .EE .UNINDENT .UNINDENT .sp The above example results in the assignment of the \(dqmark\-desktop.example.org.\(dq hostname to the client using the DUID \(dq01:02:03:04:05:0A:0B:0C:0D:0E\(dq. .SS Including Specific DHCPv6 Options in Reservations .sp Kea offers the ability to specify options on a per\-host basis. These options follow the same rules as any other options. These can be standard options (see \fI\%Standard DHCPv6 Options\fP), custom options (see \fI\%Custom DHCPv6 Options\fP), or vendor\-specific options (see \fI\%DHCPv6 Vendor\-Specific Options\fP). The following example demonstrates how standard options can be defined. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqreservations\(dq: [ { \(dqduid\(dq: \(dq01:02:03:05:06:07:08\(dq, \(dqip\-addresses\(dq: [ \(dq2001:db8:1::2\(dq ], \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqdns\-servers\(dq, \(dqdata\(dq: \(dq3000:1::234\(dq }, { \(dqname\(dq: \(dqnis\-servers\(dq, \(dqdata\(dq: \(dq3000:1::234\(dq }, ... ], ... }, \&... ], \&... } .EE .UNINDENT .UNINDENT .sp Vendor\-specific options can be reserved in a similar manner: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqreservations\(dq: [ { \(dqduid\(dq: \(dqaa:bb:cc:dd:ee:ff\(dq, \(dqip\-addresses\(dq: [ \(dq2001:db8::1\(dq ], \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqvendor\-opts\(dq, \(dqdata\(dq: 4491 }, { \(dqname\(dq: \(dqtftp\-servers\(dq, \(dqspace\(dq: \(dqvendor\-4491\(dq, \(dqdata\(dq: \(dq3000:1::234\(dq }, ... ], ... }, \&... ], \&... } .EE .UNINDENT .UNINDENT .sp Options defined at the host level have the highest priority. In other words, if there are options defined with the same type on global, subnet, class, and host levels, the host\-specific values are used. .SS Reserving Client Classes in DHCPv6 .sp \fI\%Using Expressions in Classification\fP explains how to configure the server to assign classes to a client, based on the content of the options that this client sends to the server. Host reservation mechanisms also allow for the static assignment of classes to clients. The definitions of these classes are placed in the Kea configuration file or a database. The following configuration snippet shows how to specify that a client belongs to the classes \fBreserved\-class1\fP and \fBreserved\-class2\fP\&. Those classes are associated with specific options sent to the clients which belong to them. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqreserved\-class1\(dq, \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqdns\-servers\(dq, \(dqdata\(dq: \(dq2001:db8:1::50\(dq } ] }, { \(dqname\(dq: \(dqreserved\-class2\(dq, \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqnis\-servers\(dq, \(dqdata\(dq: \(dq2001:db8:1::100\(dq } ] } ], \(dqsubnet6\(dq: [ { \(dqid\(dq: 1, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8:1::/64\(dq } ], \(dqsubnet\(dq: \(dq2001:db8:1::/48\(dq, \(dqreservations\(dq: [ { \(dqduid\(dq: \(dq01:02:03:04:05:06:07:08\(dq, \(dqclient\-classes\(dq: [ \(dqreserved\-class1\(dq, \(dqreserved\-class2\(dq ] } ] } ] } .EE .UNINDENT .UNINDENT .sp In some cases the host reservations can be used in conjunction with client classes specified within the Kea configuration. In particular, when a host reservation exists for a client within a given subnet, the \(dqKNOWN\(dq built\-in class is assigned to the client. Conversely, when there is no static assignment for the client, the \(dqUNKNOWN\(dq class is assigned to the client. Class expressions within the Kea configuration file can refer to \(dqKNOWN\(dq or \(dqUNKNOWN\(dq classes using the \(dqmember\(dq operator. For example: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqdependent\-class\(dq, \(dqtest\(dq: \(dqmember(\(aqKNOWN\(aq)\(dq, \(dqonly\-in\-additional\-list\(dq: true } ] } .EE .UNINDENT .UNINDENT .sp The \fBonly\-in\-additional\-list\fP parameter is needed here to force evaluation of the class after the lease has been allocated and thus the reserved class has been also assigned. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The classes specified in non\-global host reservations are assigned to the processed packet after all classes with the \fBonly\-in\-additional\-list\fP parameter set to \fBfalse\fP have been evaluated. This means that these classes must not depend on the statically assigned classes from the host reservations. If such a dependency is needed, the \fBonly\-in\-additional\-list\fP parameter must be set to \fBtrue\fP for the dependent classes. Such classes are evaluated after the static classes have been assigned to the packet. This, however, imposes additional configuration overhead, because all classes marked as \fBonly\-in\-additional\-list\fP must be listed in the \fBevaluate\-additional\-classes\fP list for every subnet where they are used. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Client classes specified within the Kea configuration file may depend on the classes specified within the global host reservations. In such a case the \fBonly\-in\-additional\-list\fP parameter is not needed. Refer to the \fI\%Pool Selection with Client Class Reservations\fP and \fI\%Subnet Selection with Client Class Reservations\fP for specific use cases. .UNINDENT .UNINDENT .SS Storing Host Reservations in MySQL or PostgreSQL .sp Kea can store host reservations in MySQL or PostgreSQL. See \fI\%Hosts Storage\fP for information on how to configure Kea to use reservations stored in MySQL or PostgreSQL. Kea provides a dedicated hook for managing reservations in a database; section \fI\%libdhcp_host_cmds.so: Host Commands\fP provides detailed information. The \X'tty: link https://gitlab.isc.org/isc-projects/kea/wikis/designs/commands#23-host-reservations-hr-management'\fI\%Kea wiki\fP\X'tty: link' provides some examples of how to conduct common host reservation operations. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 In Kea, the maximum length of an option specified per\-host is arbitrarily set to 4096 bytes. .UNINDENT .UNINDENT .SS Fine\-Tuning DHCPv6 Host Reservation .sp The host reservation capability introduces additional restrictions for the allocation engine (the component of Kea that selects an address for a client) during lease selection and renewal. In particular, three major checks are necessary. First, when selecting a new lease, it is not sufficient for a candidate lease to simply not be in use by another DHCP client; it also must not be reserved for another client. Similarly, when renewing a lease, an additional check must be performed to see whether the address being renewed is reserved for another client. Finally, when a host renews an address or a prefix, the server must check whether there is a reservation for this host, which would mean the existing (dynamically allocated) address should be revoked and the reserved one be used instead. .sp Some of those checks may be unnecessary in certain deployments, and not performing them may improve performance. The Kea server provides the \fBreservations\-global\fP, \fBreservations\-in\-subnet\fP and \fBreservations\-out\-of\-pool\fP configuration parameters to select the types of reservations allowed for a particular subnet. Each reservation type has different constraints for the checks to be performed by the server when allocating or renewing a lease for the client. .sp Configuration flags are: .INDENT 0.0 .IP \(bu 2 \fBreservations\-in\-subnet\fP \- when set to \fBtrue\fP, it enables in\-pool host reservation types. This setting is the default value, and is the safest and most flexible. However, as all checks are conducted, it is also the slowest. It does not check against global reservations. This flag defaults to \fBtrue\fP\&. .IP \(bu 2 \fBreservations\-out\-of\-pool\fP \- when set to \fBtrue\fP, it allows only out\-of\-pool host reservations. In this case the server assumes that all host reservations are for addresses that do not belong to the dynamic pool. Therefore, it can skip the reservation checks when dealing with in\-pool addresses, thus improving performance. Do not use this mode if any reservations use in\-pool addresses. Caution is advised when using this setting; Kea does not sanity\-check the reservations against \fBreservations\-out\-of\-pool\fP and misconfiguration may cause problems. This flag defaults to \fBfalse\fP\&. .IP \(bu 2 \fBreservations\-global\fP \- allows global host reservations. With this setting in place, the server searches for reservations for a client among the defined global reservations. If an address is specified, the server skips the reservation checks carried out in other modes, thus improving performance. Caution is advised when using this setting; Kea does not sanity\-check the reservations when \fBreservations\-global\fP is set to \fBtrue\fP, and misconfiguration may cause problems. This flag defaults to \fBfalse\fP\&. .UNINDENT .INDENT 0.0 .TP .B Note: setting all flags to \fBfalse\fP disables host reservation support. As there are no reservations, the server skips all checks. Any reservations defined are completely ignored. As checks are skipped, the server may operate faster in this mode. .UNINDENT .sp Since Kea 1.9.1 the \fBreservations\-global\fP, \fBreservations\-in\-subnet\fP and \fBreservations\-out\-of\-pool\fP flags are suported. .sp The \fBreservations\-global\fP, \fBreservations\-in\-subnet\fP and \fBreservations\-out\-of\-pool\fP parameters can be specified at: .INDENT 0.0 .IP \(bu 2 global level: \fB\&.Dhcp6[\(dqreservations\-global\(dq]\fP (lowest priority: gets overridden by all others) .IP \(bu 2 subnet level: \fB\&.Dhcp6.subnet6[][\(dqreservations\-in\-subnet\(dq]\fP (low priority) .IP \(bu 2 shared\-network level: \fB\&.Dhcp6[\(dqshared\-networks\(dq][][\(dqreservations\-out\-of\-pool\(dq]\fP (high priority) .IP \(bu 2 shared\-network subnet\-level: \fB\&.Dhcp6[\(dqshared\-networks\(dq][].subnet6[][\(dqreservations\-out\-of\-pool\(dq]\fP (highest priority: overrides all others) .UNINDENT .sp To decide which flags to use, the following decision diagram may be useful: .INDENT 0.0 .INDENT 3.5 .sp .EX O | v +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ | Is per\-host configuration needed, such as | | reserving specific addresses, | | assigning specific options or | | assigning packets to specific classes on per\-device basis? | +\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ | | no| yes| | | +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ | | | For all given hosts, | +\-\-> \(dqdisabled\(dq +\-\->+ can the reserved resources | | be used in all configured subnets? | +\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-+ | | +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ |no |yes | Is | | | | at least one reservation +<\-\-+ \(dqglobal\(dq <\-\-+ | used to reserve addresses | | or prefixes? | +\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-+ | | no| yes| +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ | | | Is high leases\-per\-second | +\-\-> \(dqout\-of\-pool\(dq +\-\->+ performance or efficient | ^ | resource usage | | | (CPU ticks, RAM usage, | | | database roundtrips) | | | important to your setup? | | +\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-+ | | | | yes| no| | | | | +\-\-\-\-\-\-\-\-\-\-\-\-\-+ | | | | | | +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ | | | | Can it be guaranteed | | | +\-\->+ that the reserved | | | | addresses/prefixes | | | | aren\(aqt part of the | | | | pools configured | | | | in the respective | | | | subnet? | | | +\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-+ | | | | | | yes| no| | | | | V +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ +\-\-> \(dqin\-subnet\(dq .EE .UNINDENT .UNINDENT .sp An example configuration that disables reservations looks as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp6\(dq: { \(dqsubnet6\(dq: [ { \(dqid\(dq: 1, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8:1::\-2001:db8:1::100\(dq } ], \(dqreservations\-global\(dq: false, \(dqreservations\-in\-subnet\(dq: false, \(dqsubnet\(dq: \(dq2001:db8:1::/64\(dq } ] } } .EE .UNINDENT .UNINDENT .sp An example configuration using global reservations is shown below: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp6\(dq: { \(dqreservations\-global\(dq: true, \(dqreservations\(dq: [ { \(dqduid\(dq: \(dq00:03:00:01:11:22:33:44:55:66\(dq, \(dqhostname\(dq: \(dqhost\-one\(dq }, { \(dqduid\(dq: \(dq00:03:00:01:99:88:77:66:55:44\(dq, \(dqhostname\(dq: \(dqhost\-two\(dq } ], \(dqsubnet6\(dq: [ { \(dqid\(dq: 1, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8:1::\-2001:db8:1::100\(dq } ], \(dqsubnet\(dq: \(dq2001:db8:1::/64\(dq } ] } } .EE .UNINDENT .UNINDENT .sp The meaning of the reservation flags are: .INDENT 0.0 .IP \(bu 2 \fBreservations\-global\fP: fetch global reservations. .IP \(bu 2 \fBreservations\-in\-subnet\fP: fetch subnet reservations. For a shared network this includes all subnet members of the shared network. .IP \(bu 2 \fBreservations\-out\-of\-pool\fP: this makes sense only when the \fBreservations\-in\-subnet\fP flag is \fBtrue\fP\&. When \fBreservations\-out\-of\-pool\fP is \fBtrue\fP, the server assumes that all host reservations are for addresses that do not belong to the dynamic pool. Therefore, it can skip the reservation checks when dealing with in\-pool addresses, thus improving performance. The server will not assign reserved addresses that are inside the dynamic pools to the respective clients. This also means that the addresses matching the respective reservations from inside the dynamic pools (if any) can be dynamically assigned to any client. .UNINDENT .sp The \fBdisabled\fP configuration corresponds to: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp6\(dq: { \(dqreservations\-global\(dq: false, \(dqreservations\-in\-subnet\(dq: false } } .EE .UNINDENT .UNINDENT .sp The \fBglobal\(ga\(gaconfiguration using \(ga\(gareservations\-global\fP corresponds to: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp6\(dq: { \(dqreservations\-global\(dq: true, \(dqreservations\-in\-subnet\(dq: false } } .EE .UNINDENT .UNINDENT .sp The \fBout\-of\-pool\fP configuration using \fBreservations\-out\-of\-pool\fP corresponds to: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp6\(dq: { \(dqreservations\-global\(dq: false, \(dqreservations\-in\-subnet\(dq: true, \(dqreservations\-out\-of\-pool\(dq: true } } .EE .UNINDENT .UNINDENT .sp And the \fBin\-subnet\fP configuration using \fBreservations\-in\-subnet\fP corresponds to: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp6\(dq: { \(dqreservations\-global\(dq: false, \(dqreservations\-in\-subnet\(dq: true, \(dqreservations\-out\-of\-pool\(dq: false } } .EE .UNINDENT .UNINDENT .sp To activate both \fBglobal\fP and \fBin\-subnet\fP, the following combination can be used: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp6\(dq: { \(dqreservations\-global\(dq: true, \(dqreservations\-in\-subnet\(dq: true, \(dqreservations\-out\-of\-pool\(dq: false } } .EE .UNINDENT .UNINDENT .sp To activate both \fBglobal\fP and \fBout\-of\-pool\fP, the following combination can be used: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp6\(dq: { \(dqreservations\-global\(dq: true, \(dqreservations\-in\-subnet\(dq: true, \(dqreservations\-out\-of\-pool\(dq: true } } .EE .UNINDENT .UNINDENT .sp Enabling \fBout\-of\-pool\fP and disabling \fBin\-subnet\fP at the same time is not recommended because \fBout\-of\-pool\fP applies to host reservations in a subnet, which are fetched only when the \fBin\-subnet\fP flag is \fBtrue\fP\&. .sp The parameter can be specified at the global, subnet, and shared\-network levels. .sp An example configuration that disables reservations looks as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp6\(dq: { \(dqsubnet6\(dq: [ { \(dqreservations\-global\(dq: false, \(dqreservations\-in\-subnet\(dq: false, \(dqsubnet\(dq: \(dq2001:db8:1::/64\(dq, \(dqid\(dq: 1 } ] } } .EE .UNINDENT .UNINDENT .sp An example configuration using global reservations is shown below: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp6\(dq: { \(dqreservations\(dq: [ { \(dqduid\(dq: \(dq00:03:00:01:11:22:33:44:55:66\(dq, \(dqhostname\(dq: \(dqhost\-one\(dq }, { \(dqduid\(dq: \(dq00:03:00:01:99:88:77:66:55:44\(dq, \(dqhostname\(dq: \(dqhost\-two\(dq } ], \(dqreservations\-global\(dq: true, \(dqreservations\-in\-subnet\(dq: false, \(dqsubnet6\(dq: [ { \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8:1::\-2001:db8:1::100\(dq } ], \(dqsubnet\(dq: \(dq2001:db8:1::/64\(dq, \(dqid\(dq: 1 } ] } } .EE .UNINDENT .UNINDENT .sp For more details regarding global reservations, see \fI\%Global Reservations in DHCPv6\fP\&. .sp Another aspect of host reservations is the different types of identifiers. Kea currently supports two types of identifiers in DHCPv6: hardware address and DUID. This is beneficial from a usability perspective; however, there is one drawback. For each incoming packet Kea has to extract each identifier type and then query the database to see if there is a reservation by this particular identifier. If nothing is found, the next identifier is extracted and the next query is issued. This process continues until either a reservation is found or all identifier types have been checked. Over time, with an increasing number of supported identifier types, Kea would become slower and slower. .sp To address this problem, a parameter called \fBhost\-reservation\-identifiers\fP is available. It takes a list of identifier types as a parameter. Kea checks only those identifier types enumerated in \fBhost\-reservation\-identifiers\fP\&. From a performance perspective, the number of identifier types should be kept to a minimum, ideally one. If the deployment uses several reservation types, please enumerate them from most\- to least\-frequently used, as this increases the chances of Kea finding the reservation using the fewest queries. An example of a \fBhost\-reservation\-identifiers\fP configuration looks as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqhost\-reservation\-identifiers\(dq: [ \(dqduid\(dq, \(dqhw\-address\(dq ], \(dqsubnet6\(dq: [ { \(dqsubnet\(dq: \(dq2001:db8:1::/64\(dq, ... } ], \&... } .EE .UNINDENT .UNINDENT .sp If not specified, the default value is: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqhost\-reservation\-identifiers\(dq: [ \(dqhw\-address\(dq, \(dqduid\(dq ] .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 As soon as a host reservation is found, the search is stopped; when a client has two host reservations using different enabled identifier types, the first is always returned and the second ignored. This is usually a configuration error. In those rare cases when having two reservations for the same host makes sense, the one to be used can be specified by ordering the list of identifier types in \fBhost\-reservation\-identifiers\fP\&. .UNINDENT .UNINDENT .SS Global Reservations in DHCPv6 .sp In some deployments, such as mobile networks, clients can roam within the network and certain parameters must be specified regardless of the client\(aqs current location. To meet such a need, Kea offers a global reservation mechanism. The idea behind it is that regular host reservations are tied to specific subnets, by using a specific subnet ID. Kea can specify a global reservation that can be used in every subnet that has global reservations enabled. .sp This feature can be used to assign certain parameters, such as hostname or other dedicated, host\-specific options. It can also be used to assign addresses or prefixes. .sp An address assigned via global host reservation must be feasible for the subnet the server selects for the client. In other words, the address must lie within the subnet; otherwise, it is ignored and the server will attempt to dynamically allocate an address. If the selected subnet belongs to a shared network, the server checks for feasibility against the subnet\(aqs siblings, selecting the first in\-range subnet. If no such subnet exists, the server falls back to dynamically allocating the address. This does not apply to globally reserved prefixes. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Prior to release 2.3.5, the server did not perform feasibility checks on globally reserved addresses, which allowed the server to be configured to hand out nonsensical leases for arbitrary address values. Later versions of Kea perform these checks. .UNINDENT .UNINDENT .sp To use global host reservations, a configuration similar to the following can be used: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { # This specifies global reservations. # They will apply to all subnets that # have global reservations enabled. \(dqreservations\(dq: [ { \(dqhw\-address\(dq: \(dqaa:bb:cc:dd:ee:ff\(dq, \(dqhostname\(dq: \(dqhw\-host\-dynamic\(dq }, { \(dqhw\-address\(dq: \(dq01:02:03:04:05:06\(dq, \(dqhostname\(dq: \(dqhw\-host\-fixed\(dq, # Use of IP addresses in global reservations is risky. # If used outside of matching subnet, such as 3001::/64, # it will result in a broken configuration being handed # to the client. \(dqip\-address\(dq: \(dq2001:db8:ff::77\(dq }, { \(dqduid\(dq: \(dq01:02:03:04:05\(dq, \(dqhostname\(dq: \(dqduid\-host\(dq } ], \(dqvalid\-lifetime\(dq: 600, \(dqsubnet4\(dq: [ { \(dqsubnet\(dq: \(dq2001:db8:1::/64\(dq, # Specify if the server should look up global reservations. \(dqreservations\-global\(dq: true, # Specify if the server should look up in\-subnet reservations. \(dqreservations\-in\-subnet\(dq: false, # Specify if the server can assume that all reserved addresses # are out\-of\-pool. It can be ignored because \(dqreservations\-in\-subnet\(dq # is false. # \(dqreservations\-out\-of\-pool\(dq: false, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8:1::\-2001:db8:1::100\(dq } ] } ] } .EE .UNINDENT .UNINDENT .sp When using database backends, the global host reservations are distinguished from regular reservations by using a \fBsubnet\-id\fP value of 0. .SS Pool Selection with Client Class Reservations .sp Client classes can be specified both in the Kea configuration file and/or via host reservations. The classes specified in the Kea configuration file are evaluated immediately after receiving the DHCP packet and therefore can be used to influence subnet selection using the \fBclient\-classes\fP parameter specified in the subnet scope. The classes specified within the host reservations are fetched and assigned to the packet after the server has already selected a subnet for the client. This means that the client class specified within a host reservation cannot be used to influence subnet assignment for this client, unless the subnet belongs to a shared network. If the subnet belongs to a shared network, the server may dynamically change the subnet assignment while trying to allocate a lease. If the subnet does not belong to a shared network, once selected, the subnet is not changed once selected. .sp If the subnet does not belong to a shared network, it is possible to use host\-reservation\-based client classification to select a pool within the subnet as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp6\(dq: { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqreserved_class\(dq }, { \(dqname\(dq: \(dqunreserved_class\(dq, \(dqtest\(dq: \(dqnot member(\(aqreserved_class\(aq)\(dq } ], \(dqsubnet6\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq2001:db8:1::/64\(dq, \(dqreservations\(dq: [ { \(dqhw\-address\(dq: \(dqaa:bb:cc:dd:ee:fe\(dq, \(dqclient\-classes\(dq: [ \(dqreserved_class\(dq ] } ], \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8:1::10 \- 2001:db8:1::20\(dq, \(dqclient\-classes\(dq: [ \(dqunreserved_class\(dq ] }, { \(dqpool\(dq: \(dq2001:db8:1::30 \- 2001:db8:1::40\(dq, \(dqclient\-classes\(dq: [ \(dqreserved_class\(dq ] }, { \(dqpool\(dq: \(dq2001:db8:1::50 \- 2001:db8:1::60\(dq } ] } ] } } .EE .UNINDENT .UNINDENT .sp \fBreserved_class\fP is declared without the \fBtest\fP parameter because it may be only assigned to a client via host reservation mechanism. The second class, \fBunreserved_class\fP, is assigned to clients which do not belong to \fBreserved_class\fP\&. .sp The first pool in the subnet is used for clients not having such a reservation. The second pool is only used for clients having a reservation for \fBreserved_class\fP\&. The third pool is an unrestricted pool for any clients, comprising of both \fBreserved_class\fP clients and \fBunreserved_class\fP\&. .sp The configuration snippet includes one host reservation which causes the client with the MAC address \fBaa:bb:cc:dd:ee:fe\fP to be assigned to \fBreserved_class\fP\&. Thus, this client will be given an IP address from the second address pool. .sp Reservations defined on a subnet that belongs to a shared network are not visible to an otherwise matching client, so they cannot be used to select pools, nor subnets for that matter. .SS Subnet Selection with Client Class Reservations .sp There is one specific use case when subnet selection may be influenced by client classes specified within host reservations: when the client belongs to a shared network. In such a case it is possible to use classification to select a subnet within this shared network. Consider the following example: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp6\(dq: { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqreserved_class\(dq }, { \(dqname\(dq: \(dqunreserved_class\(dq, \(dqtest\(dq: \(dqnot member(\(aqreserved_class\(aq)\(dq } ], \(dqreservations\(dq: [ { \(dqhw\-address\(dq: \(dqaa:bb:cc:dd:ee:fe\(dq, \(dqclient\-classes\(dq: [ \(dqreserved_class\(dq ] } ], \(dqreservations\-global\(dq: true, \(dqreservations\-in\-subnet\(dq: false, \(dqshared\-networks\(dq: [ { \(dqname\(dq: \(dqnet\(dq, \(dqsubnet6\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq2001:db8:1::/64\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8:1::10 \- 2001:db8:1::20\(dq, \(dqclient\-classes\(dq: [ \(dqunreserved_class\(dq ] }, { \(dqpool\(dq: \(dq2001:db8:1::30 \- 2001:db8:1::40\(dq, \(dqclient\-classes\(dq: [ \(dqunreserved_class\(dq ] } ] }, { \(dqid\(dq: 2, \(dqsubnet\(dq: \(dq2001:db8:2::/64\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8:2::10 \- 2001:db8:2::20\(dq, \(dqclient\-classes\(dq: [ \(dqreserved_class\(dq ] }, { \(dqpool\(dq: \(dq2001:db8:2::30 \- 2001:db8:2::40\(dq, \(dqclient\-classes\(dq: [ \(dqreserved_class\(dq ] } ] }, { \(dqid\(dq: 3, \(dqsubnet\(dq: \(dq2001:db8:3::/64\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8:3::10 \- 2001:db8:3::20\(dq }, { \(dqpool\(dq: \(dq2001:db8:3::30 \- 2001:db8:3::40\(dq } ] } ] } ] } } .EE .UNINDENT .UNINDENT .sp This is similar to the example described in the \fI\%Pool Selection with Client Class Reservations\fP\&. This time, however, there are three subnets, of which the first two have a pool associated with a different class each. .sp The clients that do not have a reservation for \fBreserved_class\fP are assigned an address from the first subnet and when that is filled from the third subnet. Clients with a reservation for \fBreserved_class\fP are assigned an address from the second subnet and when that is filled from the third subnet. .sp The subnets must belong to the same shared network. .sp For a subnet to be restricted to a certain class, or skipped, all of the pools inside that subnet must be guarded by \fBreserved_class\fP or \fBunreserved_class\fP respectively. .sp In addition, the reservation for the client class must be specified at the global scope (global reservation) and \fBreservations\-global\fP must be set to \fBtrue\fP\&. .sp In the example above, the \fBclient\-classes\fP configuration parameter could also be specified at the subnet level rather than the pool level, and would yield the same effect. .sp If the subnets were defined outside shared networks, and \fBclient\-classes\fP were specified at the subnet level, then \fBearly\-global\-reservations\-lookup\fP would also need to be enabled in order for subnet selection to work. .SS Multiple Reservations for the Same IP .sp Host reservations were designed to preclude the creation of multiple reservations for the same IP address or delegated prefix within a particular subnet, to avoid having two different clients compete for the same lease. When using the default settings, the server returns a configuration error when it finds two or more reservations for the same lease within a subnet in the Kea configuration file. \fI\%libdhcp_host_cmds.so\fP returns an error in response to the \fI\%reservation\-add\fP command when it detects that the reservation exists in the database for the lease for which the new reservation is being added. .sp Similar to DHCPv4 (see \fI\%Multiple Reservations for the Same IP\fP), the DHCPv6 server can also be configured to allow the creation of multiple reservations for the same IPv6 address and/or delegated prefix in a given subnet. This is supported since Kea release 1.9.1 as an optional mode of operation enabled with the \fBip\-reservations\-unique\fP global parameter. .sp \fBip\-reservations\-unique\fP is a boolean parameter that defaults to \fBtrue\fP, which forbids the specification of more than one reservation for the same lease in a given subnet. Setting this parameter to \fBfalse\fP allows such reservations to be created both in the Kea configuration file and in the host database backend, via \fI\%libdhcp_host_cmds.so\fP\&. .sp Setting \fBip\-reservations\-unique\fP to \fBfalse\fP when using memfile, MySQL, or PostgreSQL is supported. This setting is not supported when using Host Cache (see \fI\%libdhcp_host_cache.so: Host Cache Reservations for Improved Performance\fP) or the RADIUS backend (see \fI\%libdhcp_radius.so: RADIUS Server Support\fP). These reservation backends do not support multiple reservations for the same IP; if either of these hooks is loaded and \fBip\-reservations\-unique\fP is set to \fBfalse\fP, then a configuration error is emitted and the server fails to start. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 When \fBip\-reservations\-unique\fP is set to \fBtrue\fP (the default value), the server ensures that IP reservations are unique for a subnet within a single host backend and/or Kea configuration file. It does not guarantee that the reservations are unique across multiple backends. On server startup, only IP reservations defined in the Kea configuration file are checked for uniqueness. .UNINDENT .UNINDENT .sp The following is an example configuration with two reservations for the same IPv6 address but different MAC addresses: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqip\-reservations\-unique\(dq: false, \(dqsubnet6\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq2001:db8:1::/64\(dq, \(dqreservations\(dq: [ { \(dqhw\-address\(dq: \(dq1a:1b:1c:1d:1e:1f\(dq, \(dqip\-address\(dq: \(dq2001:db8:1::11\(dq }, { \(dqhw\-address\(dq: \(dq2a:2b:2c:2d:2e:2f\(dq, \(dqip\-address\(dq: \(dq2001:db8:1::11\(dq } ] } ] } .EE .UNINDENT .UNINDENT .sp It is possible to control the \fBip\-reservations\-unique\fP parameter via the \fI\%Configuration Backend in DHCPv6\fP\&. If the new setting of this parameter conflicts with the currently used backends (i.e. backends do not support the new setting), the new setting is ignored and a warning log message is generated. The backends continue to use the default setting, expecting that IP reservations are unique within each subnet. To allow the creation of non\-unique IP reservations, the administrator must remove the backends which lack support for them from the configuration file. .sp Administrators must be careful when they have been using multiple reservations for the same IP address and/or delegated prefix and later decide to return to the default mode in which this is no longer allowed. They must make sure that at most one reservation for a given IP address or delegated prefix exists within a subnet, prior to switching back to the default mode. If such duplicates are left in the configuration file, the server reports a configuration error. Leaving such reservations in the host databases does not cause configuration errors but may lead to lease allocation errors during the server\(aqs operation, when it unexpectedly finds multiple reservations for the same IP address or delegated prefix. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Currently, the Kea server does not verify whether multiple reservations for the same IP address and/or delegated prefix exist in MySQL and/or PostgreSQL) host databases when \fBip\-reservations\-unique\fP is updated from \fBfalse\fP to \fBtrue\fP\&. This may cause issues with lease allocations. The administrator must ensure that there is at most one reservation for each IP address and/or delegated prefix within each subnet, prior to the configuration update. .UNINDENT .UNINDENT .sp \fBreservations\-lookup\-first\fP is a boolean parameter which controls whether host reservations lookup should be performed before lease lookup. This parameter has effect only when multi\-threading is disabled. When multi\-threading is enabled, host reservations lookup is always performed first to avoid lease\-lookup resource locking. The \fBreservations\-lookup\-first\fP parameter defaults to \fBfalse\fP when multi\-threading is disabled. .SS Host Reservations as Basic Access Control .sp It is possible to define a host reservation that contains just an identifier, without any address, options, or values. In some deployments this is useful, as the hosts that have a reservation belong to the KNOWN class while others do not. This can be used as a basic access control mechanism. .sp The following example demonstrates this concept. It indicates a single IPv6 subnet and all clients will get an address from it. However, only known clients (those that have reservations) will get their default DNS server configured. Empty reservations, i.e. reservations that only have the identification criterion, can be useful as a way of making the clients known. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqKNOWN\(dq, \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqdns\-servers\(dq, \(dqdata\(dq: \(dq2001:db8::1\(dq } ] } ], \(dqreservations\(dq: [ // Clients on this list will be added to the KNOWN class. { \(dqduid\(dq: \(dq01:02:03:04:05:0A:0B:0C:0D:0E\(dq }, { \(dqduid\(dq: \(dq02:03:04:05:0A:0B:0C:0D:0E:0F\(dq } ], \(dqreservations\-in\-subnet\(dq: true, \(dqsubnet6\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq2001:db8:1::/48\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8:1:1::/64\(dq } ] } ] } .EE .UNINDENT .UNINDENT .sp This concept can be extended further. A good real\-life scenario might be a situation where some customers of an ISP have not paid their bills. A new class can be defined to use an alternative default DNS server that, instead of giving access to the Internet, redirects those customers to a captive portal urging them to bring their accounts up to date. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqblocked\(dq, \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqdns\-servers\(dq, \(dqdata\(dq: \(dq2001:db8::2\(dq } ] } ], \(dqreservations\(dq: [ // Clients on this list will be added to the KNOWN class. Some // will also be added to the blocked class. { \(dqduid\(dq: \(dq01:02:03:04:05:0A:0B:0C:0D:0E\(dq, \(dqclient\-classes\(dq: [ \(dqblocked\(dq ] }, { \(dqduid\(dq: \(dq02:03:04:05:0A:0B:0C:0D:0E:0F\(dq } ], \(dqreservations\-in\-subnet\(dq: true, \(dqsubnet6\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq2001:db8:1::/48\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8:1:1::/64\(dq } ], \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqdns\-servers\(dq, \(dqdata\(dq: \(dq2001:db8::1\(dq } ] } ] } .EE .UNINDENT .UNINDENT .SS Shared Networks in DHCPv6 .sp DHCP servers use subnet information in two ways. It is used to both determine the point of attachment, i.e. where the client is connected to the network, and to group information pertaining to a specific location in the network. Sometimes it is useful to have more than one logical IP subnet being deployed on the same physical link. Understanding that two or more subnets are used on the same link requires additional logic in the DHCP server. This capability is called \(dqshared networks\(dq in Kea, and sometimes also \(dqshared subnets\(dq; in Microsoft\(aqs nomenclature it is called \(dqmultinet.\(dq .sp There are many cases where the shared networks feature is useful; here we explain just a handful of the most common ones. The first and by far most common use case is an existing IPv4 network that has grown and is running out of available address space. This is less common in IPv6, but shared networks are still useful: for example, with the exhaustion of IPv6\- delegated prefixes within a subnet, or the desire to experiment with an addressing scheme. With the advent of IPv6 deployment and a vast address space, many organizations split the address space into subnets, deploy it, and then after a while discover that they want to split it differently. In the transition period, they want both the old and new addressing to be available: thus the need for more than one subnet on the same physical link. .sp Finally, the case of cable networks is directly applicable in IPv6. There are two types of devices in cable networks: cable modems and the end\-user devices behind them. It is a common practice to use different subnets for cable modems to prevent users from tinkering with them. In this case, the distinction is based on the type of device, rather than on address\-space exhaustion. .sp A client connected to a shared network may be assigned a lease (address or prefix) from any of the pools defined within the subnets belonging to the shared network. Internally, the server selects one of the subnets belonging to a shared network and tries to allocate a lease from this subnet. If the server is unable to allocate a lease from the selected subnet (e.g., due to pool exhaustion), it uses another subnet from the same shared network and tries to allocate a lease from this subnet. The server typically allocates all leases available in a given subnet before it starts allocating leases from other subnets belonging to the same shared network. However, in certain situations the client can be allocated a lease from another subnet before the pools in the first subnet get exhausted; this sometimes occurs when the client provides a hint that belongs to another subnet, or the client has reservations in a subnet other than the default. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Deployments should not assume that Kea waits until it has allocated all the addresses from the first subnet in a shared network before allocating addresses from other subnets. .UNINDENT .UNINDENT .sp To define a shared network, an additional configuration scope is introduced: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp6\(dq: { \(dqshared\-networks\(dq: [ { # Name of the shared network. It may be an arbitrary string # and it must be unique among all shared networks. \(dqname\(dq: \(dqipv6\-lab\-1\(dq, # The subnet selector can be specified on the shared network # level. Subnets from this shared network will be selected # for clients communicating via relay agent having # the specified IP address. \(dqrelay\(dq: { \(dqip\-addresses\(dq: [ \(dq2001:db8:2:34::1\(dq ] }, # This starts a list of subnets in this shared network. # There are two subnets in this example. \(dqsubnet6\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq2001:db8::/48\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8::1 \- 2001:db8::ffff\(dq } ] }, { \(dqid\(dq: 2, \(dqsubnet\(dq: \(dq3ffe:ffe::/64\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq3ffe:ffe::/64\(dq } ] } ] } ], # end of shared\-networks # It is likely that in the network there will be a mix of regular, # \(dqplain\(dq subnets and shared networks. It is perfectly valid # to mix them in the same configuration file. # # This is a regular subnet. It is not part of any shared\-network. \(dqsubnet6\(dq: [ { \(dqid\(dq: 3, \(dqsubnet\(dq: \(dq2001:db9::/48\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db9::/64\(dq } ], \(dqrelay\(dq: { \(dqip\-addresses\(dq: [ \(dq2001:db8:1:2::1\(dq ] } } ] } } .EE .UNINDENT .UNINDENT .sp As demonstrated in the example, it is possible to mix shared and regular (\(dqplain\(dq) subnets. Each shared network must have a unique name. This is similar to the ID for subnets, but gives administrators more flexibility. It is used for logging, but also internally for identifying shared networks. .sp In principle it makes sense to define only shared networks that consist of two or more subnets. However, for testing purposes, an empty subnet or a network with just a single subnet is allowed. This is not a recommended practice in production networks, as the shared network logic requires additional processing and thus lowers the server\(aqs performance. To avoid unnecessary performance degradation, shared subnets should only be defined when required by the deployment. .sp Shared networks provide an ability to specify many parameters in the shared network scope that apply to all subnets within it. If necessary, it is possible to specify a parameter in the shared\-network scope and then override its value in the subnet scope. For example: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqshared\-networks\(dq: [ { \(dqname\(dq: \(dqlab\-network3\(dq, \(dqrelay\(dq: { \(dqip\-addresses\(dq: [ \(dq2001:db8:2:34::1\(dq ] }, # This applies to all subnets in this shared network, unless # values are overridden on subnet scope. \(dqvalid\-lifetime\(dq: 600, # This option is made available to all subnets in this shared # network. \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqdns\-servers\(dq, \(dqdata\(dq: \(dq2001:db8::8888\(dq } ], \(dqsubnet6\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq2001:db8:1::/48\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8:1::1 \- 2001:db8:1::ffff\(dq } ], # This particular subnet uses different values. \(dqvalid\-lifetime\(dq: 1200, \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqdns\-servers\(dq, \(dqdata\(dq: \(dq2001:db8::1:2\(dq }, { \(dqname\(dq: \(dqunicast\(dq, \(dqdata\(dq: \(dq2001:abcd::1\(dq } ] }, { \(dqid\(dq: 2, \(dqsubnet\(dq: \(dq2001:db8:2::/48\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8:2::1 \- 2001:db8:2::ffff\(dq } ], # This subnet does not specify its own valid\-lifetime value, # so it is inherited from shared network scope. \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqdns\-servers\(dq, \(dqdata\(dq: \(dq2001:db8:cafe::1\(dq } ] } ] } ], ... } .EE .UNINDENT .UNINDENT .sp In this example, there is a \fBdns\-servers\fP option defined that is available to clients in both subnets in this shared network. Also, the valid lifetime is set to 10 minutes (600s). However, the first subnet overrides some of the values (the valid lifetime is 20 minutes, there is a different IP address for \fBdns\-servers\fP), but also adds its own option (the unicast address). Assuming a client asking for server unicast and \fBdns\-servers\fP options is assigned a lease from this subnet, it will get a lease for 20 minutes and \fBdns\-servers\fP, and be allowed to use server unicast at address 2001:abcd::1. If the same client is assigned to the second subnet, it will get a 10\-minute lease, a \fBdns\-servers\fP value of 2001:db8:cafe::1, and no server unicast. .sp Some parameters must be the same in all subnets in the same shared network. This restriction applies to the \fBinterface\fP and \fBrapid\-commit\fP settings. The most convenient way is to define them on the shared\-network scope, but they can be specified for each subnet. However, each subnet must have the same value. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 There is an inherent ambiguity when using clients that send multiple IA options in a single request, and shared\-networks whose subnets have different values for options and configuration parameters. The server sequentially processes IA options in the order that they occur in the client\(aqs query; if the leases requested in the IA options end up being fulfilled from different subnets, which parameters and options should apply? Currently, the code uses the values from the last subnet of the last IA option fulfilled. .sp We view this largely as a site configuration issue. A shared network generally means the same physical link, so services configured by options from subnet A should be as easily reachable from subnet B and vice versa. There are a number of ways to avoid this situation: .INDENT 0.0 .IP \(bu 2 Use the same values for options and parameters for subnets within the shared network. .IP \(bu 2 Use subnet selectors or client class guards that ensure that for a single client\(aqs query, the same subnet is used for all IA options in that query. .IP \(bu 2 Avoid using shared networks with clients that send multiple IA options per query. .UNINDENT .UNINDENT .UNINDENT .SS Local and Relayed Traffic in Shared Networks .sp It is possible to specify an interface name at the shared\-network level, to tell the server that this specific shared network is reachable directly (not via relays) using the local network interface. As all subnets in a shared network are expected to be used on the same physical link, it is a configuration error to attempt to define a shared network using subnets that are reachable over different interfaces. In other words, all subnets within the shared network must have the same value for the \fBinterface\fP parameter. The following configuration is an example of what \fBNOT\fP to do: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqshared\-networks\(dq: [ { \(dqname\(dq: \(dqoffice\-floor\-2\(dq, \(dqsubnet6\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq2001:db8::/64\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8::1 \- 2001:db8::ffff\(dq } ], \(dqinterface\(dq: \(dqeth0\(dq }, { \(dqid\(dq: 2, \(dqsubnet\(dq: \(dq3ffe:abcd::/64\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq3ffe:abcd::1 \- 3ffe:abcd::ffff\(dq } ], ... # Specifying a different interface name is a configuration # error. This value should rather be \(dqeth0\(dq or the interface # name in the other subnet should be \(dqeth1\(dq. # \(dqinterface\(dq: \(dqeth1\(dq } ] } ], \&... } .EE .UNINDENT .UNINDENT .sp To minimize the chance of configuration errors, it is often more convenient to simply specify the interface name once, at the shared\-network level, as shown in the example below. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqshared\-networks\(dq: [ { \(dqname\(dq: \(dqoffice\-floor\-2\(dq, # This tells Kea that the whole shared network is reachable over a # local interface. This applies to all subnets in this network. \(dqinterface\(dq: \(dqeth0\(dq, \(dqsubnet6\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq2001:db8::/64\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8::1 \- 2001:db8::ffff\(dq } ] }, { \(dqid\(dq: 2, \(dqsubnet\(dq: \(dq3ffe:abcd::/64\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq3ffe:abcd::1 \- 3ffe:abcd::ffff\(dq } ] } ] } ], \&... } .EE .UNINDENT .UNINDENT .sp With relayed traffic, subnets are typically selected using the relay agents\(aq addresses. If the subnets are used independently (not grouped within a shared network), a different relay address can be specified for each of these subnets. When multiple subnets belong to a shared network they must be selected via the same relay address and, similarly to the case of the local traffic described above, it is a configuration error to specify different relay addresses for the respective subnets in the shared network. The following configuration is another example of what \fBNOT\fP to do: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqshared\-networks\(dq: [ { \(dqname\(dq: \(dqkakapo\(dq, \(dqsubnet6\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq2001:db8::/64\(dq, \(dqrelay\(dq: { \(dqip\-addresses\(dq: [ \(dq2001:db8::1234\(dq ] }, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8::1 \- 2001:db8::ffff\(dq } ] }, { \(dqid\(dq: 2, \(dqsubnet\(dq: \(dq3ffe:abcd::/64\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq3ffe:abcd::1 \- 3ffe:abcd::ffff\(dq } ], \(dqrelay\(dq: { # Specifying a different relay address for this # subnet is a configuration error. In this case # it should be 2001:db8::1234 or the relay address # in the previous subnet should be 3ffe:abcd::cafe. \(dqip\-addresses\(dq: [ \(dq3ffe:abcd::cafe\(dq ] } } ] } ], \&... } .EE .UNINDENT .UNINDENT .sp Again, it is better to specify the relay address at the shared\-network level; this value will be inherited by all subnets belonging to the shared network. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqshared\-networks\(dq: [ { \(dqname\(dq: \(dqkakapo\(dq, \(dqrelay\(dq: { # This relay address is inherited by both subnets. \(dqip\-addresses\(dq: [ \(dq2001:db8::1234\(dq ] }, \(dqsubnet6\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq2001:db8::/64\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8::1 \- 2001:db8::ffff\(dq } ] }, { \(dqid\(dq: 2, \(dqsubnet\(dq: \(dq3ffe:abcd::/64\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq3ffe:abcd::1 \- 3ffe:abcd::ffff\(dq } ] } ] } ], \&... } .EE .UNINDENT .UNINDENT .sp Even though it is technically possible to configure two (or more) subnets within the shared network to use different relay addresses, this will almost always lead to a different behavior than what the user would expect. In this case, the Kea server will initially select one of the subnets by matching the relay address in the client\(aqs packet with the subnet\(aqs configuration. However, it MAY end up using the other subnet (even though it does not match the relay address) if the client already has a lease in this subnet or has a host reservation in this subnet, or simply if the initially selected subnet has no more addresses available. Therefore, it is strongly recommended to always specify subnet selectors (interface or relay address) at the shared\-network level if the subnets belong to a shared network, as it is rarely useful to specify them at the subnet level and may lead to the configuration errors described above. .SS Client Classification in Shared Networks .sp Sometimes it is desirable to segregate clients into specific subnets based on certain properties. This mechanism is called client classification and is described in \fI\%Client Classification\fP\&. Client classification can be applied to subnets belonging to shared networks in the same way as it is used for subnets specified outside of shared networks. It is important to understand how the server selects subnets for clients when client classification is in use, to ensure that the appropriate subnet is selected for a given client type. .sp If a subnet is associated with a class, only the clients belonging to this class can use this subnet. If there are no classes specified for a subnet, any client connected to a given shared network can use this subnet. A common mistake is to assume that the subnet that includes a client class is preferred over subnets without client classes. .sp The \fBclient\-classes\fP parameter may be specified at the shared network, subnet, and/or pool scopes. If specified for a shared network, clients must belong to at least one of the classes specified for that network to be considered for subnets within that network. If specified for a subnet, clients must belong to at least one of the classes specified for that subnet to be considered for any of that subnet\(aqs pools or host reservations. If specified for a pool, clients must belong to at least one of the classes specified for that pool to be given a lease from that pool. .sp Consider the following example: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqb\-devices\(dq, \(dqtest\(dq: \(dqoption[1234].hex == 0x0002\(dq } ], \(dqshared\-networks\(dq: [ { \(dqname\(dq: \(dqgalah\(dq, \(dqrelay\(dq: { \(dqip\-address\(dq: [ \(dq2001:db8:2:34::1\(dq ] }, \(dqsubnet6\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq2001:db8:1::/64\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8:1::20 \- 2001:db8:1::ff\(dq } ] }, { \(dqid\(dq: 2, \(dqsubnet\(dq: \(dq2001:db8:3::/64\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8:3::20 \- 2001:db8:3::ff\(dq } ], \(dqclient\-classes\(dq: \(dqb\-devices\(dq } ] } ] } .EE .UNINDENT .UNINDENT .sp If the client belongs to the \(dqb\-devices\(dq class (because it includes option 1234 with a value of 0x0002), that does not guarantee that the subnet 2001:db8:3::/64 will be used (or preferred) for this client. The server can use either of the two subnets, because the subnet 2001:db8:1::/64 is also allowed for this client. The client classification used in this case should be perceived as a way to restrict access to certain subnets, rather than as a way to express subnet preference. For example, if the client does not belong to the \(dqb\-devices\(dq class, it may only use the subnet 2001:db8:1::/64 and will never use the subnet 2001:db8:3::/64. .sp A typical use case for client classification is in a cable network, where cable modems should use one subnet and other devices should use another subnet within the same shared network. In this case it is necessary to apply classification on all subnets. The following example defines two classes of devices, and the subnet selection is made based on option 1234 values. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqa\-devices\(dq, \(dqtest\(dq: \(dqoption[1234].hex == 0x0001\(dq }, { \(dqname\(dq: \(dqb\-devices\(dq, \(dqtest\(dq: \(dqoption[1234].hex == 0x0002\(dq } ], \(dqshared\-networks\(dq: [ { \(dqname\(dq: \(dqgalah\(dq, \(dqrelay\(dq: { \(dqip\-addresses\(dq: [ \(dq2001:db8:2:34::1\(dq ] }, \(dqsubnet6\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq2001:db8:1::/64\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8:1::20 \- 2001:db8:1::ff\(dq } ], \(dqclient\-classes\(dq: [ \(dqa\-devices\(dq ] }, { \(dqid\(dq: 2, \(dqsubnet\(dq: \(dq2001:db8:3::/64\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8:3::20 \- 2001:db8:3::ff\(dq } ], \(dqclient\-classes\(dq: [ \(dqb\-devices\(dq ] } ] } ] } .EE .UNINDENT .UNINDENT .sp In this example each class has its own restriction. Only clients that belong to class \(dqa\-devices\(dq are able to use subnet 2001:db8:1::/64 and only clients belonging to \(dqb\-devices\(dq are able to use subnet 2001:db8:3::/64. Care should be taken not to define too\-restrictive classification rules, as clients that are unable to use any subnets will be refused service. However, this may be a desired outcome if one wishes to provide service only to clients with known properties (e.g. only VoIP phones allowed on a given link). .sp It is possible to achieve an effect similar to the one presented in this section without the use of shared networks. If the subnets are placed in the global subnets scope, rather than in the shared network, the server will still use classification rules to pick the right subnet for a given class of devices. The major benefit of placing subnets within the shared network is that common parameters for the logically grouped subnets can be specified once, in the shared network scope, e.g. the \fBinterface\fP or \fBrelay\fP parameter. All subnets belonging to this shared network will inherit those parameters. .SS Host Reservations in Shared Networks .sp Subnets that are part of a shared network allow host reservations, similar to regular subnets: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqshared\-networks\(dq: [ { \(dqname\(dq: \(dqfrog\(dq, \(dqrelay\(dq: { \(dqip\-addresses\(dq: [ \(dq2001:db8:2:34::1\(dq ] }, \(dqsubnet6\(dq: [ { \(dqsubnet\(dq: \(dq2001:db8:1::/64\(dq, \(dqid\(dq: 100, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8:1::1 \- 2001:db8:1::64\(dq } ], \(dqreservations\(dq: [ { \(dqduid\(dq: \(dq00:03:00:01:11:22:33:44:55:66\(dq, \(dqip\-addresses\(dq: [ \(dq2001:db8:1::28\(dq ] } ] }, { \(dqsubnet\(dq: \(dq2001:db8:3::/64\(dq, \(dqid\(dq: 101, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8:3::1 \- 2001:db8:3::64\(dq } ], \(dqreservations\(dq: [ { \(dqduid\(dq: \(dq00:03:00:01:aa:bb:cc:dd:ee:ff\(dq, \(dqip\-addresses\(dq: [ \(dq2001:db8:2::28\(dq ] } ] } ] } ] } .EE .UNINDENT .UNINDENT .sp It is worth noting that Kea conducts additional checks when processing a packet if shared networks are defined. First, instead of simply checking whether there is a reservation for a given client in its initially selected subnet, Kea looks through all subnets in a shared network for a reservation. This is one of the reasons why defining a shared network may impact performance. If there is a reservation for a client in any subnet, that particular subnet is picked for the client. Although it is technically not an error, it is considered bad practice to define reservations for the same host in multiple subnets belonging to the same shared network. .sp While not strictly mandatory, it is strongly recommended to use explicit \(dqid\(dq values for subnets if database storage will be used for host reservations. If an ID is not specified, the values for it are auto generated, i.e. Kea assigns increasing integer values starting from 1. Thus, the auto\-generated IDs are not stable across configuration changes. .SS Server Identifier in DHCPv6 .sp The DHCPv6 protocol uses a \(dqserver identifier\(dq (also known as a DUID) to allow clients to discriminate between several servers present on the same link. \X'tty: link https://tools.ietf.org/html/rfc8415'\fI\%RFC 8415\fP\X'tty: link' currently defines four DUID types: DUID\-LLT, DUID\-EN, DUID\-LL, and DUID\-UUID. .sp The Kea DHCPv6 server generates a server identifier once, upon the first startup, and stores it in a file. This identifier is not modified across restarts of the server and so is a stable identifier. .sp Kea follows the recommendation from \X'tty: link https://tools.ietf.org/html/rfc8415'\fI\%RFC 8415\fP\X'tty: link' to use DUID\-LLT as the default server identifier. However, ISC has received reports that some deployments require different DUID types, and that there is a need to administratively select both the DUID type and/or its contents. .sp The server identifier can be configured using parameters within the \fBserver\-id\fP map element in the global scope of the Kea configuration file. The following example demonstrates how to select DUID\-EN as a server identifier: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqserver\-id\(dq: { \(dqtype\(dq: \(dqEN\(dq }, ... } .EE .UNINDENT .UNINDENT .sp Currently supported values for the \fBtype\fP parameter are: \(dqLLT\(dq, \(dqEN\(dq, and \(dqLL\(dq, for DUID\-LLT, DUID\-EN, and DUID\-LL respectively. .sp When a new DUID type is selected, the server generates its value and replaces any existing DUID in the file. The server then uses the new server identifier in all future interactions with clients. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 If the new server identifier is created after some clients have obtained their leases, the clients using the old identifier are not able to renew their leases; the server will ignore messages containing the old server identifier. Clients will continue sending RENEW until they transition to the rebinding state. In this state, they will start sending REBIND messages to the multicast address without a server identifier. The server will respond to the REBIND messages with a new server identifier, and the clients will associate the new server identifier with their leases. Although the clients will be able to keep their leases and will eventually learn the new server identifier, this will be at the cost of an increased number of renewals and multicast traffic due to a need to rebind. Therefore, it is recommended that modification of the server\-identifier type and value be avoided if the server has already assigned leases and these leases are still valid. .UNINDENT .UNINDENT .sp There are cases when an administrator needs to explicitly specify a DUID value rather than allow the server to generate it. The following example demonstrates how to explicitly set all components of a DUID\-LLT. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqserver\-id\(dq: { \(dqtype\(dq: \(dqLLT\(dq, \(dqhtype\(dq: 8, \(dqidentifier\(dq: \(dqA65DC7410F05\(dq, \(dqtime\(dq: 2518920166 }, ... } .EE .UNINDENT .UNINDENT .sp where: .INDENT 0.0 .IP \(bu 2 \fBhtype\fP is a 16\-bit unsigned value specifying hardware type, .IP \(bu 2 \fBidentifier\fP is a link\-layer address, specified as a string of hexadecimal digits, and .IP \(bu 2 \fBtime\fP is a 32\-bit unsigned time value. .UNINDENT .sp The hexadecimal representation of the DUID generated as a result of the configuration specified above is: .INDENT 0.0 .INDENT 3.5 .sp .EX 00:01:00:08:96:23:AB:E6:A6:5D:C7:41:0F:05 |type |htype| time | identifier | .EE .UNINDENT .UNINDENT .sp A special value of \(dq0\(dq for \fBhtype\fP and \fBtime\fP is allowed, which indicates that the server should use ANY value for these components. If the server already uses a DUID\-LLT, it will use the values from this DUID; if the server uses a DUID of a different type or does not yet use any DUID, it will generate these values. Similarly, if the \fBidentifier\fP is assigned an empty string, the value of the \fBidentifier\fP will be generated. Omitting any of these parameters is equivalent to setting them to those special values. .sp For example, the following configuration: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqserver\-id\(dq: { \(dqtype\(dq: \(dqLLT\(dq, \(dqhtype\(dq: 0, \(dqidentifier\(dq: \(dq\(dq, \(dqtime\(dq: 2518920166 }, ... } .EE .UNINDENT .UNINDENT .sp indicates that the server should use ANY link\-layer address and hardware type. If the server is already using DUID\-LLT, it will use the link\-layer address and hardware type from the existing DUID. If the server is not yet using any DUID, it will use the link\-layer address and hardware type from one of the available network interfaces. The server will use an explicit value of time; if it is different than a time value present in the currently used DUID, that value will be replaced, effectively modifying the current server identifier. .sp The following example demonstrates an explicit configuration of a DUID\-EN: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqserver\-id\(dq: { \(dqtype\(dq: \(dqEN\(dq, \(dqenterprise\-id\(dq: 2495, \(dqidentifier\(dq: \(dq87ABEF7A5BB545\(dq }, ... } .EE .UNINDENT .UNINDENT .sp where: .INDENT 0.0 .IP \(bu 2 \fBenterprise\-id\fP is a 32\-bit unsigned value holding an enterprise number, and .IP \(bu 2 \fBidentifier\fP is a variable\- length identifier within DUID\-EN. .UNINDENT .sp The hexadecimal representation of the DUID\-EN created according to the configuration above is: .INDENT 0.0 .INDENT 3.5 .sp .EX 00:02:00:00:09:BF:87:AB:EF:7A:5B:B5:45 |type | ent\-id | identifier | .EE .UNINDENT .UNINDENT .sp As in the case of the DUID\-LLT, special values can be used for the configuration of the DUID\-EN. If the \fBenterprise\-id\fP is \(dq0\(dq, the server will use a value from the existing DUID\-EN. If the server is not using any DUID or the existing DUID has a different type, the ISC enterprise ID will be used. When an empty string is entered for \fBidentifier\fP, the identifier from the existing DUID\-EN will be used. If the server is not using any DUID\-EN, a new 6\-byte\-long \fBidentifier\fP will be generated. .sp DUID\-LL is configured in the same way as DUID\-LLT except that the \fBtime\fP parameter has no effect for DUID\-LL, because this DUID type only comprises a hardware type and link\-layer address. The following example demonstrates how to configure DUID\-LL: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqserver\-id\(dq: { \(dqtype\(dq: \(dqLL\(dq, \(dqhtype\(dq: 8, \(dqidentifier\(dq: \(dqA65DC7410F05\(dq }, ... } .EE .UNINDENT .UNINDENT .sp which will result in the following server identifier: .INDENT 0.0 .INDENT 3.5 .sp .EX 00:03:00:08:A6:5D:C7:41:0F:05 |type |htype| identifier | .EE .UNINDENT .UNINDENT .sp The server stores the generated server identifier in the following location: \fB[kea\-install\-dir]/var/lib/kea/kea\-dhcp6\-serverid\fP\&. .sp In some uncommon deployments where no stable storage is available, the server should be configured not to try to store the server identifier. This choice is controlled by the value of the \fBpersist\fP boolean parameter: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqserver\-id\(dq: { \(dqtype\(dq: \(dqEN\(dq, \(dqenterprise\-id\(dq: 2495, \(dqidentifier\(dq: \(dq87ABEF7A5BB545\(dq, \(dqpersist\(dq: false }, ... } .EE .UNINDENT .UNINDENT .sp The default value of the \fBpersist\fP parameter is \fBtrue\fP, which configures the server to store the server identifier on a disk. .sp In the example above, the server is configured not to store the generated server identifier on a disk. But if the server identifier is not modified in the configuration, the same value is used after server restart, because the entire server identifier is explicitly specified in the configuration. .SS DHCPv6 Data Directory .sp The Kea DHCPv6 server puts the server identifier file and the default memory lease file into its data directory. By default this directory is \fBprefix/var/lib/kea\fP but this location can be changed using the \fBdata\-directory\fP global parameter, as in: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqdata\-directory\(dq: \(dq/var/lib/kea/kea\-server6\(dq, ... } .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 As of Kea 2.7.9, \fBdata\-directory\fP is deprecated. The duid and lease files may only be loaded from the directory determined at compilation: \fB\(dq[kea\-install\-dir]/var/lib/kea\(dq\fP\&. This path may be overridden at startup by setting the environment variable \fBKEA_DHCP_DATA_DIR\fP to the desired path. If a path other than this value is used in \fBdata\-directory\fP, Kea will emit an error and refuse to start or, if already running, log an unrecoverable error. .UNINDENT .UNINDENT .SS Stateless DHCPv6 (INFORMATION\-REQUEST Message) .sp Typically DHCPv6 is used to assign both addresses and options. These assignments (leases) have a state that changes over time, hence their description as \(dqstateful.\(dq DHCPv6 also supports a \(dqstateless\(dq mode, where clients request only configuration options. This mode is considered lightweight from the server perspective, as it does not require any state tracking. .sp The Kea server supports stateless mode. When clients send INFORMATION\-REQUEST messages, the server sends back answers with the requested options, if they are available in the server configuration. The server attempts to use per\-subnet options first; if that fails, it then tries to provide options defined in the global scope. .sp Stateless and stateful mode can be used together. No special configuration directives are required to handle this; simply use the configuration for stateful clients and the stateless clients will get only the options they requested. .sp It is possible to run a server that provides only options and no addresses or prefixes. If the options have the same value in each subnet, the configuration can define the required options in the global scope and skip subnet definitions altogether. Here\(aqs a simple example of such a configuration: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqinterfaces\-config\(dq: { \(dqinterfaces\(dq: [ \(dqethX\(dq ] }, \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqdns\-servers\(dq, \(dqdata\(dq: \(dq2001:db8::1, 2001:db8::2\(dq } ], \(dqlease\-database\(dq: { \(dqtype\(dq: \(dqmemfile\(dq } } .EE .UNINDENT .UNINDENT .sp This very simple configuration provides DNS server information to all clients in the network, regardless of their location. The memfile lease database must be specified, as Kea requires a lease database to be specified even if it is not used. .SS Support for RFC 7550 (now part of RFC 8415) .sp \X'tty: link https://tools.ietf.org/html/rfc7550'\fI\%RFC 7550\fP\X'tty: link' introduced some changes to the previous DHCPv6 specifications, \X'tty: link https://tools.ietf.org/html/rfc3315'\fI\%RFC 3315\fP\X'tty: link' and \X'tty: link https://tools.ietf.org/html/rfc3633'\fI\%RFC 3633\fP\X'tty: link', to resolve issues with the coexistence of multiple stateful options in the messages sent between clients and servers. Those changes were later included in the most recent DHCPv6 protocol specification, \X'tty: link https://tools.ietf.org/html/rfc8415'\fI\%RFC 8415\fP\X'tty: link', which obsoleted \X'tty: link https://tools.ietf.org/html/rfc7550'\fI\%RFC 7550\fP\X'tty: link'\&. Kea supports \X'tty: link https://tools.ietf.org/html/rfc8415'\fI\%RFC 8415\fP\X'tty: link' along with these protocol changes, which are briefly described below. .sp When a client, such as a requesting router, requests an allocation of both addresses and prefixes during the 4\-way (SARR) exchange with the server, and the server is not configured to allocate any prefixes but can allocate some addresses, it will respond with the IA_NA(s) containing allocated addresses and the IA_PD(s) containing the NoPrefixAvail status code. According to the updated specifications, if the client can operate without prefixes it should accept allocated addresses and transition to the \(dqbound\(dq state. When the client subsequently sends RENEW/REBIND messages to the server to extend the lifetimes of the allocated addresses, according to the T1 and T2 times, and if the client is still interested in obtaining prefixes from the server, it may also include an IA_PD in the RENEW/REBIND to request allocation of the prefixes. If the server still cannot allocate the prefixes, it will respond with the IA_PD(s) containing the NoPrefixAvail status code. However, if the server can allocate the prefixes, it allocates and sends them in the IA_PD(s) to the client. A similar situation occurs when the server is unable to allocate addresses for the client but can delegate prefixes: the client may request allocation of the addresses while renewing the delegated prefixes. Allocating leases for other IA types while renewing existing leases is by default supported by the Kea DHCPv6 server, and the server provides no configuration mechanisms to disable this behavior. .sp The following are the other behaviors first introduced in \X'tty: link https://tools.ietf.org/html/rfc7550'\fI\%RFC 7550\fP\X'tty: link' (now part of \X'tty: link https://tools.ietf.org/html/rfc8415'\fI\%RFC 8415\fP\X'tty: link') and supported by the Kea DHCPv6 server: .INDENT 0.0 .IP \(bu 2 Set T1/T2 timers to the same value for all stateful (IA_NA and IA_PD) options to facilitate renewal of all of a client\(aqs leases at the same time (in a single message exchange). .IP \(bu 2 Place NoAddrsAvail and NoPrefixAvail status codes in the IA_NA and IA_PD options in the ADVERTISE message, rather than as the top\-level options. .UNINDENT .SS Using a Specific Relay Agent for a Subnet .sp The DHCPv6 server follows the same principles as the DHCPv4 server to select a subnet for the client, with noticeable differences mainly for relays. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 When the selected subnet is a member of a shared network, the whole shared network is selected. .UNINDENT .UNINDENT .sp A relay must have an interface connected to the link on which the clients are being configured. Typically the relay has a global IPv6 address configured on that interface, which belongs to the subnet from which the server assigns addresses. Normally, the server is able to use the IPv6 address inserted by the relay (in the \fBlink\-addr\fP field in the RELAY\-FORW message) to select the appropriate subnet. .sp However, that is not always the case; the relay address may not match the subnet in certain deployments. This usually means that there is more than one subnet allocated for a given link. The two most common examples of this are long\-lasting network renumbering (where both the old and new address spaces are still being used) and a cable network. In a cable network, both cable modems and the devices behind them are physically connected to the same link, yet they use distinct addressing. In such a case, the DHCPv6 server needs additional information (the value of the \fBinterface\-id\fP option or the IPv6 address inserted in the \fBlink\-addr\fP field in the RELAY\-FORW message) to properly select an appropriate subnet. .sp The following example assumes that there is a subnet 2001:db8:1::/64 that is accessible via a relay that uses 3000::1 as its IPv6 address. The server is able to select this subnet for any incoming packets that come from a relay that has an address in the 2001:db8:1::/64 subnet. It also selects that subnet for a relay with address 3000::1. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqsubnet6\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq2001:db8:1::/64\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8:1::1\-2001:db8:1::ffff\(dq } ], \(dqrelay\(dq: { \(dqip\-addresses\(dq: [ \(dq3000::1\(dq ] } } ] } .EE .UNINDENT .UNINDENT .sp If \fBrelay\fP is specified, the \fBip\-addresses\fP parameter within it is mandatory. The \fBip\-addresses\fP parameter supports specifying a list of addresses. .SS Segregating IPv6 Clients in a Cable Network .sp In certain cases, it is useful to mix relay address information (introduced in \fI\%Using a Specific Relay Agent for a Subnet\fP) with client classification (explained in \fI\%Client Classification\fP). One specific example is in a cable network, where modems typically get addresses from a different subnet than all the devices connected behind them. .sp Let us assume that there is one Cable Modem Termination System (CMTS) with one CM MAC (a physical link that modems are connected to). We want the modems to get addresses from the 3000::/64 subnet, while everything connected behind the modems should get addresses from the 2001:db8:1::/64 subnet. The CMTS that acts as a relay uses address 3000::1. The following configuration can serve that situation: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqsubnet6\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq3000::/64\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq3000::2 \- 3000::ffff\(dq } ], \(dqclient\-classes\(dq: [ \(dqVENDOR_CLASS_docsis3.0\(dq ], \(dqrelay\(dq: { \(dqip\-addresses\(dq: [ \(dq3000::1\(dq ] } }, { \(dqid\(dq: 2, \(dqsubnet\(dq: \(dq2001:db8:1::/64\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8:1::1\-2001:db8:1::ffff\(dq } ], \(dqrelay\(dq: { \(dqip\-addresses\(dq: [ \(dq3000::1\(dq ] } } ] } .EE .UNINDENT .UNINDENT .SS MAC/Hardware Addresses in DHCPv6 .sp MAC/hardware addresses are available in DHCPv4 messages from clients, and administrators frequently use that information to perform certain tasks like per\-host configuration and address reservation for specific MAC addresses. Unfortunately, the DHCPv6 protocol does not provide any completely reliable way to retrieve that information. To mitigate that issue, a number of mechanisms have been implemented in Kea. Each of these mechanisms works in certain cases, but may not in others. Whether the mechanism works in a particular deployment is somewhat dependent on the network topology and the technologies used. .sp Kea allows specification of which of the supported methods should be used and in what order, via the \fBmac\-sources\fP parameter. This configuration may be considered a fine tuning of the DHCP deployment. .sp Here is an example: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqmac\-sources\(dq: [ \(dqmethod1\(dq, \(dqmethod2\(dq, \(dqmethod3\(dq, ... ], \(dqsubnet6\(dq: [ { ... }, ... ], ... } .EE .UNINDENT .UNINDENT .sp When not specified, a value of \(dqany\(dq is used, which instructs the server to attempt to try all the methods in sequence and use the value returned by the first one that succeeds. In a typical deployment the default value of \(dqany\(dq is sufficient and there is no need to select specific methods. Changing the value of this parameter is most useful in cases when an administrator wants to disable certain methods; for example, if the administrator trusts the network infrastructure more than the information provided by the clients themselves, they may prefer information provided by the relays over that provided by clients. .sp If specified, \fBmac\-sources\fP must have at least one value. .sp Supported methods are: .INDENT 0.0 .IP \(bu 2 \fBany\fP \- this is not an actual method, just a keyword that instructs Kea to try all other methods and use the first one that succeeds. This is the default operation if no \fBmac\-sources\fP are defined. .IP \(bu 2 \fBraw\fP \- in principle, a DHCPv6 server could use raw sockets to receive incoming traffic and extract MAC/hardware address information. This is currently not implemented for DHCPv6 and this value has no effect. .IP \(bu 2 \fBduid\fP \- DHCPv6 uses DUID identifiers instead of MAC addresses. There are currently four DUID types defined, and two of them (DUID\-LLT, which is the default, and DUID\-LL) convey MAC address information. Although \X'tty: link https://tools.ietf.org/html/rfc8415'\fI\%RFC 8415\fP\X'tty: link' forbids it, it is possible to parse those DUIDs and extract necessary information from them. This method is not completely reliable, as clients may use other DUID types, namely DUID\-EN or DUID\-UUID. .IP \(bu 2 \fBipv6\-link\-local\fP \- another possible acquisition method comes from the source IPv6 address. In typical usage, clients are sending their packets from IPv6 link\-local addresses. There is a good chance that those addresses are based on EUI\-64, which contains a MAC address. This method is not completely reliable, as clients may use other link\-local address types. In particular, privacy extensions, defined in \X'tty: link https://tools.ietf.org/html/rfc4941'\fI\%RFC 4941\fP\X'tty: link', do not use MAC addresses. Also note that successful extraction requires that the address\(aqs u\-bit must be set to \(dq1\(dq and its g\-bit set to \(dq0\(dq, indicating that it is an interface identifier as per \X'tty: link https://tools.ietf.org/html/rfc2373#section-2.5.1'\fI\%RFC 2373, section 2.5.1\fP\X'tty: link'\&. .IP \(bu 2 \fBclient\-link\-addr\-option\fP \- one extension defined to alleviate missing MAC issues is the client link\-layer address option, defined in \X'tty: link https://tools.ietf.org/html/rfc6939'\fI\%RFC 6939\fP\X'tty: link'\&. This is an option that is inserted by a relay and contains information about a client\(aqs MAC address. This method requires a relay agent that supports the option and is configured to insert it. This method is useless for directly connected clients. The value \fBrfc6939\fP is an alias for \fBclient\-link\-addr\-option\fP\&. .IP \(bu 2 \fBremote\-id\fP \- \X'tty: link https://tools.ietf.org/html/rfc4649'\fI\%RFC 4649\fP\X'tty: link' defines a \fBremote\-id\fP option that is inserted by a relay agent. Depending on the relay agent configuration, the inserted option may convey the client\(aqs MAC address information. The value \fBrfc4649\fP is an alias for \fBremote\-id\fP\&. .IP \(bu 2 \fBsubscriber\-id\fP \- Defined in \X'tty: link https://tools.ietf.org/html/rfc4580'\fI\%RFC 4580\fP\X'tty: link', \fBsubscriber\-id\fP is somewhat similar to \fBremote\-id\fP; it is also inserted by a relay agent. The value \fBrfc4580\fP is an alias for \fBsubscriber\-id\fP\&. This method is currently not implemented. .IP \(bu 2 \fBdocsis\-cmts\fP \- Yet another possible source of MAC address information are the DOCSIS options inserted by a CMTS that acts as a DHCPv6 relay agent in cable networks. This method attempts to extract MAC address information from sub\-option 1026 (cm mac) of the vendor\-specific option with \fBvendor\-id=4491\fP\&. This vendor option is extracted from the Relay\-forward message, not the original client\(aqs message. .IP \(bu 2 \fBdocsis\-modem\fP \- The final possible source of MAC address information are the DOCSIS options inserted by the cable modem itself. This method attempts to extract MAC address information from sub\-option 36 (\fBdevice\-id\fP) of the vendor\-specific option with \fBvendor\-id=4491\fP\&. This vendor option is extracted from the original client\(aqs message, not from any relay options. .UNINDENT .sp An empty \fBmac\-sources\fP parameter is not allowed. Administrators who do not want to specify it should either simply omit the \fBmac\-sources\fP definition or specify it with the \(dqany\(dq value, which is the default. .SS Duplicate Addresses (DHCPDECLINE Support) .sp The DHCPv6 server is configured with a certain pool of addresses that it is expected to hand out to DHCPv6 clients. It is assumed that the server is authoritative and has complete jurisdiction over those addresses. However, for various reasons such as misconfiguration or a faulty client implementation that retains its address beyond the valid lifetime, there may be devices connected that use those addresses without the server\(aqs approval or knowledge. .sp Such an unwelcome event can be detected by legitimate clients (using Duplicate Address Detection) and reported to the DHCPv6 server using a DHCPDECLINE message. The server does a sanity check (to see whether the client declining an address really was supposed to use it), then conducts a clean\-up operation, and confirms the DHCPDECLINE by sending back a REPLY message. Any DNS entries related to that address are removed, the event is logged, and hooks are triggered. After that is complete, the address is marked as declined (which indicates that it is used by an unknown entity and thus not available for assignment) and a probation time is set on it. Unless otherwise configured, the probation period lasts 24 hours; after that time, the server will recover the lease (i.e. put it back into the available state) and the address will be available for assignment again. It should be noted that if the underlying issue of a misconfigured device is not resolved, the duplicate\-address scenario will repeat. If reconfigured correctly, this mechanism provides an opportunity to recover from such an event automatically, without any system administrator intervention. .sp To configure the decline probation period to a value other than the default, the following syntax can be used: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqdecline\-probation\-period\(dq: 3600, \(dqsubnet6\(dq: [ { ... }, ... ], ... } .EE .UNINDENT .UNINDENT .sp The parameter is expressed in seconds, so the example above instructs the server to recycle declined leases after one hour. .sp There are several statistics and hook points associated with the decline handling procedure. The \fBlease6_decline\fP hook point is triggered after the incoming DHCPDECLINE message has been sanitized and the server is about to decline the lease. The \fBdeclined\-addresses\fP statistic is increased after the hook returns (both the global and subnet\-specific variants). (See \fI\%Statistics in the DHCPv6 Server\fP and \fI\%Hook Libraries\fP for more details on DHCPv6 statistics and Kea hook points.) .sp Once the probation time elapses, the declined lease is recovered using the standard expired\-lease reclamation procedure, with several additional steps. In particular, both \fBdeclined\-addresses\fP statistics (global and subnet\-specific) are decreased. At the same time, \fBreclaimed\-declined\-addresses\fP statistics (again in two variants, global and subnet\-specific) are increased. .sp A note about statistics: The Kea server does not decrease the \fBassigned\-nas\fP statistics when a DHCPDECLINE message is received and processed successfully. While technically a declined address is no longer assigned, the primary usage of the \fBassigned\-nas\fP statistic is to monitor pool utilization. Most people would forget to include \fBdeclined\-addresses\fP in the calculation, and would simply use \fBassigned\-nas\fP/\fBtotal\-nas\fP\&. This would cause a bias towards under\-representing pool utilization. As this has a potential to cause serious confusion, ISC decided not to decrease \fBassigned\-nas\fP immediately after receiving DHCPDECLINE, but to do it later when Kea recovers the address back to the available pool. .SS Address Registration (RFC 9686 Support) .sp Kea version 2.7.7 introduces the support of self\-generated address registration as defined in \X'tty: link https://tools.ietf.org/html/rfc9686'\fI\%RFC 9686\fP\X'tty: link' i.e. when a valid ADDR\-REG\-INFORM (36) message is received a registered lease is added or updated and a ADDR\-REG\-REPLY (37) is sent back to the client. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Even if they share a common lease database with leases in other states, registered leases are independent: when a lease in another state already exists for an address this address in considered as in use and can\(aqt be registered. Similarly a registered lease can\(aqt change to another state, e.g. reclaimation of expired registered leases removes them. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Kea accepts and handles the Option Request option in the ADDR\-REG\-INFORM message (the RFC specifies the client MUST NOT put such option in it). .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Kea currently only accepts addresses which are \(dqappropriate to the link\(dq but not yet \(dqwithin a prefix delegated to the client\(dq which is not compatible with the way the topology is described in the Kea configuration. .UNINDENT .UNINDENT .SS Statistics in the DHCPv6 Server .sp The DHCPv6 server supports the following statistics: .SS DHCPv6 statistics .TS box center; l|l|l. T{ Statistic T} T{ Data Type T} T{ Description T} _ T{ pkt6\-received T} T{ integer T} T{ Number of DHCPv6 packets received. This includes all packets: valid, bogus, corrupted, rejected, etc. This statistic is expected to grow rapidly. T} _ T{ pkt6\-receive\-drop T} T{ integer T} T{ Number of incoming packets that were dropped. The exact reason for dropping packets is logged, but the most common reasons may be that an unacceptable or not\-supported packet type is received, direct responses are forbidden, the server ID sent by the client does not match the server\(aqs server ID, or the packet is malformed. T} _ T{ pkt6\-parse\-failed T} T{ integer T} T{ Number of incoming packets that could not be parsed. A non\-zero value of this statistic indicates that the server received a malformed or truncated packet. This may indicate problems in the network, faulty clients, faulty relay agents, or a bug in the server. T} _ T{ pkt6\-solicit\-received T} T{ integer T} T{ Number of SOLICIT packets received. This statistic is expected to grow; its increase means that clients that just booted started their configuration process and their initial packets reached the Kea server. T} _ T{ pkt6\-advertise\-received T} T{ integer T} T{ Number of ADVERTISE packets received. ADVERTISE packets are sent by the server and the server is never expected to receive them; a non\-zero value of this statistic indicates an error occurring in the network. One likely cause would be a misbehaving relay agent that incorrectly forwards ADVERTISE messages towards the server, rather than back to the clients. T} _ T{ pkt6\-request\-received T} T{ integer T} T{ Number of DHCPREQUEST packets received. This statistic is expected to grow. Its increase means that clients that just booted received the server\(aqs response (DHCPADVERTISE) and accepted it, and are now requesting an address (DHCPREQUEST). T} _ T{ pkt6\-reply\-received T} T{ integer T} T{ Number of REPLY packets received. This statistic is expected to remain zero at all times, as REPLY packets are sent by the server and the server is never expected to receive them. A non\-zero value indicates an error. One likely cause would be a misbehaving relay agent that incorrectly forwards REPLY messages towards the server, rather than back to the clients. T} _ T{ pkt6\-renew\-received T} T{ integer T} T{ Number of RENEW packets received. This statistic is expected to grow; its increase means that clients received their addresses and prefixes and are trying to renew them. T} _ T{ pkt6\-rebind\-received T} T{ integer T} T{ Number of REBIND packets received. A non\-zero value indicates that clients did not receive responses to their RENEW messages (through the regular lease\-renewal mechanism) and are attempting to find any server that is able to take over their leases. It may mean that some servers\(aq REPLY messages never reached the clients. T} _ T{ pkt6\-release\-received T} T{ integer T} T{ Number of RELEASE packets received. This statistic is expected to grow when a device is being shut down in the network; it indicates that the address or prefix assigned is reported as no longer needed. Note that many devices, especially wireless, do not send RELEASE packets either because of design choices or due to the client moving out of range. T} _ T{ pkt6\-decline\-received T} T{ integer T} T{ Number of DECLINE packets received. This statistic is expected to remain close to zero. Its increase means that a client leased an address, but discovered that the address is currently used by an unknown device in the network. If this statistic is growing, it may indicate a misconfigured server or devices that have statically assigned conflicting addresses. T} _ T{ pkt6\-infrequest\-received T} T{ integer T} T{ Number of INFORMATION\-REQUEST packets received. This statistic is expected to grow if there are devices that are using stateless DHCPv6. INFORMATION\-REQUEST messages are used by clients that request stateless configuration, i.e. options and parameters other than addresses or prefixes. T} _ T{ pkt6\-dhcpv4\-query\-received T} T{ integer T} T{ Number of DHCPv4\-QUERY packets received. This statistic is expected to grow if there are devices that are using DHCPv4\-over\-DHCPv6. DHCPv4\-QUERY messages are used by DHCPv4 clients on an IPv6\-only line which encapsulates the requests over DHCPv6. T} _ T{ pkt6\-dhcpv4\-response\-received T} T{ integer T} T{ Number of DHCPv4\-RESPONSE packets received. This statistic is expected to remain zero at all times, as DHCPv4\-RESPONSE packets are sent by the server and the server is never expected to receive them. A non\-zero value indicates an error. One likely cause would be a misbehaving relay agent that incorrectly forwards DHCPv4\-RESPONSE message towards the server rather than back to the clients. T} _ T{ pkt6\-addr\-reg\-inform\-received T} T{ integer T} T{ Number of ADDR\-REG\-INFORM packets received. This statistic is expected to grow if there are devices that are using address registration. T} _ T{ pkt6\-addr\-reg\-reply\-received T} T{ integer T} T{ Number of ADDR\-REG\-REPLY packets received. This statistic is expected to remain zero at all times, as ADDR\-REG\-REPLY packets are sent by the server and the server is never expected to receive them. A non\-zero value indicates an error. One likely cause would be a misbehaving relay agent that incorrectly forwards ADDR\-REG\-REPLY message towards the server rather than back to the clients. T} _ T{ pkt6\-unknown\-received T} T{ integer T} T{ Number of packets received of an unknown type. A non\-zero value of this statistic indicates that the server received a packet that it was unable to recognize; either it had an unsupported type or was possibly malformed. T} _ T{ pkt6\-sent T} T{ integer T} T{ Number of DHCPv6 packets sent. This statistic is expected to grow every time the server transmits a packet. In general, it should roughly match \fBpkt6\-received\fP, as most incoming packets cause the server to respond. There are exceptions (e.g. a server receiving a REQUEST with server ID matching another server), so do not worry if it is less than \fBpkt6\-received\fP\&. T} _ T{ pkt6\-advertise\-sent T} T{ integer T} T{ Number of ADVERTISE packets sent. This statistic is expected to grow in most cases after a SOLICIT is processed. There are certain uncommon but valid cases where incoming SOLICIT packets are dropped, but in general this statistic is expected to be close to \fBpkt6\-solicit\-received\fP\&. T} _ T{ pkt6\-reply\-sent T} T{ integer T} T{ Number of REPLY packets sent. This statistic is expected to grow in most cases after a SOLICIT (with rapid\-commit), REQUEST, RENEW, REBIND, RELEASE, DECLINE, or INFORMATION\-REQUEST is processed. There are certain cases where there is no response. T} _ T{ pkt6\-dhcpv4\-response\-sent T} T{ integer T} T{ Number of DHCPv4\-RESPONSE packets sent. This statistic is expected to grow in most cases after a DHCPv4\-QUERY is processed. There are certain cases where there is no response. T} _ T{ pkt6\-addr\-reg\-reply\-sent T} T{ integer T} T{ Number of ADDR\-REG\-REPLY packets sent. This statistic is expected to grow in most cases after a ADDR\-REG\-INFORM is processed. There are certain cases where there is n response. T} _ T{ subnet[id].total\-nas T} T{ big integer T} T{ Total number of NA addresses available for DHCPv6 management for a given subnet; in other words, this is the count of all addresses in all configured pools. This statistic changes only during configuration changes. It does not take into account any addresses that may be reserved due to host reservation. The \fIid\fP is the subnet ID of a given subnet. This statistic is exposed for each subnet separately, and is reset during a reconfiguration event. T} _ T{ subnet[id].pool[pid].total\-nas T} T{ big integer T} T{ Total number of NA addresses available for DHCPv6 management for a given subnet pool; in other words, this is the count of all addresses in configured subnet pool. This statistic changes only during configuration changes. It does not take into account any addresses that may be reserved due to host reservation. The \fIid\fP is the subnet ID of a given subnet. The \fIpid\fP is the pool ID of a given pool. This statistic is exposed for each subnet pool separately, and is reset during a reconfiguration event. T} _ T{ cumulative\-assigned\-nas T} T{ integer T} T{ Cumulative number of NA addresses that have been assigned since server startup. It is incremented each time a NA address is assigned and is not reset when the server is reconfigured. T} _ T{ subnet[id].cumulative\-assigned\-nas T} T{ integer T} T{ Cumulative number of NA addresses in a given subnet that were assigned. It increases every time a new lease is allocated (as a result of receiving a REQUEST message) and is never decreased. The \fIid\fP is the subnet ID of a given subnet. This statistic is exposed for each subnet separately, and is reset during a reconfiguration event. T} _ T{ subnet[id].pool[pid].cumulative\-assigned\-nas T} T{ integer T} T{ Cumulative number of NA addresses in a given subnet pool that were assigned. It increases every time a new lease is allocated (as a result of receiving a REQUEST message) and is never decreased. The \fIid\fP is the subnet ID of a given subnet. The \fIpid\fP is the pool ID of a given pool. This statistic is exposed for each subnet pool separately, and is reset during a reconfiguration event. T} _ T{ subnet[id].assigned\-nas T} T{ integer T} T{ Number of NA addresses in a given subnet that are assigned. It increases every time a new lease is allocated (as a result of receiving a REQUEST message) and is decreased every time a lease is released (a RELEASE message is received) or expires. The \fIid\fP is the subnet ID of a given subnet. This statistic is exposed for each subnet separately, and is reset during a reconfiguration event. T} _ T{ subnet[id].pool[pid].assigned\-nas T} T{ integer T} T{ Number of NA addresses in a given subnet pool that are assigned. It increases every time a new lease is allocated (as a result of receiving a REQUEST message) and is decreased every time a lease is released (a RELEASE message is received) or expires. The \fIid\fP is the subnet ID of a given subnet. The \fIpid\fP is the pool ID of the pool. This statistic is exposed for each subnet pool separately, and is reset during a reconfiguration event. T} _ T{ subnet[id].total\-pds T} T{ big integer T} T{ Total number of PD prefixes available for DHCPv6 management for a given subnet; in other words, this is the count of all prefixes in all configured pools. This statistic changes only during configuration changes. Note that it does not take into account any prefixes that may be reserved due to host reservation. The \fIid\fP is the subnet ID of a given subnet. This statistic is exposed for each subnet separately, and is reset during a reconfiguration event. T} _ T{ subnet[id].pd\-pool[pid].total\-pds T} T{ big integer T} T{ Total number of PD prefixes available for DHCPv6 management for a given subnet pool; in other words, this is the count of all prefixes in a configured subnet PD pool. This statistic changes only during configuration changes. It does not take into account any prefixes that may be reserved due to host reservation. The \fIid\fP is the subnet ID of a given subnet. The \fIpid\fP is the pool ID of a given pool. This statistic is exposed for each subnet PD pool separately, and is reset during a reconfiguration event. T} _ T{ cumulative\-assigned\-pds T} T{ integer T} T{ Cumulative number of PD prefixes that have been assigned since server startup. It is incremented each time a PD prefix is assigned and is not reset when the server is reconfigured. T} _ T{ subnet[id].cumulative\-assigned\-pds T} T{ integer T} T{ Cumulative number of PD prefixes in a given subnet that were assigned. It increases every time a new lease is allocated (as a result of receiving a REQUEST message) and is never decreased. The \fIid\fP is the subnet ID of a given subnet. This statistic is exposed for each subnet separately, and is reset during a reconfiguration event. T} _ T{ subnet[id].pd\-pool[pid].cumulative\-assigned\-pds T} T{ integer T} T{ Cumulative number of PD prefixes in a given subnet PD pool that were assigned. It increases every time a new lease is allocated (as a result of receiving a REQUEST message) and is never decreased. The \fIid\fP is the subnet ID of a given subnet. The \fIpid\fP is the pool ID of a given PD pool. This statistic is exposed for each subnet PD pool separately, and is reset during a reconfiguration event. T} _ T{ subnet[id].assigned\-pds T} T{ integer T} T{ Number of PD prefixes in a given subnet that are assigned. It increases every time a new lease is allocated (as a result of receiving a REQUEST message) and is decreased every time a lease is released (a RELEASE message is received) or expires. The \fIid\fP is the subnet ID of a given subnet. This statistic is exposed for each subnet separately, and is reset during a reconfiguration event. T} _ T{ subnet[id].pd\-pool[pid].assigned\-pds T} T{ integer T} T{ Number of PD prefixes in a given subnet pd\-pool that are assigned. It increases every time a new lease is allocated (as a result of receiving a REQUEST message) and is decreased every time a lease is released (a RELEASE message is received) or expires. The \fIid\fP is the subnet ID of a given subnet. The \fIpid\fP is the pool ID of the PD pool. This statistic is exposed for each subnet PD pool separately, and is reset during a reconfiguration event. T} _ T{ reclaimed\-leases T} T{ integer T} T{ Number of expired leases that have been reclaimed since server startup. It is incremented each time an expired lease is reclaimed (counting both NA and PD reclamations). This statistic never decreases. It can be used as a long\-term indicator of how many actual leases have been reclaimed. This is a global statistic that covers all subnets. T} _ T{ subnet[id].reclaimed\-leases T} T{ integer T} T{ Number of expired leases associated with a given subnet that have been reclaimed since server startup. It is incremented each time an expired lease is reclaimed (counting both NA and PD reclamations). The \fIid\fP is the subnet ID of a given subnet. This statistic is exposed for each subnet separately. T} _ T{ subnet[id].pool[pid].reclaimed\-leases T} T{ integer T} T{ Number of expired NA addresses associated with a given subnet pool that have been reclaimed since server startup. It is incremented each time an expired lease is reclaimed. The \fIid\fP is the subnet ID of a given subnet. The \fIpid\fP is the pool ID of the pool. This statistic is exposed for each subnet pool separately, and is reset during a reconfiguration event. T} _ T{ subnet[id].pd\-pool[pid].reclaimed\-leases T} T{ integer T} T{ Number of expired PD prefixes associated with a given subnet PD pool that have been reclaimed since server startup. It is incremented each time an expired lease is reclaimed. The \fIid\fP is the subnet ID of a given subnet. The \fIpid\fP is the pool ID of the PD pool. This statistic is exposed for each subnet PD pool separately, and is reset during a reconfiguration event. T} _ T{ declined\-addresses T} T{ integer T} T{ Number of IPv6 addresses that are currently declined; a count of the number of leases currently unavailable. Once a lease is recovered, this statistic is decreased; ideally, this statistic should be zero. If this statistic is non\-zero or increasing, a network administrator should investigate whether there is a misbehaving device in the network. This is a global statistic that covers all subnets. T} _ T{ subnet[id].declined\-addresses T} T{ integer T} T{ Number of IPv6 addresses that are currently declined in a given subnet; a count of the number of leases currently unavailable. Once a lease is recovered, this statistic is decreased; ideally, this statistic should be zero. If this statistic is non\-zero or increasing, a network administrator should investigate whether there is a misbehaving device in the network. The \fIid\fP is the subnet ID of a given subnet. This statistic is exposed for each subnet separately. T} _ T{ subnet[id].pool[pid].declined\-addresses T} T{ integer T} T{ Number of IPv6 addresses that are currently declined in a given subnet pool; a count of the number of leases currently unavailable. Once a lease is recovered, this statistic is decreased; ideally, this statistic should be zero. If this statistic is non\-zero or increasing, a network administrator should investigate whether there is a misbehaving device in the network. The \fIid\fP is the subnet ID of a given subnet. The \fIpid\fP is the pool ID of the pool. This statistic is exposed for each subnet pool separately. T} _ T{ reclaimed\-declined\-addresses T} T{ integer T} T{ Number of IPv6 addresses that were declined, but have now been recovered. Unlike \fBdeclined\-addresses\fP, this statistic never decreases. It can be used as a long\-term indicator of how many actual valid declines were processed and recovered from. This is a global statistic that covers all subnets. T} _ T{ subnet[id].reclaimed\-declined\-addresses T} T{ integer T} T{ Number of IPv6 addresses that were declined, but have now been recovered. Unlike \fBdeclined\-addresses\fP, this statistic never decreases. It can be used as a long\-term indicator of how many actual valid declines were processed and recovered from. The \fIid\fP is the subnet ID of a given subnet. This statistic is exposed for each subnet separately. T} _ T{ subnet[id].pool[pid].reclaimed\-declined\-addresses T} T{ integer T} T{ Number of IPv6 addresses that were declined, but have now been recovered. Unlike \fBdeclined\-addresses\fP, this statistic never decreases. It can be used as a long\-term indicator of how many actual valid declines were processed and recovered from. The \fIid\fP is the subnet ID of a given subnet. The \fIpid\fP is the pool ID of the pool. This statistic is exposed for each subnet pool separately. T} _ T{ v6\-allocation\-fail T} T{ integer T} T{ Number of total address allocation failures for a particular client. This consists of the number of lease allocation attempts that the server made before giving up, if it was unable to use any of the address pools. This is a global statistic that covers all subnets. T} _ T{ subnet[id].v6\-allocation\-fail T} T{ integer T} T{ Number of total address allocation failures for a particular client. This consists of the number of lease allocation attempts that the server made before giving up, if it was unable to use any of the address pools. The \fIid\fP is the subnet ID of a given subnet. This statistic is exposed for each subnet separately. T} _ T{ v6\-allocation\-fail\-shared\-network T} T{ integer T} T{ Number of address allocation failures for a particular client connected to a shared network. This is a global statistic that covers all subnets. T} _ T{ subnet[id].v6\-allocation\-fail\-shared\-network T} T{ integer T} T{ Number of address allocation failures for a particular client connected to a shared network. The \fIid\fP is the subnet ID of a given subnet. This statistic is exposed for each subnet separately. T} _ T{ v6\-allocation\-fail\-subnet T} T{ integer T} T{ Number of address allocation failures for a particular client connected to a subnet that does not belong to a shared network. This is a global statistic that covers all subnets. T} _ T{ subnet[id].v6\-allocation\-fail\-subnet T} T{ integer T} T{ Number of address allocation failures for a particular client connected to a subnet that does not belong to a shared network. The \fIid\fP is the subnet ID of a given subnet. This statistic is exposed for each subnet separately. T} _ T{ v6\-allocation\-fail\-no\-pools T} T{ integer T} T{ Number of address allocation failures because the server could not use any configured pools for a particular client. It is also possible that all of the subnets from which the server attempted to assign an address lack address pools. In this case, it should be considered misconfiguration if an operator expects that some clients should be assigned dynamic addresses. This is a global statistic that covers all subnets. T} _ T{ subnet[id].v6\-allocation\-fail\-no\-pools T} T{ integer T} T{ Number of address allocation failures because the server could not use any configured pools for a particular client. It is also possible that all of the subnets from which the server attempted to assign an address lack address pools. In this case, it should be considered misconfiguration if an operator expects that some clients should be assigned dynamic addresses. The \fIid\fP is the subnet ID of a given subnet. This statistic is exposed for each subnet separately. T} _ T{ v6\-allocation\-fail\-classes T} T{ integer T} T{ Number of address allocation failures when the client\(aqs packet belongs to one or more classes. There may be several reasons why a lease was not assigned: for example, if all pools require packets to belong to certain classes and the incoming packet does not belong to any. Another case where this information may be useful is to indicate that the pool reserved for a given class has run out of addresses. This is a global statistic that covers all subnets. T} _ T{ subnet[id].v6\-allocation\-fail\-classes T} T{ integer T} T{ Number of address allocation failures when the client\(aqs packet belongs to one or more classes. There may be several reasons why a lease was not assigned: for example, if all pools require packets to belong to certain classes and the incoming packet does not belong to any Another case where this information may be useful is to indicate that the pool reserved for a given class has run out of addresses. The \fIid\fP is the subnet ID of a given subnet. This statistic is exposed for each subnet separately. T} _ T{ v6\-ia\-na\-lease\-reuses T} T{ integer T} T{ Number of times an IA_NA lease had its CLTT increased in memory and its expiration time left unchanged in persistent storage, as part of the lease caching feature. This is referred to as a lease reuse. This statistic is global. T} _ T{ subnet[id].v6\-ia\-na\-lease\-reuses T} T{ integer T} T{ Number of times an IA_NA lease had its CLTT increased in memory and its expiration time left unchanged in persistent storage, as part of the lease caching feature. This is referred to as a lease reuse. This statistic is on a per\-subnet basis. The \fIid\fP is the subnet ID of a given subnet. T} _ T{ v6\-ia\-pd\-lease\-reuses T} T{ integer T} T{ Number of times an IA_PD lease had its CLTT increased in memory and its expiration time left unchanged in persistent storage, as part of the lease caching feature. This is referred to as a lease reuse. This statistic is global. T} _ T{ subnet[id].v6\-ia\-pd\-lease\-reuses T} T{ integer T} T{ Number of times an IA_PD lease had its CLTT increased in memory and its expiration time left unchanged in persistent storage, as part of the lease caching feature. This is referred to as a lease reuse. This statistic is on a per\-subnet basis. The \fIid\fP is the subnet ID of a given subnet. T} _ T{ cumulative\-registered T} T{ integer T} T{ Cumulative number of NA addresses that have been registered since server startup. It is incremented each time a NA address is registered and is not reset when the server is reconfigured. T} _ T{ subnet[id].cumulative\-registered T} T{ integer T} T{ Cumulative number of NA addresses in a given subnet that were registered. It increases every time a new address is registered (as a result of receiving an ADDR\-REG\-INFORM message) and is never decreased. The \fIid\fP is the subnet ID of a given subnet. This statistic is exposed for each subnet separately, and is reset during a reconfiguration event. T} _ T{ subnet[id].registered T} T{ integer T} T{ Number of NA addresses in a given subnet that are registered. It increases every time a new address registered (as a result of receiving an ADDR\-REG\-INFORM message) and is decreased every time a registration expires. The \fIid\fP is the the subnet ID of a given subnet. This statistic is exposed for each subnet separately, and is reset during a reconfiguration event. T} .TE .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The pool ID can be configured on each pool by explicitly setting the \fBpool\-id\fP parameter in the pool parameter map. If not configured, \fBpool\-id\fP defaults to 0. The statistics related to pool ID 0 refer to all the statistics of all the pools that have an unconfigured \fBpool\-id\fP\&. The pool ID does not need to be unique within the subnet or across subnets. The statistics regarding a specific pool ID within a subnet are combined with the other statistics of all other pools with the same pool ID in the respective subnet. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 This section describes DHCPv6\-specific statistics. For a general overview and usage of statistics, see \fI\%Statistics\fP\&. .UNINDENT .UNINDENT .sp The DHCPv6 server provides two global parameters to control the default sample limits of statistics: .INDENT 0.0 .IP \(bu 2 \fBstatistic\-default\-sample\-count\fP \- determines the default maximum number of samples to be kept. The special value of 0 indicates that a default maximum age should be used. .IP \(bu 2 \fBstatistic\-default\-sample\-age\fP \- determines the default maximum age, in seconds, of samples to be kept. .UNINDENT .sp For instance, to reduce the statistic\-keeping overhead, set the default maximum sample count to 1 so only one sample is kept: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqstatistic\-default\-sample\-count\(dq: 1, \(dqsubnet6\(dq: [ { ... }, ... ], ... } .EE .UNINDENT .UNINDENT .sp Statistics can be retrieved periodically to gain more insight into Kea operations. One tool that leverages that capability is ISC Stork. See \fI\%Monitoring Kea With Stork\fP for details. .SS Management API for the DHCPv6 Server .sp The management API allows the issuing of specific management commands, such as statistics retrieval, reconfiguration, or shutdown. For more details, see \fI\%Management API\fP\&. By default there are no sockets open; to instruct Kea to open a socket, the following entry in the configuration file can be used: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqcontrol\-sockets\(dq: [ { \(dqsocket\-type\(dq: \(dqunix\(dq, \(dqsocket\-name\(dq: \(dq/path/to/the/unix/socket\(dq } ], \(dqsubnet6\(dq: [ { ... }, ... ], ... } .EE .UNINDENT .UNINDENT .SS UNIX Control Socket .sp Until Kea server 2.7.2 the only supported communication channel type was the UNIX stream socket with \fBsocket\-type\fP set to \fBunix\fP and \fBsocket\-name\fP to the file path of the UNIX/LOCAL socket. .sp The length of the path specified by the \fBsocket\-name\fP parameter is restricted by the maximum length for the UNIX socket name on the administrator\(aqs operating system, i.e. the size of the \fBsun_path\fP field in the \fBsockaddr_un\fP structure, decreased by 1. This value varies on different operating systems, between 91 and 107 characters. Typical values are 107 on Linux and 103 on FreeBSD. .sp Kea supports only one \fBunix\fP control socket in the \(dqcontrol\-sockets\(dq list. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 As of Kea 2.7.9, control sockets may only reside in the directory determined during compilation as \fB\(dq[kea\-install\-dir]/var/run/kea\(dq\fP, which must also have \fB0750\fP access rights. This path may be overridden at startup by setting the environment variable \fBKEA_CONTROL_SOCKET_DIR\fP to the desired path. If a path other than this value is used in \fBsocket\-name\fP, Kea will emit an error and refuse to start or, if already running, log an unrecoverable error. For ease of use in simply omit the path component from \fBsocket\-name\fP\&. .UNINDENT .UNINDENT .sp Communication over the control channel is conducted using JSON structures. See the \X'tty: link https://reports.kea.isc.org/dev_guide/d2/d96/ctrlSocket.html'\fI\%Control Channel section in the Kea Developer\(aqs Guide\fP\X'tty: link' for more details. .sp The DHCPv6 server supports the following operational commands: .INDENT 0.0 .IP \(bu 2 \fI\%build\-report\fP .IP \(bu 2 \fI\%config\-get\fP .IP \(bu 2 \fI\%config\-hash\-get\fP .IP \(bu 2 \fI\%config\-reload\fP .IP \(bu 2 \fI\%config\-set\fP .IP \(bu 2 \fI\%config\-test\fP .IP \(bu 2 \fI\%config\-write\fP .IP \(bu 2 \fI\%dhcp\-disable\fP .IP \(bu 2 \fI\%dhcp\-enable\fP .IP \(bu 2 \fI\%leases\-reclaim\fP .IP \(bu 2 \fI\%list\-commands\fP .IP \(bu 2 \fI\%shutdown\fP .IP \(bu 2 \fI\%status\-get\fP .IP \(bu 2 \fI\%version\-get\fP .UNINDENT .sp as described in \fI\%Commands Supported by Both the DHCPv4 and DHCPv6 Servers\fP\&. In addition, it supports the following statistics\-related commands: .INDENT 0.0 .IP \(bu 2 \fI\%statistic\-get\fP .IP \(bu 2 \fI\%statistic\-reset\fP .IP \(bu 2 \fI\%statistic\-remove\fP .IP \(bu 2 \fI\%statistic\-get\fP\-all .IP \(bu 2 \fI\%statistic\-reset\fP\-all .IP \(bu 2 \fI\%statistic\-remove\fP\-all .IP \(bu 2 \fI\%statistic\-sample\-age\-set\fP .IP \(bu 2 \fI\%statistic\-sample\-age\-set\fP\-all .IP \(bu 2 \fI\%statistic\-sample\-count\-set\fP .IP \(bu 2 \fI\%statistic\-sample\-count\-set\fP\-all .UNINDENT .sp as described in \fI\%Commands for Manipulating Statistics\fP\&. .SS HTTP/HTTPS Control Socket .sp The \fBsocket\-type\fP must be \fBhttp\fP or \fBhttps\fP (when the type is \fBhttps\fP TLS is required). The \fBsocket\-address\fP (default \fB::1\fP) and \fBsocket\-port\fP (default 8000) specify an IP address and port to which the HTTP service will be bound. .sp Since Kea 2.7.5 the \fBhttp\-headers\fP parameter specifies a list of extra HTTP headers to add to HTTP responses. .sp The \fBtrust\-anchor\fP, \fBcert\-file\fP, \fBkey\-file\fP, and \fBcert\-required\fP parameters specify the TLS setup for HTTP, i.e. HTTPS. If these parameters are not specified, HTTP is used. The TLS/HTTPS support in Kea is described in \fI\%TLS/HTTPS Support\fP\&. .sp Basic HTTP authentication protects against unauthorized uses of the control agent by local users. For protection against remote attackers, HTTPS and reverse proxy of \fI\%Secure Connections\fP provide stronger security. .sp The authentication is described in the \fBauthentication\fP block with the mandatory \fBtype\fP parameter, which selects the authentication. Currently only the basic HTTP authentication (type basic) is supported. .sp The \fBrealm\fP authentication parameter (default \fBkea\-dhcpv6\-server\fP is used for error messages when the basic HTTP authentication is required but the client is not authorized. .sp When the \fBclients\fP authentication list is configured and not empty, basic HTTP authentication is required. Each element of the list specifies a user ID and a password. The user ID is mandatory, must not be empty, and must not contain the colon (:) character. The password is optional; when it is not specified an empty password is used. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The basic HTTP authentication user ID and password are encoded in UTF\-8, but the current Kea JSON syntax only supports the Latin\-1 (i.e. 0x00..0xff) Unicode subset. .UNINDENT .UNINDENT .sp To avoid exposing the user ID and/or the associated password, these values can be read from files. The syntax is extended by: .INDENT 0.0 .IP \(bu 2 The \fBdirectory\fP authentication parameter, which handles the common part of file paths. The default value is the empty string. .IP \(bu 2 The \fBpassword\-file\fP client parameter, which, alongside the \fBdirectory\fP parameter, specifies the path of a file that can contain the password, or when no user ID is given, the whole basic HTTP authentication secret. .IP \(bu 2 The \fBuser\-file\fP client parameter, which, with the \fBdirectory\fP parameter, specifies the path of a file where the user ID can be read. .UNINDENT .sp Since Kea\-2.7.6 Kea supports multiple HTTP/HTTPS connections. Both IPv4 and IPv6 addresses can be used. The server will issue an error when changing the socket type from HTTP to HTTPS or from HTTPS to HTTP using the same address and port. This action is not allowed as it might introduce a security issue accidentally caused by a user mistake. A different address or port must be specified when using the \(dqconfig\-set\(dq command to switch from HTTP to HTTPS or from HTTPS to HTTP. The same applies when modyfying the configuration file and then running \(dqconfig\-reload\(dq command. .sp When files are used, they are read when the configuration is loaded, to detect configuration errors as soon as possible. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqcontrol\-sockets\(dq: [ { \(dqsocket\-type\(dq: \(dqhttps\(dq, \(dqsocket\-address\(dq: \(dq2010:30:40::50\(dq, \(dqsocket\-port\(dq: 8005, \(dqhttp\-headers\(dq: [ { \(dqname\(dq: \(dqStrict\-Transport\-Security\(dq, \(dqvalue\(dq: \(dqmax\-age=31536000\(dq } ], \(dqtrust\-anchor\(dq: \(dq/path/to/the/ca\-cert.pem\(dq, \(dqcert\-file\(dq: \(dq/path/to/the/agent\-cert.pem\(dq, \(dqkey\-file\(dq: \(dq/path/to/the/agent\-key.pem\(dq, \(dqcert\-required\(dq: true, \(dqauthentication\(dq: { \(dqtype\(dq: \(dqbasic\(dq, \(dqrealm\(dq: \(dqkea\-control\-agent\(dq, \(dqclients\(dq: [ { \(dquser\(dq: \(dqadmin\(dq, \(dqpassword\(dq: \(dq1234\(dq } ] } }, { \(dqsocket\-type\(dq: \(dqhttp\(dq, \(dqsocket\-address\(dq: \(dq10.20.30.40\(dq, \(dqsocket\-port\(dq: 8005 } ], \(dqsubnet6\(dq: [ { ... }, ... ], ... } .EE .UNINDENT .UNINDENT .SS User Contexts in IPv6 .sp Kea allows the loading of hook libraries that can sometimes benefit from additional parameters. If such a parameter is specific to the whole library, it is typically defined as a parameter for the hook library. However, sometimes there is a need to specify parameters that are different for each pool. .sp See \fI\%Comments and User Context\fP for additional background regarding the user\-context idea. See \fI\%User Contexts in Hooks\fP for a discussion from the hooks perspective. .sp User contexts can be specified at global scope; at the shared\-network, subnet, pool, client\-class, option\-data, or definition level; and via host reservation. One other useful feature is the ability to store comments or descriptions. .sp Let\(aqs consider an example deployment of lightweight 4over6, an IPv6 transition technology that allows mapping IPv6 prefixes into full or partial IPv4 addresses. In the DHCP context, these are specific parameters that are supposed to be delivered to clients in the form of additional options. Values of these options are correlated to delegated prefixes, so it is reasonable to keep these parameters together with the prefix delegation (PD) pool. On the other hand, lightweight 4over6 is not a commonly used feature, so it is not a part of the base Kea code. The solution to this problem is to specify a user context. For each PD pool that is expected to be used for lightweight 4over6, a user context with extra parameters is defined. Those extra parameters will be used by a hook library and loaded only when dynamic calculation of the lightweight 4over6 option is actually needed. An example configuration looks as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqsubnet6\(dq: [ { \(dqpd\-pools\(dq: [ { \(dqprefix\(dq: \(dq2001:db8::\(dq, \(dqprefix\-len\(dq: 56, \(dqdelegated\-len\(dq: 64, # This is a pool\-specific context. \(dquser\-context\(dq: { \(dqthreshold\-percent\(dq: 85, \(dqv4\-network\(dq: \(dq192.168.0.0/16\(dq, \(dqv4\-overflow\(dq: \(dq10.0.0.0/16\(dq, \(dqlw4over6\-sharing\-ratio\(dq: 64, \(dqlw4over6\-v4\-pool\(dq: \(dq192.0.2.0/24\(dq, \(dqlw4over6\-sysports\-exclude\(dq: true, \(dqlw4over6\-bind\-prefix\-len\(dq: 56 } } ], \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq2001:db8::/32\(dq, # This is a subnet\-specific context. Any type of # information can be entered here as long as it is valid JSON. \(dquser\-context\(dq: { \(dqcomment\(dq: \(dqThose v4\-v6 migration technologies are tricky.\(dq, \(dqexperimental\(dq: true, \(dqbilling\-department\(dq: 42, \(dqcontacts\(dq: [ \(dqAlice\(dq, \(dqBob\(dq ] } } ] } .EE .UNINDENT .UNINDENT .sp Kea does not interpret or use the user\-context information; it simply stores it and makes it available to the hook libraries. It is up to each hook library to extract that information and use it. The parser translates a \fBcomment\fP entry into a user context with the entry, which allows a comment to be attached inside the configuration itself. .SS Supported DHCPv6 Standards .sp The following standards are currently supported in Kea: .INDENT 0.0 .IP \(bu 2 \fIDynamic Host Configuration Protocol for IPv6\fP, \X'tty: link https://tools.ietf.org/html/rfc3315'\fI\%RFC 3315\fP\X'tty: link': Supported messages are SOLICIT, ADVERTISE, REQUEST, RELEASE, RENEW, REBIND, INFORMATION\-REQUEST, CONFIRM, DECLINE and REPLY. The only unsupported message is RECONFIGURE. Almost all options are supported, except AUTHENTICATION and RECONFIGURE\-ACCEPT. .IP \(bu 2 \fIDynamic Host Configuration Protocol (DHCPv6) Options for Session Initiation Protocol (SIP) Servers\fP, \X'tty: link https://tools.ietf.org/html/rfc3319'\fI\%RFC 3319\fP\X'tty: link': All defined options are supported. .IP \(bu 2 \fIIPv6 Prefix Options for Dynamic Host Configuration Protocol (DHCP) version 6\fP, \X'tty: link https://tools.ietf.org/html/rfc3633'\fI\%RFC 3633\fP\X'tty: link': Supported options are IA_PD and IA_PREFIX. Also supported is the status code NoPrefixAvail. .IP \(bu 2 \fIDNS Configuration options for Dynamic Host Configuration Protocol for IPv6 (DHCPv6)\fP, \X'tty: link https://tools.ietf.org/html/rfc3646'\fI\%RFC 3646\fP\X'tty: link': All defined options are supported. .IP \(bu 2 \fIStateless Dynamic Host Configuration Protocol (DHCP) Service for IPv6\fP, \X'tty: link https://tools.ietf.org/html/rfc3736'\fI\%RFC 3736\fP\X'tty: link': Server operation in stateless mode is supported. Kea is currently server\-only, so the client side is not implemented. .IP \(bu 2 \fISimple Network Time Protocol (SNTP) Configuration Option for DHCPv6\fP, \X'tty: link https://tools.ietf.org/html/rfc4075'\fI\%RFC 4075\fP\X'tty: link': The SNTP option is supported. .IP \(bu 2 \fIRenumbering Requirements for Stateless Dynamic Host Configuration Protocol for IPv6 (DHCPv6)\fP, \X'tty: link https://tools.ietf.org/html/rfc4076'\fI\%RFC 4076\fP\X'tty: link': The server supports all the stateless renumbering requirements. .IP \(bu 2 \fIInformation Refresh Time Option for Dynamic Host Configuration Protocol for IPv6 (DHCPv6)\fP, \X'tty: link https://tools.ietf.org/html/rfc4242'\fI\%RFC 4242\fP\X'tty: link': The sole defined option (\fBinformation\-refresh\-time\fP) is supported. .IP \(bu 2 \fIDynamic Host Configuration Protocol (DHCP) Options for Broadcast and Multicast Control Servers\fP, \X'tty: link https://tools.ietf.org/html/rfc4280'\fI\%RFC 4280\fP\X'tty: link': The DHCPv6 options are supported. .IP \(bu 2 \fIDynamic Host Configuration Protocol for IPv6 (DHCPv6) Relay Agent Subscriber\-ID Option\fP, \X'tty: link https://tools.ietf.org/html/rfc4580'\fI\%RFC 4580\fP\X'tty: link': The subscribed\-id option is supported and can be used in any expression. .IP \(bu 2 \fIThe Dynamic Host Configuration Protocol for IPv6 (DHCPv6) Relay Agent Remote\-ID Option\fP, \X'tty: link https://tools.ietf.org/html/rfc4649'\fI\%RFC 4649\fP\X'tty: link': The Remote\-ID option is supported. .IP \(bu 2 \fIA DNS Resource Record (RR) for Encoding Dynamic Host Configuration Protocol (DHCP) Information (DHCID RR)\fP, \X'tty: link https://tools.ietf.org/html/rfc4701'\fI\%RFC 4701\fP\X'tty: link': The DHCPv6 server supports DHCID records. The DHCP\-DDNS server must be running to add, update, and/or delete DHCID records. .IP \(bu 2 \fIResolution of Fully Qualified Domain Name (FQDN) Conflicts among Dynamic Host Configuration Protocol (DHCP) Clients\fP, \X'tty: link https://tools.ietf.org/html/rfc4703'\fI\%RFC 4703\fP\X'tty: link': The DHCPv6 server uses the DHCP\-DDNS server to resolve conflicts. .IP \(bu 2 \fIThe Dynamic Host Configuration Protocol for IPv6 (DHCPv6) Client Fully Qualified Domain Name (FQDN) Option\fP, \X'tty: link https://tools.ietf.org/html/rfc4704'\fI\%RFC 4704\fP\X'tty: link': The supported option is CLIENT_FQDN. .IP \(bu 2 \fITimezone Options for DHCP\fP: \X'tty: link https://tools.ietf.org/html/rfc4833'\fI\%RFC 4833\fP\X'tty: link': Both DHCPv6 options are supported. .IP \(bu 2 \fIDHCPv6 Leasequery\fP: \X'tty: link https://tools.ietf.org/html/rfc5007'\fI\%RFC 5007\fP\X'tty: link': The server functionality (message types, options) is supported. This requires the leasequery hook. See \fI\%libdhcp_lease_query.so: Leasequery Support\fP for details. .IP \(bu 2 \fIDHCP Options for Protocol for Carrying Authentication for Network Access (PANA) Authentication Agents\fP: \X'tty: link https://tools.ietf.org/html/rfc5192'\fI\%RFC 5192\fP\X'tty: link': The PANA option is supported. .IP \(bu 2 \fIDiscovering Location\-to\-Service Translation (LoST) Servers Using the Dynamic Host Configuration Protocol (DHCP)\fP: \X'tty: link https://tools.ietf.org/html/rfc5223'\fI\%RFC 5223\fP\X'tty: link': The LOST option is supported. .IP \(bu 2 \fIControl And Provisioning of Wireless Access Points (CAPWAP) Access Controller DHCP Option\fP: \X'tty: link https://tools.ietf.org/html/rfc5417'\fI\%RFC 5417\fP\X'tty: link': The CAPWAP for IPv6 option is supported. .IP \(bu 2 \fIDHCPv6 Bulk Leasequery\fP: \X'tty: link https://tools.ietf.org/html/rfc5460'\fI\%RFC 5460\fP\X'tty: link': The server functionality (TCP connection, new message types and options, new query types) is supported. This requires the leasequery hook. See \fI\%libdhcp_lease_query.so: Leasequery Support\fP for details. .IP \(bu 2 \fINetwork Time Protocol (NTP) Server Option for DHCPv6\fP: \X'tty: link https://tools.ietf.org/html/rfc5908'\fI\%RFC 5908\fP\X'tty: link': The NTP server option and its suboptions are supported. See \fI\%NTP Server Suboptions\fP for details. .IP \(bu 2 \fIDHCPv6 Options for Network Boot\fP: \X'tty: link https://tools.ietf.org/html/rfc5970'\fI\%RFC 5970\fP\X'tty: link': The network boot options are supported. .IP \(bu 2 \fILightweight DHCPv6 Relay Agent\fP, \X'tty: link https://tools.ietf.org/html/rfc6221'\fI\%RFC 6221\fP\X'tty: link': Kea can handle lightweight relay messages and use other methods than link address to perform subnet selection. .IP \(bu 2 \fIDynamic Host Configuration Protocol for IPv6 (DHCPv6) Option for Dual\-Stack Lite\fP, \X'tty: link https://tools.ietf.org/html/rfc6334'\fI\%RFC 6334\fP\X'tty: link': The AFTR\-Name DHCPv6 Option is supported. .IP \(bu 2 \fIRelay\-Supplied DHCP Options\fP, \X'tty: link https://tools.ietf.org/html/rfc6422'\fI\%RFC 6422\fP\X'tty: link': The full functionality is supported, including OPTION_RSOO; the ability of the server to echo back the options; verification of whether an option is RSOO\-enabled; and the ability to mark additional options as RSOO\-enabled. .IP \(bu 2 \fIThe EAP Re\-authentication Protocol (ERP) Local Domain Name DHCPv6 Option\fP, \X'tty: link https://tools.ietf.org/html/rfc6440'\fI\%RFC 6440\fP\X'tty: link': The option is supported. .IP \(bu 2 \fIPrefix Exclude Option for DHCPv6\-based Prefix Delegation\fP, \X'tty: link https://tools.ietf.org/html/rfc6603'\fI\%RFC 6603\fP\X'tty: link': The Prefix Exclude option is supported. .IP \(bu 2 \fIClient Link\-Layer Address Option in DHCPv6\fP, \X'tty: link https://tools.ietf.org/html/rfc6939'\fI\%RFC 6939\fP\X'tty: link': The supported option is the client link\-layer address option. .IP \(bu 2 \fIModification to Default values of SOL_MAX_RT and INF_MAX_RT\fP, \X'tty: link https://tools.ietf.org/html/rfc7083'\fI\%RFC 7083\fP\X'tty: link': The new options are supported. .IP \(bu 2 \fIIssues and Recommendations with Multiple Stateful DHCPv6 Options\fP, \X'tty: link https://tools.ietf.org/html/rfc7550'\fI\%RFC 7550\fP\X'tty: link': All recommendations related to the DHCPv6 server operation are supported. .IP \(bu 2 \fIDHCPv6 Options for Configuration of Softwire Address and Port\-Mapped Clients\fP, \X'tty: link https://tools.ietf.org/html/rfc7598'\fI\%RFC 7598\fP\X'tty: link': All options indicated in this specification are supported by the DHCPv6 server. .IP \(bu 2 \fIGeneralized UDP Source Port for DHCP Relay\fP, \X'tty: link https://tools.ietf.org/html/rfc8357'\fI\%RFC 8357\fP\X'tty: link': The Kea server is able to handle the Relay Source Port option in a received Relay\-forward message, remembers the UDP port, and sends back Relay\-reply with a copy of the option to the relay agent using this UDP port. .IP \(bu 2 \fIDynamic Host Configuration Protocol for IPv6 (DHCPv6)\fP, \X'tty: link https://tools.ietf.org/html/rfc8415'\fI\%RFC 8415\fP\X'tty: link': This new DHCPv6 protocol specification obsoletes RFC 3315, RFC 3633, RFC 3736, RFC 4242, RFC 7083, RFC 7283, and RFC 7550. All features, with the exception of the RECONFIGURE mechanism and the now\-deprecated temporary addresses (IA_TA) mechanism, are supported. .IP \(bu 2 \fICaptive\-Portal Identification in DHCP and Router Advertisements (RAs)\fP, \X'tty: link https://tools.ietf.org/html/rfc8910'\fI\%RFC 8910\fP\X'tty: link': The Kea server can configure both v4 and v6 versions of the captive portal options. .IP \(bu 2 \fIDHCP and Router Advertisement Options for the Discovery of Network\-designated Resolvers (DNR)\fP, \X'tty: link https://tools.ietf.org/html/rfc9463'\fI\%RFC 9463\fP\X'tty: link'\&. The Kea server supports the DNR option. .IP \(bu 2 \fIRegistering Self\-Generated IPv6 Addresses Using DHCPv6\fP, \X'tty: link https://tools.ietf.org/html/rfc9686'\fI\%RFC 9686\fP\X'tty: link'\&. The Kea server supports self\-generated address registration. See \fI\%Address Registration (RFC 9686 Support)\fP for details. .UNINDENT .SS DHCPv6 Server Limitations .sp These are the current known limitations of the Kea DHCPv6 server software. Most of them are reflections of the current stage of development and should be treated as “not yet implemented,” rather than actual limitations. .INDENT 0.0 .IP \(bu 2 The server allocates, renews, or rebinds a maximum of one lease for a particular IA option (IA_NA or IA_PD) sent by a client. \X'tty: link https://tools.ietf.org/html/rfc8415'\fI\%RFC 8415\fP\X'tty: link' allows for multiple addresses or prefixes to be allocated for a single IA. .IP \(bu 2 Temporary addresses are not supported. There is no intention to ever implement this feature, as it is deprecated in \X'tty: link https://tools.ietf.org/html/rfc8415'\fI\%RFC 8415\fP\X'tty: link'\&. .IP \(bu 2 Client reconfiguration (RECONFIGURE) is not yet supported. .UNINDENT .SS Kea DHCPv6 Server Examples .sp A collection of simple\-to\-use examples for the DHCPv6 component of Kea is available with the source files, located in the \fBdoc/examples/kea6\fP directory. .SS Configuration Backend in DHCPv6 .sp In the \fI\%Kea Configuration Backend\fP section we have described the Configuration Backend (CB) feature, its applicability, and its limitations. This section focuses on the usage of the CB with the DHCPv6 server. It lists the supported parameters, describes limitations, and gives examples of DHCPv6 server configurations to take advantage of the CB. Please also refer to the corresponding section \fI\%Configuration Backend in DHCPv4\fP for DHCPv4\-specific usage of the CB. .SS Supported Parameters .sp The ultimate goal for the CB is to serve as a central configuration repository for one or multiple Kea servers connected to a database. In currently supported Kea versions, only a subset of the DHCPv6 server parameters can be configured in the database. All other parameters must be specified in the JSON configuration file, if required. .sp All supported parameters can be configured via \fI\%libdhcp_cb_cmds.so\fP\&. The general rule is that scalar global parameters are set using \fI\%remote\-global\-parameter6\-set\fP; shared\-network\-specific parameters are set using \fI\%remote\-network6\-set\fP; and subnet\-level and pool\-level parameters are set using \fI\%remote\-subnet6\-set\fP\&. Whenever there is an exception to this general rule, it is highlighted in the table. Non\-scalar global parameters have dedicated commands; for example, the global DHCPv6 options (\fBoption\-data\fP) are modified using \fI\%remote\-option6\-global\-set\fP\&. Client classes, together with class\-specific option definitions and DHCPv6 options, are configured using the \fI\%remote\-class6\-set\fP command. .sp The \fI\%Configuration Sharing and Server Tags\fP section explains the concept of shareable and non\-shareable configuration elements and the limitations for sharing them between multiple servers. In the DHCP configuration (both DHCPv4 and DHCPv6), the shareable configuration elements are subnets and shared networks. Thus, they can be explicitly associated with multiple server tags. The global parameters, option definitions, and global options are non\-shareable and can be associated with only one server tag. This rule does not apply to the configuration elements associated with \fBall\fP servers. Any configuration element associated with \fBall\fP servers (using the \fBall\fP keyword as a server tag) is used by all servers connecting to the configuration database. .sp The following table lists DHCPv6\-specific parameters supported by the configuration backend, with an indication of the level of the hierarchy at which it is currently supported. .SS List of DHCPv6 parameters supported by the configuration backend .TS box center; l|l|l|l|l|l|l. T{ Parameter T} T{ Global T} T{ Client Class T} T{ Shared Network T} T{ Subnet T} T{ Pool T} T{ Prefix Delegation Pool T} _ T{ allocator T} T{ yes T} T{ n/a T} T{ yes T} T{ yes T} T{ n/a T} T{ n/a T} _ T{ cache\-max\-age T} T{ yes T} T{ n/a T} T{ no T} T{ no T} T{ n/a T} T{ n/a T} _ T{ cache\-threshold T} T{ yes T} T{ n/a T} T{ no T} T{ no T} T{ n/a T} T{ n/a T} _ T{ calculate\-tee\-times T} T{ yes T} T{ n/a T} T{ yes T} T{ yes T} T{ n/a T} T{ n/a T} _ T{ client\-class T} T{ n/a T} T{ n/a T} T{ yes T} T{ yes T} T{ yes T} T{ yes T} _ T{ ddns\-send\-update T} T{ yes T} T{ n/a T} T{ yes T} T{ yes T} T{ n/a T} T{ n/a T} _ T{ ddns\-override\-no\-update T} T{ yes T} T{ n/a T} T{ yes T} T{ yes T} T{ n/a T} T{ n/a T} _ T{ ddns\-override\-client\-update T} T{ yes T} T{ n/a T} T{ yes T} T{ yes T} T{ n/a T} T{ n/a T} _ T{ ddns\-replace\-client\-name T} T{ yes T} T{ n/a T} T{ yes T} T{ yes T} T{ n/a T} T{ n/a T} _ T{ ddns\-generated\-prefix T} T{ yes T} T{ n/a T} T{ yes T} T{ yes T} T{ n/a T} T{ n/a T} _ T{ ddns\-qualifying\-suffix T} T{ yes T} T{ n/a T} T{ yes T} T{ yes T} T{ n/a T} T{ n/a T} _ T{ decline\-probation\-period T} T{ yes T} T{ n/a T} T{ n/a T} T{ n/a T} T{ n/a T} T{ n/a T} _ T{ delegated\-len T} T{ n/a T} T{ n/a T} T{ n/a T} T{ n/a T} T{ n/a T} T{ yes T} _ T{ dhcp4o6\-port T} T{ yes T} T{ n/a T} T{ n/a T} T{ n/a T} T{ n/a T} T{ n/a T} _ T{ excluded\-prefix T} T{ n/a T} T{ n/a T} T{ n/a T} T{ n/a T} T{ n/a T} T{ yes T} _ T{ excluded\-prefix\-len T} T{ n/a T} T{ n/a T} T{ n/a T} T{ n/a T} T{ n/a T} T{ yes T} _ T{ hostname\-char\-set T} T{ yes T} T{ n/a T} T{ yes T} T{ yes T} T{ n/a T} T{ n/a T} _ T{ hostname\-char\-replacement T} T{ yes T} T{ n/a T} T{ yes T} T{ yes T} T{ n/a T} T{ n/a T} _ T{ interface T} T{ n/a T} T{ n/a T} T{ yes T} T{ yes T} T{ n/a T} T{ n/a T} _ T{ interface\-id T} T{ n/a T} T{ n/a T} T{ yes T} T{ yes T} T{ n/a T} T{ n/a T} _ T{ max\-preferred\-lifetime T} T{ yes T} T{ yes T} T{ yes T} T{ yes T} T{ n/a T} T{ n/a T} _ T{ max\-valid\-lifetime T} T{ yes T} T{ yes T} T{ yes T} T{ yes T} T{ n/a T} T{ n/a T} _ T{ min\-preferred\-lifetime T} T{ yes T} T{ yes T} T{ yes T} T{ yes T} T{ n/a T} T{ n/a T} _ T{ min\-valid\-lifetime T} T{ yes T} T{ yes T} T{ yes T} T{ yes T} T{ n/a T} T{ n/a T} _ T{ option\-data T} T{ yes (via remote\-option6\-global\-set) T} T{ yes T} T{ yes T} T{ yes T} T{ yes T} T{ yes T} _ T{ option\-def T} T{ yes (via remote\-option\-def6\-set) T} T{ yes T} T{ n/a T} T{ n/a T} T{ n/a T} T{ n/a T} _ T{ pd\-allocator T} T{ yes T} T{ n/a T} T{ yes T} T{ yes T} T{ n/a T} T{ n/a T} _ T{ preferred\-lifetime T} T{ yes T} T{ yes T} T{ yes T} T{ yes T} T{ n/a T} T{ n/a T} _ T{ prefix T} T{ n/a T} T{ n/a T} T{ n/a T} T{ n/a T} T{ n/a T} T{ yes T} _ T{ prefix\-len T} T{ n/a T} T{ n/a T} T{ n/a T} T{ n/a T} T{ n/a T} T{ yes T} _ T{ rapid\-commit T} T{ yes T} T{ n/a T} T{ yes T} T{ yes T} T{ n/a T} T{ n/a T} _ T{ rebind\-timer T} T{ yes T} T{ n/a T} T{ yes T} T{ yes T} T{ n/a T} T{ n/a T} _ T{ relay T} T{ n/a T} T{ n/a T} T{ yes T} T{ yes T} T{ n/a T} T{ n/a T} _ T{ renew\-timer T} T{ yes T} T{ n/a T} T{ yes T} T{ yes T} T{ n/a T} T{ n/a T} _ T{ require\-client\-classes T} T{ no T} T{ n/a T} T{ yes T} T{ yes T} T{ yes T} T{ yes T} _ T{ evaluate\-additional\-classes T} T{ no T} T{ n/a T} T{ yes T} T{ yes T} T{ yes T} T{ yes T} _ T{ reservations\-global T} T{ yes T} T{ n/a T} T{ yes T} T{ yes T} T{ n/a T} T{ n/a T} _ T{ reservations\-in\-subnet T} T{ yes T} T{ n/a T} T{ yes T} T{ yes T} T{ n/a T} T{ n/a T} _ T{ reservations\-out\-of\-pool T} T{ yes T} T{ n/a T} T{ yes T} T{ yes T} T{ n/a T} T{ n/a T} _ T{ t1\-percent T} T{ yes T} T{ n/a T} T{ yes T} T{ yes T} T{ n/a T} T{ n/a T} _ T{ t2\-percent T} T{ yes T} T{ n/a T} T{ yes T} T{ yes T} T{ n/a T} T{ n/a T} _ T{ valid\-lifetime T} T{ yes T} T{ yes T} T{ yes T} T{ yes T} T{ n/a T} T{ n/a T} .TE .INDENT 0.0 .IP \(bu 2 \fByes\fP \- indicates that the parameter is supported at the given level of the hierarchy and can be configured via the configuration backend. .IP \(bu 2 \fBno\fP \- indicates that a parameter is supported at the given level of the hierarchy but cannot be configured via the configuration backend. .IP \(bu 2 \fBn/a\fP \- indicates that a given parameter is not applicable at the particular level of the hierarchy or that the server does not support the parameter at that level. .UNINDENT .sp Some scalar parameters contained by top level global maps are supported by the configuration backend. .SS List of DHCPv6 map parameters supported by the configuration backend .TS box center; l|l|l. T{ Parameter name (flat naming format) T} T{ Global map T} T{ Parameter name T} _ T{ compatibility.lenient\-option\-parsing T} T{ compatibility T} T{ lenient\-option\-parsing T} _ T{ dhcp\-ddns.enable\-updates T} T{ dhcp\-ddns T} T{ enable\-updates T} _ T{ dhcp\-ddns.max\-queue\-size T} T{ dhcp\-ddns T} T{ max\-queue\-size T} _ T{ dhcp\-ddns.ncr\-format T} T{ dhcp\-ddns T} T{ ncr\-format T} _ T{ dhcp\-ddns.ncr\-protocol T} T{ dhcp\-ddns T} T{ ncr\-protocol T} _ T{ dhcp\-ddns.sender\-ip T} T{ dhcp\-ddns T} T{ sender\-ip T} _ T{ dhcp\-ddns.sender\-port T} T{ dhcp\-ddns T} T{ sender\-port T} _ T{ dhcp\-ddns.server\-ip T} T{ dhcp\-ddns T} T{ server\-ip T} _ T{ dhcp\-ddns.server\-port T} T{ dhcp\-ddns T} T{ server\-port T} _ T{ expired\-leases\-processing.flush\-reclaimed\-timer\-wait\-time T} T{ expired\-leases\-processing T} T{ flush\-reclaimed\-timer\-wait\-time T} _ T{ expired\-leases\-processing.hold\-reclaimed\-time T} T{ expired\-leases\-processing T} T{ hold\-reclaimed\-time T} _ T{ expired\-leases\-processing.max\-reclaim\-leases T} T{ expired\-leases\-processing T} T{ max\-reclaim\-leases T} _ T{ expired\-leases\-processing.max\-reclaim\-time T} T{ expired\-leases\-processing T} T{ max\-reclaim\-time T} _ T{ expired\-leases\-processing.reclaim\-timer\-wait\-time T} T{ expired\-leases\-processing T} T{ reclaim\-timer\-wait\-time T} _ T{ expired\-leases\-processing.unwarned\-reclaim\-cycles T} T{ expired\-leases\-processing T} T{ unwarned\-reclaim\-cycles T} _ T{ multi\-threading.enable\-multi\-threading T} T{ multi\-threading T} T{ enable\-multi\-threading T} _ T{ multi\-threading.thread\-pool\-size T} T{ multi\-threading T} T{ thread\-pool\-size T} _ T{ multi\-threading.packet\-queue\-size T} T{ multi\-threading T} T{ packet\-queue\-size T} _ T{ sanity\-checks.lease\-checks T} T{ sanity\-checks T} T{ lease\-checks T} _ T{ sanity\-checks.extended\-info\-checks T} T{ sanity\-checks T} T{ extended\-info\-checks T} _ T{ server\-id.type T} T{ server\-id T} T{ type T} _ T{ server\-id.enterprise\-id T} T{ server\-id T} T{ enterprise\-id T} _ T{ server\-id.identifier T} T{ server\-id T} T{ identifier T} _ T{ server\-id.persist T} T{ server\-id T} T{ persist T} _ T{ dhcp\-queue\-control.enable\-queue T} T{ dhcp\-queue\-control T} T{ enable\-queue T} _ T{ dhcp\-queue\-control.queue\-type T} T{ dhcp\-queue\-control T} T{ queue\-type T} _ T{ dhcp\-queue\-control.capacity T} T{ dhcp\-queue\-control T} T{ capacity T} .TE .SS Enabling the Configuration Backend .sp Consider the following configuration snippet, which uses a MySQL configuration database: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp6\(dq: { \(dqserver\-tag\(dq: \(dqmy DHCPv6 server\(dq, \(dqconfig\-control\(dq: { \(dqconfig\-databases\(dq: [ { \(dqtype\(dq: \(dqmysql\(dq, \(dqname\(dq: \(dqkea\(dq, \(dquser\(dq: \(dqkea\(dq, \(dqpassword\(dq: \(dq1234\(dq, \(dqhost\(dq: \(dq2001:db8:1::1\(dq, \(dqport\(dq: 3302 } ], \(dqconfig\-fetch\-wait\-time\(dq: 20 }, \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dq/usr/local/lib/kea/hooks/libdhcp_mysql.so\(dq }, { \(dqlibrary\(dq: \(dq/usr/local/lib/kea/hooks/libdhcp_cb_cmds.so\(dq } ] } } .EE .UNINDENT .UNINDENT .sp The following snippet illustrates the use of a PostgreSQL database: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp6\(dq: { \(dqserver\-tag\(dq: \(dqmy DHCPv6 server\(dq, \(dqconfig\-control\(dq: { \(dqconfig\-databases\(dq: [ { \(dqtype\(dq: \(dqpostgresql\(dq, \(dqname\(dq: \(dqkea\(dq, \(dquser\(dq: \(dqkea\(dq, \(dqpassword\(dq: \(dq1234\(dq, \(dqhost\(dq: \(dq2001:db8:1::1\(dq, \(dqport\(dq: 3302 } ], \(dqconfig\-fetch\-wait\-time\(dq: 20 }, \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dq/usr/local/lib/kea/hooks/libdhcp_pgsql.so\(dq }, { \(dqlibrary\(dq: \(dq/usr/local/lib/kea/hooks/libdhcp_cb_cmds.so\(dq } ] } } .EE .UNINDENT .UNINDENT .sp The configuration structure is almost identical to that of the DHCPv4 server (see \fI\%Enabling the Configuration Backend\fP for the detailed description). .SS Kea DHCPv6 Compatibility Configuration Parameters .sp ISC\(aqs intention is for Kea to follow the RFC documents to promote better standards compliance. However, many buggy DHCP implementations already exist that cannot be easily fixed or upgraded. Therefore, Kea provides an easy\-to\-use compatibility mode for broken or non\-compliant clients. For that purpose, the compatibility option must be enabled to permit uncommon practices: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp6\(dq: { \(dqcompatibility\(dq: { } } } .EE .UNINDENT .UNINDENT .SS Lenient Option Parsing .sp By default, DHCPv6 option 16\(aqs \fBvendor\-class\-data\fP field is parsed as a set of length\-value pairs; the same is true for tuple fields defined in custom options. .sp With \fB\(dqlenient\-option\-parsing\(dq: true\fP, if a length ever exceeds the rest of the option\(aqs buffer, previous versions of Kea returned a log message \fBunable to parse the opaque data tuple, the buffer length is x, but the tuple length is y\fP with \fBx < y\fP; this no longer occurs. Instead, the value is considered to be the rest of the buffer, or in terms of the log message above, the tuple length \fBy\fP becomes \fBx\fP\&. .sp Enabling this flag is expected to improve compatibility with devices such as RAD MiNID. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp6\(dq: { \(dqcompatibility\(dq: { \(dqlenient\-option\-parsing\(dq: true } } } .EE .UNINDENT .UNINDENT .sp Starting with Kea version 2.5.8, this parsing is extended to silently ignore client\-fqdn (39) options with some invalid domain names. .SS Allocation Strategies in DHCPv6 .sp A DHCP server follows a complicated algorithm to select a DHCPv6 lease for a client. It prefers assigning specific addresses or delegated prefixes requested by the client and the ones for which the client has reservations. .sp When the client requests a specific delegated prefix, \fI\%kea\-dhcp6\fP follows a series of steps to try to satisfy the request, in this order: .INDENT 0.0 .IP 1. 3 It searches for a lease that matches the requested prefix and prefix length. .IP 2. 3 It searches for a lease that matches the prefix length. .IP 3. 3 It searches for a lease with a larger address space (smaller prefix length). .IP 4. 3 It searches for a lease with a smaller address space (larger prefix length). .UNINDENT .sp If the client requests no particular lease and has no reservations, or other clients are already using any requested leases, the server must find another available lease within the configured pools. A server function called an \(dqallocator\(dq is responsible in Kea for finding an available lease in such a case. .sp The Kea DHCPv6 server provides configuration parameters to select different allocators at the global, shared\-network, and subnet levels. It also allows different allocation strategies to be selected for address assignments and prefix delegation. .sp Consider the following example: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp6\(dq: { \(dqallocator\(dq: \(dqiterative\(dq, \(dqpd\-allocator\(dq: \(dqrandom\(dq, \(dqsubnet6\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq2001:db8:1::/64\(dq, \(dqallocator\(dq: \(dqrandom\(dq }, { \(dqid\(dq: 2, \(dqsubnet\(dq: \(dq2001:db8:2::/64\(dq, \(dqpd\-allocator\(dq: \(dqiterative\(dq } ] } } .EE .UNINDENT .UNINDENT .sp The iterative allocator is globally selected for address assignments, while the random allocator is globally selected for prefix delegation. These settings are selectively overridden at the subnet level. .sp The following sections describe the supported allocators and their recommended uses. .SS Allocators Comparison .sp In the table below, we briefly compare the supported allocators, all of which are described in detail in later sections. .SS Comparison of the lease allocators supported by Kea DHCPv6 .TS box center; l|l|l|l|l|l. T{ Allocator T} T{ Low Utilization Performance T} T{ High Utilization Performance T} T{ Lease Randomization T} T{ Startup/Configuration T} T{ Memory Usage T} _ T{ Iterative T} T{ very high T} T{ low T} T{ no T} T{ very fast T} T{ low T} _ T{ Random T} T{ high T} T{ low T} T{ yes T} T{ very fast T} T{ high (varying) T} _ T{ Free Lease Queue T} T{ high T} T{ high T} T{ yes T} T{ slow (depends on pool sizes) T} T{ high (varying) T} .TE .SS Iterative Allocator .sp This is the default allocator used by the Kea DHCPv6 server. It remembers the last offered lease and offers the following sequential lease to the next client. For example, it may offer addresses in this order: \fB2001:db8:1::10\fP, \fB2001:db8:1::11\fP, \fB2001:db8:1::12\fP, and so on. Similarly, it offers the next sequential delegated prefix after the previous one to the next client. The time to find and offer the next lease or delegated prefix is very short; thus, this is the most performant allocator when pool utilization is low and there is a high probability that the next selected lease is available. .sp The iterative allocation underperforms when multiple DHCP servers share a lease database or are connected to a cluster. The servers tend to offer and allocate the same blocks of addresses to different clients independently, which causes many allocation conflicts between the servers and retransmissions by clients. A random allocation addresses this issue by dispersing the allocation order. .SS Random Allocator .sp The random allocator uses a uniform randomization function to select offered addresses and delegated prefixes from subnet pools. It is suitable in deployments where multiple servers are connected to a shared database or a database cluster. By dispersing the offered leases, the servers minimize the risk of allocating the same lease to two different clients at the same or nearly the same time. In addition, it improves the server\(aqs resilience against attacks based on allocation predictability. .sp The random allocator is, however, slightly slower than the iterative allocator. Moreover, it increases the server\(aqs memory consumption because it must remember randomized leases to avoid offering them repeatedly. Memory consumption grows with the number of offered leases; in other words, larger pools and more clients increase memory consumption by random allocation. .SS Free Lease Queue Allocator (Prefix Delegation Only) .sp This is a sophisticated allocator whose use should be considered in subnets with highly utilized delegated prefix pools. In such cases, it can take a considerable amount of time for the iterative or random allocator to find an available prefix, because they must repeatedly check whether there is a valid lease for a prefix they will offer. The number of checks can be as high as the number of delegated prefixes in the subnet when the subnet pools are exhausted, which can have a direct negative impact on the DHCP response time for each request. .sp The Free Lease Queue (FLQ) allocator tracks lease allocations and de\-allocations and maintains a running list of available delegated prefixes for each pool. It allows an available lease to be selected within a constant time, regardless of the subnet pools\(aq utilization. The allocator continuously updates the list of free leases by removing any allocated leases and adding released or reclaimed ones. .sp The following configuration snippet shows how to select the FLQ allocator for prefix delegation in a subnet: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp6\(dq: { \(dqsubnet6\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq2001:db8:1::/64\(dq, \(dqpd\-allocator\(dq: \(dqflq\(dq } ] } } .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The Free Lease Queue allocator can only be used for DHCPv6 prefix delegation. An attempt to use this allocator for address assignment (with the \fBallocator\fP parameter) will cause a configuration error. DHCPv6 address pools are typically very large and their utilization is low; in this situation, the benefits of using the FLQ allocator diminish. The amount of time required for the allocator to populate the free lease queue would cause the server to freeze upon startup. .UNINDENT .UNINDENT .sp There are several considerations that the administrator should take into account before using this allocator for prefix delegation. The FLQ allocator can heavily impact the server\(aqs startup and reconfiguration time, because the allocator has to populate the list of free leases for each subnet where it is used. These delays can be observed both during the configuration reload and when the subnets are created using \fI\%libdhcp_subnet_cmds.so\fP\&. This allocator increases memory consumption to hold the list of free leases, proportional to the total size of the pools for which this allocator is used. Finally, lease reclamation must be enabled with a low value of the \fBreclaim\-timer\-wait\-time\fP parameter, to ensure that the server frequently collects expired leases and makes them available for allocation via the free lease queue. Expired leases are not considered free by the allocator until they are reclaimed by the server. See \fI\%Lease Reclamation\fP for more details about the lease reclamation process. .sp We recommend that the FLQ allocator be selected only after careful consideration. The server puts no restrictions on the delegated\-prefix pool sizes used with the FLQ allocator, so we advise users to test how long it takes for the server to load the pools before deploying the configuration using the FLQ allocator in production. We also recommend specifying another allocator type in the global configuration settings and overriding this selection at the subnet or shared\-network level, to use the FLQ allocator only for selected subnets. That way, when a new subnet is added without an allocator specification, the global setting is used, thus avoiding unnecessary impact on the server\(aqs startup time. .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 The FLQ allocator is not suitable for use with a shared lease database (i.e., when multiple Kea servers store leases in the same database). The servers are unaware of the expired leases reclaimed by the sibling servers and never return them to their local free lease queues. As a result, the servers will not be able to offer some of the available leases to the clients. Only a server reclaiming a particular lease will be able to offer it. .UNINDENT .UNINDENT .SH DATABASE CONNECTIVITY .sp The Kea servers (\fI\%kea\-dhcp4\fP and \fI\%kea\-dhcp6\fP) can be configured to use a variety of database backends for leases, hosts, and configuration. They can be configured to support automatic recovery when connectivity is lost, via the \fBon\-fail\fP and \fBretry\-on\-startup\fP parameters. (The \fBreconnect\-wait\-time\fP and \fBmax\-reconnect\-tries\fP parameters are described in \fI\%Lease Database Configuration\fP and \fI\%Lease Database Configuration\fP\&.) .sp It is important to understand how and when automatic recovery comes into play. Automatic recovery, when configured, only operates after a successful startup or reconfiguration during which connectivity to all backends has been successfully established. .sp During server startup, the inability to connect to any of the configured backends is considered fatal only if \fBretry\-on\-startup\fP is set to \fBfalse\fP (the default). A fatal error is logged and the server exits, based on the idea that the configuration should be valid at startup. Exiting to the operating system allows nanny scripts to detect the problem. If \fBretry\-on\-startup\fP is set to \fBtrue\fP, the server will start reconnection attempts even at server startup or on reconfigure events, and will honor the action specified in the \fBon\-fail\fP parameter. .sp During dynamic reconfiguration, all backends are disconnected and then reconnected using the new configuration. If connectivity to any of the backends cannot be established, the server logs a fatal error but remains up. It is able to process commands but does not serve clients. This allows the configuration to be corrected via the \fI\%config\-set\fP or \fBremote\-*\fP commands, if required. .sp During normal operations, if connectivity to any of the backends is lost and automatic recovery for that backend is enabled, the server disconnects from the respective backend and then attempts to reconnect. During the recovery process, the server ceases to serve clients according to the \fBon\-fail\fP configured option but continues to respond to commands. .sp The \fBon\-fail\fP parameter configures the actions the server should take when a connection is lost. It can have one of the following values: .INDENT 0.0 .IP \(bu 2 \fBstop\-retry\-exit\fP \- indicates that the server should stop the service while it tries to recover the connection, and exit if recovery is not successful after \fBmax\-reconnect\-tries\fP\&. .IP \(bu 2 \fBserve\-retry\-exit\fP \- indicates that the server should not stop the service while it tries to recover the connection, and exit if recovery is not successful after \fBmax\-reconnect\-tries\fP\&. .IP \(bu 2 \fBserve\-retry\-continue\fP \- indicates that the server should not stop the service while it tries to recover the connection, and not exit if recovery is not successful after \fBmax\-reconnect\-tries\fP\&. .UNINDENT .sp If connectivity to all backends is restored, the server returns to normal operations. If the connection cannot be restored and the server is configured to exit, it issues a fatal error before shutdown. .sp For Kea DHCP servers to work with database backends, the database schema must be created and must match the version of the Kea server. If the version check fails and the database backend is not configured as read\-only, Kea attempts to initialize the schema. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Kea does not automatically attempt to upgrade an existing schema; doing so might deprive users of the opportunity to take precautions, such as backing up the database or temporarily shutting off running Kea servers that are currently operating on the database. .UNINDENT .UNINDENT .sp The connection to the database server can optionally be protected by TLS. Corresponding database configuration parameters for Kea servers are: .INDENT 0.0 .IP \(bu 2 The \fBtrust\-anchor\fP specifies the Certification Authority file name or directory path. .IP \(bu 2 The \fBcert\-file\fP specifies the client certificate file name. .IP \(bu 2 The \fBkey\-file\fP specifies the private key file name. .IP \(bu 2 The \fBcipher\-list\fP specifies the list of TLS ciphers (the syntax of the content of this parameter is described in the OpenSSL ciphers manual). .UNINDENT .sp These parameters are similar to the parameters of the secure connections with the agent but are interpreted by different backends using database configurations too. .sp Currently the support for each database is: .INDENT 0.0 .IP \(bu 2 MySQL supports the whole set, additional configuration must be done in the MySQL local setup, for instance certificate revocation list, choice of a specific TLS version, mutual authentication, etc. When a TLS connection was required but the actual connection is in clear text an error log is emitted. .IP \(bu 2 PostgreSQL only uses the configuration to enable the SSL/TLS support in the client library (libpq). Anything else must be done in the PostgreSQL local configuration. .UNINDENT .SH LEASE EXPIRATION .sp The primary role of the DHCP server is to assign addresses and/or delegate prefixes to DHCP clients. These addresses and prefixes are often referred to as \(dqleases.\(dq Leases are typically assigned to clients for a finite amount of time, known as the \(dqvalid lifetime.\(dq DHCP clients who wish to continue using their assigned leases periodically renew them by sending the appropriate message to the DHCP server. The DHCP server records the time when these leases are renewed and calculates new expiration times for them. .sp If the client does not renew a lease before its valid lifetime elapses, the lease is considered expired. There are many situations when the client may cease lease renewals; common scenarios include when the machine running the client shuts down for an extended period of time, or when a mobile device leaves the vicinity of a network. .sp The process through which the DHCP server makes expired leases available for reassignment is referred to as \(dqlease reclamation,\(dq and expired leases returned to availability through this process are referred to as \(dqreclaimed.\(dq The DHCP server attempts to reclaim an expired lease as soon as it detects that it has expired. The server has several possible ways to detect expiration: it may attempt to allocate a lease to a client but find this lease already present in the database and expired; or it can periodically query the lease database for expired leases. Regardless of how an expired lease is detected, it must be reclaimed before it can be assigned to a client. .sp This chapter explains how to configure the server to periodically query for the expired leases, and how to minimize the impact of the periodic lease\-reclamation process on the server\(aqs responsiveness. Finally, it explains \(dqlease affinity,\(dq which provides the means to assign the same lease to a returning client after its lease has expired. .sp Although all configuration examples in this section are provided for the DHCPv4 server, the same parameters may be used for DHCPv6 server configuration. .SS Lease Reclamation .sp Lease reclamation is the process through which an expired lease becomes available for assignment to the same or a different client. This process involves the following steps for each reclaimed lease: .INDENT 0.0 .IP \(bu 2 Invoke callouts for the \fBlease4_expire\fP or \fBlease6_expire\fP hook points, if hook libraries supporting those callouts are currently loaded. .IP \(bu 2 Update the DNS, i.e. remove any DNS entries associated with the expired lease. .IP \(bu 2 Update lease information in the lease database to indicate that the lease is now available for reassignment. .IP \(bu 2 Update counters on the server, a process that includes increasing the number of reclaimed leases and decreasing the number of assigned addresses or delegated prefixes. .UNINDENT .sp Please refer to \fI\%The DHCP\-DDNS Server\fP to see how to configure DNS updates in Kea, and to \fI\%Hook Libraries\fP for information about using hook libraries. .SS Lease Reclamation Configuration Parameters .sp The following list presents all the configuration parameters pertaining to processing expired leases, with their default values: .INDENT 0.0 .IP \(bu 2 \fBreclaim\-timer\-wait\-time\fP \- this parameter governs intervals between the completion of the previous reclamation cycle and the start of the next one. Specified in seconds; the default value is 10. .IP \(bu 2 \fBflush\-reclaimed\-timer\-wait\-time\fP \- this parameter controls how often the server initiates the lease reclamation procedure. Expressed in seconds; the default value is 25. If both \fBflush\-reclaimed\-timer\-wait\-time\fP and \fBhold\-reclaimed\-time\fP are not 0, when the client sends a release message the lease is expired instead of being deleted from lease storage. .IP \(bu 2 \fBhold\-reclaimed\-time\fP \- this parameter governs how long the lease should be kept after it is reclaimed. This enables lease affinity when set to a non\-zero value. Expressed in seconds; the default value is 3600. If both \fBflush\-reclaimed\-timer\-wait\-time\fP and \fBhold\-reclaimed\-time\fP are not 0, when the client sends a release message the lease is expired instead of being deleted from lease storage. .IP \(bu 2 \fBmax\-reclaim\-leases\fP \- this parameter specifies the maximum number of reclaimed leases that can be processed at one time. Zero means unlimited (i.e. process all reclaimed leases). The default value is 100. .IP \(bu 2 \fBmax\-reclaim\-time\fP \- this parameter specifies an upper limit to the length of time a lease reclamation procedure can take. Zero means no time limit. Expressed in milliseconds; the default value is 250. .IP \(bu 2 \fBunwarned\-reclaim\-cycles\fP \- if lease reclamation limits are specified (\fBmax\-reclaim\-leases\fP and/or \fBmax\-reclaim\-time\fP), then under certain circumstances the server may not be able to deal with the leases to be reclaimed fast enough. This parameter specifies how many consecutive clean\-up cycles must end with remaining leases to be processed before a warning is printed. The default is 5 cycles. .UNINDENT .sp The parameters are explained in more detail in the rest of this chapter. .sp The default value for any parameter is used when the parameter is not explicitly specified in the configuration. If the \fBexpired\-leases\-processing\fP map is omitted entirely in the configuration, the default values are used for all parameters listed above. .SS Configuring Lease Reclamation .sp Kea can be configured to periodically detect and reclaim expired leases. During this process the lease entries in the database are modified or removed. While this is happening the server does not process incoming DHCP messages, to avoid issues with concurrent access to database information. As a result, the server is unresponsive while lease reclamation is performed and DHCP queries will accumulate; responses will be sent once the lease\-reclamation cycle is complete. .sp In deployments where response time is critical, administrators may wish to minimize the interruptions in service caused by lease reclamation. To this end, Kea provides configuration parameters to control the frequency of lease reclamation cycles, the maximum number of leases processed in a single reclamation cycle, and the maximum amount of time a single reclamation cycle is allowed to run before being interrupted. The following examples demonstrate how these parameters can be used: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp4\(dq: { \(dqexpired\-leases\-processing\(dq: { \(dqreclaim\-timer\-wait\-time\(dq: 5, \(dqmax\-reclaim\-leases\(dq: 0, \(dqmax\-reclaim\-time\(dq: 0 } } } .EE .UNINDENT .UNINDENT .sp The first parameter is expressed in seconds and specifies an interval between the two consecutive lease reclamation cycles. This is explained by the following diagram: .INDENT 0.0 .INDENT 3.5 .sp .EX | c1 | | c2 | |c3| | c4 | |<\-\-\-\->|<\-\-\-\-\-\-\-\-\-\->|<\-\->|<\-\-\-\-\-\-\-\-\-\->|<>|<\-\-\-\-\-\-\-\-\-\->|<\-\->|<\-\- \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-> | | 5s | | 5s | | 5s | | time .EE .UNINDENT .UNINDENT .sp This diagram shows four lease\-reclamation cycles (c1 through c4) of variable duration. The duration of the reclamation cycle depends on the number of expired leases detected and processed in a particular cycle. This duration is usually significantly shorter than the interval between the cycles. .sp According to the \fBreclaim\-timer\-wait\-time\fP, the server keeps fixed intervals of five seconds between the end of one cycle and the start of the next cycle. This guarantees the presence of 5\-second\-long periods during which the server remains responsive to DHCP queries and does not perform lease reclamation. The \fBmax\-reclaim\-leases\fP and \fBmax\-reclaim\-time\fP are set to 0, which sets no restriction on the maximum number of leases reclaimed in the particular cycle, or on the maximum duration of each cycle. .sp In deployments with high lease\-pool utilization, relatively short valid lifetimes, and frequently disconnecting clients which allow leases to expire, the number of expired leases requiring reclamation at any given time may rise significantly. In this case, it is often desirable to apply restrictions to the maximum duration of a reclamation cycle or the maximum number of leases reclaimed in a cycle. The following configuration demonstrates how this can be done: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp4\(dq: { \(dqexpired\-leases\-processing\(dq: { \(dqreclaim\-timer\-wait\-time\(dq: 3, \(dqmax\-reclaim\-leases\(dq: 100, \(dqmax\-reclaim\-time\(dq: 50, \(dqunwarned\-reclaim\-cycles\(dq: 10 } } } .EE .UNINDENT .UNINDENT .sp In this example, the \fBmax\-reclaim\-leases\fP parameter limits the number of leases reclaimed in a single cycle to 100, and the \fBmax\-reclaim\-time\fP limits the maximum duration of each cycle to 50ms. The lease\-reclamation cycle will be interrupted if either of these limitations is reached. The reclamation of any unreclaimed leases will be attempted in subsequent cycles. .sp The following diagram illustrates the behavior of the system in the presence of many expired leases, when the limits are applied for the reclamation cycles: .INDENT 0.0 .INDENT 3.5 .sp .EX | c1 | | c2 | | c3 | | c4 | |<\-\->|<\-\-\-\-\-\-\-\-\-\-\-\-\-\->|<\-\->|<\-\-\-\-\-\-\-\-\-\-\-\-\-\->|<\-\->|<\-\-\-\-\-\-\-\-\-\-\-\-\-\->|<\-\->|<\-\- \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-> |50ms| 3s |50ms| 3s |50ms| 3s |50ms| time .EE .UNINDENT .UNINDENT .sp In this case, if any reclamation cycle takes more than 50ms, it is interrupted according to the value of the \fBmax\-reclaim\-time\fP\&. This results in equal durations of all reclamation cycles over time. In this example, the limitation of the maximum 100 leases is not reached. This may be the case when database transactions or callouts in the hook libraries attached to the server are slow. Regardless, the chosen values for either the maximum number of leases or a maximum cycle time strongly depend on the particular deployment, the lease database backend being used, any hook libraries, etc. Administrators may need to experiment to tune the system to suit the dynamics of their deployment. .sp It is important to realize that with the use of these limits, there is a risk that expired leases will accumulate faster than the server can reclaim them. This should not be a problem if the server is dealing with a temporary burst of expirations, because it should be able to eventually deal with them over time. However, if leases expire at a high rate for a long period of time, the unreclaimed leases will pile up in the database. To notify the administrator that the current configuration does not satisfy the needs for reclamation of expired leases, the server issues a warning message in the log if it is unable to reclaim all leases within several reclamation cycles. The number of cycles after which such a warning is issued is specified with the \fBunwarned\-reclaim\-cycles\fP configuration parameter. .sp Setting the \fBreclaim\-timer\-wait\-time\fP to 0 disables periodic reclamation of the expired leases. .SS Configuring Lease Affinity .sp Suppose that a laptop goes into sleep mode after a period of user inactivity. While the laptop is in sleep mode, its DHCP client does not renew leases obtained from the server and these leases will eventually expire. When the laptop wakes up, it is often desirable for it to continue using its previous assigned IP addresses. To facilitate this, the server needs to correlate returning clients with their expired leases. When the client returns, the server first checks for those leases and reassigns them if they have not been assigned to another client. The ability of the server to reassign the same lease to a returning client is referred to as \(dqlease affinity.\(dq .sp When lease affinity is enabled (i.e. when \fBhold\-reclaimed\-time\fP is configured to a value greater than zero), the server still reclaims leases according to the parameters described in \fI\%Configuring Lease Reclamation\fP, but the reclaimed leases are held in the database for a specified amount of time rather than removed. If both \fBflush\-reclaimed\-timer\-wait\-time\fP and \fBhold\-reclaimed\-time\fP are greater than zero, the lease is expired immediately when the client sends a release message, instead of being deleted from lease storage. When the client returns, the server first verifies whether there are any reclaimed leases associated with this client and then reassigns them if possible. However, it is important to note that any reclaimed lease may be assigned to another client if that client specifically asks for it. Therefore, lease affinity does not guarantee that the reclaimed lease will be available for the client who used it before; it merely increases the chances of the client being assigned the same lease. If the lease pool is small \- namely, in DHCPv4, for which address space is limited \- there is an increased likelihood that the expired lease will be assigned to another client. .sp Consider the following configuration: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqexpired\-leases\-processing\(dq: { \(dqreclaim\-timer\-wait\-time\(dq: 3, \(dqhold\-reclaimed\-time\(dq: 1800, \(dqflush\-reclaimed\-timer\-wait\-time\(dq: 5 }, ... } .EE .UNINDENT .UNINDENT .sp The \fBhold\-reclaimed\-time\fP specifies how many seconds after an expiration a reclaimed lease should be held in the database for reassignment to the same client. In the example given above, reclaimed leases are held for 30 minutes (1800 seconds) after their expiration. During this time, the server will likely be able to reassign the same lease to the returning client, unless another client specifically requests this lease and the server assigns it. .sp The server must periodically remove reclaimed leases for which the time indicated by \fBhold\-reclaimed\-time\fP has elapsed. The \fBflush\-reclaimed\-timer\-wait\-time\fP parameter controls how often the server removes such leases. In the example provided above, the server initiates removal of such leases five seconds after the previous removal attempt was completed. Setting this value to 0 disables lease affinity, meaning leases are removed from the lease database when they are reclaimed. If lease affinity is enabled, it is recommended that the \fBhold\-reclaimed\-time\fP be set to a value significantly higher than the \fBreclaim\-timer\-wait\-time\fP, as timely removal of expired\-reclaimed leases is less critical than the removal process, which may impact server responsiveness. .sp There is no guarantee that lease affinity will work every time; if a server is running out of addresses, it will reassign expired addresses to new clients. Also, clients can request specific addresses and the server tries to honor such requests if possible. Administrators who want to ensure a client keeps its address, even after periods of inactivity, should consider using host reservations or leases with very long lifetimes. .SS Reclaiming Expired Leases via Command .sp The \fI\%leases\-reclaim\fP command can be used to trigger lease reclamation at any time. Please consult the \fI\%The leases\-reclaim Command\fP section for details about using this command. .SH CONGESTION HANDLING .SS What is Congestion? .sp Congestion occurs when servers are subjected to client queries faster than those queries can be processed. As a result, the servers begin accumulating a backlog of pending queries. The longer the high rate of traffic continues, the farther behind the servers fall. Depending on the client implementations, those that fail to get leases either give up or simply continue to retry forever. In the former case, the server may eventually recover, but the latter case is a vicious cycle from which the server is unable to escape. .sp Congestion typically occurs when there is a network event that causes overly large numbers of clients to simultaneously need leases, such as recovery after a network outage. In a well\-planned deployment, the number and capacity of servers is matched to the maximum expected client load. If the load is routinely too heavy, then the deployment needs to be re\-evaluated. .sp The goal of congestion handling is to help servers mitigate the peak in traffic by fulfilling as many of the most relevant requests as possible until the congestion subsides. .SS Configuring Congestion Handling .sp Congestion handling offers the ability to configure the server to use a separate thread to read packets from the interface socket buffers. As the thread reads packets from the buffers, they are added to an internal packet queue, and the server\(aqs main application thread processes packets from this queue rather than from the socket buffers. By structuring it this way, a configurable layer has been introduced which can make decisions on which packets to process, how to store them, and the order in which they are processed by the server. .sp The default packet queue implementation for both \fI\%kea\-dhcp4\fP and \fI\%kea\-dhcp6\fP is a simple ring buffer. Once it reaches capacity, new packets get added to the back of the queue by discarding packets from the front of the queue. Rather than always discarding the newest packets, Kea now always discards the oldest packets. The capacity of the buffer, i.e. the maximum number of packets the buffer can contain, is configurable. A reasonable starting point is to match the capacity to the number of leases per second a specific installation of Kea can handle. This figure varies widely depending on the specifics of an individual deployment. .sp As there is no one algorithm that can best handle the dynamics of all sites, and because over time new approaches will evolve, the packet queue is implemented as a plug\-in, which can be replaced by a custom queue implementation via a hook library. This should make it straightforward for interested parties to experiment with their own solutions. (Developers can refer to \fBisc::dhcp::PacketQueue\fP and \fBisc::dhcp::PacketQueueMgr\fP, described in the \X'tty: link https://reports.kea.isc.org/dev_guide/index.html'\fI\%Kea Developer\(aqs Guide\fP\X'tty: link'\&.) .sp Packet queue behavior is configured in both \fI\%kea\-dhcp4\fP and \fI\%kea\-dhcp6\fP servers through an optional, top\-level, configuration element, \fBdhcp\-queue\-control\fP\&. Omitting this element disables packet queueing: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqdhcp\-queue\-control\(dq: { \(dqenable\-queue\(dq: true, // true|false \(dqqueue\-type\(dq: \(dqqueue type\(dq, \(dqcapacity\(dq : 256 // n packets } .EE .UNINDENT .UNINDENT .sp where: .INDENT 0.0 .IP \(bu 2 \fBenable\-queue\fP \- enables or disables packet queueing. When \fBtrue\fP, the server processes packets from the packet queue, which is filled by a separate thread. When \fBfalse\fP, the server processes packets directly from the socket buffers in the main thread. It is disabled (\fBfalse\fP) by default. .IP \(bu 2 \fBqueue\-type\fP \- the name of the queue implementation to use. This value exists so that custom implementations can be registered (via a hook library) and then selected. There is a default packet queue implementation that is pre\-registered during server start up: \(dqkea\-ring4\(dq for \fI\%kea\-dhcp4\fP and \(dqkea\-ring6\(dq for \fI\%kea\-dhcp6\fP\&. .IP \(bu 2 \fBcapacity\fP \- this is the maximum number of packets the queue can hold before packets are discarded. The optimal value for this is extremely site\-dependent. The default value is 64 for both \(dqkea\-ring4\(dq and \(dqkea\-ring6\(dq. .UNINDENT .sp The following example enables the default packet queue for \fI\%kea\-dhcp4\fP, with a queue capacity of 250 packets: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqdhcp\-queue\-control\(dq: { \(dqenable\-queue\(dq: true, \(dqqueue\-type\(dq: \(dqkea\-ring4\(dq, \(dqcapacity\(dq : 250 }, ... } .EE .UNINDENT .UNINDENT .sp The following example enables the default packet queue for \fI\%kea\-dhcp6\fP, with a queue capacity of 300 packets: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqdhcp\-queue\-control\(dq: { \(dqenable\-queue\(dq: true, \(dqqueue\-type\(dq: \(dqkea\-ring6\(dq, \(dqcapacity\(dq : 300 }, ... } .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Congestion handling is currently incompatible with multi\-threading; when both are enabled, congestion handling is silently disabled. .UNINDENT .UNINDENT .SH THE DHCP-DDNS SERVER .SS Overview .sp The DHCP\-DDNS Server (\fI\%kea\-dhcp\-ddns\fP, known informally as D2) conducts the client side of the Dynamic DNS protocol (DDNS, defined in \X'tty: link https://tools.ietf.org/html/rfc2136'\fI\%RFC 2136\fP\X'tty: link') on behalf of the DHCPv4 and DHCPv6 servers (\fI\%kea\-dhcp4\fP and \fI\%kea\-dhcp6\fP, respectively). The DHCP servers construct DDNS update requests, known as NameChangeRequests (NCRs), based on DHCP lease change events and then post them to D2. D2 attempts to match each request to the appropriate DNS server(s) and carries out the necessary conversation with those servers to update the DNS data. .sp The Kea hook library \fI\%libdhcp_ddns_tuning.so\fP provides the ability for both \fI\%kea\-dhcp4\fP and \fI\%kea\-dhcp6\fP to generate host names procedurally based on an expression, to skip DDNS updates on a per\-client basis, or to fine\-tune various DNS update aspects. Please refer to the \fI\%libdhcp_ddns_tuning.so: DDNS Tuning\fP documentation for the configuration options. .SS DNS Server Selection .sp To match a request to the appropriate DNS servers, D2 must have a catalog of servers from which to select. In fact, D2 has two such catalogs, one for forward DNS and one for reverse DNS; these catalogs are referred to as \(dqDDNS domain lists.\(dq Each list consists of one or more named DDNS domains. Further, each DDNS domain has a list of one or more DNS servers that publish the DNS data for that domain. .sp When conducting forward\-domain matching, D2 compares the fully qualified domain name (FQDN) in the request against the name of each forward DDNS domain in its catalog. The domain whose name matches the longest portion of the FQDN is considered the best match. For example, if the FQDN is \(dqmyhost.sample.example.com.\(dq, and there are two forward domains in the catalog, \(dqsample.example.com.\(dq and \(dqexample.com.\(dq, the former is regarded as the best match. In some cases, it may not be possible to find a suitable match. Given the same two forward domains there would be no match for the FQDN \(dqbogus.net\(dq, so the request would be rejected. Finally, if there are no forward DDNS domains defined, D2 simply disregards the forward\-update portion of requests. .sp When conducting reverse\-domain matching, D2 constructs a reverse FQDN from the lease address in the request and compares that against the name of each reverse DDNS domain. Again, the domain whose name matches the longest portion of the FQDN is considered the best match. For instance, if the lease address is \(dq172.16.1.40\(dq and there are two reverse domains in the catalog, \(dq1.16.172.in\-addr.arpa.\(dq and \(dq16.172.in\-addr.arpa\(dq, the former is the best match. As with forward matching, D2 may not find a suitable match. Given the same two domains, there would be no match for the lease address, \(dq192.168.1.50\(dq, and the request would be rejected. As with forward\-domain matching, if there are no reverse DDNS domains defined, D2 simply disregards the reverse\-update portion of requests. .SS Conflict Resolution .sp D2 implements the conflict resolution strategy prescribed by \X'tty: link https://tools.ietf.org/html/rfc4703'\fI\%RFC 4703\fP\X'tty: link'\&. Conflict resolution is intended to prevent different clients from mapping to the same FQDN at the same time. To make this possible, the RFC requires that forward DNS entries for a given FQDN must be accompanied by a DHCID resource record (RR). This record contains a client identifier that uniquely identifies the client to whom the name belongs. Furthermore, any DNS updater that wishes to update or remove existing forward entries for an FQDN may only do so if their client matches that of the DHCID RR. .sp In other words, the DHCID RR maps an FQDN to the client to whom it belongs, and thereafter changes to that mapping can only be done by or at the behest of that client. .sp Conflict resolution can be indirectly enabled or disabled via the configuration parameter \fBddns\-use\-conflict\-resolution\fP, supported by both \fI\%kea\-dhcp4\fP and \fI\%kea\-dhcp6\fP\&. These servers use this parameter to set a flag within each NameChangeRequest they send that tells D2 whether conflict resolution should be employed for that request. By default, conflict resolution is enabled. For more details, please refer to discussions of \fBddns\-use\-conflict\-resolution\fP in \fI\%DDNS for DHCPv4\fP and \fI\%DDNS for DHCPv6\fP\&. .sp When conflict resolution is disabled, D2 still adds DHCID RRs but does not use them to enforce client ownership of DNS entries. Disabling it should only be used after careful consideration. .SS Dual\-Stack Environments .sp \X'tty: link https://tools.ietf.org/html/rfc4703#section-5.2'\fI\%RFC 4703, section 5.2,\fP\X'tty: link' describes issues that may arise with dual\-stack clients. These are clients that wish to have both IPv4 and IPv6 mappings for the same FQDN. To work properly, clients must embed their IPv6 DUID within their IPv4 client identifier option, as described in \X'tty: link https://tools.ietf.org/html/rfc4361'\fI\%RFC 4361\fP\X'tty: link'\&. In this way, DNS updates for both IPv4 and IPv6 can be managed under the same DHCID RR. This feature is supported by Kea beginning with release 2.1.2. .SS Starting and Stopping the DHCP\-DDNS Server .sp \fI\%kea\-dhcp\-ddns\fP is the Kea DHCP\-DDNS server and, due to the nature of DDNS, it runs alongside either the DHCPv4 or DHCPv6 component (or both). Like other parts of Kea, it is a separate binary that can be run on its own or through \fI\%keactrl\fP (see \fI\%Managing Kea with keactrl\fP). In normal operation, controlling \fI\%kea\-dhcp\-ddns\fP with \fI\%keactrl\fP is recommended; however, it is also possible to run the DHCP\-DDNS server directly. It accepts the following command\-line switches: .INDENT 0.0 .IP \(bu 2 \fB\-c file\fP \- specifies the configuration file. This is the only mandatory switch. .IP \(bu 2 \fB\-d\fP \- specifies whether server logging should be switched to debug/verbose mode. In verbose mode, the logging severity and debuglevel specified in the configuration file are ignored and \(dqdebug\(dq severity and the maximum debuglevel (99) are assumed. The flag is convenient for temporarily switching the server into maximum verbosity, e.g. when debugging. .IP \(bu 2 \fB\-t file\fP \- specifies the configuration file to be tested. \fI\%kea\-dhcp\-ddns\fP attempts to load it and conducts sanity checks. Certain checks are possible only while running the actual server. The actual status is reported with an exit code (0 = configuration looks okay, 1 = error encountered). Kea prints out log messages to standard output and errors to standard error when testing the configuration. .IP \(bu 2 \fB\-v\fP \- displays the Kea version and exits. .IP \(bu 2 \fB\-V\fP \- displays the extended Kea version and exits. .IP \(bu 2 \fB\-W\fP \- displays the Kea configuration report and exits. The report is a copy of the \fBconfig.report\fP file produced by \fBmeson setup\fP; it is embedded in the executable binary. .sp The contents of the \fBconfig.report\fP file may also be accessed by examining certain libraries in the installation tree or in the source tree. .INDENT 2.0 .INDENT 3.5 .sp .EX # from installation using libkea\-process.so $ strings ${prefix}/lib/libkea\-process.so | sed \-n \(aqs/;;;; //p\(aq # from sources using libkea\-process.so $ strings src/lib/process/.libs/libkea\-process.so | sed \-n \(aqs/;;;; //p\(aq # from sources using libkea\-process.a $ strings src/lib/process/.libs/libkea\-process.a | sed \-n \(aqs/;;;; //p\(aq # from sources using libcfgrpt.a $ strings src/lib/process/cfgrpt/.libs/libcfgrpt.a | sed \-n \(aqs/;;;; //p\(aq .EE .UNINDENT .UNINDENT .IP \(bu 2 \fB\-X\fP \- As of Kea 3.0, disables path and permissions restrictions. The server will emit a warning at startup that sercurity restrictions have been disabled. Do not use this mode of operation without careful consideration and taking any necessary precautions. Failure to do so can expose deployments to security vulnerabilities. For more information please read section \fI\%Securing a Kea Deployment\fP\&. .UNINDENT .sp Upon startup, the module loads its configuration and begins listening for NCRs based on that configuration. .sp During startup, the server attempts to create a PID file of the form: \fB[pidfile_dir]/[conf name].kea\-dhcp\-ddns.pid\fP where: .INDENT 0.0 .IP \(bu 2 \fBpidfile_dir\fP \- is \fB[prefix]/[localstatedir]/run/kea\fP where \fBprefix\fP and \fBlocalstatedir\fP are the values passed into meson setup using \fB\-\-prefix\fP and \fB\-\-localstatedir\fP which default to \fB/usr/local\fP and \fBvar\fP respectively. So the whole \fBpidfile_dir\fP defaults to \fB/usr/local/var\fP\&. Note that this value may be overridden at runtime by setting the environment variable \fBKEA_PIDFILE_DIR\fP intended primarily for testing purposes. .IP \(bu 2 \fBconf name\fP \- is the configuration file name used to start the server, minus all preceding paths and the file extension. For example, given a pathname of \fB/usr/local/etc/kea/myconf.txt\fP, the portion used would be \fBmyconf\fP\&. .UNINDENT .sp If the file already exists and contains the PID of a live process, the server issues a \fBDHCP_DDNS_ALREADY_RUNNING\fP log message and exits. It is possible, though unlikely, that the file is a remnant of a system crash and the process to which the PID belongs is unrelated to Kea. In such a case it is necessary to manually delete the PID file. .SS Configuring the DHCP\-DDNS Server .sp Before starting the \fI\%kea\-dhcp\-ddns\fP module for the first time, a configuration file must be created. The following default configuration is a template that can be customized to individual requirements. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcpDdns\(dq: { \(dqip\-address\(dq: \(dq127.0.0.1\(dq, \(dqport\(dq: 53001, \(dqdns\-server\-timeout\(dq: 500, \(dqncr\-protocol\(dq: \(dqUDP\(dq, \(dqncr\-format\(dq: \(dqJSON\(dq, \(dqtsig\-keys\(dq: [ ], \(dqforward\-ddns\(dq: { \(dqddns\-domains\(dq: [ ] }, \(dqreverse\-ddns\(dq: { \(dqddns\-domains\(dq: [ ] } } .EE .UNINDENT .UNINDENT .sp The configuration can be divided into the following sections, each of which is described below: .INDENT 0.0 .IP \(bu 2 \fIGlobal Server Parameters\fP \- define values which control connectivity and global server behavior. .IP \(bu 2 \fIControl Sockets\fP \- defines the Control Socket list. .IP \(bu 2 \fITSIG Key Info\fP \- defines the TSIG keys used for secure traffic with DNS servers. .IP \(bu 2 \fIForward DDNS\fP \- defines the catalog of forward DDNS domains. .IP \(bu 2 \fIReverse DDNS\fP \- defines the catalog of reverse DDNS domains. .UNINDENT .SS Global Server Parameters .INDENT 0.0 .IP \(bu 2 \fBip\-address\fP \- the IP address on which D2 listens for requests. The default is the local loopback interface at address 127.0.0.1. Either an IPv4 or IPv6 address may be specified. .IP \(bu 2 \fBport\fP \- the port on which D2 listens for requests. The default value is 53001. .IP \(bu 2 \fBdns\-server\-timeout\fP \- the maximum amount of time, in milliseconds, that D2 will wait for a response from a DNS server to a single DNS update message. The default is 500 ms. .IP \(bu 2 \fBncr\-protocol\fP \- the socket protocol to use when sending requests to D2. Currently only UDP is supported. .IP \(bu 2 \fBncr\-format\fP \- the packet format to use when sending requests to D2. Currently only JSON format is supported. .UNINDENT .sp D2 must listen for change requests on a known address and port. By default it listens at 127.0.0.1 on port 53001. The following example illustrates how to change D2\(aqs global parameters so it will listen at 192.168.1.10 port 900: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcpDdns\(dq: { \(dqip\-address\(dq: \(dq192.168.1.10\(dq, \(dqport\(dq: 900, ... } .EE .UNINDENT .UNINDENT .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 It is possible for a malicious attacker to send bogus NameChangeRequests to the DHCP\-DDNS server. Addresses other than the IPv4 or IPv6 loopback addresses (127.0.0.1 or ::1) should only be used for testing purposes; note that local users may still communicate with the DHCP\-DDNS server. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 If the \fBip\-address\fP and \fBport\fP are changed, the corresponding values in the DHCP servers\(aq \fBdhcp\-ddns\fP configuration section must be changed. .UNINDENT .UNINDENT .SS Management API for the D2 Server .sp The management API allows the issuing of specific management commands, such as configuration retrieval or shutdown. For more details, see \fI\%Management API\fP\&. By default there are no sockets open; to instruct Kea to open a socket, the following entry in the configuration file can be used: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcpDdns\(dq: { \(dqcontrol\-sockets\(dq: [ { \(dqsocket\-type\(dq: \(dqunix\(dq, \(dqsocket\-name\(dq: \(dq/path/to/the/unix/socket\(dq } ], ... } .EE .UNINDENT .UNINDENT .SS UNIX Control Socket .sp Until Kea server 2.7.2 the only supported communication channel type was the UNIX stream socket with \fBsocket\-type\fP set to \fBunix\fP and \fBsocket\-name\fP to the file path of the UNIX/LOCAL socket. .sp The length of the path specified by the \fBsocket\-name\fP parameter is restricted by the maximum length for the UNIX socket name on the operating system, i.e. the size of the \fBsun_path\fP field in the \fBsockaddr_un\fP structure, decreased by 1. This value varies on different operating systems, between 91 and 107 characters. Typical values are 107 on Linux and 103 on FreeBSD. .sp Kea supports only one \fBunix\fP control socket in the \(dqcontrol\-sockets\(dq list. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 As of Kea 2.7.9, control sockets may only reside in the directory determined during compilation as \fB\(dq[kea\-install\-dir]/var/run/kea\(dq\fP, which must also have \fB0750\fP access rights. This path may be overridden at startup by setting the environment variable \fBKEA_CONTROL_SOCKET_DIR\fP to the desired path. If a path other than this value is used in \fBsocket\-name\fP, Kea will emit an error and refuse to start or, if already running, log an unrecoverable error. For ease of use in simply omit the path component from \fBsocket\-name\fP\&. .UNINDENT .UNINDENT .sp Communication over the control channel is conducted using JSON structures. See the \X'tty: link https://reports.kea.isc.org/dev_guide/d2/d96/ctrlSocket.html'\fI\%Control Channel section in the Kea Developer\(aqs Guide\fP\X'tty: link' for more details. .sp The D2 server supports the following operational commands: .INDENT 0.0 .IP \(bu 2 \fI\%build\-report\fP .IP \(bu 2 \fI\%config\-get\fP .IP \(bu 2 \fI\%config\-hash\-get\fP .IP \(bu 2 \fI\%config\-reload\fP .IP \(bu 2 \fI\%config\-set\fP .IP \(bu 2 \fI\%config\-test\fP .IP \(bu 2 \fI\%config\-write\fP .IP \(bu 2 \fI\%list\-commands\fP .IP \(bu 2 \fI\%shutdown\fP .IP \(bu 2 \fI\%status\-get\fP .IP \(bu 2 \fI\%version\-get\fP .UNINDENT .sp Since Kea version 2.0.0, the D2 server also supports the following operational commands for statistics: .INDENT 0.0 .IP \(bu 2 \fI\%statistic\-get\fP .IP \(bu 2 \fI\%statistic\-get\fP\-all .IP \(bu 2 \fI\%statistic\-reset\fP .IP \(bu 2 \fI\%statistic\-reset\fP\-all .UNINDENT .sp The \fI\%shutdown\fP command supports the extra \fBtype\fP argument, which controls the way the D2 server cleans up on exit. The supported shutdown types are: .INDENT 0.0 .IP \(bu 2 \fBnormal\fP \- stops the queue manager and finishes all current transactions before exiting. This is the default. .IP \(bu 2 \fBdrain_first\fP \- stops the queue manager but continues processing requests from the queue until it is empty. .IP \(bu 2 \fBnow\fP \- exits immediately. .UNINDENT .sp An example command may look like this: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqshutdown\(dq, \(dqarguments\(dq: { \(dqexit\-value\(dq: 3, \(dqtype\(dq: \(dqdrain_first\(dq } } .EE .UNINDENT .UNINDENT .SS HTTP/HTTPS Control Socket .sp The \fBsocket\-type\fP must be \fBhttp\fP or \fBhttps\fP (when the type is \fBhttps\fP TLS is required). The \fBsocket\-address\fP (default \fB127.0.0.1\fP) and \fBsocket\-port\fP (default 8000) specify an IP address and port to which the HTTP service will be bound. .sp The \fBtrust\-anchor\fP, \fBcert\-file\fP, \fBkey\-file\fP, and \fBcert\-required\fP parameters specify the TLS setup for HTTP, i.e. HTTPS. If these parameters are not specified, HTTP is used. The TLS/HTTPS support in Kea is described in \fI\%TLS/HTTPS Support\fP\&. .sp Basic HTTP authentication protects against unauthorized uses of the control agent by local users. For protection against remote attackers, HTTPS and reverse proxy of \fI\%Secure Connections\fP provide stronger security. .sp The authentication is described in the \fBauthentication\fP block with the mandatory \fBtype\fP parameter, which selects the authentication. Currently only the basic HTTP authentication (type basic) is supported. .sp The \fBrealm\fP authentication parameter (default \fBkea\-dhcp\-ddns\-server\fP is used for error messages when the basic HTTP authentication is required but the client is not authorized. .sp When the \fBclients\fP authentication list is configured and not empty, basic HTTP authentication is required. Each element of the list specifies a user ID and a password. The user ID is mandatory, must not be empty, and must not contain the colon (:) character. The password is optional; when it is not specified an empty password is used. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The basic HTTP authentication user ID and password are encoded in UTF\-8, but the current Kea JSON syntax only supports the Latin\-1 (i.e. 0x00..0xff) Unicode subset. .UNINDENT .UNINDENT .sp To avoid exposing the user ID and/or the associated password, these values can be read from files. The syntax is extended by: .INDENT 0.0 .IP \(bu 2 The \fBdirectory\fP authentication parameter, which handles the common part of file paths. The default value is the empty string. .IP \(bu 2 The \fBpassword\-file\fP client parameter, which, alongside the \fBdirectory\fP parameter, specifies the path of a file that can contain the password, or when no user ID is given, the whole basic HTTP authentication secret. .IP \(bu 2 The \fBuser\-file\fP client parameter, which, with the \fBdirectory\fP parameter, specifies the path of a file where the user ID can be read. .UNINDENT .sp Since Kea\-2.7.6 Kea supports multiple HTTP/HTTPS connections. Both IPv4 and IPv6 addresses can be used. The server will issue an error when changing the socket type from HTTP to HTTPS or from HTTPS to HTTP using the same address and port. This action is not allowed as it might introduce a security issue accidentally caused by a user mistake. A different address or port must be specified when using the \(dqconfig\-set\(dq command to switch from HTTP to HTTPS or from HTTPS to HTTP. The same applies when modyfying the configuration file and then running \(dqconfig\-reload\(dq command. .sp When files are used, they are read when the configuration is loaded, to detect configuration errors as soon as possible. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcpDdns\(dq: { \(dqcontrol\-sockets\(dq: [ { \(dqsocket\-type\(dq: \(dqhttps\(dq, \(dqsocket\-address\(dq: \(dq10.20.30.40\(dq, \(dqsocket\-port\(dq: 8005, \(dqtrust\-anchor\(dq: \(dq/path/to/the/ca\-cert.pem\(dq, \(dqcert\-file\(dq: \(dq/path/to/the/agent\-cert.pem\(dq, \(dqkey\-file\(dq: \(dq/path/to/the/agent\-key.pem\(dq, \(dqcert\-required\(dq: true, \(dqauthentication\(dq: { \(dqtype\(dq: \(dqbasic\(dq, \(dqrealm\(dq: \(dqkea\-dhcp\-ddns\-server\(dq, \(dqclients\(dq: [ { \(dquser\(dq: \(dqadmin\(dq, \(dqpassword\(dq: \(dq1234\(dq } ] } }, { \(dqsocket\-type\(dq: \(dqhttp\(dq, \(dqsocket\-address\(dq: \(dq2010:30:40::50\(dq, \(dqsocket\-port\(dq: 8004 } ], ... } .EE .UNINDENT .UNINDENT .SS TSIG Key List .sp A DDNS protocol exchange can be conducted with or without a transaction signature, or TSIG (defined in \X'tty: link https://tools.ietf.org/html/rfc2845'\fI\%RFC 2845\fP\X'tty: link'). This configuration section allows the administrator to define the set of TSIG keys that may be used in such exchanges. .sp To use TSIG when updating entries in a DNS domain, a key must be defined in the TSIG key list and referenced by name in that domain\(aqs configuration entry. When D2 matches a change request to a domain, it checks whether the domain has a TSIG key associated with it. If so, D2 uses that key to sign DNS update messages sent to and verify responses received from the domain\(aqs DNS server(s). For each TSIG key required by the DNS servers that D2 is working with, there must be a corresponding TSIG key in the TSIG key list. .sp As one might gather from the name, the \fBtsig\-key\fP section of the D2 configuration lists the TSIG keys. Each entry describes a TSIG key used by one or more DNS servers to authenticate requests and sign responses. Every entry in the list has three parameters: .INDENT 0.0 .IP \(bu 2 \fBname\fP \- is a unique text label used to identify this key within the list. This value is used to specify which key (if any) should be used when updating a specific domain. As long as the name is unique its content is arbitrary, although for clarity and ease of maintenance it is recommended that it match the name used on the DNS server(s). This field cannot be blank. .IP \(bu 2 \fBalgorithm\fP \- specifies which hashing algorithm should be used with this key. This value must specify the same algorithm used for the key on the DNS server(s). The supported algorithms are listed below: .INDENT 2.0 .IP \(bu 2 HMAC\-MD5 .IP \(bu 2 HMAC\-SHA1 .IP \(bu 2 HMAC\-SHA224 .IP \(bu 2 HMAC\-SHA256 .IP \(bu 2 HMAC\-SHA384 .IP \(bu 2 HMAC\-SHA512 .UNINDENT .sp This value is not case\-sensitive. .IP \(bu 2 \fBdigest\-bits\fP \- is used to specify the minimum truncated length in bits. The default value 0 means truncation is forbidden; non\-zero values must be an integral number of octets, and be greater than both 80 and half of the full length. (Note that in BIND 9 this parameter is appended to the algorithm name, after a dash.) .IP \(bu 2 \fBsecret\fP \- is used to specify the shared secret key code for this key. This value is case\-sensitive and must exactly match the value specified on the DNS server(s). It is a base64\-encoded text value. .IP \(bu 2 \fBsecret\-file\fP \- since Kea 2.5.8, this more secure alternative is supported. This value specifies the file name where the secret can be found, i.e. the base64\-encoded secret is the content of the file. .UNINDENT .sp As an example, suppose that a domain D2 will be updating is maintained by a BIND 9 DNS server, which requires dynamic updates to be secured with TSIG. Suppose further that the entry for the TSIG key in BIND 9\(aqs named.conf file looks like this: .INDENT 0.0 .INDENT 3.5 .sp .EX : key \(dqkey.four.example.com.\(dq { algorithm hmac\-sha224; secret \(dqbZEG7Ow8OgAUPfLWV3aAUQ==\(dq; }; : .EE .UNINDENT .UNINDENT .sp By default, the TSIG key list is empty: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcpDdns\(dq: { \(dqtsig\-keys\(dq: [ ], ... } .EE .UNINDENT .UNINDENT .sp A new key must be added to the list: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcpDdns\(dq: { \(dqtsig\-keys\(dq: [ { \(dqname\(dq: \(dqkey.four.example.com.\(dq, \(dqalgorithm\(dq: \(dqHMAC\-SHA224\(dq, \(dqsecret\(dq: \(dqbZEG7Ow8OgAUPfLWV3aAUQ==\(dq } ], ... } .EE .UNINDENT .UNINDENT .sp These steps must be repeated for each TSIG key needed, although the same TSIG key can be used with more than one domain. .SS Forward DDNS .sp The forward DDNS section is used to configure D2\(aqs forward\-update behavior. Currently it contains a single parameter, the catalog of forward DDNS domains, which is a list of structures. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcpDdns\(dq: { \(dqforward\-ddns\(dq: { \(dqddns\-domains\(dq: [ ] }, ... } .EE .UNINDENT .UNINDENT .sp By default, this list is empty, which causes the server to ignore the forward\-update portions of requests. .SS Adding Forward DDNS Domains .sp A forward DDNS domain maps a forward DNS zone to a set of DNS servers which maintain the forward DNS data (i.e. name\-to\-address mapping) for that zone. Each zone served needs one forward DDNS domain. Some or all of the zones may be maintained by the same servers, but one DDNS domain is still needed for each zone. Remember that matching a request to the appropriate server(s) is done by zone and a DDNS domain only defines a single zone. .sp This section describes how to add forward DDNS domains; repeat these steps for each forward DDNS domain desired. Each forward DDNS domain has the following parameters: .INDENT 0.0 .IP \(bu 2 \fBname\fP \- this is the fully qualified domain name (or zone) that this DDNS domain can update. This value is compared against the request FQDN during forward matching. It must be unique within the catalog. .IP \(bu 2 \fBkey\-name\fP \- if TSIG is used with this domain\(aqs servers, this value should be the name of the key from the TSIG key list. If the value is blank (the default), TSIG will not be used in DDNS conversations with this domain\(aqs servers. .IP \(bu 2 \fBdns\-servers\fP \- this is a list of one or more DNS servers which can conduct the server side of the DDNS protocol for this domain. The servers are used in a first\-to\-last preference; in other words, when D2 begins to process a request for this domain, it will pick the first server in this list and attempt to communicate with it. If that attempt fails, D2 will move to the next one in the list and so on, until either it is successful or the list is exhausted. .UNINDENT .sp To create a new forward DDNS domain, add a new domain element and set its parameters: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcpDdns\(dq: { \(dqforward\-ddns\(dq: { \(dqddns\-domains\(dq: [ { \(dqname\(dq: \(dqother.example.com.\(dq, \(dqkey\-name\(dq: \(dq\(dq, \(dqdns\-servers\(dq: [ ] } ] } } .EE .UNINDENT .UNINDENT .sp It is possible to add a domain without any servers; however, if that domain matches a request, the request will fail. To make the domain useful, at least one DNS server must be added to it. .SS Adding Forward DNS Servers .sp This section describes how to add DNS servers to a forward DDNS domain. Repeat these instructions as needed for all the servers in each domain. .sp Forward DNS server entries represent actual DNS servers which support the server side of the DDNS protocol. Each forward DNS server has the following parameters: .INDENT 0.0 .IP \(bu 2 \fBhostname\fP \- the resolvable host name of the DNS server; this parameter is not yet implemented. .IP \(bu 2 \fBip\-address\fP \- the IP address at which the server listens for DDNS requests. This may be either an IPv4 or an IPv6 address. .IP \(bu 2 \fBport\fP \- the port on which the server listens for DDNS requests. It defaults to the standard DNS service port of 53. .UNINDENT .sp To create a new forward DNS server, a new server element must be added to the domain and its parameters filled in. If, for example, the service is running at \(dq172.88.99.10\(dq, set the forward DNS server as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcpDdns\(dq: { \(dqforward\-ddns\(dq: { \(dqddns\-domains\(dq: [ { \(dqname\(dq: \(dqother.example.com.\(dq, \(dqkey\-name\(dq: \(dq\(dq, \(dqdns\-servers\(dq: [ { \(dqip\-address\(dq: \(dq172.88.99.10\(dq, \(dqport\(dq: 53 } ] } ] } } .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Since \fBhostname\fP is not yet supported, the parameter \fBip\-address\fP must be set to the address of the DNS server. .UNINDENT .UNINDENT .SS Reverse DDNS .sp The reverse DDNS section is used to configure D2\(aqs reverse update behavior, and the concepts are the same as for the forward DDNS section. Currently it contains a single parameter, the catalog of reverse DDNS domains, which is a list of structures. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcpDdns\(dq: { \(dqreverse\-ddns\(dq: { \(dqddns\-domains\(dq: [ ] }, ... } .EE .UNINDENT .UNINDENT .sp By default, this list is empty, which causes the server to ignore the reverse\-update portions of requests. .SS Adding Reverse DDNS Domains .sp A reverse DDNS domain maps a reverse DNS zone to a set of DNS servers which maintain the reverse DNS data (address\-to\-name mapping) for that zone. Each zone served needs one reverse DDNS domain. Some or all of the zones may be maintained by the same servers, but one DDNS domain entry is needed for each zone. Remember that matching a request to the appropriate server(s) is done by zone and a DDNS domain only defines a single zone. .sp This section describes how to add reverse DDNS domains; repeat these steps for each reverse DDNS domain desired. Each reverse DDNS domain has the following parameters: .INDENT 0.0 .IP \(bu 2 \fBname\fP \- this is the fully qualified reverse zone that this DDNS domain can update. This is the value used during reverse matching, which compares it with a reversed version of the request\(aqs lease address. The zone name should follow the appropriate standards; for example, to support the IPv4 subnet 172.16.1, the name should be \(dq1.16.172.in\-addr.arpa.\(dq. Similarly, to support an IPv6 subnet of 2001:db8:1, the name should be \(dq1.0.0.0.8.B.D.0.1.0.0.2.ip6.arpa.\(dq The name must be unique within the catalog. .IP \(bu 2 \fBkey\-name\fP \- if TSIG is used with this domain\(aqs servers, this value should be the name of the key from the TSIG key list. If the value is blank (the default), TSIG will not be used in DDNS conversations with this domain\(aqs servers. .IP \(bu 2 \fBdns\-servers\fP \- this is a list of one or more DNS servers which can conduct the server side of the DDNS protocol for this domain. Currently, the servers are used in a first\-to\-last preference; in other words, when D2 begins to process a request for this domain, it will pick the first server in this list and attempt to communicate with it. If that attempt fails, D2 will move to the next one in the list and so on, until either it is successful or the list is exhausted. .UNINDENT .sp To create a new reverse DDNS domain, a new domain element must be added and its parameters set. For example, to support subnet 2001:db8:1::, the following configuration could be used: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcpDdns\(dq: { \(dqreverse\-ddns\(dq: { \(dqddns\-domains\(dq: [ { \(dqname\(dq: \(dq1.0.0.0.8.B.D.0.1.0.0.2.ip6.arpa.\(dq, \(dqkey\-name\(dq: \(dq\(dq, \(dqdns\-servers\(dq: [ ] } ] } } .EE .UNINDENT .UNINDENT .sp It is possible to add a domain without any servers; however, if that domain matches a request, the request will fail. To make the domain useful, at least one DNS server must be added to it. .SS Adding Reverse DNS Servers .sp This section describes how to add DNS servers to a reverse DDNS domain. Repeat these instructions as needed for all the servers in each domain. .sp Reverse DNS server entries represent actual DNS servers which support the server side of the DDNS protocol. Each reverse DNS server has the following parameters: .INDENT 0.0 .IP \(bu 2 \fBhostname\fP \- the resolvable host name of the DNS server; this value is currently ignored. .IP \(bu 2 \fBip\-address\fP \- the IP address at which the server listens for DDNS requests. .IP \(bu 2 \fBport\fP \- the port on which the server listens for DDNS requests. It defaults to the standard DNS service port of 53. .UNINDENT .sp To create a new reverse DNS server, a new server element must be added to the domain and its parameters specified. If, for example, the service is running at \(dq172.88.99.10\(dq, then set it as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcpDdns\(dq: { \(dqreverse\-ddns\(dq: { \(dqddns\-domains\(dq: [ { \(dqname\(dq: \(dq1.0.0.0.8.B.D.0.1.0.0.2.ip6.arpa.\(dq, \(dqkey\-name\(dq: \(dq\(dq, \(dqdns\-servers\(dq: [ { \(dqip\-address\(dq: \(dq172.88.99.10\(dq, \(dqport\(dq: 53 } ] } ] } } .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Since \fBhostname\fP is not yet supported, the parameter \fBip\-address\fP must be set to the address of the DNS server. .UNINDENT .UNINDENT .SS Per\-DNS\-Server TSIG Keys .sp Since Kea version 2.0.0, a TSIG key can be specified in a DNS server configuration. The priority rule is: .INDENT 0.0 .IP \(bu 2 if a not\-empty key name is specified in a DNS server entry, this TSIG key protects DNS updates sent to this server. .IP \(bu 2 if the DNS server entry is empty, but a not\-empty key name is specified in the parent\(aqs domain entry, the parent domain\(aqs TSIG key protects DNS updates sent to this server. .IP \(bu 2 if the DNS server entry is empty, and no key name is specified in its parent domain entry, no TSIG protects DNS updates sent to this server. .UNINDENT .sp For instance, in this configuration: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcpDdns\(dq: { \(dqforward\-ddns\(dq: { \(dqddns\-domains\(dq: [ { \(dqname\(dq: \(dqother.example.com.\(dq, \(dqkey\-name\(dq: \(dqfoo\(dq, \(dqdns\-servers\(dq: [ { \(dqip\-address\(dq: \(dq172.88.99.10\(dq, \(dqport\(dq: 53 }, { \(dqip\-address\(dq: \(dq172.88.99.11\(dq, \(dqport\(dq: 53, \(dqkey\-name\(dq: \(dqbar\(dq } ] } ] }, \(dqreverse\-ddns\(dq: { \(dqddns\-domains\(dq: [ { \(dqname\(dq: \(dq1.0.0.0.8.B.D.0.1.0.0.2.ip6.arpa.\(dq, \(dqdns\-servers\(dq: [ { \(dqip\-address\(dq: \(dq172.88.99.12\(dq, \(dqport\(dq: 53 }, { \(dqip\-address\(dq: \(dq172.88.99.13\(dq, \(dqport\(dq: 53, \(dqkey\-name\(dq: \(dqbar\(dq } ] } ] }, \(dqtsig\-keys\(dq: [ { \(dqname\(dq: \(dqfoo\(dq, \(dqalgorithm\(dq: \(dqHMAC\-MD5\(dq, \(dqsecret\(dq: \(dqLSWXnfkKZjdPJI5QxlpnfQ==\(dq }, { \(dqname\(dq: \(dqbar\(dq, \(dqalgorithm\(dq: \(dqHMAC\-SHA224\(dq, \(dqsecret\(dq: \(dqbZEG7Ow8OgAUPfLWV3aAUQ==\(dq } ] } .EE .UNINDENT .UNINDENT .sp The 172.88.99.10 server will use the \(dqfoo\(dq TSIG key, the 172.88.99.11 and 172.88.99.13 servers will use the \(dqbar\(dq key. and 172.88.99.12 will not use TSIG. .SS User Contexts in DDNS .sp See \fI\%Comments and User Context\fP for additional background regarding the user context idea. .sp User contexts can be specified on a global scope, a DDNS domain, a DNS server, a TSIG key, and loggers. One other useful usage is the ability to store comments or descriptions; the parser translates a \(dqcomment\(dq entry into a user context with the entry, which allows a comment to be attached inside the configuration itself. .SS Example DHCP\-DDNS Server Configuration .sp This section provides a sample DHCP\-DDNS server configuration, based on a small example network. Let\(aqs suppose our example network has three domains, each with their own subnet. .SS Our example network .TS box center; l|l|l|l. T{ Domain T} T{ Subnet T} T{ Forward DNS Servers T} T{ Reverse DNS Servers T} _ T{ four.example.com T} T{ 192.0.2.0/24 T} T{ 172.16.1.5, 172.16.2.5 T} T{ 172.16.1.5, 172.16.2.5 T} _ T{ six.example.com T} T{ 2001:db8:1::/64 T} T{ 3001:1::50 T} T{ 3001:1::51 T} _ T{ example.com T} T{ 192.0.0.0/16 T} T{ 172.16.2.5 T} T{ 172.16.2.5 T} .TE .sp We need to construct three forward DDNS domains: .SS Forward DDNS domains needed .TS box center; l|l|l. T{ # T} T{ DDNS Domain Name T} T{ DNS Servers T} _ T{ .INDENT 0.0 .IP 1. 3 .UNINDENT T} T{ four.example.com. T} T{ 172.16.1.5, 172.16.2.5 T} _ T{ .INDENT 0.0 .IP 2. 3 .UNINDENT T} T{ six.example.com. T} T{ 3001:1::50 T} _ T{ .INDENT 0.0 .IP 3. 3 .UNINDENT T} T{ example.com. T} T{ 172.16.2.5 T} .TE .sp As discussed earlier, FQDN\-to\-domain matching is based on the longest match. The FQDN \(dqmyhost.four.example.com.\(dq matches the first domain (\(dqfour.example.com\(dq), while \(dqadmin.example.com.\(dq matches the third domain (\(dqexample.com\(dq). The FQDN \(dqother.example.net.\(dq fails to match any domain and is rejected. .sp The following example configuration specifies the forward DDNS domains. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcpDdns\(dq: { \(dqcomment\(dq: \(dqexample configuration: forward part\(dq, \(dqforward\-ddns\(dq: { \(dqddns\-domains\(dq: [ { \(dqname\(dq: \(dqfour.example.com.\(dq, \(dqkey\-name\(dq: \(dq\(dq, \(dqdns\-servers\(dq: [ { \(dqip\-address\(dq: \(dq172.16.1.5\(dq }, { \(dqip\-address\(dq: \(dq172.16.2.5\(dq } ] }, { \(dqname\(dq: \(dqsix.example.com.\(dq, \(dqkey\-name\(dq: \(dq\(dq, \(dqdns\-servers\(dq: [ { \(dqip\-address\(dq: \(dq2001:db8::1\(dq } ] }, { \(dqname\(dq: \(dqexample.com.\(dq, \(dqkey\-name\(dq: \(dq\(dq, \(dqdns\-servers\(dq: [ { \(dqip\-address\(dq: \(dq172.16.2.5\(dq } ], \(dquser\-context\(dq: { \(dqbackup\(dq: false } }, ... ] } } .EE .UNINDENT .UNINDENT .sp Similarly, we need to construct the three reverse DDNS domains: .SS Reverse DDNS domains needed .TS box center; l|l|l. T{ # T} T{ DDNS Domain Name T} T{ DNS Servers T} _ T{ .INDENT 0.0 .IP 1. 3 .UNINDENT T} T{ 2.0.192.in\-addr.arpa. T} T{ 172.16.1.5, 172.16.2.5 T} _ T{ .INDENT 0.0 .IP 2. 3 .UNINDENT T} T{ 1.0.0.0.8.d.b.0.1.0.0.2.ip6.arpa. T} T{ 3001:1::50 T} _ T{ .INDENT 0.0 .IP 3. 3 .UNINDENT T} T{ 0.182.in\-addr.arpa. T} T{ 172.16.2.5 T} .TE .sp An address of \(dq192.0.2.150\(dq matches the first domain, \(dq2001:db8:1::10\(dq matches the second domain, and \(dq192.0.50.77\(dq matches the third domain. .sp These reverse DDNS domains are specified as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcpDdns\(dq: { \(dqcomment\(dq: \(dqexample configuration: reverse part\(dq, \(dqreverse\-ddns\(dq: { \(dqddns\-domains\(dq: [ { \(dqname\(dq: \(dq2.0.192.in\-addr.arpa.\(dq, \(dqkey\-name\(dq: \(dq\(dq, \(dqdns\-servers\(dq: [ { \(dqip\-address\(dq: \(dq172.16.1.5\(dq }, { \(dqip\-address\(dq: \(dq172.16.2.5\(dq } ] }, { \(dqname\(dq: \(dq1.0.0.0.8.B.D.0.1.0.0.2.ip6.arpa.\(dq, \(dqkey\-name\(dq: \(dq\(dq, \(dqdns\-servers\(dq: [ { \(dqip\-address\(dq: \(dq2001:db8::1\(dq } ] }, { \(dqname\(dq: \(dq0.192.in\-addr.arpa.\(dq, \(dqkey\-name\(dq: \(dq\(dq, \(dqdns\-servers\(dq: [ { \(dqip\-address\(dq: \(dq172.16.2.5\(dq } ] }, ... ] } } .EE .UNINDENT .UNINDENT .SS DHCP\-DDNS Server Statistics .sp Kea version 2.0.0 introduced statistics support for DHCP\-DDNS. .sp Statistics are divided into three groups: NameChangeRequests, DNS updates, and per\-TSIG\-key DNS updates. While the statistics of the first two groups are cumulative, i.e. not affected by configuration change or reload, per\-key statistics are reset to 0 when the underlying object is (re)created. .sp Currently Kea\(aqs statistics management has the following limitations: .INDENT 0.0 .IP \(bu 2 only integer samples (i.e. a counter and a timestamp) are used; .IP \(bu 2 the maximum sample count is 1; .IP \(bu 2 there is no API to remove one or all statistics; .IP \(bu 2 there is no API to set the maximum sample count or age. .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Hook libraries, such as the ISC subscriber\-only GSS\-TSIG library, make new statistics available in Kea. .UNINDENT .UNINDENT .sp More information about Kea statistics can be found at \fI\%Statistics\fP\&. .SS NCR Statistics .sp The NameChangeRequest statistics are: .INDENT 0.0 .IP \(bu 2 \fBncr\-received\fP \- the number of received valid NCRs .IP \(bu 2 \fBncr\-invalid\fP \- the number of received invalid NCRs .IP \(bu 2 \fBncr\-error\fP \- the number of errors in NCR receptions other than an I/O cancel on shutdown .IP \(bu 2 \fBqueue\-mgr\-queue\-full\fP \- the number of times the NCR receive queue reached maxium capacity .UNINDENT .SS DNS Update Statistics .sp The global DNS update statistics are: .INDENT 0.0 .IP \(bu 2 \fBupdate\-sent\fP \- the number of DNS updates sent .IP \(bu 2 \fBupdate\-signed\fP \- the number of DNS updates sent and protected by TSIG .IP \(bu 2 \fBupdate\-unsigned\fP \- the number of DNS updates sent and not protected by TSIG .IP \(bu 2 \fBupdate\-success\fP \- the number of DNS updates which successfully completed .IP \(bu 2 \fBupdate\-timeout\fP \- the number of DNS updates which completed on timeout .IP \(bu 2 \fBupdate\-error\fP \- the number of DNS updates which completed with an error other than timeout .UNINDENT .SS Per\-TSIG\-Key DNS Update Statistics .sp The per TSIG key DNS update statistics are: .INDENT 0.0 .IP \(bu 2 \fBupdate\-sent\fP \- the number of DNS updates sent .IP \(bu 2 \fBupdate\-success\fP \- the number of DNS updates which successfully completed .IP \(bu 2 \fBupdate\-timeout\fP \- the number of DNS updates which completed on timeout .IP \(bu 2 \fBupdate\-error\fP \- the number of DNS updates which completed with an error other than timeout .UNINDENT .sp The name format for per\-key statistics is \fBkey[].\fP: for instance, the name of the \fBupdate\-sent\fP statistics for the \fBkey.example.com.\fP TSIG key is \fBkey[key.example.com.].update\-sent\fP\&. .SS DHCP\-DDNS Server Limitations .sp The following are the current limitations of the DHCP\-DDNS server. .INDENT 0.0 .IP \(bu 2 Requests received from the DHCP servers are placed in a queue until they are processed. Currently, all queued requests are lost if the server shuts down. .UNINDENT .SS Supported Standards .sp The following RFCs are supported by the DHCP\-DDNS server: .INDENT 0.0 .IP \(bu 2 \fISecret Key Transaction Authentication for DNS (TSIG)\fP, \X'tty: link https://tools.ietf.org/html/rfc2845'\fI\%RFC 2845\fP\X'tty: link': All DNS update packets sent and received by the DHCP\-DDNS server can be protected by TSIG signatures. .IP \(bu 2 \fIDynamic Updates in the Domain Name System (DNS UPDATE)\fP, \X'tty: link https://tools.ietf.org/html/rfc2136'\fI\%RFC 2136\fP\X'tty: link': The complete DNS update mechanism is supported. .IP \(bu 2 \fIResolution of Fully Qualified Domain Name (FQDN) Conflicts among Dynamic Host Configuration Protocol (DHCP) Clients\fP, \X'tty: link https://tools.ietf.org/html/rfc4703'\fI\%RFC 4703\fP\X'tty: link': DHCP\-DDNS takes care of conflict resolution, for both DHCPv4 and DHCPv6 servers. .IP \(bu 2 \fIA DNS Resource Record (RR) for Encoding Dynamic Host Configuration Protocol (DHCP) Information (DHCID RR)\fP, \X'tty: link https://tools.ietf.org/html/rfc4701'\fI\%RFC 4701\fP\X'tty: link': The DHCP\-DDNS server uses DHCID records. .UNINDENT .SH THE LFC PROCESS .SS Overview .sp \fI\%kea\-lfc\fP is a service process that removes redundant information from the files used to provide persistent storage for the memfile database backend. This service is written to run as a standalone process. .sp While \fI\%kea\-lfc\fP can be started externally, there is usually no need to do so. \fI\%kea\-lfc\fP is run on a periodic basis by the Kea DHCP servers. .sp The process operates on a set of files, using them to receive input and output of the lease entries and to indicate what stage the process is in, in the event of an interruption. Currently the caller must supply names for all of the files. .SS Command\-Line Options .sp \fI\%kea\-lfc\fP is run as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX kea\-lfc [\-4 | \-6] \-c config\-file \-p pid\-file \-x previous\-file \-i copy\-file \-o output\-file \-f finish\-file .EE .UNINDENT .UNINDENT .sp The argument \fB\-4\fP or \fB\-6\fP selects the protocol version of the lease files. .sp The \fB\-c\fP argument specifies the configuration file. This is required, but is not currently used by the process. .sp The \fB\-p\fP argument specifies the PID file. When the \fI\%kea\-lfc\fP process starts, it attempts to determine whether another instance of the process is already running by examining the PID file. If one is already running, the new process is terminated; if one is not running, Kea writes its PID into the PID file. .sp The other filenames specify where the \fI\%kea\-lfc\fP process should look for input, write its output, and perform its bookkeeping: .INDENT 0.0 .IP \(bu 2 \fBprevious\fP — when \fI\%kea\-lfc\fP starts, this is the result of any previous run of \fI\%kea\-lfc\fP\&. When \fI\%kea\-lfc\fP finishes, it is the result of this run. If \fI\%kea\-lfc\fP is interrupted before completing, this file may not exist. .IP \(bu 2 \fBinput\fP — before the DHCP server invokes \fI\%kea\-lfc\fP, it moves the current lease file here and then calls \fI\%kea\-lfc\fP with this file. .IP \(bu 2 \fBoutput\fP — this is the temporary file where \fI\%kea\-lfc\fP writes the leases. Once the file has finished writing, it is moved to the \fBfinish\fP file (see below). .IP \(bu 2 \fBfinish\fP — this is another temporary file \fI\%kea\-lfc\fP uses for bookkeeping. When \fI\%kea\-lfc\fP completes writing the \fBoutput\fP file, it moves the contents to the file of this name. After \fI\%kea\-lfc\fP finishes deleting the other files (\fBprevious\fP and \fBinput\fP), it moves this file to the \fBprevious\fP lease file. By moving the files in this fashion, \fI\%kea\-lfc\fP and the DHCP server processes can determine the correct file to use even if one of the processes is interrupted before completing its task. .UNINDENT .sp There are several additional arguments, mostly for debugging purposes. \fB\-d\fP sets the logging level to debug. \fB\-v\fP and \fB\-V\fP print out version stamps, with \fB\-V\fP providing a longer form. \fB\-h\fP prints out the usage string. .SH CLIENT CLASSIFICATION .SS Client Classification Overview .sp In certain cases it is useful to differentiate among different types of clients and treat them accordingly. Common reasons include: .INDENT 0.0 .IP \(bu 2 The clients represent different pieces of topology, e.g. a cable modem is not the same as the clients behind that modem. .IP \(bu 2 The clients have different behavior, e.g. a smartphone behaves differently from a laptop. .IP \(bu 2 The clients require different values for some options, e.g. a docsis3.0 cable modem requires different settings from a docsis2.0 cable modem. .UNINDENT .sp To make management easier, different clients can be grouped into a client class to receive common options. .sp An incoming packet can be associated with a client class in several ways: .INDENT 0.0 .IP \(bu 2 Implicitly, using a vendor class option or another built\-in condition. .IP \(bu 2 Using an expression which evaluates to \fBtrue\fP\&. .IP \(bu 2 Using static host reservations, a shared network, a subnet, etc. .IP \(bu 2 Using a hook. .UNINDENT .sp Client classification can be used to change the behavior of almost any part of the DHCP message processing. There are currently nine mechanisms that take advantage of client classification: .INDENT 0.0 .IP \(bu 2 Dropping queries. .IP \(bu 2 Subnet selection. .IP \(bu 2 Pool selection. .IP \(bu 2 Lease limiting. .IP \(bu 2 Rate limiting. .IP \(bu 2 DDNS tuning. .IP \(bu 2 Defining DHCPv4 private (codes 224\-254) and code 43 options. .IP \(bu 2 Assigning different options. .IP \(bu 2 Setting specific options for use with the TFTP server address and the boot file field for DHCPv4 cable modems. .UNINDENT .SS Classification Steps .sp The classification process is conducted in several steps: .INDENT 0.0 .IP 1. 3 The \fBALL\fP class is associated with the incoming packet. .IP 2. 3 Vendor class options are processed. .IP 3. 3 Classes with matching expressions and not marked for later evaluation (\(dqon request\(dq or depending on the \fBKNOWN\fP/\fBUNKNOWN\fP built\-in classes) are processed in the order they are defined in the configuration; the boolean expression is evaluated and, if it returns \fBtrue\fP (a match), the incoming packet is associated with the class. .IP 4. 3 If a private or code 43 DHCPv4 option is received, it is decoded following its client\-class or global (or, for option 43, last\-resort) definition. .IP 5. 3 When the incoming packet belongs to the special class \fBDROP\fP, it is dropped and an informational message is logged with the packet information. .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The \fBpkt4_receive\fP and \fBpkt6_receive\fP callouts are called here. .UNINDENT .UNINDENT .INDENT 0.0 .IP 6. 3 When the \fBearly\-global\-reservations\-lookup\fP global parameter is configured to \fBtrue\fP, the process looks up global reservations and partially performs steps 8, 9, and 10. The lookup is limited to global reservations; if one is found the \fBKNOWN\fP class is set, but if none is found the \fBUNKNOWN\fP class is \fBnot\fP set. .IP 7. 3 A subnet is chosen, possibly based on the class information when some subnets are reserved. More precisely: when choosing a subnet, the server iterates over all of the subnets that are feasible given the information found in the packet (client address, relay address, etc.). It uses the first subnet it finds that either has no class associated with it, or has a class which matches one of the packet\(aqs classes. .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The \fBsubnet4_select\fP and \fBsubnet6_select\fP callouts are called here. .UNINDENT .UNINDENT .INDENT 0.0 .IP 8. 3 The server looks for host reservations. If an identifier from the incoming packet matches a host reservation in the subnet or shared network, the packet is associated with the \fBKNOWN\fP class and all classes of the host reservation. If a reservation is not found, the packet is assigned to the \fBUNKNOWN\fP class. .IP 9. 3 Classes with matching expressions \- directly, or indirectly using the \fBKNOWN\fP/\fBUNKNOWN\fP built\-in classes and not marked for later evaluation (\(dqon request\(dq) \- are processed in the order they are defined in the configuration; the boolean expression is evaluated and, if it returns \fBtrue\fP (a match), the incoming packet is associated with the class. After a subnet is selected, the server determines whether there is a reservation for a given client. Therefore, it is not possible to use the \fBUNKNOWN\fP class to select a shared network or a subnet. For the \fBKNOWN\fP class, only global reservations are used and the \fBearly\-global\-reservations\-lookup\fP parameter must be configured to \fBtrue\fP\&. .IP 10. 3 When the incoming packet belongs to the special class \fBDROP\fP, it is dropped and an informational message is logged with the packet information. Since Kea version 1.9.8, it is permissible to make the \fBDROP\fP class dependent on the \fBKNOWN\fP/\fBUNKNOWN\fP classes. .IP 11. 3 If needed, addresses and prefixes from pools are assigned, possibly based on the class information when some pools are reserved for class members. .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The \fBlease4_select\fP, \fBlease4_renew\fP, \fBlease6_select\fP, \fBlease6_renew\fP, and \fBlease6_rebind\fP callouts are called here. .UNINDENT .UNINDENT .INDENT 0.0 .IP 12. 4 The \fBevaluate\-additional\-classes\fP lists (if any) are evaluated first for the pool, then the subnet, and the finally shared\-network to which the assigned resources belong. Classes are evaluated in the order they appear within each list. .IP 13. 4 Options are assigned, again possibly based on the class information in the order that classes were associated with the incoming packet. The first class matched to the packet which specifies a given option wins. For DHCPv4 private and code 43 options, this includes option definitions specified within classes. The order of precedence for options is as follows: .INDENT 4.0 .IP 1. 3 Host options .IP 2. 3 Pool options .IP 3. 3 Subnet options .IP 4. 3 Shared network options .IP 5. 3 Options from classes assigned during normal classification: .INDENT 4.0 .INDENT 3.5 .INDENT 0.0 .IP a. 3 \fBALL\fP class .IP b. 3 Vendor classes .IP c. 3 Host classes .IP d. 3 Evaluated classes that do not depend on \fBKNOWN\fP class .IP e. 3 \fBKNOWN\fP and \fBUNKNOWN\fP classes .IP f. 3 Evaluated classes that depend on \fBKNOWN\fP class .UNINDENT .UNINDENT .UNINDENT .IP 6. 3 Options from classes in \fBevaluate\-additional\-classes\fP from: .INDENT 4.0 .INDENT 3.5 .INDENT 0.0 .IP a. 3 Pool .IP b. 3 Subnet .IP c. 3 Shared network .UNINDENT .UNINDENT .UNINDENT .IP 7. 3 Global options .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Care should be taken with client classification, as it is easy for clients that do not meet any class criteria to be denied service altogether. .UNINDENT .UNINDENT .SS Built\-in Client Classes .sp Some classes are built\-in, so they do not need to be explicitly defined. They can be defined if there is a need to associate lease lifetimes, option data, etc. with them. .sp Vendor class information is the primary example: the server checks whether an incoming DHCPv4 packet includes the vendor class identifier option (60) or an incoming DHCPv6 packet includes the vendor class option (16). If it does, the content of that option is prepended with \fBVENDOR_CLASS_\fP and the result is interpreted as a class for that packet. The content that is considered is the whole class identifier for DHCPv4, and the first vendor class data field for DHCPv6. The enterprise number and subsequent vendor class data fields are not used for the purpose of classification. For example, modern cable modems send such options with value \fBdocsis3.0\fP, so the packet belongs to class \fBVENDOR_CLASS_docsis3.0\fP\&. .sp The \fBHA_\fP prefix is used by \fI\%libdhcp_ha.so\fP to designate certain servers to process DHCP packets as a result of load balancing. The class name is constructed by prepending the \fBHA_\fP prefix to the name of the server which should process the DHCP packet. This server uses an appropriate pool or subnet to allocate IP addresses (and/or prefixes), based on the assigned client classes. The details can be found in \fI\%libdhcp_ha.so: High Availability Outage Resilience for Kea Servers\fP\&. .sp The \fBSPAWN_\fP prefix is used by template classes to generate spawned class names at runtime. The spawned class name is constructed by prepending the \fBSPAWN_\fP prefix to the template class name and the evaluated value: \fBSPAWN__\fP\&. More details can be found in \fI\%Configuring Classes\fP\&. .sp The \fBBOOTP\fP class is used by \fI\%libdhcp_bootp.so\fP to classify and respond to inbound BOOTP queries. .sp The \fBSKIP_DDNS\fP class is used by the DDNS\-tuning hook library to suppress DDNS updates on a per client basis. .sp Other examples are the \fBALL\fP class, to which all incoming packets belong, and the \fBKNOWN\fP class, assigned when host reservations exist for a particular client. By convention, the names of built\-in classes begin with all capital letters. .sp Currently recognized built\-in class names are \fBALL\fP, \fBKNOWN\fP and \fBUNKNOWN\fP, and the prefixes \fBVENDOR_CLASS_\fP, \fBHA_\fP, \fBAFTER_\fP, \fBEXTERNAL_\fP, \fBSKIP_DDNS\fP\&. Although the \fBAFTER_\fP prefix is a provision for an as\-yet\-unwritten hook, the \fBEXTERNAL_\fP prefix can be freely used; built\-in classes are implicitly defined so they never raise warnings if they do not appear in the configuration. .SS Using Expressions in Classification .sp The expression portion of a classification definition contains operators and values. All values are currently strings; operators take a string or strings and return another string. When all the operations have completed, the result should be a value of \fBtrue\fP or \fBfalse\fP\&. The packet belongs to the class (and the class name is added to the list of classes) if the result is \fBtrue\fP\&. Expressions are written in standard format and can be nested. .sp Expressions are pre\-processed during the parsing of the configuration file and converted to an internal representation. This allows certain types of errors to be caught and logged during parsing. Examples of these errors include an incorrect number or type of argument to an operator. The evaluation code also checks for this class of error and generally throws an exception, though this should not occur in a normally functioning system. .sp Other issues, such as the starting position of a substring being outside of the substring or an option not existing in the packet, result in the operator returning an empty string. .sp Dependencies between classes are also checked. For instance, forward dependencies are rejected when the configuration is parsed; an expression can only depend on already\-defined classes (including built\-in classes) which are evaluated in a previous or the same evaluation phase. This does not apply to the \fBKNOWN\fP or \fBUNKNOWN\fP classes. .SS List of classification values .TS box center; l|l|l. T{ Name T} T{ Example expression T} T{ Example value T} _ T{ String literal T} T{ \(aqexample\(aq T} T{ \(aqexample\(aq T} _ T{ Hexadecimal string literal T} T{ 0x5a7d T} T{ \(aqZ}\(aq T} _ T{ IP address literal T} T{ 10.0.0.1 T} T{ 0x0a000001 T} _ T{ Integer literal T} T{ 123 T} T{ \(aq123\(aq T} _ T{ Binary content of the option T} T{ option[123].hex T} T{ \(aq(content of the option)\(aq T} _ T{ Option existence T} T{ option[123].exists T} T{ \(aqtrue\(aq T} _ T{ Binary content of the sub\-option T} T{ option[12].option[34].hex T} T{ \(aq(content of the sub\-option)\(aq T} _ T{ Sub\-Option existence T} T{ option[12].option[34].exists T} T{ \(aqtrue\(aq T} _ T{ Client class membership T} T{ member(\(aqfoobar\(aq) T} T{ \(aqtrue\(aq T} _ T{ Known client T} T{ known T} T{ member(\(aqKNOWN\(aq) T} _ T{ Unknown client T} T{ unknown T} T{ not member(\(aqKNOWN\(aq) T} _ T{ DHCPv4 relay agent sub\-option T} T{ relay4[123].hex T} T{ \(aq(content of the RAI sub\-option)\(aq T} _ T{ DHCPv6 Relay Options T} T{ relay6[nest].option[code].hex T} T{ (value of the option) T} _ T{ DHCPv6 Relay Peer Address T} T{ relay6[nest].peeraddr T} T{ 2001:DB8::1 T} _ T{ DHCPv6 Relay Link Address T} T{ relay6[nest].linkaddr T} T{ 2001:DB8::1 T} _ T{ Interface name of packet T} T{ pkt.iface T} T{ eth0 T} _ T{ Source address of packet T} T{ pkt.src T} T{ 10.1.2.3 T} _ T{ Destination address of packet T} T{ pkt.dst T} T{ 10.1.2.3 T} _ T{ Length of packet T} T{ pkt.len T} T{ 513 T} _ T{ Hardware address in DHCPv4 packet T} T{ pkt4.mac T} T{ 0x010203040506 T} _ T{ Hardware length in DHCPv4 packet T} T{ pkt4.hlen T} T{ 6 T} _ T{ Hardware type in DHCPv4 packet T} T{ pkt4.htype T} T{ 6 T} _ T{ ciaddr field in DHCPv4 packet T} T{ pkt4.ciaddr T} T{ 192.0.2.1 T} _ T{ giaddr field in DHCPv4 packet T} T{ pkt4.giaddr T} T{ 192.0.2.1 T} _ T{ yiaddr field in DHCPv4 packet T} T{ pkt4.yiaddr T} T{ 192.0.2.1 T} _ T{ siaddr field in DHCPv4 packet T} T{ pkt4.siaddr T} T{ 192.0.2.1 T} _ T{ Message type in DHCPv4 packet T} T{ pkt4.msgtype T} T{ 1 T} _ T{ Transaction ID (xid) in DHCPv4 packet T} T{ pkt4.transid T} T{ 12345 T} _ T{ Message type in DHCPv6 packet T} T{ pkt6.msgtype T} T{ 1 T} _ T{ Transaction ID in DHCPv6 packet T} T{ pkt6.transid T} T{ 12345 T} _ T{ Vendor option existence (any vendor) T} T{ vendor[*].exists T} T{ \(aqtrue\(aq T} _ T{ Vendor option existence (specific vendor) T} T{ vendor[4491].exists T} T{ \(aqtrue\(aq T} _ T{ Enterprise\-id from vendor option T} T{ vendor.enterprise T} T{ 4491 T} _ T{ Vendor sub\-option existence T} T{ vendor[4491].option[1].exists T} T{ \(aqtrue\(aq T} _ T{ Vendor sub\-option content T} T{ vendor[4491].option[1].hex T} T{ docsis3.0 T} _ T{ Vendor class option existence (any vendor) T} T{ vendor\-class[*].exists T} T{ \(aqtrue\(aq T} _ T{ Vendor class option existence (specific vendor) T} T{ vendor\-class[4491].exists T} T{ \(aqtrue\(aq T} _ T{ Enterprise\-id from vendor class option T} T{ vendor\-class.enterprise T} T{ 4491 T} _ T{ First data chunk from vendor class option T} T{ vendor\-class[4491].data T} T{ docsis3.0 T} _ T{ Specific data chunk from vendor class option T} T{ vendor\-class[4491].data[3] T} T{ docsis3.0 T} .TE .sp Notes: .INDENT 0.0 .IP \(bu 2 Hexadecimal strings are converted into a string as expected. The starting \fB0X\fP or \fB0x\fP is removed, and if the string is an odd number of characters a \(dq0\(dq is prepended to it. .IP \(bu 2 IP addresses are converted into strings of length 4 or 16. IPv4, IPv6, and IPv4\-embedded IPv6 (e.g. IPv4\-mapped IPv6) addresses are supported. .IP \(bu 2 Integers in an expression are converted to 32\-bit unsigned integers and are represented as four\-byte strings; for example, 123 is represented as \fB0x0000007b\fP\&. All expressions that return numeric values use 32\-bit unsigned integers, even if the field in the packet is smaller. In general, it is easier to use decimal notation to represent integers, but it is also possible to use hexadecimal notation. When writing an integer in hexadecimal, care should be taken to make sure the value is represented as 32 bits, e.g. use \fB0x00000001\fP instead of \fB0x1\fP or \fB0x01\fP\&. Also, make sure the value is specified in network order, e.g. 1 is represented as \fB0x00000001\fP\&. .IP \(bu 2 \fBoption[code].hex\fP extracts the value of the option with the code \fBcode\fP from the incoming packet. If the packet does not contain the option, it returns an empty string. The string is presented as a byte string of the option payload, without the type code or length fields. .IP \(bu 2 \fBoption[code].exists\fP checks whether an option with the code \fBcode\fP is present in the incoming packet. It can be used with empty options. .IP \(bu 2 \fBmember(\(aqfoobar\(aq)\fP checks whether the packet belongs to the client class \fBfoobar\fP\&. To avoid dependency loops, the configuration file parser verifies whether client classes were already defined or are built\-in, i.e., beginning with \fBVENDOR_CLASS_\fP, \fBAFTER_\fP (for the to\-come \(dqafter\(dq hook) and \fBEXTERNAL_\fP or equal to \fBALL\fP, \fBKNOWN\fP, \fBUNKNOWN\fP, etc. .sp \fBknown\fP and \fBunknown\fP are shorthand for \fBmember(\(aqKNOWN\(aq)\fP and \fBnot member(\(aqKNOWN\(aq)\fP\&. Note that the evaluation of any expression using the \fBKNOWN\fP class (directly or indirectly) is deferred after the host reservation lookup (i.e. when the \fBKNOWN\fP or \fBUNKNOWN\fP partition is determined). .IP \(bu 2 \fBrelay4[code].hex\fP attempts to extract the value of the sub\-option \fBcode\fP from the option inserted as the DHCPv4 Relay Agent Information (82) option. If the packet does not contain a RAI option, or the RAI option does not contain the requested sub\-option, the expression returns an empty string. The string is presented as a byte string of the option payload without the type code or length fields. This expression is allowed in DHCPv4 only. .IP \(bu 2 \fBrelay4\fP shares the same representation types as \fBoption\fP; for instance, \fBrelay4[code].exists\fP is supported. .IP \(bu 2 \fBrelay6[nest]\fP allows access to the encapsulations used by any DHCPv6 relays that forwarded the packet. The \fBnest\fP level specifies the relay from which to extract the information, with a value of 0 indicating the relay closest to the DHCPv6 server. Negative values allow relays to be specified counting from the DHCPv6 client, with \-1 indicating the relay closest to the client. If the requested encapsulation does not exist, an empty string \fB\(dq\(dq\fP is returned. This expression is allowed in DHCPv6 only. .IP \(bu 2 \fBrelay6[nest].option[code]\fP shares the same representation types as \fBoption\fP; for instance, \fBrelay6[nest].option[code].exists\fP is supported. .IP \(bu 2 Expressions starting with \fBpkt4\fP can be used only in DHCPv4. They allow access to DHCPv4 message fields. .IP \(bu 2 \fBpkt6\fP refers to information from the client request. To access any information from an intermediate relay, use \fBrelay6\fP\&. \fBpkt6.msgtype\fP and \fBpkt6.transid\fP output a 4\-byte binary string for the message type or transaction ID. For example, the message type \fBSOLICIT\fP is \fB0x00000001\fP or simply 1, as in \fBpkt6.msgtype == 1\fP\&. .IP \(bu 2 \(dqVendor option\(dq means the Vendor\-Identifying Vendor\-Specific Information option in DHCPv4 (code 125; see \X'tty: link https://tools.ietf.org/html/rfc3925#section-4'\fI\%Section 4 of RFC 3925\fP\X'tty: link') and the Vendor\-Specific Information Option in DHCPv6 (code 17, defined in \X'tty: link https://tools.ietf.org/html/rfc8415#section-21.17'\fI\%Section 21.17 of RFC 8415\fP\X'tty: link'). \(dqVendor class option\(dq means the Vendor\-Identifying Vendor Class Option in DHCPv4 (code 124; see \X'tty: link https://tools.ietf.org/html/rfc3925#section-3'\fI\%Section 3 of RFC 3925\fP\X'tty: link') in DHCPv4 and the Class Option in DHCPv6 (code 16; see \X'tty: link https://tools.ietf.org/html/rfc8415#section-21.16'\fI\%Section 21.16 of RFC 8415\fP\X'tty: link'). Vendor options may have sub\-options that are referenced by their codes. Vendor class options do not have sub\-options, but rather data chunks, which are referenced by index value. Index 0 means the first data chunk, index 1 is for the second data chunk (if present), etc. .IP \(bu 2 In the vendor and vendor\-class constructs an asterisk (*) or 0 can be used to specify a wildcard \fBenterprise\-id\fP value, i.e. it will match any \fBenterprise\-id\fP value. .IP \(bu 2 Vendor Class Identifier (option 60 in DHCPv4) can be accessed using the option[60] expression. .IP \(bu 2 \X'tty: link https://tools.ietf.org/html/rfc3925'\fI\%RFC 3925\fP\X'tty: link' and \X'tty: link https://tools.ietf.org/html/rfc8415'\fI\%RFC 8415\fP\X'tty: link' allow for multiple instances of vendor options to appear in a single message. The client classification code currently examines the first instance if more than one appear. For the \fBvendor.enterprise\fP and \fBvendor\-class.enterprise\fP expressions, the value from the first instance is returned. Please submit a feature request on the \X'tty: link https://gitlab.isc.org/isc-projects/kea'\fI\%Kea GitLab site\fP\X'tty: link' to request support for multiple instances. .UNINDENT .SS List of classification expressions .TS box center; l|l|l. T{ Name T} T{ Example T} T{ Description T} _ T{ Equal T} T{ \(aqfoo\(aq == \(aqbar\(aq T} T{ Compare the two values and return \fBtrue\fP or \fBfalse\fP T} _ T{ Match T} T{ match(\(aqfoo.*\(aq, \(aqfoobar\(aq) T} T{ Match a regular expression with a value. T} _ T{ Not T} T{ not (\(aqfoo\(aq == \(aqbar\(aq) T} T{ Logical negation T} _ T{ And T} T{ (\(aqfoo\(aq == \(aqbar\(aq) and (\(aqbar\(aq == \(aqfoo\(aq) T} T{ Logical and T} _ T{ Or T} T{ (\(aqfoo\(aq == \(aqbar\(aq) or (\(aqbar\(aq == \(aqfoo\(aq) T} T{ Logical or T} _ T{ Substring T} T{ substring(\(aqfoobar\(aq,0,3) T} T{ Return the requested substring T} _ T{ Concat T} T{ concat(\(aqfoo\(aq,\(aqbar\(aq) T} T{ Return the concatenation of the strings T} _ T{ Concat (operator +) T} T{ \(aqfoo\(aq + \(aqbar\(aq T} T{ Return the concatenation of the strings T} _ T{ Ifelse T} T{ ifelse(\(aqfoo\(aq == \(aqbar\(aq,\(aqus\(aq,\(aqthem\(aq) T} T{ Return the branch value according to the condition T} _ T{ Hexstring T} T{ hexstring(\(aqfoo\(aq, \(aq\-\(aq) T} T{ Converts the value to a hexadecimal string, e.g. 66\-6F\-6F T} _ T{ Lcase T} T{ lcase(\(aqLoWeR\(aq) T} T{ Converts the value of a string expression to lower case, e.g. \(aqlower\(aq T} _ T{ Ucase T} T{ ucase(\(aquPpEr\(aq) T} T{ Converts the value of a string expression to upper case, e.g. \(aqUPPER\(aq T} _ T{ Split T} T{ split(\(aqfoo.bar\(aq, \(aq.\(aq, 2) T} T{ Return the second field, splitting on dots. T} .TE .SS List of conversion\-to\-text expressions .TS box center; l|l|l. T{ Name T} T{ Example T} T{ Description T} _ T{ AddressToText T} T{ addrtotext (192.10.0.1) addrtotext (2003:db8::) T} T{ Represent the 4 bytes of an IPv4 address or the 16 bytes of an IPv6 address in human readable format T} _ T{ Int8ToText T} T{ int8totext (\-1) T} T{ Represents the 8\-bit signed integer in text format T} _ T{ Int16ToText T} T{ int16totext (\-1) T} T{ Represents the 16\-bit signed integer in text format T} _ T{ Int32ToText T} T{ int32totext (\-1) T} T{ Represents the 32\-bit signed integer in text format T} _ T{ UInt8ToText T} T{ uint8totext (255) T} T{ Represents the 8\-bit unsigned integer in text format T} _ T{ UInt16ToText T} T{ uint16totext (65535) T} T{ Represents the 16\-bit unsigned integer in text format T} _ T{ UInt32ToText T} T{ uint32totext (4294967295) T} T{ Represents the 32\-bit unsigned integer in text format T} .TE .sp Notes: .sp The conversion operators can be used to transform data from binary to the text representation. The only requirement is that the input data type length matches an expected value. .sp The \fBAddressToText\fP token expects 4 bytes for IPv4 addresses or 16 bytes for IPv6 addresses. The \fBInt8ToText\fP and \fBUInt8ToText\fP tokens expect 1 byte, the \fBInt16ToText\fP and \fBUInt16ToText\fP tokens expect 2 bytes, and \fBInt32ToText\fP and \fBUInt32ToText\fP expect 4 bytes. For all conversion tokens, if the data length is 0, the result string is empty. .SS Predicates .sp The two predicates are Equal and Match. They can be used to build other common predicates, for instance: .INDENT 0.0 .INDENT 3.5 .sp .EX not (substring(\(aqfoobar\(aq, 3, 3) == \(aqbar\(aq) match(\(aqfoo.*\(aq, lcase(\(aqFooBar\(aq)) match(\(aq.*foo.*\(aq, \(aqis it foo or bar\(aq) match(\(aq^.*foo.*$\(aq, \(aqis it foo or bar\(aq) .EE .UNINDENT .UNINDENT .sp So inequality, case insensitive pattern matching or pattern search. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Detected invalid regular expressions are considered as syntax errors, runtime exceptions during match are handled as no match. .UNINDENT .UNINDENT .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Be careful with the match operator as it can result in very poor performance leading to regular expression denial of service (ReDoS). .UNINDENT .UNINDENT .SS Logical Operators .sp The Not, And, and Or logical operators are the common operators. Not has the highest precedence and Or the lowest. And and Or are (left) associative. Parentheses around a logical expression can be used to enforce a specific grouping; for instance, in \(dqA and (B or C)\(dq. Without parentheses, \(dqA and B or C\(dq means \(dq(A and B) or C\(dq. .SS Substring .sp The substring operator \fBsubstring(value, start, length)\fP accepts both positive and negative values for the starting position and the length. For \fBstart\fP, a value of 0 is the first byte in the string while \-1 is the last byte. If the starting point is outside of the original string an empty string is returned. \fBlength\fP is the number of bytes to extract. A negative number means to count towards the beginning of the string but does not include the byte pointed to by \fBstart\fP\&. The special value \fBall\fP means to return all bytes from start to the end of the string. If the length is longer than the remaining portion of the string, then the entire remaining portion is returned. Some examples may be helpful: .INDENT 0.0 .INDENT 3.5 .sp .EX substring(\(aqfoobar\(aq, 0, 6) == \(aqfoobar\(aq substring(\(aqfoobar\(aq, 3, 3) == \(aqbar\(aq substring(\(aqfoobar\(aq, 3, all) == \(aqbar\(aq substring(\(aqfoobar\(aq, 1, 4) == \(aqooba\(aq substring(\(aqfoobar\(aq, \-5, 4) == \(aqooba\(aq substring(\(aqfoobar\(aq, \-1, \-3) == \(aqoba\(aq substring(\(aqfoobar\(aq, 4, \-2) == \(aqob\(aq substring(\(aqfoobar\(aq, 10, 2) == \(aq\(aq .EE .UNINDENT .UNINDENT .SS Concat .sp The concat function \fBconcat(string1, string2)\fP returns the concatenation of its two arguments. For instance: .INDENT 0.0 .INDENT 3.5 .sp .EX concat(\(aqfoo\(aq, \(aqbar\(aq) == \(aqfoobar\(aq .EE .UNINDENT .UNINDENT .sp For user convenience, Kea version 1.9.8 added an associative operator version of the concat function. For instance: .INDENT 0.0 .INDENT 3.5 .sp .EX \(aqabc\(aq + \(aqdef\(aq + \(aqghi\(aq + \(aqjkl\(aq + \(aq...\(aq .EE .UNINDENT .UNINDENT .sp is the same as: .INDENT 0.0 .INDENT 3.5 .sp .EX concat(concat(concat(concat(\(aqabc\(aq, \(aqdef\(aq), \(aqghi\(aq), \(aqjkl\(aq), \(aq...\(aq) .EE .UNINDENT .UNINDENT .sp or: .INDENT 0.0 .INDENT 3.5 .sp .EX concat(\(aqabc\(aq, concat(\(aqdef\(aq, concat(\(aqghi\(aq, concat(\(aqjkl\(aq, \(aq...\(aq)))) .EE .UNINDENT .UNINDENT .sp or: .INDENT 0.0 .INDENT 3.5 .sp .EX \(aqabcdefghijkl...\(aq .EE .UNINDENT .UNINDENT .SS Split .sp The split operator \fBsplit(value, delimiters, field\-number)\fP accepts a list of characters to use as delimiters and a positive field number of the desired field when the value is split into fields separated by the delimiters. Adjacent delimiters are not compressed out, rather they result in an empty string for that field number. If value is an empty string, the result will be an empty string. If the delimiters list is empty, the result will be the original value. If the field\-number is less than one or larger than the number of fields, the result will be an empty string. Some examples follow: .INDENT 0.0 .INDENT 3.5 .sp .EX split (\(aqone.two..four\(aq, \(aq.\(aq, 1) == \(aqone\(aq split (\(aqone.two..four\(aq, \(aq.\(aq, 2) == \(aqtwo\(aq split (\(aqone.two..four\(aq, \(aq.\(aq, 3) == \(aq\(aq split (\(aqone.two..four\(aq, \(aq.\(aq, 4) == \(aqfour\(aq split (\(aqone.two..four\(aq, \(aq.\(aq, 5) == \(aq\(aq .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 To use a hard\-to\-escape character as a delimiter, use its ASCII hex value. For example, split by \fBsingle quote\fP using \fB0x27\fP: \fBsplit(option[39].text, 0x27, 1)\fP .UNINDENT .UNINDENT .SS Ifelse .sp The ifelse function \fBifelse(cond, iftrue, ifelse)\fP returns the \fBiftrue\fP or \fBifelse\fP branch value following the boolean condition \fBcond\fP\&. For instance: .INDENT 0.0 .INDENT 3.5 .sp .EX ifelse(option[230].exists, option[230].hex, \(aqnone\(aq) .EE .UNINDENT .UNINDENT .SS Hexstring .sp The hexstring function \fBhexstring(binary, separator)\fP returns the binary value as its hexadecimal string representation: pairs of hexadecimal digits separated by the separator, e.g \fB\(aq:\(aq\fP, \fB\(aq\-\(aq\fP, \fB\(aq\(aq\fP (empty separator). .INDENT 0.0 .INDENT 3.5 .sp .EX hexstring(pkt4.mac, \(aq:\(aq) .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The expression for each class is executed on each packet received. If the expressions are overly complex, the time taken to execute them may impact the performance of the server. Administrators who need complex or time\-consuming expressions should consider writing a \fI\%hook\fP to perform the necessary work. .UNINDENT .UNINDENT .SS Configuring Classes .INDENT 0.0 .TP .B A client class definition can contain the following properties: .INDENT 7.0 .IP \(bu 2 The \fBname\fP parameter is mandatory and must be unique among all classes. .IP \(bu 2 The \fBtest\fP expression is not mandatory and represents a string containing the logical expression used to determine membership in the class. The entire expression is included in double quotes (\fB\(dq\fP). The result should evaluate to a boolean value (\fBtrue\fP or \fBfalse\fP). .IP \(bu 2 The \fBtemplate\-test\fP expression is not mandatory and represents a string containing the logical expression used to generate a spawning class. The entire expression is included in double quotes (\fB\(dq\fP). The result should evaluate to a string value representing the variable part of the spawned class name. If the resulting string is empty, no spawning class is generated. The resulting spawned class has the following generated name format: \fBSPAWN__\fP\&. After classes are evaluated and a spawned class is generated, the corresponding template class name is also associated with the packet. An Option specified in a spawned class will take precedence over the same option if set in its template class. .IP \(bu 2 The \fBoption\-data\fP list is not mandatory and contains options that should be assigned to members of this class. In the case of a template class, these options are assigned to the generated spawned class. .IP \(bu 2 The \fBoption\-def\fP list is not mandatory and is used to define custom options. .IP \(bu 2 The \fBonly\-if\-required\fP has been replaced with \fBonly\-in\-additional\-list\fP and is now deprecated. It will still be accepted as input for a time to allow users to migrate but will eventually be unsupported. .IP \(bu 2 The \fBonly\-in\-additional\-list\fP flag is not mandatory; when its value is set to \fBfalse\fP (the default), membership is determined during classification and is available for subnet selection, for instance. When the value is set to \fBtrue\fP, membership is evaluated only if the class appears in an \fBevaluate\-additional\-classes\fP list and is usable only for option configuration. .IP \(bu 2 The \fBuser\-context\fP is not mandatory and represents a map with user\-defined data and possibly configuration options for hook libraries. .IP \(bu 2 The \fBnext\-server\fP parameter is not mandatory and configures the \fBsiaddr\fP field in packets associated with this class. It is used in DHCPv4 only. .IP \(bu 2 The \fBserver\-hostname\fP is not mandatory and configures the \fBsname\fP field in packets associated with this class. It is used in DHCPv4 only. .IP \(bu 2 The \fBboot\-file\-name\fP is not mandatory and configures the \fBfile\fP field in packets associated with this class. It is used in DHCPv4 only. .IP \(bu 2 The \fBvalid\-lifetime\fP, \fBmin\-valid\-lifetime\fP, and \fBmax\-valid\-lifetime\fP are not mandatory and configure the valid lifetime fields for this client class. .IP \(bu 2 The \fBpreferred\-lifetime\fP, \fBmin\-preferred\-lifetime\fP, and \fBmax\-preferred\-lifetime\fP are not mandatory and configure the preferred lifetime fields for this client class. It is used in DHCPv6 only. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 \fBtest\fP and \fBtemplate\-test\fP are mutually exclusive in a client class definition. Use either one, or neither, but not both. If both are provided, the configuration is rejected. .UNINDENT .UNINDENT .sp In the following example, the class named \fBClient_foo\fP is defined. It is comprised of all clients whose client IDs (option 61) start with the string \fBfoo\fP\&. Members of this class will be given 192.0.2.1 and 192.0.2.2 as their domain name servers. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqClient_foo\(dq, \(dqtest\(dq: \(dqsubstring(option[61].hex,0,3) == \(aqfoo\(aq\(dq, \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqdomain\-name\-servers\(dq, \(dqcode\(dq: 6, \(dqspace\(dq: \(dqdhcp4\(dq, \(dqcsv\-format\(dq: true, \(dqdata\(dq: \(dq192.0.2.1, 192.0.2.2\(dq } ] }, ... ], ... } .EE .UNINDENT .UNINDENT .sp The next example shows a client class named \(dqClient_enterprise\(dq being defined for use by the DHCPv6 server. It is comprised of all clients whose client identifiers start with the given hex string, which would indicate a DUID based on an enterprise ID of \fB0x0002AABBCCDD\fP\&. Members of this class will be given 2001:db8:0::1 and 2001:db8:2::1 as their domain name servers. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqClient_enterprise\(dq, \(dqtest\(dq: \(dqsubstring(option[1].hex,0,6) == 0x0002AABBCCDD\(dq, \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqdns\-servers\(dq, \(dqcode\(dq: 23, \(dqspace\(dq: \(dqdhcp6\(dq, \(dqcsv\-format\(dq: true, \(dqdata\(dq: \(dq2001:db8:0::1, 2001:db8:2::1\(dq } ] }, ... ], ... } .EE .UNINDENT .UNINDENT .sp It is also possible to have both left and right operands of the evaluated expression processed at runtime. Expressions related to packets can appear in the expression as many times as needed; there is no limit. However, each token has a small impact on performance and excessively complex expressions may cause a bottleneck. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqInfrastructure\(dq, \(dqtest\(dq: \(dqoption[82].option[2].hex == pkt4.mac\(dq, ... }, ... ], ... } .EE .UNINDENT .UNINDENT .SS Template Classes .sp The \fBtemplate\-test\fP parameter indicates that the class is a template class. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqClient\-ID\(dq, \(dqtemplate\-test\(dq: \(dqsubstring(option[61].hex,0,3)\(dq, ... }, ... ], ... } .EE .UNINDENT .UNINDENT .sp If the received DHCPv4 packet contains option 61, then the first three bytes represent the value \fBfoo\fP in ASCII, and the spawned class uses the \fBSPAWN_Client\-ID_foo\fP name. Both the \fBSPAWN_Client\-ID_foo\fP and \fBClient\-ID\fP classes are associated with the packet. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Template classes can also be used to spawn classes which match regular classes, effectively associating the regular class to the packet. To achieve this, the regular class must also contain the fixed part of the spawned class name: .sp \fBSPAWN__\fP .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqSPAWN_Client\-ID_foobar\(dq, \(dqtest\(dq: \(dqsubstring(option[1].hex,0,6) == 0x0002AABBCCDD\(dq, ... }, { \(dqname\(dq: \(dqClient\-ID\(dq, \(dqtemplate\-test\(dq: \(dqsubstring(option[1].hex,0,6)\(dq, ... }, ... ], ... } .EE .UNINDENT .UNINDENT .sp If the received DHCPv6 packet contains option 1 (client identifier) with hex value \fB0x0002AABBCCDD\fP, then the \fBSPAWN_Client\-ID_foobar\fP is associated with the packet. Moreover, if the first six bytes represent value \fBfoobar\fP in ASCII, then the spawned class uses the \fBSPAWN_Client\-ID_foobar\fP name, effectively associating the regular class to the packet. In this second case, both the \fBSPAWN_Client\-ID_foobar\fP and \fBClient\-ID\fP classes are associated with the packet. The \fBtest\fP expression on the regular class \fBSPAWN_Client\-ID_foobar\fP is not mandatory and can be omitted, but it is used here with a different match expression for example purposes. .sp Usually the \fBtest\fP and \fBtemplate\-test\fP expressions are evaluated before subnet selection, but in some cases it is useful to evaluate it later when the subnet, shared network, or pools are known but output\-option processing has not yet been done. For this purpose, the \fBonly\-in\-additional\-list\fP flag, which is \fBfalse\fP by default, allows the evaluation of the \fBtest\fP expression or the \fBtemplate\-test\fP expression only when it is required by the class\(aqs presence in the \fBevaluate\-additional\-classes\fP list of the selected pool, subnet, or shared network. .sp The \fBevaluate\-additional\-classes\fP list, which is valid for pool, subnet, and shared\-network scope, specifies the classes which are evaluated in the second pass before output\-option processing. The list is built in same precedence order as the option data, i.e. an option data item in a subnet takes precedence over one in a shared network. An additional class in a subnet is added before one in a shared network. The mechanism is related to the \fBonly\-in\-additional\-list\fP flag but it is not mandatory that the flag be set to \fBtrue\fP\&. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The \fBtemplate\-test\fP expression can also be used to filter generated spawned classes, so that they are created only when needed by using the \fBifelse\fP instruction. .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqClient\-ID\(dq, \(dqtemplate\-test\(dq: \(dqifelse(substring(option[61].hex,4,3) == \(aqfoo\(aq, substring(option[12].hex,0,12), \(aq\(aq)\(dq, ... }, ... ], ... } .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The template classes can be used to configure limits which, just like options, are associated with the spawned class. This permits the configuration of limits that apply to all packets associated with a class spawned at runtime, according to the \fBtemplate\-test\fP expression in the parent template class. For a more detailed description of how to configure limits using the limits hook library, see \fI\%Configuration\fP\&. For example, using the configuration below, ingress DHCPv6 packets that have client ID values (in the format expressed by the Kea evaluator) \fBfoobar\fP and \fBfoofoo\fP both amount to the same limit of 60 packets per day, while other packets that have the first three hextets different than \fBfoo\fP are put in separate rate\-limiting buckets. .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqClient\-ID\(dq, \(dqtemplate\-test\(dq: \(dqsubstring(option[1].hex,0,3)\(dq, \(dquser\-context\(dq : { \(dqlimits\(dq: { \(dqrate\-limit\(dq: \(dq60 packets per day\(dq } }, ... }, ... ], ... } .EE .UNINDENT .UNINDENT .SS Using Static Host Reservations in Classification .sp Classes can be statically assigned to clients using techniques described in \fI\%Reserving Client Classes in DHCPv4\fP and \fI\%Reserving Client Classes in DHCPv6\fP\&. .sp Subnet host reservations are searched after subnet selection. Global host reservations are searched at the same time by default but the \fBearly\-global\-reservations\-lookup\fP allows to change this behavior into searching them before the subnet selection. .sp Pool selection is performed after all host reservations lookups. .SS Configuring Subnets With Class Information .sp In certain cases it is beneficial to restrict access to certain subnets only to clients that belong to a given class, using the \fBclient\-classes\fP parameter when defining the subnet. This parameter may be used to specify a list of one or more classes to which clients must belong in order to use the subnet. This can be referred to as a class guard for the subnet, or in other words the subnet is guarded by a client class. .sp Let\(aqs assume that the server is connected to a network segment that uses the 192.0.2.0/24 prefix. The administrator of that network has decided that addresses from the range 192.0.2.10 to 192.0.2.20 will be managed by the DHCPv4 server. Only clients belonging to client class \fBClient_foo\fP are allowed to use this subnet. Such a configuration can be achieved in the following way: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqClient_foo\(dq, \(dqtest\(dq: \(dqsubstring(option[61].hex,0,3) == \(aqfoo\(aq\(dq, \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqdomain\-name\-servers\(dq, \(dqcode\(dq: 6, \(dqspace\(dq: \(dqdhcp4\(dq, \(dqcsv\-format\(dq: true, \(dqdata\(dq: \(dq192.0.2.1, 192.0.2.2\(dq } ] }, ... ], \(dqsubnet4\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.2.10 \- 192.0.2.20\(dq } ], \(dqclient\-classes\(dq: [ \(dqClient_foo\(dq ] }, ... ], ... } .EE .UNINDENT .UNINDENT .sp The following example shows how to restrict access to a DHCPv6 subnet. This configuration restricts use of the addresses in the range 2001:db8:1::1 to 2001:db8:1::FFFF to members of the \(dqClient_enterprise\(dq class. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqClient_enterprise\(dq, \(dqtest\(dq: \(dqsubstring(option[1].hex,0,6) == 0x0002AABBCCDD\(dq, \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqdns\-servers\(dq, \(dqcode\(dq: 23, \(dqspace\(dq: \(dqdhcp6\(dq, \(dqcsv\-format\(dq: true, \(dqdata\(dq: \(dq2001:db8:0::1, 2001:db8:2::1\(dq } ] }, ... ], \(dqsubnet6\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq2001:db8:1::/64\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8:1::\-2001:db8:1::ffff\(dq } ], \(dqclient\-classes\(dq: \(dqClient_enterprise\(dq } ], ... } .EE .UNINDENT .UNINDENT .SS Configuring Pools With Class Information .sp Similar to subnets, in certain cases access to certain address or prefix pools must be restricted to only clients that belong to at least one of a list of one or more classes, using the \fBclient\-classes\fP when defining the pool. This can be referred to as a class guard for the pool, or in other words the pool is guarded by a client class. .sp Let\(aqs assume that the server is connected to a network segment that uses the 192.0.2.0/24 prefix. The administrator of that network has decided that addresses from the range 192.0.2.10 to 192.0.2.20 are going to be managed by the DHCPv4 server. Only clients belonging to client class \fBClient_foo\fP are allowed to use this pool. Such a configuration can be achieved in the following way: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqClient_foo\(dq, \(dqtest\(dq: \(dqsubstring(option[61].hex,0,3) == \(aqfoo\(aq\(dq, \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqdomain\-name\-servers\(dq, \(dqcode\(dq: 6, \(dqspace\(dq: \(dqdhcp4\(dq, \(dqcsv\-format\(dq: true, \(dqdata\(dq: \(dq192.0.2.1, 192.0.2.2\(dq } ] }, ... ], \(dqsubnet4\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.2.10 \- 192.0.2.20\(dq, \(dqclient\-classes\(dq: [ \(dqClient_foo\(dq ] } ] }, ... ], ... } .EE .UNINDENT .UNINDENT .sp The following example shows how to restrict access to an address pool. This configuration restricts use of the addresses in the range 2001:db8:1::1 to 2001:db8:1::FFFF to members of the \(dqClient_enterprise\(dq class. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqClient_enterprise_\(dq, \(dqtest\(dq: \(dqsubstring(option[1].hex,0,6) == 0x0002AABBCCDD\(dq, \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqdns\-servers\(dq, \(dqcode\(dq: 23, \(dqspace\(dq: \(dqdhcp6\(dq, \(dqcsv\-format\(dq: true, \(dqdata\(dq: \(dq2001:db8:0::1, 2001:db8:2::1\(dq } ] }, ... ], \(dqsubnet6\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq2001:db8:1::/64\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8:1::\-2001:db8:1::ffff\(dq, \(dqclient\-classes\(dq: [ \(dqClient_foo\(dq ] } ] }, ... ], ... } .EE .UNINDENT .UNINDENT .SS Class Priority .sp Client classes in Kea follow the order in which they are specified in the configuration (vs. alphabetical order). Additional classes are ordered by pool, subnet, and then shared\-network and within each scope by the order in which they appear in \fBevaluate\-additional\-classes\fP\&. .sp When determining which client\-class information (comprised of options, lease lifetimes, or DHCPv4 field values) is part of the class definitions to be included in the response, the server examines the union of options from all of the assigned classes. If two or more classes include the same class information, the value from the first assigned class is used. \fBALL\fP is always the first class, i.e. the class with the highest priority, and matching required classes are last, so they have the lowest priority. .sp Options defined in classes override any global options, and in turn are overridden by options defined for an individual subnet, shared network, pool, or reservation. .sp On the other hand, lease lifetimes and DHCPv4 field values defined at class scope override any values defined globally, in a subnet scope, or in a shared\-network scope. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Because additional evaluation occurs after lease assignment, parameters that would otherwise impact lease life times (e.g. \fBvalid\-lifetime\fP, \fBoffer\-lifetime\fP) will have no effect when specified in a class that also sets \fBonly\-in\-additional\-list\fP true. .UNINDENT .UNINDENT .sp As an example, imagine that an incoming packet matches two classes. Class \fBfoo\fP defines values for an NTP server (option 42 in DHCPv4) and an SMTP server (option 69 in DHCPv4), while class \fBbar\fP defines values for an NTP server and a POP3 server (option 70 in DHCPv4). The server examines the three options \- NTP, SMTP, and POP3 \- and returns any that the client requested. As the NTP server was defined twice, the server chooses only one of the values for the reply; the class from which the value is obtained is determined as explained in the previous paragraphs. .SS Option Class\-Tagging .sp Option class\-tagging allows an option value to be conditionally applied to the response based on the client\(aqs class membership. The effect is similar to using an if\-block in ISC DHCP to conditionally include options at a given scope. Class\-tagging is done by specifying a list of one of more class names in the option\(aqs \fBclient\-classes\fP entry. .sp Consider a case where members of a given class need the same value for one option but a subnet\-specific value for another option. The following example shows class\-tagging used to give clients who belong to \(dqGROUP1\(dq a subnet\-specific value for option \(dqbar\(dq, while giving all members of \(dqGROUP1\(dq the same value for option \(dqfoo\(dq: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqGROUP1\(dq, \(dqtest\(dq:\(dqsubstring(option[123].hex,0,4) == \(aqONE\(aq\(dq, \(dqoption\-data\(dq: [{ \(dqname\(dq: \(dqfoo\(dq, \(dqdata\(dq: \(dqsomefile.txt\(dq }] }], \(dqsubnet4\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq178.16.1.0/24\(dq, \(dqoption\-data\(dq: [{ \(dqclient\-classes\(dq: [\(dqGROUP1\(dq], \(dqname\(dq: \(dqbar\(dq, \(dqdata\(dq: 123 }] }, { \(dqid\(dq: 2, \(dqsubnet\(dq: \(dq178.16.2.0/24\(dq, \(dqoption\-data\(dq: [ { \(dqclient\-classes\(dq: [\(dqGROUP1\(dq], \(dqname\(dq: \(dqbar\(dq, \(dqdata\(dq: 789 }] }] } .EE .UNINDENT .UNINDENT .sp The \fBclient\-classes\fP list is allowed in an option specification at any scope. Option class\-tagging is enforced at the time options are being added to the response which occurs after lease assignment just before the response is to be sent to the client. .sp When \fBnever\-send\fP for an option is true at any scope, all \fBclient\-classes\fP entries for that option are ignored. The option will not be included. .sp When \fBalways\-send\fP is true at any scope, the option will be included unless, the option determined by scope specifies a \fBclient\-classes\fP list that does not contain any of the client\(aqs classes. .sp Otherwise, an option requested by the client will be included in the response if the option either does not specify \fBclient\-classes\fP or the client belongs to at least one of the classes in \fBclient\-classes\fP\&. .sp When an option\(aqs class\-tag does not match, it is as though the option was not specified at that scope. In the following example the option \(dqfoo\(dq is specified for both the subnet and the pool. The pool specification includes a class\-tag that limits the option to members of class \(dqmelon\(dq: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqid\(dq: 100, \(dqsubnet\(dq: \(dq178.16.1.0/24\(dq, \(dqoption\-data\(dq: [{ \(dqname\(dq: \(dqfoo\(dq, \(dqdata\(dq: 456 }], \(dqpools\(dq: [{ \(dqpool\(dq: \(dq178.16.1.100 \- 178.16.1.200\(dq, \(dqoption\-data\(dq: [{ \(dqname\(dq: \(dqfoo\(dq, \(dqdata\(dq: 123, \(dqclient\-classes\(dq : [ \(dqmelon\(dq ] }] }] } .EE .UNINDENT .UNINDENT .sp Clients that match class \(dqmelon\(dq will have a value of 123 for option \(dqfoo\(dq, while clients that do not match \(dqmelon\(dq will have a value of 456 for option \(dqfoo\(dq. .sp It is possible to achieve an if\-elseif\-else effect but specifying an option more than once with different class tags and values. Consider the following configuration for a subnet which provides three possible values for the \(dqserver\-str\(dq option: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq192.0.1.0/24\(dq, \(dqpools\(dq: [{ \(dqpool\(dq: \(dq192.0.1.1 \- 192.0.1.255\(dq }], \(dqoption\-data\(dq: [{ \(dqclient\-classes\(dq: [ \(dqclass\-one\(dq ], \(dqname\(dq: \(dqserver\-str\(dq, \(dqdata\(dq: \(dqstring.one\(dq },{ \(dqclient\-classes\(dq: [ \(dqclass\-two\(dq ], \(dqname\(dq: \(dqserver\-str\(dq, \(dqdata\(dq: \(dqstring.two\(dq },{ \(dqname\(dq: \(dqserver\-str\(dq, \(dqdata\(dq: \(dqstring.other\(dq }] } .EE .UNINDENT .UNINDENT .sp Clients belonging to \(dqclass\-one\(dq will get a value of \(dqstring.one\(dq, clients belonging to \(dqclass\-two\(dq will get a value of \(dqstring.two\(dq, and clients that belong to neither \(dqclass\-one\(dq nor \(dqclass\-two\(dq will get a value of \(dqstring.other\(dq. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The order that the options are tested is not guaranteed other than an option with an empty \(dqclient\-classes\(dq list is checked last. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Though examples above are for DHCPv4, class\-tagging syntax and behavior is the same for DHCPv6. .UNINDENT .UNINDENT .SS Classes and Hooks .sp Hooks may be used to classify packets. This may be useful if the expression would be complex or time\-consuming to write, and could be better or more easily written as code. Once the hook has added the proper class name to the packet, the rest of the classification system will work as expected in choosing a subnet and selecting options. For a description of hooks, see \fI\%Hook Libraries\fP; for information on configuring classes, see \fI\%Configuring Classes\fP and \fI\%Configuring Subnets With Class Information\fP\&. .SS Debugging Expressions .sp While constructing classification expressions, administrators may find it useful to enable logging; see \fI\%Logging\fP for a more complete description of the logging facility. .sp To enable the debug statements in the classification system, the severity must be set to \fBDEBUG\fP and the debug level to at least 55. The specific loggers are \fBkea\-dhcp4.eval\fP and \fBkea\-dhcp6.eval\fP\&. .sp To understand the logging statements, it is essential to understand a bit about how expressions are evaluated; for a more complete description, refer to [the design document](\X'tty: link https://gitlab.isc.org/isc-projects/kea/-/wikis/designs/client-classification-design'\fI\%https://gitlab.isc.org/isc\-projects/kea/\-/wikis/designs/client\-classification\-design\fP\X'tty: link'). In brief, there are two structures used during the evaluation of an expression: a list of tokens which represent the expressions, and a value stack which represents the values being manipulated. .sp The list of tokens is created when the configuration file is processed, with most expressions and values being converted to a token. The list is organized in reverse Polish notation. During execution, the list is traversed in order; as each token is executed, it is able to pop values from the top of the stack and eventually push its result on the top of the stack. Imagine the following expression: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqtest\(dq: \(dqsubstring(option[61].hex,0,3) == \(aqfoo\(aq\(dq, .EE .UNINDENT .UNINDENT .sp This will result in the following tokens: .INDENT 0.0 .INDENT 3.5 .sp .EX option, number (0), number (3), substring, text (\(aqfoo\(aq), equals .EE .UNINDENT .UNINDENT .sp In this example, the first three tokens will simply push values onto the stack. The substring token will then remove those three values and compute a result that it places on the stack. The text option also places a value on the stack, and finally the equals token removes the two tokens on the stack and places its result on the stack. .sp When debug logging is enabled, each time a token is evaluated it emits a log message indicating the values of any objects that were popped off of the value stack, and any objects that were pushed onto the value stack. .sp The values are displayed as either text, if the command is known to use text values, or hexadecimal, if the command either uses binary values or can manipulate either text or binary values. For expressions that pop multiple values off the stack, the values are displayed in the order they were popped. For most expressions this will not matter, but for the concat expression the values are displayed in reverse order from their written order in the expression. .sp Let us assume that the following test has been entered into the configuration. This example skips most of the configuration to concentrate on the test. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqtest\(dq: \(dqsubstring(option[61].hex,0,3) == \(aqfoo\(aq\(dq, .EE .UNINDENT .UNINDENT .sp The logging might then resemble this: .INDENT 0.0 .INDENT 3.5 .sp .EX 2016\-05\-19 13:35:04.163 DEBUG [kea.eval/44478] EVAL_DEBUG_OPTION Pushing option 61 with value 0x666F6F626172 2016\-05\-19 13:35:04.164 DEBUG [kea.eval/44478] EVAL_DEBUG_STRING Pushing text string \(aq0\(aq 2016\-05\-19 13:35:04.165 DEBUG [kea.eval/44478] EVAL_DEBUG_STRING Pushing text string \(aq3\(aq 2016\-05\-19 13:35:04.166 DEBUG [kea.eval/44478] EVAL_DEBUG_SUBSTRING Popping length 3, start 0, string 0x666F6F626172 pushing result 0x666F6F 2016\-05\-19 13:35:04.167 DEBUG [kea.eval/44478] EVAL_DEBUG_STRING Pushing text string \(aqfoo\(aq 2016\-05\-19 13:35:04.168 DEBUG [kea.eval/44478] EVAL_DEBUG_EQUAL Popping 0x666F6F and 0x666F6F pushing result \(aqtrue\(aq .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The debug logging may be quite verbose if there are multiple expressions to evaluate; it is intended as an aid in helping create and debug expressions. Administrators should plan to disable debug logging when expressions are working correctly. Users may also wish to include only one set of expressions at a time in the configuration file while debugging them, to limit the log statements. For example, when adding a new set of expressions, an administrator might find it more convenient to create a configuration file that only includes the new expressions until they are working correctly, and then add the new set to the main configuration file. .UNINDENT .UNINDENT .SH HOOK LIBRARIES .SS Introduction .sp Kea is both flexible and customizable, via the use of \(dqhooks.\(dq This feature lets Kea load one or more dynamically linked libraries (known as \(dqhook libraries\(dq) and call functions in them at various points in its processing (\(dqhook points\(dq). Those functions perform whatever custom processing is required. .sp The hooks concept allows the core Kea code to remain reasonably small by moving features that only some, but not all, users find useful to external libraries. Those with no need for certain functions can simply choose not to load those libraries. .sp Hook libraries are loaded by individual Kea processes, not by Kea as a whole. This means, among other things, that it is possible to associate one set of libraries with the DHCPv4 server and a different set with the DHCPv6 server. .sp It is also possible for a process to load multiple libraries. When processing reaches a hook point, Kea calls the hook library functions attached to it. If multiple libraries have attached a function to a given hook point, Kea calls all of them, in the order in which the libraries are specified in the configuration file. The order may be important; consult the documentation of the libraries for specifics. .sp When a Kea process unloads a library, it expects the \fBdlclose\fP function to remove all library symbols, as well as the library code, from address space. Although most OSes implement the \fBdlclose\fP function, this behavior is not required by the POSIX standard and not all systems support it; for example, the musl library, used by default by Alpine Linux, implements the \fBdlclose\fP function as a no operation. On such systems a library actually remains loaded for the lifetime of the process, which means that it must be restarted to update libraries with newer versions; it is not sufficient to simply reconfigure or reload the Kea process. .sp The next sections describe how to install and configure hook libraries. Users who are interested in writing their own hook library can find information in the \X'tty: link https://reports.kea.isc.org/dev_guide/df/d46/hooksdgDevelopersGuide.html'\fI\%Hooks Developer\(aqs Guide section of the Kea Developer\(aqs Guide\fP\X'tty: link'\&. .sp Note that some libraries are available under different licenses. .sp Please also note that some libraries may require additional dependencies and/or compilation switches to be enabled. .SS Installing Hook Packages .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 For more details about installing the Kea Subscriber Hooks, please read \X'tty: link https://kb.isc.org/docs/aa-01587'\fI\%this Knowledgebase article\fP\X'tty: link'\&. .UNINDENT .UNINDENT .sp Most hook packages are now included in the base Kea sources. There is no need to do anything special to compile or install them, as they are covered by the usual building and installation procedures. Please refer to \fI\%Installation\fP for a general overview of the installation process. .sp ISC provides several additional subscriber\-only hooks in the form of packages, which follow a similar installation procedure but with several additional steps. For our users\(aq convenience, the subscriber hooks\(aq installation procedure is described in this section. .sp 1. Download the package; detailed instructions are provided in the KB article above. The package will be a file with a name similar to \fBkea\-subscriber\-|release|.tar.xz\fP\&. .sp 2. Administrators who have the sources for the corresponding version of the open\-source Kea package on their system from the initial Kea installation should skip this step. Otherwise, extract the Kea source from the original tarball that was downloaded. For example, with a download of Kea 3.0.0, there should be a tarball called \fBkea\-|release|.tar.xz\fP on the system. Unpack this tarball: .INDENT 0.0 .INDENT 3.5 .sp .EX $ tar \-Jxvf kea\-3.0.0\&.tar.xz .EE .UNINDENT .UNINDENT .sp This will unpack the tarball into the \fBkea\-|release|\fP subdirectory of the current working directory. .sp 3. Unpack the Kea subscriber hooks tarball into the same directory where the original Kea source is located. Once Kea 3.0.0 has been unpacked into a \fBkea\-|release|\fP subdirectory and the Kea subscriber tarball is in the current directory, the following steps will unpack the subscriber tarball into the correct location: .INDENT 0.0 .INDENT 3.5 .sp .EX $ cd kea\-3.0.0 $ tar \-Jxvf ../kea\-subscriber\-3.0.0\&.tar.xz .EE .UNINDENT .UNINDENT .sp Note that unpacking the Kea subscriber package puts the files into a directory named \fBpremium\fP\&. Regardless of the name of the package, the directory is always called \fBpremium\fP\&. .INDENT 0.0 .IP 4. 3 Set up the build. Make sure \fBmeson\fP and \fBninja\fP are installed on your system. The first section of the output should look something like this: .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX $ meson setup build .EE .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX Package: Name: kea Version: 3.0.0 Extended version: 3.0.0 (tarball) Version type: development OS Family: Linux Prefix: /opt/kea Hooks directory: /opt/kea/lib/kea/hooks Premium hooks: yes .EE .UNINDENT .UNINDENT .INDENT 0.0 .IP 6. 3 Compile Kea. .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX $ meson compile \-C build .EE .UNINDENT .UNINDENT .INDENT 0.0 .IP 7. 3 Install Kea sources along with the hooks: .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX $ sudo make install .EE .UNINDENT .UNINDENT .sp The installation location of the hook libraries depends on whether the \fB\-\-prefix\fP parameter was specified at the \fBmeson setup\fP step. If not, the default location is \fB/usr/local/lib/kea/hooks\fP\&. The proper installation of the libraries can be verified with this command: .INDENT 0.0 .INDENT 3.5 .sp .EX $ ls \-l /usr/local/lib/kea/hooks/*.so /usr/local/lib/kea/hooks/libddns_gss_tsig.so /usr/local/lib/kea/hooks/libdhcp_bootp.so /usr/local/lib/kea/hooks/libdhcp_class_cmds.so /usr/local/lib/kea/hooks/libdhcp_ddns_tuning.so /usr/local/lib/kea/hooks/libdhcp_flex_id.so /usr/local/lib/kea/hooks/libdhcp_flex_option.so /usr/local/lib/kea/hooks/libdhcp_ha.so /usr/local/lib/kea/hooks/libdhcp_host_cache.so /usr/local/lib/kea/hooks/libdhcp_host_cmds.so /usr/local/lib/kea/hooks/libdhcp_lease_cmds.so /usr/local/lib/kea/hooks/libdhcp_lease_query.so /usr/local/lib/kea/hooks/libdhcp_legal_log.so /usr/local/lib/kea/hooks/libdhcp_limits.so /usr/local/lib/kea/hooks/libdhcp_mysql.so /usr/local/lib/kea/hooks/libdhcp_perfmon.so /usr/local/lib/kea/hooks/libdhcp_pgsql.so /usr/local/lib/kea/hooks/libdhcp_ping_check.so /usr/local/lib/kea/hooks/libdhcp_radius.so /usr/local/lib/kea/hooks/libdhcp_run_script.so /usr/local/lib/kea/hooks/libdhcp_stat_cmds.so /usr/local/lib/kea/hooks/libdhcp_subnet_cmds.so .EE .UNINDENT .UNINDENT .sp with the following subscriber libraries: .INDENT 0.0 .INDENT 3.5 .sp .EX /usr/local/lib/kea/hooks/libca_rbac.so \-> libdhcp_rbac.so /usr/local/lib/kea/hooks/libdhcp_cb_cmds.so /usr/local/lib/kea/hooks/libdhcp_rbac.so .EE .UNINDENT .UNINDENT .sp The exact list returned depends on the packages installed. If the directory was specified via \fB\-\-prefix\fP, the hook libraries will be located in \fB{prefix directory}/lib/kea/hooks\fP\&. .SS Configuring Hook Libraries .sp The hook libraries for a given process are configured using the \fBhooks\-libraries\fP keyword in the configuration for that process. (Note that the word \(dqhooks\(dq is plural.) The value of the keyword is an array of map structures, with each structure corresponding to a hook library. For example, to set up two hook libraries for the DHCPv4 server, the configuration would be: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp6\(dq: { \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dq/opt/first_custom_hooks_example.so\(dq }, { \(dqlibrary\(dq: \(dq/opt/local/second_custom_hooks_example.so\(dq, \(dqparameters\(dq: { \(dqmail\(dq: \(dqspam@example.com\(dq, \(dqfloor\(dq: 13, \(dqdebug\(dq: false, \(dqusers\(dq: [ \(dqalice\(dq, \(dqbob\(dq, \(dqcharlie\(dq ], \(dqlanguages\(dq: { \(dqfrench\(dq: \(dqbonjour\(dq, \(dqklingon\(dq: \(dqyl\(aqel\(dq } } } ] } } .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Libraries are reloaded even if their lists have not changed, because the parameters specified for the library (or the files those parameters point to) may have changed. .UNINDENT .UNINDENT .sp As of Kea 2.7.9, hook libraries may only be loaded from the default installation directory determined during compilation and shown in the config report as \(dqHooks directory\(dq. This value may be overridden at startup by setting the environment variable \fBKEA_HOOKS_PATH\fP to the desired path. If a path other than this value is used in a \fBlibrary\fP element Kea will emit an error and refuse to load the library. For ease of use \fBlibrary\fP elements may simply omit path components, specifying the file name only as shown below: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp6\(dq: { \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dqfirst_custom_hooks_example.so\(dq }, { \(dqlibrary\(dq: \(dqsecond_custom_hooks_example.so\(dq } ] } } .EE .UNINDENT .UNINDENT .sp This snippet (on Debian 12) is equivalent to: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp6\(dq: { \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dq/usr/lib/x86_64\-linux\-gnu/kea/hooks/first_custom_hooks_example.so\(dq }, { \(dqlibrary\(dq: \(dq/usr/lib/x86_64\-linux\-gnu/kea/hooks/second_custom_hooks_example.so\(dq } ] } } .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The support for path components in \fBlibrary\fP elements is deprecated as of 2.7.8, and will eventually be removed. .UNINDENT .UNINDENT .sp Libraries may have additional parameters that are not mandatory, in the sense that there may be libraries that do not require them. However, for any given library there is often a requirement to specify a certain set of parameters. Please consult the documentation for each individual library for details. In the example above, the first library (\fB/opt/first_custom_hooks_example.so\fP) has no parameters. The second library (\fB/opt/local/second_custom_hooks_example.so\fP) has five parameters: specifying mail (string parameter), floor (integer parameter), debug (boolean parameter), lists (list of strings), and maps (containing strings). Nested parameters can be used if the library supports it. This topic is explained in detail in the \X'tty: link https://reports.kea.isc.org/dev_guide/df/d46/hooksdgDevelopersGuide.html'\fI\%Hooks Developer\(aqs Guide section of the Kea Developer\(aqs Guide\fP\X'tty: link'\&. .sp Some hooks use user context to set the parameters. See \fI\%User Contexts in Hooks\fP\&. .sp Notes: .INDENT 0.0 .IP \(bu 2 The full path to each library should be given. .IP \(bu 2 As noted above, the order in which the hooks are called may be important; consult the documentation for each library for specifics. .IP \(bu 2 An empty list has the same effect as omitting the \fBhooks\-libraries\fP configuration element altogether. .sp \fBNOTE:\fP .INDENT 2.0 .INDENT 3.5 There is one case where this is not true: if Kea is running with a configuration that contains a \fBhooks\-libraries\fP item, and that item is removed and the configuration reloaded, the removal is ignored and the libraries remain loaded. As a workaround, instead of removing the \fBhooks\-libraries\fP item, change it to an empty list. .UNINDENT .UNINDENT .UNINDENT .sp At the moment, only the \fI\%kea\-dhcp4\fP and \fI\%kea\-dhcp6\fP processes support hook libraries. .SS Order of Configuration: .sp It is important to recognize that the order in which hook libraries are configured determines the order in which their callouts will be executed, in cases where more than one hook library implements the same callout. For example, to use the Flexible Identifier (also called Flex ID) hook library to formulate the client IDs in conjunction with the High Availability (HA) hook library for load\-balanced HA, it is essential that the Flex ID library be specified first in the server\(aqs \fBhooks\-libraries\fP section. This ensures that the client ID is formulated by the Flex ID library before the HA library uses it for load\-balancing. Similarly, it is best to specify the Forensic Logging library last, to ensure that any other installed hooks have already made their contributions to the packet processing before that one is loaded. .SS User Contexts in Hooks .sp Hook libraries can have their own configuration parameters, which is convenient if the parameter applies to the whole library. However, sometimes it is useful to extend certain configuration entities with additional configuration data. This is where the concept of user contexts comes in. A system administrator can define an arbitrary set of data and attach it to Kea structures, as long as the data is specified as a JSON map. In particular, it is possible to define fields that are integers, strings, boolean, lists, or maps. It is possible to define nested structures of arbitrary complexity. Kea does not use that data on its own; it simply stores it and makes it available for the hook libraries. .sp Another use case for user contexts may be storing comments and other information that will be retained by Kea. Regular comments are discarded when the configuration is loaded, but user contexts are retained. This is useful if administrators want their comments to survive \fI\%config\-set\fP or \fI\%config\-get\fP operations, for example. .sp If user context is supported in a given context, the parser translates \(dqcomment\(dq entries into user context with a \(dqcomment\(dq entry. .sp User context can store configuration for multiple hooks and comments at once. .sp Some hooks use user context for a configuration that can be easily edited without the need to restart the server. .sp The DDNS Tuning hook uses user context to configure per\-subnet behavior. Here\(aqs an example: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqsubnet4\(dq: [{ \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq, \(dqpools\(dq: [{ \(dqpool\(dq: \(dq192.0.2.10 \- 192.0.2.20\(dq } ], \(dquser\-context\(dq: { \(dqddns\-tuning\(dq: { \(dqhostname\-expr\(dq: \(dq\(aqguest\-\(aq+int8totext(substring(pkt4.yiaddr, 0,1))+\(aq\-\(aq \e +int8totext(substring(pkt4.yiaddr, 1,2))+\(aq\-\(aq \e +int8totext(substring(pkt4.yiaddr, 2,3))+\(aq\-\(aq \e +int8totext(substring(pkt4.yiaddr, 3,4))\(dq }, \(dqlast\-modified\(dq: \(dq2017\-09\-04 13:32\(dq, \(dqphones\(dq: [ \(dqx1234\(dq, \(dqx2345\(dq ], \(dqdevices\-registered\(dq: 42, \(dqbilling\(dq: false } }] .EE .UNINDENT .UNINDENT .sp The Limits hook uses user\-context in classes and subnets to set parameters. For example: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp6\(dq: { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqgold\(dq, \(dquser\-context\(dq: { \(dqlimits\(dq: { \(dqaddress\-limit\(dq: 2, \(dqprefix\-limit\(dq: 1, \(dqrate\-limit\(dq: \(dq1000 packets per second\(dq } } } ], \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dq/usr/local/lib/libdhcp_limits.so\(dq } ], \(dqsubnet6\(dq: [ { \(dqid\(dq: 1, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8::/64\(dq } ], \(dqsubnet\(dq: \(dq2001:db8::/64\(dq, \(dquser\-context\(dq: { \(dqlimits\(dq: { \(dqaddress\-limit\(dq: 4, \(dqprefix\-limit\(dq: 2, \(dqrate\-limit\(dq: \(dq10 packets per minute\(dq } } } ] } } .EE .UNINDENT .UNINDENT .SS Parked\-Packet Limit .sp Kea servers contain a mechanism by which the response to a client packet may be held, pending completion of hook library work. We refer to this as \(dqparking the packet.\(dq When work is ready to continue, the server unparks the response and continues processing. .sp There is a global parameter, \fBparked\-packet\-limit\fP, that may be used to limit the number of responses that may be parked at any given time. This acts as a form of congestion handling and protects the server from being swamped when the volume of client queries is outpacing the server\(aqs ability to respond. Once the limit is reached, the server emits a log and drops any new responses until parking spaces are available. .sp In general, smaller values for the parking lot limit are likely to cause more drops but with shorter response times; larger values are likely to result in fewer drops but with longer response times. Currently, the default value for \fBparked\-packet\-limit\fP is 256. .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Using too small a value may result in an unnecessarily high drop rate, while using too large a value may lead to response times that are simply too long to be useful. A value of 0, while allowed, disables the limit altogether, but this is highly discouraged as it may lead to Kea servers becoming unresponsive to clients. Choosing the best value is very site\-specific; we recommend users initially leave it at the default value of 256 and observe how the system behaves over time with varying load conditions. .UNINDENT .UNINDENT .sp Here is an example of the global parameter used with \fI\%libdhcp_ha.so\fP\&. It lowers the number of concurrently parked packets to 128. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp6\(dq: { \(dqparked\-packet\-limit\(dq: 128 \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dq/usr/lib/kea/hooks/libdhcp_lease_cmds.so\(dq }, { \(dqlibrary\(dq: \(dq/usr/lib/kea/hooks/libdhcp_ha.so\(dq, \(dqparameters\(dq: { \(dqhigh\-availability\(dq: [ { \(dqmode\(dq: \(dqhot\-standby\(dq, \(dqpeers\(dq: [ { \(dqname\(dq: \(dqserver1\(dq, \(dqrole\(dq: \(dqprimary\(dq, \(dqurl\(dq: \(dqhttp://127.0.0.1:8080/\(dq }, { \(dqname\(dq: \(dqserver2\(dq, \(dqrole\(dq: \(dqstandby\(dq, \(dqurl\(dq: \(dqhttp://127.0.0.1:8088/\(dq } ], \(dqthis\-server\-name\(dq: \(dqserver1\(dq } ] } } ] } } .EE .UNINDENT .UNINDENT .SS Available Hook Libraries .sp As described above, the hook functionality provides a way to customize a Kea server without modifying the core code. ISC has chosen to take advantage of this feature to provide functions that may only be useful to a subset of Kea users. To this end, ISC has created some hook libraries, discussed in the following sections. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 As of Kea 3.0.0, most of these libraries are available at no cost with the open source base code; a few are only available to organizations that contribute to Kea\(aqs development through paid ISC support contracts. Paid support includes professional engineering assistance, advance security notifications, input into ISC\(aqs roadmap planning, and many other benefits, while helping keep Kea sustainable in the long term. ISC encourages companies and organizations to consider purchasing a paid support contract; further information can be obtained by completing the form at \X'tty: link https://www.isc.org/contact'\fI\%https://www.isc.org/contact\fP\X'tty: link'\&. .UNINDENT .UNINDENT .sp The following table provides a list of hook libraries currently available from ISC. It is important to pay attention to which libraries may be loaded by which Kea processes. It is a common mistake to configure the \fI\%kea\-ctrl\-agent\fP process to load libraries that should, in fact, be loaded by the \fI\%kea\-dhcp4\fP or \fI\%kea\-dhcp6\fP processes. If a library from ISC does not work as expected, please make sure that it has been loaded by the correct process per the table below. .SS List of available hook libraries .TS box center; l|l|l. T{ Name T} T{ Availability T} T{ Description T} _ T{ \fI\%BOOTP\fP T} T{ Kea open source T} T{ This hook library adds BOOTP support, as defined in RFC 1497. It recognizes received BOOTP requests: they are translated into DHCPREQUEST packets, put into the BOOTP client class, and receive infinite lifetime leases. T} _ T{ \fI\%Class Commands\fP T} T{ Kea open source T} T{ This hook library allows configured DHCP client classes to be added, updated, deleted, and fetched without needing to restart the DHCP server. T} _ T{ \fI\%Configuration Backend Commands\fP T} T{ ISC support customers T} T{ This hook library implements a collection of commands to manage Kea configuration information in a database. This library may only be used in conjunction with one of the supported Configuration Backend implementations. T} _ T{ \fI\%DDNS Tuning\fP T} T{ Kea open source T} T{ This hook library adds custom behaviors related to Dynamic DNS updates on a per\-client basis. Its primary feature is to allow the host name used for DNS to be calculated using an expression. T} _ T{ \fI\%Flexible Identifier\fP T} T{ Kea open source T} T{ Kea software provides a way to handle host reservations that include addresses, prefixes, options, client classes and other features. The reservation can be based on hardware address, DUID, circuit\-id, or client\-id in DHCPv4 and on hardware address or DUID in DHCPv6. However, there are sometimes scenarios where the reservation is more complex, e.g. uses other options than mentioned above, uses parts of specific options, or perhaps uses a combination of several options and fields to uniquely identify a client. Those scenarios are addressed by the Flexible Identifier hook application. It allows defining an expression, similar to the one used in client classification, e.g. \fBsubstring(relay6[0].option[37],0,6)\fP\&. Each incoming packet is evaluated against that expression and its value is then searched in the reservations database. T} _ T{ \fI\%Flexible Option\fP T} T{ Kea open source T} T{ This library provides hooks that compute option values instead of static configured values. An expression is evaluated on the query packet. Defined add, supersede, and remove actions are applied on the response packet before it is sent using the evaluation result. T} _ T{ \fI\%Forensic Logging\fP T} T{ Kea open source T} T{ This library provides hooks that record a detailed log of lease assignments and renewals in a set of log files. In many legal jurisdictions, companies \- especially ISPs \- must record information about the addresses they have leased to DHCP clients. This library is designed to help with that requirement. If the information that it records is sufficient, it may be used directly. If a jurisdiction requires a different set of information to be saved, it can be used as a template or example to create custom logging hooks. In Kea 1.9.8, additional parameters were added to give users more flexibility regarding what information should be logged. T} _ T{ \fI\%GSS\-TSIG\fP T} T{ Kea open source T} T{ This hook library adds support to the Kea D2 server (kea\-dhcp\-ddns) for using GSS\-TSIG to sign DNS updates. T} _ T{ \fI\%High Availability\fP T} T{ Kea open source T} T{ The risk of DHCP service unavailability can be minimized by setting up a pair of DHCP servers in a network. Two modes of operation are supported. The first one is called load\-balancing, and is sometimes referred to as \(dqactive\-active.\(dq Each server can handle selected groups of clients in this network, or all clients if it detects that its partner has become unavailable. It is also possible to designate one server to serve all DHCP clients, and leave another server as standby. This mode is called \(dqhot standby\(dq and is sometimes referred to as \(dqactive\-passive.\(dq This server activates its DHCP function only when it detects that its partner is not available. Such cooperation between the DHCP servers requires that these servers constantly communicate with each other to send updates about allocated leases, and to periodically test whether their partners are still operational. The hook library also provides an ability to send lease updates to external backup servers, making it much easier to have a replacement that is up to date. T} _ T{ \fI\%Host Cache\fP T} T{ Kea open source T} T{ Some database backends, such as RADIUS, may take a long time to respond. Since Kea in general is synchronous, backend performance directly affects DHCP performance. To minimize performance impact, this library provides a way to cache responses from other hosts. This includes negative caching, i.e. the ability to remember that there is no client information in the database. T} _ T{ \fI\%Host Commands\fP T} T{ Kea open source T} T{ Kea provides a way to store host reservations in a database. In many larger deployments it is useful to be able to manage that information while the server is running. This library provides management commands for adding, querying, and deleting host reservations in a safe way without restarting the server. In particular, it validates the parameters, so an attempt to insert incorrect data, e.g. add a host with conflicting identifier in the same subnet, is rejected. Those commands are exposed via the command channel (JSON over UNIX sockets) and the Control Agent (JSON over RESTful interface). T} _ T{ \fI\%Lease Commands\fP T} T{ Kea open source T} T{ This hook library offers a number of commands used to manage leases. Kea can store lease information in various backends: memfile, MySQL, PostgreSQL. This library provides a unified interface to manipulate leases in an unified, safe way. In particular, it allows manipulation of memfile leases while Kea is running, sanity check changes, lease existence checks, and removal of all leases belonging to a specific subnet. It can also catch obscure errors, like the addition of a lease with subnet\-id that does not exist in the configuration, or configuration of a lease to use an address that is outside of the subnet to which it is supposed to belong. This library allows easy management of user contexts associated with leases. T} _ T{ \fI\%Leasequery\fP T} T{ Kea open source T} T{ This library adds support for DHCPv4 Leasequery (RFC 4388), DHCPv4 Bulk Leasequery (RFC6926); DHCPv6 Leasequery (RFC 5007), and DHCPv6 Bulk Leasequery (RFC5460). T} _ T{ \fI\%Limits\fP T} T{ Kea open source T} T{ With this hook library, \fI\%kea\-dhcp4\fP and \fI\%kea\-dhcp6\fP servers can apply a limit to the rate at which packets receive a response. The limit can be applied per\-client class or per\-subnet. T} _ T{ \fI\%MySQL Configuration Backend\fP T} T{ Kea open source T} T{ This hook library is an implementation of the Kea Lease, Host and Configuration Backend for MySQL. It uses a MySQL database as a repository for the Kea leases, host reservations and configuration information. Kea servers use this library to fetch their configurations if Configuration Backend is used. T} _ T{ \fI\%PerfMon\fP T} T{ Kea open source T} T{ With this hook library, \fI\%kea\-dhcp4\fP and \fI\%kea\-dhcp6\fP servers can track and report performance data. T} _ T{ \fI\%Ping Check\fP T} T{ Kea open source T} T{ With this hook library, the \fI\%kea\-dhcp4\fP server can perform ping checks of candidate lease addresses before offering them to clients. T} _ T{ \fI\%PostgreSQL Database Backend\fP T} T{ Kea open source T} T{ This hook library is an implementation of the Kea Lease, Host and Configuration Backend for PostgreSQL. It uses a PostgreSQL database as a repository for the Kea leases, host reservations and configuration information. Kea servers use this library to fetch their configurations if Configuration Backend is used. T} _ T{ \fI\%RADIUS\fP T} T{ Kea open source T} T{ The RADIUS hook library allows Kea to interact with RADIUS servers using access and accounting mechanisms. The access mechanism may be used for access control, assigning specific IPv4 or IPv6 addresses reserved by RADIUS, dynamically assigning addresses from designated pools chosen by RADIUS, or rejecting the client\(aqs messages altogether. The accounting mechanism allows a RADIUS server to keep track of device activity over time. T} _ T{ \fI\%RBAC\fP T} T{ ISC support customers T} T{ This hook library adds support to the Kea Control Agent (kea\-ctrl\-agent) and Kea servers (kea\-dhcp4, kea\-dhcp6 and kea\-dhcp\-ddns) for Role\-Based Access Control filtering of commands. T} _ T{ \fI\%Run Script\fP T} T{ Kea open source T} T{ This hook library adds support to run external scripts for specific packet\-processing hook points. There are several exported environment variables available for the script. T} _ T{ \fI\%Statistics Commands\fP T} T{ Kea open source T} T{ This library provides additional commands for retrieving accurate DHCP lease statistics, for Kea DHCP servers that share the same lease database. This setup is common in deployments where DHCP service redundancy is required and a shared lease database is used to avoid lease\-data replication between the DHCP servers. This hook library returns lease statistics for each subnet. T} _ T{ \fI\%Subnet Commands\fP T} T{ Kea open source T} T{ In deployments in which subnet configuration needs to be frequently updated, it is a hard requirement that such updates be performed without the need for a full DHCP server reconfiguration or restart. This hook library allows for incremental changes to the subnet configuration such as adding or removing a subnet. It also allows for listing all available subnets and fetching detailed information about a selected subnet. The commands exposed by this library do not affect other subnets or configuration parameters currently used by the server. T} _ T{ \fI\%User Check\fP T} T{ Kea open source T} T{ Reads known users list from a file. Unknown users will be assigned a lease from the last subnet defined in the configuration file, e.g. to redirect them to a captive portal. This demonstrates how an external source of information can be used to influence the Kea allocation engine. This hook is part of the Kea source code and is available in the \fBsrc/hooks/dhcp/user_chk\fP directory. T} .TE .sp ISC hopes to see more hook libraries become available as time progresses, developed both internally and externally. Since this list may evolve dynamically, it is maintained on a wiki page, available at \X'tty: link https://gitlab.isc.org/isc-projects/kea/wikis/Hooks-available'\fI\%https://gitlab.isc.org/isc\-projects/kea/wikis/Hooks\-available\fP\X'tty: link'\&. Developers or others who are aware of any hook libraries not listed there are asked to please send a note to the kea\-users or kea\-dev mailing lists for updating. (Information on all of ISC\(aqs public mailing lists can be found at \X'tty: link https://www.isc.org/mailinglists/'\fI\%https://www.isc.org/mailinglists/\fP\X'tty: link'\&.) .sp The libraries developed by ISC are described in detail in the following sections. .SS \fBlibdhcp_bootp.so\fP: Support for BOOTP Clients .sp This hook library adds support for BOOTP with vendor\-information extensions (\X'tty: link https://tools.ietf.org/html/rfc1497'\fI\%RFC 1497\fP\X'tty: link'). Received BOOTP requests are recognized, translated into DHCPREQUEST packets by adding a \fBdhcp\-message\-type\fP option, and put into the \(dqBOOTP\(dq client class. Members of this class get infinite lifetime leases but the class can also be used to guard a pool of addresses. .sp The DHCP\-specific options, such as \fBdhcp\-message\-type\fP, are removed from the server\(aqs responses; responses shorter than the BOOTP minimum size of 300 octets are padded to this size. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 \fI\%libdhcp_bootp.so\fP is part of the open source code and is available to every Kea user. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 This library can only be loaded by the \fI\%kea\-dhcp4\fP process, as there is no BOOTP protocol for IPv6. .UNINDENT .UNINDENT .sp This library is loaded similarly to other hook libraries, and it takes no parameters. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dq/usr/local/lib/libdhcp_bootp.so\(dq }, ... ] } .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 A host reservation for a BOOTP client should use the hardware address as the identifier (the \fBclient\-id\fP option is a DHCP\-specific option). .UNINDENT .UNINDENT .sp Incoming BOOTP packets are added to the BOOTP class, allowing administrators to segregate BOOTP clients into separate pools. For example: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqclient\-classes\(dq: [ { // The DHCP class is the complement of the BOOTP class \(dqname\(dq: \(dqDHCP\(dq, \(dqtest\(dq: \(dqnot member(\(aqBOOTP\(aq)\(dq } ], \(dqsubnet4\(dq: [ { \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq, \(dqpools\(dq: [ { // BOOTP clients will be handled here \(dqpool\(dq: \(dq192.0.2.200 \- 192.0.2.254\(dq, \(dqclient\-classes\(dq: [ \(dqBOOTP\(dq ] }, { // Regular DHCP clients will be handled here \(dqpool\(dq: \(dq192.0.2.1 \- 192.0.2.199\(dq, \(dqclient\-classes\(dq: [ \(dqDHCP\(dq ] }], ... }, ... ], ... } .EE .UNINDENT .UNINDENT .SS BOOTP Hooks Limitations .sp Currently the BOOTP library has the following limitation: .INDENT 0.0 .IP \(bu 2 Basic BOOTP, as defined in \X'tty: link https://tools.ietf.org/html/rfc951'\fI\%RFC 951\fP\X'tty: link', is not supported. Kea only supports BOOTP with vendor\-information extensions. .UNINDENT .SS \fBlibdhcp_cb_cmds.so\fP: Configuration Backend Commands .sp This hook library is used to manage Kea servers\(aq configurations in a configuration backend database. This library must be used in conjunction with the available CB hook libraries implementing the common APIs to create, read, update, and delete (CRUD) the configuration information in the respective databases. For example: \fI\%libdhcp_mysql.so\fP implements this API for MySQL while \fI\%libdhcp_pgsql.so\fP implements this API for PostgreSQL. To manage the configuration information in a MySQL database, both \fI\%libdhcp_mysql.so\fP and \fI\%libdhcp_cb_cmds.so\fP must be loaded by the server used for configuration management. To manage the configuration information in a PostgreSQL database, both \fI\%libdhcp_pgsql.so\fP and \fI\%libdhcp_cb_cmds.so\fP must be loaded by the server used for configuration management. .sp More information on how to configure the Configuration Backend hook library for use with a MySQL or PostgreSQL database can be found in the \fI\%Configuration Backend in DHCPv4\fP and \fI\%Configuration Backend in DHCPv6\fP sections. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 \fI\%libdhcp_cb_cmds.so\fP is available only to ISC customers with a paid support contract. For more information on subscription options, please complete the form at \X'tty: link https://www.isc.org/contact'\fI\%https://www.isc.org/contact\fP\X'tty: link'\&. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 This library can only be loaded by the \fI\%kea\-dhcp4\fP or \fI\%kea\-dhcp6\fP process. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Please read about \fI\%Limitations and Warnings\fP before using the commands described in this section. .UNINDENT .UNINDENT .SS Command Structure .sp There are 5 types of commands supported by this library: .INDENT 0.0 .IP \(bu 2 \fBdel\fP \- delete the selected object from the database, e.g. \fI\%remote\-global\-parameter4\-del\fP\&. .IP \(bu 2 \fBget\fP \- fetch the selected object from the database, e.g. \fI\%remote\-subnet4\-get\-by\-id\fP\&. .IP \(bu 2 \fBget\-all\fP \- fetch all objects of the particular type from the database, e.g. \fI\%remote\-option\-def4\-get\-all\fP\&. .IP \(bu 2 \fBlist\fP \- list all objects of the particular type in the database, e.g. \fI\%remote\-network4\-list\fP; this class of commands returns brief information about each object compared to the output of \fBget\-all\fP\&. .IP \(bu 2 \fBset\fP \- creates or replaces an object of the given type in the database, e.g. \fI\%remote\-option4\-global\-set\fP\&. .UNINDENT .sp All types of commands accept an optional \fBremote\fP map which selects the database instance to which the command refers. For example: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqremote\-subnet4\-list\(dq, \(dqarguments\(dq: { \(dqremote\(dq: { \(dqtype\(dq: \(dqmysql\(dq, \(dqhost\(dq: \(dq192.0.2.33\(dq, \(dqport\(dq: 3302 } } } .EE .UNINDENT .UNINDENT .sp selects the MySQL database, running on host 192.0.2.33 and port 3302, to fetch the list of subnets from. All parameters in the \fBremote\fP argument are optional. The \fBport\fP parameter can be only specified in conjunction with the \fBhost\fP\&. If no options in the \fBremote\fP parameter are to be specified, the parameter should be omitted. In this case, the server will use the first backend listed in the \fBconfig\-control\fP map within the configuration of the server receiving the command. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 In the current Kea release, it is only possible to configure the Kea server to use a single configuration backend. Strictly speaking, it is possible to point the Kea server to at most one database (either MySQL or PostgreSQL) using the \fBconfig\-control\fP parameter. Therefore, the \fBremote\fP parameter may be omitted in the commands and \fI\%libdhcp_cb_cmds.so\fP uses the sole backend by default. The example commands below most often show a value of \(dqmysql\(dq for the \fBtype\fP parameter; it should be assumed that the value is \(dqpostgresql\(dq for installations using a PostgreSQL database. .UNINDENT .UNINDENT .SS Control Commands for DHCP Servers .sp This section describes and gives some examples of the control commands implemented by \fI\%libdhcp_cb_cmds.so\fP, to manage the configuration information of the DHCPv4 and DHCPv6 servers. Many of the commands are almost identical between DHCPv4 and DHCPv6; they only differ by the command name. Other commands differ slightly by the structure of the inserted data; for example, the structure of the IPv4 subnet information is different than that of the IPv6 subnet. Nevertheless, they still share the structure of their command arguments and thus it makes sense to describe them together. .sp In addition, whenever the text in the subsequent sections refers to a DHCP command or DHCP parameter, it refers to both DHCPv4 and DHCPv6 variants. The text specific to the particular server type refers to them as: DHCPv4 command, DHCPv4 parameter, DHCPv6 command, DHCPv6 parameter, etc. .SS Metadata .sp The typical response to the \fBget\fP or \fBlist\fP command includes a list of returned objects (e.g. subnets), and each such object contains the \fBmetadata\fP map with some database\-specific information describing this object. In other words, the metadata contains any information about the fetched object which may be useful for an administrator but which is not part of the object specification from the DHCP server standpoint. In the present Kea release, the metadata is limited to the \fBserver\-tag\fP\&. It describes the association of the object with a particular server or all servers. .sp The following is the example response to the \fI\%remote\-network4\-list\fP command, which includes the metadata: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dq1 IPv4 shared network(s) found.\(dq, \(dqarguments\(dq: { \(dqshared\-networks\(dq: [ { \(dqname\(dq: \(dqlevel3\(dq, \(dqmetadata\(dq: { \(dqserver\-tags\(dq: [ \(dqall\(dq ] } } ], \(dqcount\(dq: 1 } } .EE .UNINDENT .UNINDENT .sp Client implementations must not assume that the metadata contains only the \fBserver\-tags\fP parameter. In future releases, it is expected that this map will be extended with additional information, e.g. object modification time, log message created during the last modification, etc. .SS The \fBremote\-server4\-del\fP, \fBremote\-server6\-del\fP Commands .sp This command is used to delete the information about a selected DHCP server from the configuration database. The server is identified by a unique case insensitive server tag. For example: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqremote\-server4\-del\(dq, \(dqarguments\(dq: { \(dqservers\(dq: [ { \(dqserver\-tag\(dq: \(dqserver1\(dq } ], \(dqremote\(dq: { \(dqtype\(dq: \(dqpostgresql\(dq } } } .EE .UNINDENT .UNINDENT .sp As a result of this command, all associations of the configuration for the user\-defined server called \(dqserver1\(dq are removed from the database, including non\-shareable configuration information, such as global parameters, option definitions, and global options. Any shareable configuration information, i.e. the configuration elements which may be associated with more than one server, is preserved. In particular, the subnets and shared networks associated with the deleted servers are preserved. If any of the shareable configuration elements was associated only with the deleted server, this object becomes unassigned (orphaned). For example: if a subnet has been created and associated with \(dqserver1\(dq using the \fI\%remote\-subnet4\-set\fP command and \(dqserver1\(dq is subsequently deleted, the subnet remains in the database but no servers can use this subnet. The subnet can be updated using the \fI\%remote\-subnet4\-set\fP command, and can be associated with either another server or with all servers, using the special server tag \(dqall\(dq. Such a subnet can be also deleted from the database using the \fI\%remote\-subnet4\-del\-by\-id\fP or \fI\%remote\-subnet4\-del\-by\-prefix\fP command, if it is no longer needed. .sp The following is the successful response to the \fI\%remote\-server4\-del\fP command: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dq1 DHCPv4 server(s) deleted.\(dq, \(dqarguments\(dq: { \(dqcount\(dq: 1 } } .EE .UNINDENT .UNINDENT .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 The \fI\%remote\-server4\-del\fP and \fI\%remote\-server6\-del\fP commands must be used with care, because an accidental deletion of the server can cause some parts of the existing configurations to be lost permanently from the database. This operation is not reversible. Re\-creation of the accidentally deleted server does not revert the lost configuration for that server and such configuration must be re\-created manually by the user. .UNINDENT .UNINDENT .SS The \fBremote\-server4\-get\fP, \fBremote\-server6\-get\fP Commands .sp This command is used to fetch the information about the selected DHCP server from the configuration database. For example: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqremote\-server6\-get\(dq, \(dqarguments\(dq: { \(dqservers\(dq: [ { \(dqserver\-tag\(dq: \(dqserver1\(dq } ], \(dqremote\(dq: { \(dqtype\(dq: \(dqmysql\(dq } } } .EE .UNINDENT .UNINDENT .sp This command fetches the information about the DHCPv6 server identified by the server tag \(dqserver1\(dq. The server tag is case\-insensitive. A successful response returns basic information about the server, such as the server tag and the user\(aqs description of the server: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dqDHCP server server1 found.\(dq, \(dqarguments\(dq: { \(dqservers\(dq: [ { \(dqserver\-tag\(dq: \(dqserver1\(dq, \(dqdescription\(dq: \(dqA DHCPv6 server located on the first floor.\(dq } ], \(dqcount\(dq: 1 } } .EE .UNINDENT .UNINDENT .SS The \fBremote\-server4\-get\-all\fP, \fBremote\-server6\-get\-all\fP Commands .sp This command is used to fetch all user\-defined DHCPv4 or DHCPv6 servers from the database. The command structure is very simple: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqremote\-server4\-get\-all\(dq, \(dqarguments\(dq: { \(dqremote\(dq: { \(dqtype\(dq: \(dqmysql\(dq } } } .EE .UNINDENT .UNINDENT .sp The response includes basic information about each server, such as its server tag and description: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dqDHCPv4 servers found.\(dq, \(dqarguments\(dq: { \(dqservers\(dq: [ { \(dqserver\-tag\(dq: \(dqserver1\(dq, \(dqdescription\(dq: \(dqA DHCP server located on the first floor.\(dq }, { \(dqserver\-tag\(dq: \(dqserver2\(dq, \(dqdescription\(dq: \(dqAn old DHCP server to be soon replaced.\(dq } ], \(dqcount\(dq: 2 } } .EE .UNINDENT .UNINDENT .SS The \fBremote\-server4\-set\fP, \fBremote\-server6\-set\fP Commands .sp This command is used to create or replace an information about a DHCP server in the database. The information about the server must be created when there is a need to differentiate the configurations used by various Kea instances connecting to the same database. Various configuration elements, e.g. global parameters, subnets, etc. may be explicitly associated with the selected servers (using server tags as identifiers), allowing only these servers to use the respective configuration elements. Using the particular server tag to make such associations is only possible when the server information has been stored in the database via the \fI\%remote\-server4\-set\fP or \fI\%remote\-server6\-set\fP commands. The following command creates a new (or updates an existing) DHCPv6 server in the database: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqremote\-server6\-set\(dq, \(dqarguments\(dq: { \(dqservers\(dq: [ { \(dqserver\-tag\(dq: \(dqserver1\(dq, \(dqdescription\(dq: \(dqA DHCP server on the ground floor.\(dq } ], \(dqremote\(dq: { \(dqtype\(dq: \(dqmysql\(dq } } } .EE .UNINDENT .UNINDENT .sp The server tag must be unique across all servers in the database. When the server information under the given server tag already exists, it is replaced with the new information. The specified server tag is case\-insensitive, and the maximum length of the server tag is 256 characters. The following keywords are reserved and cannot be used as server tags: \(dqall\(dq and \(dqany\(dq. .sp The following is the example response to the above command: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dqDHCPv6 server successfully set.\(dq, \(dqarguments\(dq: { \(dqservers\(dq: [ { \(dqserver\-tag\(dq: \(dqserver1\(dq, \(dqdescription\(dq: \(dqA DHCP server on the ground floor.\(dq } ] } } .EE .UNINDENT .UNINDENT .SS The \fBremote\-global\-parameter4\-del\fP, \fBremote\-global\-parameter6\-del\fP Commands .sp These commands are used to delete a global DHCP parameter from the configuration database. When the parameter is deleted from the database, the server uses the value specified in the configuration file for this parameter, or a default value if the parameter is not specified in the configuration file. .sp The following command attempts to delete the DHCPv4 \fBrenew\-timer\fP parameter common for all servers from the database: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqremote\-global\-parameter4\-del\(dq, \(dqarguments\(dq: { \(dqparameters\(dq: [ \(dqrenew\-timer\(dq ], \(dqremote\(dq: { \(dqtype\(dq: \(dqmysql\(dq }, \(dqserver\-tags\(dq: [ \(dqall\(dq ] } } .EE .UNINDENT .UNINDENT .sp If a server\-specific parameter is to be deleted, the \fBserver\-tags\fP list must contain the tag of the appropriate server. There must be exactly one server tag specified in this list. .SS The \fBremote\-global\-parameter4\-get\fP, \fBremote\-global\-parameter6\-get\fP Commands .sp These commands are used to fetch a scalar global DHCP parameter from the configuration database. .sp The following command attempts to fetch the \fBboot\-file\-name\fP parameter for \(dqserver1\(dq: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqremote\-global\-parameter4\-get\(dq, \(dqarguments\(dq: { \(dqparameters\(dq: [ \(dqboot\-file\-name\(dq ], \(dqremote\(dq: { \(dqtype\(dq: \(dqmysql\(dq }, \(dqserver\-tags\(dq: [ \(dqserver1\(dq ] } } .EE .UNINDENT .UNINDENT .sp The returned value has one of the four scalar types: string, integer, real, or boolean. Non\-scalar global configuration parameters, such as map or list, are not returned by this command. .sp In the case of the example above, the string value is returned, e.g.: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dq1 DHCPv4 global parameter found.\(dq, \(dqarguments\(dq: { \(dqparameters\(dq: { \(dqboot\-file\-name\(dq: \(dq/dev/null\(dq, \(dqmetadata\(dq: { \(dqserver\-tags\(dq: [ \(dqall\(dq ] } }, \(dqcount\(dq: 1 } } .EE .UNINDENT .UNINDENT .sp Note that the response above indicates that the returned parameter is associated with \(dqall\(dq servers rather than \(dqserver1\(dq, used in the command. This indicates that there is no \(dqserver1\(dq\-specific value in the database and therefore, the value shared by all servers is returned. If there were a \(dqserver1\(dq\-specific value in the database, that value would be returned instead. .sp The example response for the integer value is: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dq1 DHCPv4 global parameter found.\(dq, \(dqarguments\(dq: { \(dqparameters\(dq: { \(dqrenew\-timer\(dq: 2000, \(dqmetadata\(dq: { \(dqserver\-tags\(dq: [ \(dqserver1\(dq ] } }, \(dqcount\(dq: 1 } } .EE .UNINDENT .UNINDENT .sp The real value: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dq1 DHCPv4 global parameter found.\(dq, \(dqarguments\(dq: { \(dqparameters\(dq: { \(dqt1\-percent\(dq: 0.85, \(dqmetadata\(dq: { \(dqserver\-tags\(dq: [ \(dqall\(dq ] } }, \(dqcount\(dq: 1 } } .EE .UNINDENT .UNINDENT .sp Finally, the boolean value: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dq1 DHCPv4 global parameter found.\(dq, \(dqarguments\(dq: { \(dqparameters\(dq: { \(dqmatch\-client\-id\(dq: true, \(dqmetadata\(dq: { \(dqserver\-tags\(dq: [ \(dqserver2\(dq ] } }, \(dqcount\(dq: 1 } } .EE .UNINDENT .UNINDENT .SS The \fBremote\-global\-parameter4\-get\-all\fP, \fBremote\-global\-parameter6\-get\-all\fP Commands .sp These commands are used to fetch all global DHCP parameters from the database for the specified server. The following example demonstrates how to fetch all global parameters to be used by the server \(dqserver1\(dq: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqremote\-global\-parameter4\-get\-all\(dq, \(dqarguments\(dq: { \(dqremote\(dq: { \(dqtype\(dq: \(dqmysql\(dq }, \(dqserver\-tags\(dq: [ \(dqserver1\(dq ] } } .EE .UNINDENT .UNINDENT .sp The example response may look as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dqDHCPv4 global parameters found.\(dq, \(dqarguments\(dq: { \(dqparameters\(dq: [ { \(dqboot\-file\-name\(dq: \(dq/dev/null\(dq, \(dqmetadata\(dq: { \(dqserver\-tags\(dq: [ \(dqserver1\(dq ] } }, { \(dqmatch\-client\-id\(dq: true, \(dqmetadata\(dq: { \(dqserver\-tags\(dq: [ \(dqall\(dq ] } } ], \(dqcount\(dq: 2 } } .EE .UNINDENT .UNINDENT .sp The example response contains two parameters: one string parameter and one boolean parameter. The metadata returned for each parameter indicates whether this parameter is specific to \(dqserver1\(dq or applies to all servers. Since the \fBmatch\-client\-id\fP value is associated with \(dqall\(dq servers, it indicates that there is no \(dqserver1\(dq\-specific setting for this parameter. Each parameter always has exactly one server tag associated with it, because global parameters are non\-shareable configuration elements. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 If the server tag is set to \(dqall\(dq in the command, the response will contain only the global parameters associated with the logical server \(dqall\(dq. When the server tag points to the specific server (as in the example above), the returned list combines parameters associated with this server and all servers, but the former take precedence. .UNINDENT .UNINDENT .SS The \fBremote\-global\-parameter4\-set\fP, \fBremote\-global\-parameter6\-set\fP Commands .sp This command is used to create scalar global DHCP parameters in the database. If any of the parameters already exists, its value is replaced as a result of this command. It is possible to set multiple parameters within a single command, each having one of the four types: string, integer, real, or boolean. For example: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqremote\-global\-parameter4\-set\(dq, \(dqarguments\(dq: { \(dqparameters\(dq: { \(dqboot\-file\-name\(dq: \(dq/dev/null\(dq, \(dqrenew\-timer\(dq: 2000, \(dqt1\-percent\(dq: 0.85, \(dqmatch\-client\-id\(dq: true }, \(dqremote\(dq: { \(dqtype\(dq: \(dqmysql\(dq }, \(dqserver\-tags\(dq: [ \(dqserver1\(dq ] } } .EE .UNINDENT .UNINDENT .sp An error is returned if any of the parameters is not supported by the DHCP server or its type does not match. Care should be taken when multiple parameters are specified in a single command, because it is possible that only some of the parameters will be stored successfully and some will fail. If an error occurs when processing this command, it is recommended to use \fI\%remote\-global\-parameter4\-get\-all\fP or \fI\%remote\-global\-parameter6\-get\-all\fP to check which of the parameters have been stored/updated successfully and which have failed. .sp The \fBserver\-tags\fP list is mandatory and must contain a single server tag or the keyword \(dqall\(dq. In the example above, all specified parameters are associated with the \(dqserver1\(dq server. .SS The \fBremote\-network4\-del\fP, \fBremote\-network6\-del\fP Commands .sp These commands are used to delete an IPv4 or IPv6 shared network from the database. The optional parameter \fBsubnets\-action\fP determines whether the subnets belonging to the deleted shared network should also be deleted or preserved. The \fBsubnets\-action\fP parameter defaults to \fBkeep\fP, which preserves the subnets. If it is set to \fBdelete\fP, the subnets are deleted along with the shared network. .sp The following command: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqremote\-network6\-del\(dq, \(dqarguments\(dq: { \(dqshared\-networks\(dq: [ { \(dqname\(dq: \(dqlevel3\(dq } ], \(dqsubnets\-action\(dq: \(dqkeep\(dq, \(dqremote\(dq: { \(dqtype\(dq: \(dqmysql\(dq } } } .EE .UNINDENT .UNINDENT .sp deletes the \(dqlevel3\(dq IPv6 shared network. The subnets are preserved, but they are disassociated from the deleted shared network and become global. This behavior corresponds to the behavior of the \fI\%network4\-del\fP, \fI\%network6\-del\fP commands with respect to the \fBsubnets\-action\fP parameter. .sp Note that the \fBserver\-tags\fP parameter cannot be used for this command. .SS The \fBremote\-network4\-get\fP, \fBremote\-network6\-get\fP Commands .sp These commands are used to retrieve information about an IPv4 or IPv6 shared network. The optional parameter \fBsubnets\-include\fP denotes whether the subnets belonging to the shared network should also be returned. This parameter defaults to \fBno\fP, in which case the subnets are not returned. If this parameter is set to \fBfull\fP, the subnets are returned together with the shared network. .sp The following command fetches the \(dqlevel3\(dq IPv6 shared network along with the full information about the subnets belonging to it: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqremote\-network6\-get\(dq, \(dqarguments\(dq: { \(dqshared\-networks\(dq: [ { \(dqname\(dq: \(dqlevel3\(dq } ], \(dqsubnets\-include\(dq: \(dqfull\(dq, \(dqremote\(dq: { \(dqtype\(dq: \(dqmysql\(dq } } } .EE .UNINDENT .UNINDENT .sp Note that the \fBserver\-tags\fP parameter cannot be used for this command. .SS The \fBremote\-network4\-list\fP, \fBremote\-network6\-list\fP Commands .sp These commands are used to list all IPv4 or IPv6 shared networks for a server. .sp The following command retrieves all shared networks to be used by \(dqserver1\(dq and \(dqserver2\(dq: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqremote\-network4\-list\(dq, \(dqarguments\(dq: { \(dqremote\(dq: { \(dqtype\(dq: \(dqmysql\(dq }, \(dqserver\-tags\(dq: [ \(dqserver1\(dq, \(dqserver2\(dq ] } } .EE .UNINDENT .UNINDENT .sp The \fBserver\-tags\fP parameter is mandatory and contains one or more server tags. It may contain the keyword \(dqall\(dq to fetch the shared networks associated with all servers. When the \fBserver\-tags\fP list contains the \fBnull\fP value, the returned response contains a list of unassigned shared networks, i.e. the networks which are associated with no servers. For example: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqremote\-network4\-list\(dq, \(dqarguments\(dq: { \(dqremote\(dq: { \(dqtype\(dq: \(dqmysql\(dq }, \(dqserver\-tags\(dq: [ null ] } } .EE .UNINDENT .UNINDENT .sp The example response to this command when non\-null server tags are specified looks similar to this: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dq3 IPv4 shared network(s) found.\(dq, \(dqarguments\(dq: { \(dqshared\-networks\(dq: [ { \(dqname\(dq: \(dqground floor\(dq, \(dqmetadata\(dq: { \(dqserver\-tags\(dq: [ \(dqall\(dq ] } }, { \(dqname\(dq: \(dqfloor2\(dq, \(dqmetadata\(dq: { \(dqserver\-tags\(dq: [ \(dqserver1\(dq ] } }, { \(dqname\(dq: \(dqfloor3\(dq, \(dqmetadata\(dq: { \(dqserver\-tags\(dq: [ \(dqserver2\(dq ] } } ], \(dqcount\(dq: 3 } } .EE .UNINDENT .UNINDENT .sp The returned information about each shared network merely contains the shared network name and the metadata. To fetch detailed information about the selected shared network, use the \fI\%remote\-network4\-get\fP or \fI\%remote\-network6\-get\fP command. .sp The example response above contains three shared networks. One of the shared networks is associated with all servers, so it is included in the list of shared networks to be used by \(dqserver1\(dq and \(dqserver2\(dq. The remaining two shared networks are returned because one of them is associated with \(dqserver1\(dq and another one is associated with \(dqserver2\(dq. .sp When listing unassigned shared networks, the response looks similar to this: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dq1 IPv4 shared network(s) found.\(dq, \(dqarguments\(dq: { \(dqshared\-networks\(dq: [ { \(dqname\(dq: \(dqfancy\(dq, \(dqmetadata\(dq: { \(dqserver\-tags\(dq: [ null ] } } ], \(dqcount\(dq: 1 } } .EE .UNINDENT .UNINDENT .sp The \fBnull\fP value in the metadata indicates that the returned shared network is unassigned. .SS The \fBremote\-network4\-set\fP, \fBremote\-network6\-set\fP Commands .sp These commands create a new or replace an existing IPv4 or IPv6 shared network in the database. The structure of the shared network information is the same as in the Kea configuration file (see \fI\%Shared Networks in DHCPv4\fP and \fI\%Shared Networks in DHCPv6\fP for details), except that specifying subnets along with the shared network information is not allowed. Including the \fBsubnet4\fP or \fBsubnet6\fP parameter within the shared network information results in an error. .sp These commands are intended to be used for managing the shared network\-specific information and DHCP options. To associate and disassociate the subnets with the shared networks, the \fI\%remote\-subnet4\-set\fP, \fI\%remote\-subnet6\-set\fP commands should be used. .sp The following command adds the IPv6 shared network \(dqlevel3\(dq to the database: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqremote\-network6\-set\(dq, \(dqarguments\(dq: { \(dqshared\-networks\(dq: [ { \(dqname\(dq: \(dqlevel3\(dq, \(dqinterface\(dq: \(dqeth0\(dq, \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqsntp\-servers\(dq, \(dqdata\(dq: \(dq2001:db8:1::1\(dq } ] } ], \(dqremote\(dq: { \(dqtype\(dq: \(dqmysql\(dq }, \(dqserver\-tags\(dq: [ \(dqall\(dq ] } } .EE .UNINDENT .UNINDENT .sp This command includes the \fBinterface\fP parameter, which sets the shared network\-level interface name. Any remaining shared\-network\-level parameters, which are not specified with the command, will be marked as \(dqunspecified\(dq in the database. The DHCP server uses the global values for unspecified parameters or, if the global values are not specified, the default values are used. .sp The \fBserver\-tags\fP list is mandatory for this command and must include one or more server tags. As a result, the shared network is associated with all listed servers. The shared network may be associated with all servers connecting to the database when the keyword \(dqall\(dq is included. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 As with other \(dqset\(dq commands, this command replaces all the information about the given shared network in the database, if the shared network already exists. Therefore, when sending this command, make sure to always include all parameters that must be specified for the updated shared\-network instance. Any unspecified parameter will be marked unspecified in the database, even if its value was present prior to sending the command. .UNINDENT .UNINDENT .SS The \fBremote\-option\-def4\-del\fP, \fBremote\-option\-def6\-del\fP Commands .sp These commands are used to delete a DHCP option definition from the database. The option definition is identified by an option code and option space. For example: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqremote\-option\-def6\-del\(dq, \(dqarguments\(dq: { \(dqoption\-defs\(dq: [ { \(dqcode\(dq: 1, \(dqspace\(dq: \(dqisc\(dq } ], \(dqremote\(dq: { \(dqtype\(dq: \(dqmysql\(dq }, \(dqserver\-tags\(dq: [ \(dqserver1\(dq ] } } .EE .UNINDENT .UNINDENT .sp deletes the definition of the option associated with \(dqserver1\(dq, having the code of 1 and belonging to the option space \(dqisc\(dq. The default option spaces are \(dqdhcp4\(dq and \(dqdhcp6\(dq for the DHCPv4 and DHCPv6 top\-level options, respectively. If there is no such option explicitly associated with \(dqserver1\(dq, no option is deleted. To delete an option belonging to \(dqall\(dq servers, the keyword \(dqall\(dq must be used as the server tag. The \fBserver\-tags\fP list must contain exactly one tag and cannot include the \fBnull\fP value. .SS The \fBremote\-option\-def4\-get\fP, \fBremote\-option\-def6\-get\fP Commands .sp These commands are used to fetch a specified DHCP option definition from the database. The option definition is identified by the option code and option space. The default option spaces are \(dqdhcp4\(dq and \(dqdhcp6\(dq for the DHCPv4 and DHCPv6 top\-level options, respectively. .sp The following command retrieves a DHCPv4 option definition associated with all servers, having the code of 1 and belonging to the option space \(dqisc\(dq: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqremote\-option\-def4\-get\(dq, \(dqarguments\(dq: { \(dqoption\-defs\(dq: [ { \(dqcode\(dq: 1, \(dqspace\(dq: \(dqisc\(dq } ], \(dqremote\(dq: { \(dqtype\(dq: \(dqmysql\(dq }, \(dqserver\-tags\(dq: [ \(dqall\(dq ] } } .EE .UNINDENT .UNINDENT .sp The \fBserver\-tags\fP list must include exactly one server tag or the keyword \(dqall\(dq, and cannot contain the \fInull\fP value. .SS The \fBremote\-option\-def4\-get\-all\fP, \fBremote\-option\-def6\-get\-all\fP Commands .sp These commands are used to fetch all DHCP option definitions from the database for the given server or all servers. For example: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqremote\-option\-def6\-get\-all\(dq, \(dqarguments\(dq: { \(dqremote\(dq: { \(dqtype\(dq: \(dqmysql\(dq }, \(dqserver\-tags\(dq: [ \(dqall\(dq ] } } .EE .UNINDENT .UNINDENT .sp This command attempts to fetch all DHCPv6 option definitions associated with \(dqall\(dq servers. The \fBserver\-tags\fP list is mandatory for this command and must include exactly one server tag or the keyword \(dqall\(dq. It cannot include the \fBnull\fP value. .sp The following is the example response to this command: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dq1 DHCPv6 option definition(s) found.\(dq, \(dqarguments\(dq: { \(dqoption\-defs\(dq: [ { \(dqname\(dq: \(dqbar\(dq, \(dqcode\(dq: 1012, \(dqspace\(dq: \(dqdhcp6\(dq, \(dqtype\(dq: \(dqrecord\(dq, \(dqarray\(dq: true, \(dqrecord\-types\(dq: \(dqipv6\-address, uint16\(dq, \(dqencapsulate\(dq: \(dq\(dq, \(dqmetadata\(dq: { \(dqserver\-tags\(dq: [ \(dqall\(dq ] } } ], \(dqcount\(dq: 1 } } .EE .UNINDENT .UNINDENT .sp The response contains an option definition associated with all servers, as indicated by the metadata. .SS The \fBremote\-option\-def4\-set\fP, \fBremote\-option\-def6\-set\fP Commands .sp These commands create a new DHCP option definition or replace an existing option definition in the database. The structure of the option definition information is the same as in the Kea configuration file (see \fI\%Custom DHCPv4 Options\fP and \fI\%Custom DHCPv6 Options\fP). The following command creates the DHCPv4 option definition at the top\-level \(dqdhcp4\(dq option space and associates it with \(dqserver1\(dq: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqremote\-option\-def4\-set\(dq, \(dqarguments\(dq: { \(dqoption\-defs\(dq: [ { \(dqname\(dq: \(dqfoo\(dq, \(dqcode\(dq: 222, \(dqtype\(dq: \(dquint32\(dq, \(dqarray\(dq: false, \(dqrecord\-types\(dq: \(dq\(dq, \(dqspace\(dq: \(dqdhcp4\(dq, \(dqencapsulate\(dq: \(dq\(dq } ], \(dqremote\(dq: { \(dqtype\(dq: \(dqmysql\(dq }, \(dqserver\-tags\(dq: [ \(dqserver1\(dq ] } } .EE .UNINDENT .UNINDENT .sp The \fBserver\-tags\fP list must include exactly one server tag or the keyword \(dqall\(dq, and cannot contain the \fBnull\fP value. .SS The \fBremote\-option4\-global\-del\fP, \fBremote\-option6\-global\-del\fP Commands .sp These commands are used to delete a global DHCP option from the database. The option is identified by an option code and option space. For example: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqremote\-option4\-global\-del\(dq, \(dqarguments\(dq: { \(dqoptions\(dq: [ { \(dqcode\(dq: 5, \(dqspace\(dq: \(dqdhcp4\(dq } ], \(dqremote\(dq: { \(dqtype\(dq: \(dqmysql\(dq }, \(dqserver\-tags\(dq: [ \(dqserver1\(dq ] } } .EE .UNINDENT .UNINDENT .sp The \(dqdhcp4\(dq value represents the top\-level option space where the standard DHCPv4 options belong. The \fBserver\-tags\fP parameter is mandatory and must include a single option tag or the keyword \(dqall\(dq. If the explicit server tag is specified, this command attempts to delete a global option associated with this server. If there is no such option associated with the given server, no option is deleted. To delete an option associated with all servers, the keyword \(dqall\(dq must be specified. .SS The \fBremote\-option4\-global\-get\fP, \fBremote\-option6\-global\-get\fP Commands .sp These commands are used to fetch a global DHCP option from the database. The option is identified by the code and option space. The top\-level option spaces where DHCP standard options belong are called \(dqdhcp4\(dq and \(dqdhcp6\(dq for the DHCPv4 and DHCPv6 servers, respectively. .sp The following command retrieves the IPv6 \(dqDNS Servers\(dq (code 23) option associated with all servers: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqremote\-option6\-global\-get\(dq, \(dqarguments\(dq: { \(dqoptions\(dq: [ { \(dqcode\(dq: 23, \(dqspace\(dq: \(dqdhcp6\(dq } ], \(dqremote\(dq: { \(dqtype\(dq: \(dqmysql\(dq }, \(dqserver\-tags\(dq: [ \(dqall\(dq ] } } .EE .UNINDENT .UNINDENT .sp The \fBserver\-tags\fP parameter is mandatory and must include exactly one server tag or the keyword \(dqall\(dq. It cannot contain the \fBnull\fP value. .SS The \fBremote\-option4\-global\-get\-all\fP, \fBremote\-option6\-global\-get\-all\fP Commands .sp These commands are used to fetch all global DHCP options from the configuration database for the given server or for all servers. The following command fetches all global DHCPv4 options for \(dqserver1\(dq: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqremote\-option6\-global\-get\-all\(dq, \(dqarguments\(dq: { \(dqremote\(dq: { \(dqtype\(dq: \(dqmysql\(dq }, \(dqserver\-tags\(dq: [ \(dqserver1\(dq ] } } .EE .UNINDENT .UNINDENT .sp The \fBserver\-tags\fP list is mandatory for this command and must contain exactly one server tag or a keyword \(dqall\(dq; it cannot contain the \fBnull\fP value. .sp The following is a example response to this command with a single option being associated with \(dqserver1\(dq returned: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dqDHCPv4 options found.\(dq, \(dqarguments\(dq: { \(dqoptions\(dq: [ { \(dqname\(dq: \(dqdomain\-name\-servers\(dq, \(dqcode\(dq: 6, \(dqspace\(dq: \(dqdhcp4\(dq, \(dqcsv\-format\(dq: false, \(dqdata\(dq: \(dq192.0.2.3\(dq, \(dqmetadata\(dq: { \(dqserver\-tags\(dq: [ \(dqserver1\(dq ] } } ], \(dqcount\(dq: 1 } } .EE .UNINDENT .UNINDENT .SS The \fBremote\-option4\-global\-set\fP, \fBremote\-option6\-global\-set\fP Commands .sp These commands create a new global DHCP option or replace an existing option in the database. The structure of the option information is the same as in the Kea configuration file (see \fI\%Standard DHCPv4 Options\fP and \fI\%Standard DHCPv6 Options\fP). For example: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqremote\-option6\-global\-set\(dq, \(dqarguments\(dq: { \(dqoptions\(dq: [ { \(dqname\(dq: \(dqdns\-servers\(dq, \(dqdata\(dq: \(dq2001:db8:1::1\(dq } ], \(dqremote\(dq: { \(dqtype\(dq: \(dqmysql\(dq }, \(dqserver\-tags\(dq: [ \(dqserver1\(dq ] } } .EE .UNINDENT .UNINDENT .sp The \fBserver\-tags\fP list is mandatory for this command and must include exactly one server tag or the keyword \(dqall\(dq; it cannot include the \fBnull\fP value. The command above associates the option with the \(dqserver1\(dq server. .sp Note that specifying an option name instead of the option code only works reliably for standard DHCP options. When specifying a value for a user\-defined DHCP option, the option code should be indicated instead of the name. For example: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqremote\-option6\-global\-set\(dq, \(dqarguments\(dq: { \(dqoptions\(dq: [ { \(dqcode\(dq: 1, \(dqspace\(dq: \(dqisc\(dq, \(dqdata\(dq: \(dq2001:db8:1::1\(dq } ], \(dqserver\-tags\(dq: [ \(dqserver1\(dq ] } } .EE .UNINDENT .UNINDENT .SS The \fBremote\-option4\-network\-del\fP, \fBremote\-option6\-network\-del\fP Commands .sp These commands are used to delete a shared\-network\-specific DHCP option from the database. The option is identified by an option code and option space and these two parameters are passed within the \fBoptions\fP list. Another list, \fBshared\-networks\fP, contains a map with the name of the shared network from which the option is to be deleted. If the option is not explicitly specified for this shared network, no option is deleted. In particular, the given option may be present for a subnet belonging to the shared network. Such an option instance is not affected by this command as this command merely deletes the shared\-network\-level option. To delete a subnet\-level option, the \fI\%remote\-option4\-subnet\-del\fP, \fI\%remote\-option6\-subnet\-del\fP commands must be used instead. .sp The following command attempts to delete an option having the option code 5 in the top\-level option space from the shared network \(dqfancy\(dq. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqremote\-option4\-network\-del\(dq, \(dqarguments\(dq: { \(dqshared\-networks\(dq: [ { \(dqname\(dq: \(dqfancy\(dq } ], \(dqoptions\(dq: [ { \(dqcode\(dq: 5, \(dqspace\(dq: \(dqdhcp4\(dq } ], \(dqremote\(dq: { \(dqtype\(dq: \(dqmysql\(dq } } } .EE .UNINDENT .UNINDENT .sp The \(dqdhcp4\(dq value represents the top\-level option space where the standard DHCPv4 options belong. The \fBserver\-tags\fP parameter cannot be specified for this command. .SS The \fBremote\-option4\-network\-set\fP, \fBremote\-option6\-network\-set\fP Commands .sp These commands create a new shared\-network\-specific DHCP option or replace an existing option in the database. The structure of the option information is the same as in the Kea configuration file (see \fI\%Standard DHCPv4 Options\fP and \fI\%Standard DHCPv6 Options\fP). The option information is carried in the \fBoptions\fP list. Another list, \fBshared\-networks\fP, contains a map with the name of the shared network for which the option is to be set. If such an option already exists for the shared network, it is replaced with the new instance. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqremote\-option6\-network\-set\(dq, \(dqarguments\(dq: { \(dqshared\-networks\(dq: [ { \(dqname\(dq: \(dqfancy\(dq } ], \(dqoptions\(dq: [ { \(dqname\(dq: \(dqdns\-servers\(dq, \(dqdata\(dq: \(dq2001:db8:1::1\(dq } ], \(dqremote\(dq: { \(dqtype\(dq: \(dqmysql\(dq } } } .EE .UNINDENT .UNINDENT .sp The \fBserver\-tags\fP parameter cannot be specified for this command. .sp Specifying an option name instead of the option code only works reliably for standard DHCP options. When specifying a value for a user\-defined DHCP option, the option code should be indicated instead of the name. .SS The \fBremote\-option6\-pd\-pool\-del\fP Command .sp This command is used to delete a prefix delegation pool\-specific DHCPv6 option from the database. The option is identified by an option code and option space, and these two parameters are passed within the \fBoptions\fP list. Another list, \fBpd\-pools\fP, contains a map with the prefix\-delegation\-pool prefix and length identifying the pool. If the option is not explicitly specified for this pool, no option is deleted. In particular, the given option may exist for a subnet containing the specified pool. Such an option instance is not affected by this command, as this command merely deletes a prefix delegation pool\-level option. To delete a subnet\-level option, the \fI\%remote\-option6\-subnet\-del\fP command must be used instead. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqremote\-option6\-pd\-pool\-del\(dq, \(dqarguments\(dq: { \(dqpd\-pools\(dq: [ { \(dqprefix\(dq: \(dq3000::\(dq, \(dqprefix\-len\(dq: 64 } ], \(dqoptions\(dq: [ { \(dqcode\(dq: 23, \(dqspace\(dq: \(dqdhcp6\(dq } ], \(dqremote\(dq: { \(dqtype\(dq: \(dqmysql\(dq } } } .EE .UNINDENT .UNINDENT .sp The \(dqdhcp6\(dq value represents the top\-level option space where the standard DHCPv6 options belong. The \fBserver\-tags\fP parameter cannot be specified for this command. .SS The \fBremote\-option6\-pd\-pool\-set\fP Command .sp This command creates a new prefix delegation pool\-specific DHCPv6 option or replaces an existing option in the database. The structure of the option information is the same as in the Kea configuration file (see \fI\%Standard DHCPv4 Options\fP and \fI\%Standard DHCPv6 Options\fP). The option information is carried in the \fBoptions\fP list. Another list, \fBpd\-pools\fP, contains a map with the prefix\-delegation\-pool prefix and the prefix length identifying the pool. If such an option already exists for the prefix delegation pool, it is replaced with the new instance. .sp For example: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqremote\-option6\-pd\-pool\-set\(dq, \(dqarguments\(dq: { \(dqpd\-pools\(dq: [ { \(dqprefix\(dq: \(dq3001:1::\(dq, \(dqlength\(dq: 64 } ], \(dqoptions\(dq: [ { \(dqname\(dq: \(dqdns\-servers\(dq, \(dqdata\(dq: \(dq2001:db8:1::1\(dq } ], \(dqremote\(dq: { \(dqtype\(dq: \(dqmysql\(dq } } } .EE .UNINDENT .UNINDENT .sp The \fBserver\-tags\fP parameter cannot be specified for this command. .sp Specifying an option name instead of the option code only works reliably for standard DHCP options. When specifying a value for a user\-defined DHCP option, the option code should be indicated instead of the name. .SS The \fBremote\-option4\-pool\-del\fP, \fBremote\-option6\-pool\-del\fP Commands .sp These commands are used to delete an address\-pool\-specific DHCP option from the database. The option is identified by an option code and option space, and these two parameters are passed within the \fBoptions\fP list. Another list, \fBpools\fP, contains a map with the IP address range or prefix identifying the pool. If the option is not explicitly specified for this pool, no option is deleted. In particular, the given option may exist for a subnet containing the specified pool. Such an option instance is not affected by this command, as this command merely deletes a pool\-level option. To delete a subnet\-level option, the \fI\%remote\-option4\-subnet\-del\fP or \fI\%remote\-option6\-subnet\-del\fP command must be used instead. .sp The following command attempts to delete an option having the option code 5 in the top\-level option space from an IPv4 address pool: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqremote\-option4\-pool\-del\(dq, \(dqarguments\(dq: { \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.2.10 \- 192.0.2.100\(dq } ], \(dqoptions\(dq: [ { \(dqcode\(dq: 5, \(dqspace\(dq: \(dqdhcp4\(dq } ], \(dqremote\(dq: { \(dqtype\(dq: \(dqmysql\(dq } } } .EE .UNINDENT .UNINDENT .sp The \(dqdhcp4\(dq value represents the top\-level option space where the standard DHCPv4 options belong. The \fBserver\-tags\fP parameter cannot be specified for this command. .SS The \fBremote\-option4\-pool\-set\fP, \fBremote\-option6\-pool\-set\fP Commands .sp These commands create a new address\-pool\-specific DHCP option or replace an existing option in the database. The structure of the option information is the same as in the Kea configuration file (see \fI\%Standard DHCPv4 Options\fP and \fI\%Standard DHCPv6 Options\fP). The option information is carried in the \fBoptions\fP list. Another list, \fBpools\fP, contains a map with the IP address range or prefix identifying the pool. If such an option already exists for the pool, it is replaced with the new instance. .sp For example: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqremote\-option4\-pool\-set\(dq, \(dqarguments\(dq: { \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.2.10 \- 192.0.2.100\(dq } ], \(dqoptions\(dq: [ { \(dqname\(dq: \(dqdomain\-name\-servers\(dq, \(dqdata\(dq: \(dq10.0.0.1\(dq } ], \(dqremote\(dq: { \(dqtype\(dq: \(dqmysql\(dq } } } .EE .UNINDENT .UNINDENT .sp The \fBserver\-tags\fP parameter cannot be specified for this command. .sp Specifying an option name instead of the option code only works reliably for standard DHCP options. When specifying a value for a user\-defined DHCP option, the option code should be indicated instead of the name. .SS The \fBremote\-option4\-subnet\-del\fP, \fBremote\-option6\-subnet\-del\fP Commands .sp These commands are used to delete a subnet\-specific DHCP option from the database. The option is identified by an option code and option space, and these two parameters are passed within the \fBoptions\fP list. Another list, \fBsubnets\fP, contains a map with the identifier of the subnet from which the option is to be deleted. If the option is not explicitly specified for this subnet, no option is deleted. .sp The following command attempts to delete an option having the option code 5 in the top\-level option space from the subnet having an identifier of 123. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqremote\-option4\-subnet\-del\(dq, \(dqarguments\(dq: { \(dqsubnets\(dq: [ { \(dqid\(dq: 123 } ], \(dqoptions\(dq: [ { \(dqcode\(dq: 5, \(dqspace\(dq: \(dqdhcp4\(dq } ], \(dqremote\(dq: { \(dqtype\(dq: \(dqmysql\(dq } } } .EE .UNINDENT .UNINDENT .sp The \(dqdhcp4\(dq value represents the top\-level option space where the standard DHCPv4 options belong. The \fBserver\-tags\fP parameter cannot be specified for this command. .SS The \fBremote\-option4\-subnet\-set\fP, \fBremote\-option6\-subnet\-set\fP Commands .sp These commands create a new subnet\-specific DHCP option or replace an existing option in the database. The structure of the option information is the same as in the Kea configuration file (see \fI\%Standard DHCPv4 Options\fP and \fI\%Standard DHCPv6 Options\fP). The option information is carried in the \fBoptions\fP list. Another list, \fBsubnets\fP, contains a map with the identifier of the subnet for which the option is to be set. If such an option already exists for the subnet, it is replaced with the new instance. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqremote\-option6\-subnet\-set\(dq, \(dqarguments\(dq: { \(dqsubnets\(dq: [ { \(dqid\(dq: 123 } ], \(dqoptions\(dq: [ { \(dqname\(dq: \(dqdns\-servers\(dq, \(dqdata\(dq: \(dq2001:db8:1::1\(dq } ], \(dqremote\(dq: { \(dqtype\(dq: \(dqmysql\(dq } } } .EE .UNINDENT .UNINDENT .sp The \fBserver\-tags\fP parameter cannot be specified for this command. .sp Specifying an option name instead of the option code only works reliably for the standard DHCP options. When specifying a value for the user\-defined DHCP option, the option code should be indicated instead of the name. .SS The \fBremote\-subnet4\-del\-by\-id\fP, \fBremote\-subnet6\-del\-by\-id\fP Commands .sp This is the first variant of the commands used to delete an IPv4 or IPv6 subnet from the database. It uses the subnet ID to identify the subnet. For example, to delete the IPv4 subnet with an ID of 5: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqremote\-subnet4\-del\-by\-id\(dq, \(dqarguments\(dq: { \(dqsubnets\(dq: [ { \(dqid\(dq: 5 } ], \(dqremote\(dq: { \(dqtype\(dq: \(dqmysql\(dq } } } .EE .UNINDENT .UNINDENT .sp The \fBserver\-tags\fP parameter cannot be used with this command. .SS The \fBremote\-subnet4\-del\-by\-prefix\fP, \fBremote\-subnet6\-del\-by\-prefix\fP Commands .sp This is the second variant of the commands used to delete an IPv4 or IPv6 subnet from the database. It uses the subnet prefix to identify the subnet. For example: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqremote\-subnet6\-del\-by\-prefix\(dq, \(dqarguments\(dq: { \(dqsubnets\(dq: [ { \(dqsubnet\(dq: \(dq2001:db8:1::/64\(dq } ], \(dqremote\(dq: { \(dqtype\(dq: \(dqmysql\(dq } } } .EE .UNINDENT .UNINDENT .sp The \fBserver\-tags\fP parameter cannot be used with this command. .SS The \fBremote\-subnet4\-get\-by\-id\fP, \fBremote\-subnet6\-get\-by\-id\fP Commands .sp This is the first variant of the commands used to fetch an IPv4 or IPv6 subnet from the database. It uses a subnet ID to identify the subnet. For example: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqremote\-subnet4\-get\-by\-id\(dq, \(dqarguments\(dq: { \(dqsubnets\(dq: [ { \(dqid\(dq: 5 } ], \(dqremote\(dq: { \(dqtype\(dq: \(dqmysql\(dq } } } .EE .UNINDENT .UNINDENT .sp The \fBserver\-tags\fP parameter cannot be used with this command. .SS The \fBremote\-subnet4\-get\-by\-prefix\fP, \fBremote\-subnet6\-get\-by\-prefix\fP Commands .sp This is the second variant of the commands used to fetch an IPv4 or IPv6 subnet from the database. It uses a subnet prefix to identify the subnet. For example: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqremote\-subnet6\-get\-by\-prefix\(dq, \(dqarguments\(dq: { \(dqsubnets\(dq: [ { \(dqsubnet\(dq: \(dq2001:db8:1::/64\(dq } ], \(dqremote\(dq: { \(dqtype\(dq: \(dqmysql\(dq } } } .EE .UNINDENT .UNINDENT .sp The \fBserver\-tags\fP parameter cannot be used with this command. .SS The \fBremote\-subnet4\-list\fP, \fBremote\-subnet6\-list\fP Commands .sp These commands are used to list all IPv4 or IPv6 subnets from the database for selected servers or all servers. The following command retrieves all servers to be used by \(dqserver1\(dq and \(dqserver2\(dq: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqremote\-subnet4\-list\(dq, \(dqarguments\(dq: { \(dqremote\(dq: { \(dqtype\(dq: \(dqmysql\(dq }, \(dqserver\-tags\(dq: [ \(dqserver1\(dq, \(dqserver2\(dq ] } } .EE .UNINDENT .UNINDENT .sp The \fBserver\-tags\fP parameter is mandatory and contains one or more server tags. It may contain the keyword \(dqall\(dq, to fetch the subnets associated with all servers. When the \fBserver\-tags\fP list contains the \fBnull\fP value, the returned response contains a list of unassigned subnets, i.e. the subnets which are associated with no servers. For example: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqremote\-subnet4\-list\(dq, \(dqarguments\(dq: { \(dqremote\(dq: { \(dqtype\(dq: \(dqmysql\(dq }, \(dqserver\-tags\(dq: [ null ] } } .EE .UNINDENT .UNINDENT .sp The example response to this command when non\-null server tags are specified looks similar to this: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dq2 IPv4 subnet(s) found.\(dq, \(dqarguments\(dq: { \(dqsubnets\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq, \(dqshared\-network\-name\(dq: null, \(dqmetadata\(dq: { \(dqserver\-tags\(dq: [ \(dqserver1\(dq, \(dqserver2\(dq ] } }, { \(dqid\(dq: 2, \(dqsubnet\(dq: \(dq192.0.3.0/24\(dq, \(dqshared\-network\-name\(dq: null, \(dqmetadata\(dq: { \(dqserver\-tags\(dq: [ \(dqall\(dq ] } } ], \(dqcount\(dq: 2 } } .EE .UNINDENT .UNINDENT .sp The returned information about each subnet is limited to the subnet identifier, prefix, and associated shared network name. To retrieve full information about the selected subnet, use the \fI\%remote\-subnet4\-get\-by\-id\fP / \fI\%remote\-subnet6\-get\-by\-id\fP command or the \fI\%remote\-subnet4\-get\-by\-prefix\fP / \fI\%remote\-subnet6\-get\-by\-prefix\fP command. .sp The example response above contains two subnets. One of the subnets is associated with both servers: \(dqserver1\(dq and \(dqserver2\(dq. The second subnet is associated with all servers, so it is also present in the configurations for \(dqserver1\(dq and \(dqserver2\(dq. .sp When listing unassigned subnets, the response will look similar to this: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dq1 IPv4 subnet(s) found.\(dq, \(dqarguments\(dq: { \(dqsubnets\(dq: [ { \(dqid\(dq: 3, \(dqsubnet\(dq: \(dq192.0.4.0/24\(dq, \(dqshared\-network\-name\(dq: null, \(dqmetadata\(dq: { \(dqserver\-tags\(dq: [ null ] } } ], \(dqcount\(dq: 1 } } .EE .UNINDENT .UNINDENT .sp The \fBnull\fP value in the metadata indicates that the returned subnet is unassigned. .SS The \fBremote\-subnet4\-set\fP, \fBremote\-subnet6\-set\fP Commands .sp These commands are used to create a new IPv4 or IPv6 subnet or replace an existing subnet in the database. Setting the subnet also associates or disassociates the subnet with a shared network. .sp The structure of the subnet information is similar to the structure used in the configuration file (see \fI\%DHCPv4 Server Configuration\fP and \fI\%DHCPv6 Server Configuration\fP). The subnet information conveyed in the \fI\%remote\-subnet4\-set\fP or \fI\%remote\-subnet6\-set\fP command must include the additional parameter \fBshared\-network\-name\fP, which denotes whether the subnet belongs to a shared network. .sp Consider the following example: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqremote\-subnet4\-set\(dq, \(dqarguments\(dq: { \(dqsubnets\(dq: [ { \(dqid\(dq: 5, \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq, \(dqshared\-network\-name\(dq: \(dqlevel3\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.2.100\-192.0.2.200\(dq } ], \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqrouters\(dq, \(dqdata\(dq: \(dq192.0.2.1\(dq } ] } ], \(dqremote\(dq: { \(dqtype\(dq: \(dqmysql\(dq }, \(dqserver\-tags\(dq: [ \(dqall\(dq ] } } .EE .UNINDENT .UNINDENT .sp It creates the subnet and associates it with the \(dqlevel3\(dq shared network. The \(dqlevel3\(dq shared network must be created with the \fI\%remote\-network4\-set\fP command prior to creating the subnet. .sp If the created subnet must be global \- that is, not associated with any shared network \- the \fBshared\-network\-name\fP must be explicitly set to \fBnull\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqremote\-subnet4\-set\(dq, \(dqarguments\(dq: { \(dqsubnets\(dq: [ { \(dqid\(dq: 5, \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq, \(dqshared\-network\-name\(dq: null, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.2.100\-192.0.2.200\(dq } ], \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqrouters\(dq, \(dqdata\(dq: \(dq192.0.2.1\(dq } ] } ], \(dqserver\-tags\(dq: [ \(dqall\(dq ] } } .EE .UNINDENT .UNINDENT .sp The subnet created in the previous example is replaced with the new subnet having the same parameters, but it becomes global. .sp The \fBshared\-network\-name\fP parameter is mandatory for the \fI\%remote\-subnet4\-set\fP command. The \fBserver\-tags\fP list is mandatory and must include one or more server tags. As a result, the subnet is associated with all of the listed servers. It may also be associated with all servers connecting to the database when the keyword \(dqall\(dq is used as the server tag. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 As with other \(dqset\(dq commands, this command replaces all the information about the particular subnet in the database, if the subnet information is already present. Therefore, when sending this command, make sure to always include all parameters that must be specified for the updated subnet instance. Any unspecified parameter will be marked as unspecified in the database, even if its value was present prior to sending the command. .UNINDENT .UNINDENT .SS The \fBremote\-class4\-del\fP, \fBremote\-class6\-del\fP Commands .sp These commands delete a DHCPv4 or DHCPv6 client class by name. If any client classes in the database depend on the deleted class, an error is returned in response to this command. In this case, to successfully delete the class, the dependent client classes must be deleted first. Use the \fI\%remote\-class4\-get\-all\fP command to fetch all client classes and find the dependent ones. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqremote\-class4\-del\(dq, \(dqarguments\(dq: { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqfoo\(dq } ], \(dqremote\(dq: { \(dqtype\(dq: \(dqmysql\(dq } } } .EE .UNINDENT .UNINDENT .sp The \fBserver\-tags\fP parameter cannot be used for this command because client classes are uniquely identified by name. .SS The \fBremote\-class4\-get\fP, \fBremote\-class6\-get\fP Commands .sp These commands retrieve DHCPv4 or DHCPv6 client class information by a client\-class name. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqremote\-class4\-get\(dq, \(dqarguments\(dq: { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqfoo\(dq } ], \(dqremote\(dq: { \(dqtype\(dq: \(dqmysql\(dq } } } .EE .UNINDENT .UNINDENT .sp The \fBserver\-tags\fP parameter cannot be used for this command because client classes are uniquely identified by name. .sp A response to the command looks similar to this: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dqDHCPv4 client class \(aqfoo\(aq found.\(dq, \(dqarguments\(dq: { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqfoo\(dq, \(dqmetadata\(dq: { \(dqserver\-tags\(dq: [ \(dqall\(dq ] } } ], \(dqcount\(dq: 1 } } .EE .UNINDENT .UNINDENT .SS The \fBremote\-class4\-get\-all\fP, \fBremote\-class6\-get\-all\fP Commands .sp These commands retrieve all DHCPv4 or DHCPv6 client classes for a particular server, multiple explicitly listed servers, and/or all servers. A given server has its own server\-specific tag and also has the \(dqall\(dq server tag; these commands retrieve the classes for both an individual server and for \(dqall\(dq servers. For example, the following command retrieves all client classes defined for \(dqserver1\(dq as well as the client classes defined for \(dqall\(dq servers: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqremote\-class4\-get\-all\(dq, \(dqarguments\(dq: { \(dqremote\(dq: { \(dqtype\(dq: \(dqmysql\(dq }, \(dqserver\-tags\(dq: [ \(dqserver1\(dq ] } } .EE .UNINDENT .UNINDENT .sp The \fBserver\-tags\fP parameter is mandatory and contains one or more server tags. If other server tags are specified, \(dqall\(dq does not need to be included in \fBserver\-tags\fP, as every server automatically also has the \(dqall\(dq server tag. If \fBserver\-tags\fP contains only the keyword \(dqall\(dq, only the client classes associated with \(dqall\(dq servers are returned. When the \fBserver\-tags\fP list contains the \fBnull\fP value, the returned response contains a list of unassigned client classes, i.e. the networks which are associated with no servers. .sp A response to the command looks similar to this: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dq2 DHCPv4 client class(es) found.\(dq, \(dqarguments\(dq: { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqfoo\(dq, \(dqmetadata\(dq: { \(dqserver\-tags\(dq: [ \(dqall\(dq ] } }, { \(dqname\(dq: \(dqbar\(dq, \(dqtest\(dq: \(dqmember(\(aqfoo\(aq)\(dq, \(dqmetadata\(dq: { \(dqserver\-tags\(dq: [ \(dqall\(dq ] } } ], \(dqcount\(dq: 2 } } .EE .UNINDENT .UNINDENT .SS The \fBremote\-class4\-set\fP, \fBremote\-class6\-set\fP Commands .sp These commands insert a new or replace an existing DHCPv4 or DHCPv6 client class in the database. The client class information structure is the same as in the Kea configuration file (see \fI\%Client Classification in DHCPv4\fP and \fI\%Client Classification in DHCPv6\fP for details). .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqremote\-class4\-set\(dq, \(dqarguments\(dq: { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqfoo\(dq, \(dqtest\(dq: \(dqmember(\(aqKNOWN\(aq) or member(\(aqbar\(aq)\(dq, \(dqoption\-def\(dq: [ { \(dqname\(dq: \(dqconfigfile\(dq, \(dqcode\(dq: 224, \(dqtype\(dq: \(dqstring\(dq } ], \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqconfigfile\(dq, \(dqdata\(dq: \(dq1APC\(dq } ] } ], \(dqremote\(dq: { \(dqtype\(dq: \(dqmysql\(dq }, \(dqserver\-tags\(dq: [ \(dqall\(dq ] } } .EE .UNINDENT .UNINDENT .sp Client\-class ordering rules described in \fI\%Using Expressions in Classification\fP apply to the classes inserted into the database. They imply that the class \fIbar\fP referenced in the test expression must exist in the database when issuing the above command. .sp By default, a new client class is inserted at the end of the class hierarchy in the database and can reference any class associated with the same server tag or with the special server tag \(dqall\(dq. If an existing class is updated, it remains at its current position within the class hierarchy. .sp However, the class commands allow the position of the inserted or updated client class to be specified. The optional \fBfollow\-class\-name\fP parameter can be included in the command to indicate the name of the existing class after which the managed class should be placed. Suppose there are two DHCPv6 classes in the database: \fIfirst\-class\fP and \fIsecond\-class\fP\&. To add a new class, \fIthird\-class\fP, between these two, use a command similar to the following: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqremote\-class6\-set\(dq, \(dqarguments\(dq: { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqthird\-class\(dq, \(dqtest\(dq: \(dqmember(\(aqfirst\-class\(aq)\(dq } ], \(dqfollow\-class\-name\(dq: \(dqfirst\-class\(dq, \(dqremote\(dq: { \(dqtype\(dq: \(dqmysql\(dq }, \(dqserver\-tags\(dq: [ \(dqall\(dq ] } } .EE .UNINDENT .UNINDENT .sp Note that \fIthird\-class\fP can depend on \fIfirst\-class\fP because it is placed after \fIfirst\-class\fP; \fIthird\-class\fP cannot depend on \fIsecond\-class\fP because it is placed before it. However, \fIsecond\-class\fP could be updated to depend on \fIthird\-class\fP\&. .sp The \fBfollow\-class\-name\fP parameter can be explicitly set to \fBnull\fP, e.g.: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqremote\-class6\-set\(dq, \(dqarguments\(dq: { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqthird\-class\(dq, \(dqtest\(dq: \(dqmember(\(aqfirst\-class\(aq)\(dq } ], \(dqfollow\-class\-name\(dq: null, \(dqremote\(dq: { \(dqtype\(dq: \(dqmysql\(dq }, \(dqserver\-tags\(dq: [ \(dqall\(dq ] } } .EE .UNINDENT .UNINDENT .sp It yields the same behavior as if the \fBfollow\-class\-name\fP parameter were not included, i.e. the new class is appended at the end of the class hierarchy, and the updated class remains at the current position. .SS \fBlibdhcp_class_cmds.so\fP: Class Commands .sp This hook library exposes several control commands for manipulating client classes (part of the Kea DHCP servers\(aq configurations) without the need to restart those servers. Using these commands it is possible to add, update, delete, and list the client classes configured for a given server. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 \fI\%libdhcp_class_cmds.so\fP is part of the open source code and is available to every Kea user. It was previously available only to ISC customers with a paid support contract. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 This library can only be loaded by the \fI\%kea\-dhcp4\fP or \fI\%kea\-dhcp6\fP process. .UNINDENT .UNINDENT .SS The \fBclass\-add\fP Command .sp The \fI\%class\-add\fP command adds a new client class to the DHCP server configuration. This class is appended at the end of the list of classes used by the server and may depend on any of the already\-configured client classes. .sp The following example demonstrates how to add a new client class to the DHCPv4 server configuration: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqclass\-add\(dq, \(dqarguments\(dq: { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqipxe_efi_x64\(dq, \(dqtest\(dq: \(dqoption[93].hex == 0x0009\(dq, \(dqnext\-server\(dq: \(dq192.0.2.254\(dq, \(dqserver\-hostname\(dq: \(dqhal9000\(dq, \(dqboot\-file\-name\(dq: \(dq/dev/null\(dq } ] } } .EE .UNINDENT .UNINDENT .sp Note that the \fBclient\-classes\fP parameter is a JSON list, but it allows only a single client class to be present. .sp Here is the response to the \fI\%class\-add\fP command in our example: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dqClass \(aqipxe_efi_x64\(aq added.\(dq } .EE .UNINDENT .UNINDENT .SS The \fBclass\-update\fP Command .sp The \fI\%class\-update\fP command updates an existing client class in the DHCP server configuration. If the client class with the given name does not exist, the server returns the result code of 3, which means that the server configuration is not modified and the client class does not exist. The \fI\%class\-add\fP command must be used instead to create the new client class. .sp The \fI\%class\-update\fP command has the same argument structure as the \fI\%class\-add\fP command: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqclass\-update\(dq, \(dqarguments\(dq: { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqipxe_efi_x64\(dq, \(dqtest\(dq: \(dqoption[93].hex == 0x0017\(dq, \(dqnext\-server\(dq: \(dq0.0.0.0\(dq, \(dqserver\-hostname\(dq: \(dqxfce\(dq, \(dqboot\-file\-name\(dq: \(dq/dev/null\(dq } ] } } .EE .UNINDENT .UNINDENT .sp Here is the response for our example: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dqClass \(aqipxe_efi_x64\(aq updated.\(dq } .EE .UNINDENT .UNINDENT .sp Any parameter of the client class can be modified with this command, except \fBname\fP\&. There is currently no way to rename the class, because the class name is used as a key for searching the class to be updated. To achieve a similar effect to renaming the class, an existing class can be removed with the \fI\%class\-del\fP command and then added again with a different name using \fI\%class\-add\fP\&. Note, however, that the class with the new name will be added at the end of the list of configured classes. .sp As with other update commands, this command overwrites all the contents of an entry. If the client class previously had a resource assigned to it, and the \fI\%class\-update\fP command is missing the resource, it is deleted from the server configuration. If an incremental update of the class is desired, it can be achieved by issuing a \fI\%class\-get\fP to get the current state of the client class, selecting the client class from the response, modifying it to the required outcome, and then issuing the \fBclient\-update\fP command with the resulting client class attached. .SS The \fBclass\-del\fP Command .sp The \fI\%class\-del\fP command is used to remove a particular class from the server configuration. The class to be removed is identified by name. The class is not removed if there are other classes depending on it; to remove such a class, the dependent classes must be removed first. .sp The following is a sample command removing the \fBipxe_efi_x64\fP class: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqclass\-del\(dq, \(dqarguments\(dq: { \(dqname\(dq: \(dqipxe_efi_x64\(dq } } .EE .UNINDENT .UNINDENT .sp Here is the response to the \fI\%class\-del\fP command in our example, when the specified client class has been found: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dqClass \(aqipxe_efi_x64\(aq deleted.\(dq } .EE .UNINDENT .UNINDENT .sp If the class does not exist, the result of 3 is returned. .SS The \fBclass\-list\fP Command .sp \fI\%class\-list\fP is used to retrieve a list of all client classes. This command includes no arguments: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqclass\-list\(dq } .EE .UNINDENT .UNINDENT .sp Here is the response of the server in our example, including the list of client classes: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dq2 classes found\(dq, \(dqarguments\(dq: { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqipxe_efi_x64\(dq }, { \(dqname\(dq: \(dqpxeclient\(dq } ] } } .EE .UNINDENT .UNINDENT .sp Note that the returned list does not contain full class definitions, but merely class names. To retrieve full class information, the \fI\%class\-get\fP command should be used. .SS The \fBclass\-get\fP Command .sp \fI\%class\-get\fP is used to retrieve detailed information about a specified class. The command structure is very simple: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqclass\-get\(dq, \(dqarguments\(dq: { \(dqname\(dq: \(dqpxeclient\(dq } } .EE .UNINDENT .UNINDENT .sp If the class with the specified name does not exist, the status code of 3 is returned. If the specified client class exists, the class details are returned in the following format: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dqClass \(aqpxeclient\(aq definition returned\(dq, \(dqarguments\(dq: { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqpxeclient\(dq, \(dqonly\-in\-additional\-list\(dq: true, \(dqtest\(dq: \(dqoption[vendor\-class\-identifier].text == \(aqPXEClient\(aq\(dq, \(dqoption\-def\(dq: [ { \(dqname\(dq: \(dqconfigfile\(dq, \(dqcode\(dq: 209, \(dqtype\(dq: \(dqstring\(dq } ], \(dqoption\-data\(dq: [ ], \(dqnext\-server\(dq: \(dq0.0.0.0\(dq, \(dqserver\-hostname\(dq: \(dqxfce\(dq, \(dqboot\-file\-name\(dq: \(dq/dev/null\(dq } ] } } .EE .UNINDENT .UNINDENT .sp Note that the example above is DHCPv4\-specific; the last three parameters are only returned by the DHCPv4 server and are never returned by the DHCPv6 server. Also, some of the parameters provided in this example may not be returned if they are not specified for the class. Specifically, \fBonly\-in\-additional\-list\fP, \fBtest\fP, and \fBoption\-def\fP are not returned if they are not specified for the class. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 As of Kea version 2.7.4, \fBonly\-if\-required\fP has been replaced with \fBonly\-in\-additional\-list\fP and deprecated. In order to allow users time to migrate class commands will still accept it as input but translate it to \fBonly\-in\-additional\-list\fP on output. Eventually support for the old name will be removed. .UNINDENT .UNINDENT .SS \fBlibdhcp_ddns_tuning.so\fP: DDNS Tuning .sp This hook library adds support for fine\-tuning various DNS update aspects. It currently supports procedural host\-name generation and the ability to skip performing DDNS updates for select clients. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 \fI\%libdhcp_ddns_tuning.so\fP is part of the open source code and is available to every Kea user. It was previously available only to ISC customers with a paid support contract. .UNINDENT .UNINDENT .sp The library, which was added in Kea 2.1.5, can be loaded by the \fI\%kea\-dhcp4\fP and \fI\%kea\-dhcp6\fP daemons by adding it to the \fBhooks\-libraries\fP element of the server\(aqs configuration: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dq/usr/local/lib/libdhcp_ddns_tuning.so\(dq, \(dqparameters\(dq: { ... } }, ... ], ... } .EE .UNINDENT .UNINDENT .SS Procedural Host\-Name Generation .sp This hook library provides the ability to generate host names procedurally, based on an expression. The expression can be defined globally in the hook parameters, using \fIhostname\-expr\fP\&. If defined globally, it applies to all hosts in all subnets. The expressions can use all tokens defined in \fI\%Client Classification\fP\&. An example of a global expression is shown below: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dq/usr/local/lib/libdhcp_ddns_tuning.so\(dq, \(dqparameters\(dq: { \(dqhostname\-expr\(dq: \(dq\(aqhost\-\(aq+hexstring(pkt4.mac,\(aq\-\(aq)\(dq, ... } }, ... ], ... } .EE .UNINDENT .UNINDENT .sp The default behavior of \fI\%kea\-dhcp4\fP is to prefer the FQDN option (code 81) over the host name option (code 12) when a client sends both. The following example shows the \fBhostname\-expr\fP one would use to reverse this rule: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dq/usr/local/lib/libdhcp_ddns_tuning.so\(dq, \(dqparameters\(dq: { \(dqhostname\-expr\(dq : \(dqifelse(option[12].exists, option[host\-name].text, option[81].text)\(dq } } ] } .EE .UNINDENT .UNINDENT .sp It is also possible to define this parameter in a subnet, using the user\-context mechanism. If defined at the subnet level, the expression applies to a specific subnet only. If the subnet expression is defined as empty, \fB\(dq\(dq\fP, it suppresses (or disables) the use of a global expression for that subnet. An example subnet expression is shown below: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqsubnet4\(dq: [{ \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq, \(dqpools\(dq: [{ \(dqpool\(dq: \(dq192.0.2.10 \- 192.0.2.20\(dq } ], \(dquser\-context\(dq: { \(dqddns\-tuning\(dq: { \(dqhostname\-expr\(dq: \(dq\(aqguest\-\(aq+int8totext(substring(pkt4.yiaddr, 0,1))+\(aq\-\(aq \e +int8totext(substring(pkt4.yiaddr, 1,2))+\(aq\-\(aq \e +int8totext(substring(pkt4.yiaddr, 2,3))+\(aq\-\(aq \e +int8totext(substring(pkt4.yiaddr, 3,4))\(dq } } }], ... } .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The expression value above uses a backslash, \fB\e\fP, to show line continuation. This is for clarity only and is not valid JSON supported by Kea parsing. The actual value must be expressed on a single line. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Privacy should be taken into consideration when generating a host name. The host name is usually inserted into the DNS, which is a public system. Exposing identifiers that can be used to track devices, such as a MAC address, are usually a very bad idea. The global expression example here used a MAC address for simplicity. .UNINDENT .UNINDENT .SS DHCPv4 Host\-Name Generation .sp With this library installed, the behavior for \fI\%kea\-dhcp4\fP when forming host names in response to a client query (e.g. DISCOVER, REQUEST) is as follows: .INDENT 0.0 .INDENT 3.5 1. If a host name is supplied via a host reservation, use it with the DDNS behavioral parameters to form the final host name. Go to step 4. .sp 2. If the client supplied an FQDN option (option 81), use the domain name value specified within it, with the DDNS behavioral parameters, to form the final host name. Go to step 4. .sp 3. If the client supplied a host\-name option (option 12), use the host name specified within it, with the DDNS behavioral parameters, to form the final host name. .sp 4. If there is a \fBddns\-tuning\fP in\-scope host\-name expression (either global or subnet), calculate the host name using the expression. If the calculated value is not a fully qualified name and there is an in\-scope \fBddns\-qualifying\-suffix\fP, append the suffix. .sp 5. If the value calculated by the hook is not an empty string and is different than the host name formed in steps 1 or 2, the calculated value becomes the final host name. .UNINDENT .UNINDENT .SS DHCPv6 Host\-Name Generation .sp With this library installed, the behavior for \fI\%kea\-dhcp6\fP when forming host names in response to a client query (e.g. SOLICIT, REQUEST, RENEW, REBIND) is as follows: .INDENT 0.0 .INDENT 3.5 1. If the client supplied an FQDN option (option 39), use the domain name value specified within it, with the DDNS behavioral parameters, to form the final host name. Go to step 4. .sp 2. If the client did not supply an FQDN but \fBddns\-replace\-client\-name\fP is either \fBalways\fP or \fBwhen\-not\-present\fP, then calculate the final form of the host name and use it to create an outbound FQDN. Go to step 4. .sp 3. If there is no outbound FQDN at this point, client\-name processing for this packet stops. Without an outbound FQDN there is no way to communicate a host name to the client. .sp 4. If a host name is supplied via a host reservation, use it along with the DDNS behavioral parameters to form the final host name; it supersedes the FQDN value calculated in steps 1 or 2. .sp 5. If there is a \fBddns\-tuning\fP in\-scope host name expression (either global or subnet), calculate the host name using the expression. If the calculated value is not a fully qualified name and there is an in\-scope \fBddns\-qualifying\-suffix\fP, append the suffix. .sp 6. If the value calculated by the hook is not an empty string and is different than the host name formed in steps 1 or 2, the calculated value becomes the final host name. .UNINDENT .UNINDENT .SS Skipping DDNS Updates .sp \fI\%libdhcp_ddns_tuning.so\fP also provides the ability to skip DDNS updates on a per\-client basis. The library recognizes a special client class, \(dqSKIP_DDNS\(dq; when a client is matched to this class, the Kea servers (\fI\%kea\-dhcp4\fP and \fI\%kea\-dhcp6\fP) do not send DDNS update requests (NCRs) to \fI\%kea\-dhcp\-ddns\fP\&. A common use case would be to skip DDNS updates for fixed\-address host reservations. This is done easily by simply assigning the class to the host reservation as shown below: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqreservations\(dq: [ { \(dqhw\-address\(dq: \(dq01:02:03:04:05:06\(dq, \(dqip\-address\(dq: \(dq192.0.2.1\(dq, \(dqclient\-classes\(dq: [ \(dqSKIP_DDNS\(dq, \(dqfoo\(dq, \(dqbar\(dq ] }] } .EE .UNINDENT .UNINDENT .sp The \fI\%libdhcp_ddns_tuning.so\fP hook library notes the presence of the \fB\(dqSKIP_DDNS\(dq\fP class in the client\(aqs class list each time the client requests, renews, or releases its lease, and instructs \fI\%kea\-dhcp4\fP to bypass sending DDNS updates. A similar workflow is supported for \fI\%kea\-dhcp6\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqreservations\(dq: [ { \(dqduid\(dq: \(dq01:02:03:04:05:06\(dq, \(dqip\-address\(dq: \(dq2001:db8::1\(dq, \(dqclient\-classes\(dq: [ \(dqSKIP_DDNS\(dq, \(dqfoo\(dq, \(dqbar\(dq ] }] } .EE .UNINDENT .UNINDENT .sp Although \(dqSKIP_DDNS\(dq is a special class, it can be defined with a test expression. Defining it as shown below would omit DDNS updates for all KNOWN clients: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqclient\-classes\(dq:[ { \(dqname\(dq: \(dqSKIP_DDNS\(dq, \(dqtest\(dq: \(dqmember(\(aqKNOWN\(aq)\(dq }] } .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The \fI\%libdhcp_ddns_tuning.so\fP hook library must be loaded for the \fB\(dqSKIP_DDNS\(dq\fP class to have an effect. .UNINDENT .UNINDENT .SS \fBlibdhcp_flex_id.so\fP: Flexible Identifier for Host Reservations .sp The Kea software provides a way to handle host reservations that include addresses, prefixes, options, client classes, and other features. The reservation can be based on hardware address, DUID, circuit\-id, or client\-id in DHCPv4 and on hardware address or DUID in DHCPv6. However, there are sometimes scenarios where the reservation is more complex; it may use options other than those mentioned above, use parts of specific options, or perhaps even use a combination of several options and fields to uniquely identify a client. Those scenarios are addressed by the Flexible Identifiers hook application. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 \fI\%libdhcp_flex_id.so\fP is part of the open source code and is available to every Kea user. It was previously available only to ISC customers with a paid support contract. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 This library can only be loaded by the \fI\%kea\-dhcp4\fP or \fI\%kea\-dhcp6\fP process. .UNINDENT .UNINDENT .sp \fI\%libdhcp_flex_id.so\fP allows the definition of an expression, using notation initially used only for client classification. (See \fI\%Using Expressions in Classification\fP for a detailed description of the syntax available.) One notable difference is that for client classification, the expression currently has to evaluate to either \fBtrue\fP or \fBfalse\fP, while the flexible identifier expression is expected to evaluate to a string that will be used as an identifier. It is a valid case for the expression to evaluate to an empty string (e.g. in cases where a client does not send specific options). This expression is then evaluated for each incoming packet, and this evaluation generates an identifier that is used to identify the client. In particular, there may be host reservations that are tied to specific values of the flexible identifier. .sp The library can be loaded similarly to other hook libraries. It takes a mandatory parameter \fBidentifier\-expression\fP and some optional boolean parameters like \fBreplace\-client\-id\fP and \fBignore\-iaid\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dq/path/libdhcp_flex_id.so\(dq, \(dqparameters\(dq: { \(dqidentifier\-expression\(dq: \(dqexpression\(dq, \(dqreplace\-client\-id\(dq: false, \(dqignore\-iaid\(dq: false } }, ... ] } .EE .UNINDENT .UNINDENT .sp The flexible identifier library supports both DHCPv4 and DHCPv6. .sp Let\(aqs consider a case of an IPv6 network that has an independent interface for each of its connected customers. Customers are able to plug in whatever device they want, so any type of identifier (e.g. a client\-id) is unreliable. Therefore, the operator may decide to use an option inserted by a relay agent to differentiate between clients. In this particular deployment, the operator has verified that the interface\-id is unique for each customer\-facing interface, so it is suitable for usage as a reservation. However, only the first six bytes of the interface\-id are interesting, because the remaining bytes are either randomly changed or not unique between devices. Therefore, the customer decides to use the first six bytes of the interface\-id option inserted by the relay agent. After adding \fBflex\-id\fP, the \fBhost\-reservation\-identifiers\fP goal can be achieved by using the following configuration: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqsubnet6\(dq: [{ # subnet definition starts here \(dqreservations\(dq: [{ \(dqflex\-id\(dq: \(dq\(aqport1234\(aq\(dq, # value of the first 8 bytes of the interface\-id \(dqip\-addresses\(dq: [ \(dq2001:db8::1\(dq ] }, ... ], ... }, ... ], # end of subnet definitions \(dqhost\-reservation\-identifiers\(dq: [\(dqduid\(dq, \(dqflex\-id\(dq], # add \(dqflex\-id\(dq to reservation identifiers \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dq/path/libdhcp_flex_id.so\(dq, \(dqparameters\(dq: { \(dqidentifier\-expression\(dq: \(dqsubstring(relay6[0].option[18].hex,0,8)\(dq } }, ... ], ... } .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Care should be taken when adjusting the expression. If the expression changes, then all the \fBflex\-id\fP values may change, possibly rendering all reservations based on \fBflex\-id\fP unusable until they are manually updated. It is strongly recommended that administrators start with the expression and a handful of reservations, and then adjust the expression as needed. Once the desired result is obtained with the expression, host reservations can be deployed on a broader scale. .UNINDENT .UNINDENT .sp \fBflex\-id\fP values in host reservations can be specified in two ways. First, they can be expressed as a hex string, e.g. the string \(dqbar\(dq can be represented as 626174. Alternatively, it can be expressed as a quoted value (using double and single quotes), e.g. \(dq\(aqbar\(aq\(dq. The former is more convenient for printable characters, while hex string values are more convenient for non\-printable characters and do not require the use of the \fBhexstring\fP operator. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqsubnet6\(dq: [{ # subnet definition starts here \(dqreservations\(dq: [{ \(dqflex\-id\(dq: \(dq01:02:03:04:05:06\(dq, # value of the first 8 bytes of the interface\-id \(dqip\-addresses\(dq: [ \(dq2001:db8::1\(dq ] }, ... ], ... }, ... ], # end of subnet definitions \(dqhost\-reservation\-identifiers\(dq: [\(dqduid\(dq, \(dqflex\-id\(dq], # add \(dqflex\-id\(dq to reservation identifiers \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dq/path/libdhcp_flex_id.so\(dq, \(dqparameters\(dq: { \(dqidentifier\-expression\(dq: \(dqvendor[4491].option[1026].hex\(dq } }, ... ], ... } .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 One less common scenario where the examples above may prove useful is for DHCPv6 clients that change their DUIDs between exchanges. Certain PXE clients are known to behave this way. .UNINDENT .UNINDENT .SS The \fBreplace\-client\-id\fP Flag .sp When \fBreplace\-client\-id\fP is set to \fBfalse\fP (which is the default setting), \fI\%libdhcp_flex_id.so\fP uses the evaluated flexible identifier solely for identifying host reservations, i.e. searching for reservations within a database. This is the functional equivalent of other identifiers, similar to hardware address or circuit\-id. However, this mode of operation implies that if a client device is replaced, it may cause a conflict between an existing lease (allocated to the old device) and the new lease being allocated to the new device. The conflict arises because the same flexible identifier is computed for the replaced device, so the server will try to allocate the same lease. The mismatch between client identifiers sent by the new device and the old device causes the server to refuse this new allocation until the old lease expires. A manifestation of this problem is dependent on the specific expression used as the flexible identifier, and is likely to appear if only options and other parameters are used that identify where the device is connected (e.g. circuit\-id), rather than the device identification itself (e.g. MAC address). .sp \fI\%libdhcp_flex_id.so\fP offers a way to overcome the problem with lease conflicts by dynamically replacing the client identifier (or DUID in DHCPv6) with a value derived from the flexible identifier. The server processes the client\(aqs query as if the flexible identifier were sent in the client identifier (or DUID) option. This guarantees that a returning client (for which the same flexible identifier is evaluated) will be assigned the same lease, despite the client identifier and/or MAC address change. .sp The following is a stub configuration that enables this behavior: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dq/path/libdhcp_flex_id.so\(dq, \(dqparameters\(dq: { \(dqidentifier\-expression\(dq: \(dqexpression\(dq, \(dqreplace\-client\-id\(dq: true } }, ... ] } .EE .UNINDENT .UNINDENT .sp In the DHCPv4 case, the value derived from the flexible identifier is formed by prepending one byte with a value of zero to the flexible identifier. In the DHCPv6 case, it is formed by prepending two zero bytes before the flexible identifier. .sp Note that for this mechanism to take effect, the DHCPv4 server must be configured to respect the client identifier option value during lease allocation, i.e. \fBmatch\-client\-id\fP must be set to \fBtrue\fP\&. See \fI\%Using Client Identifier and Hardware Address\fP for details. No additional settings are required for DHCPv6. .sp If the \fBreplace\-client\-id\fP option is set to \fBtrue\fP, the value of the \fBecho\-client\-id\fP parameter (which governs whether to send back a client\-id option) is ignored. .sp The \fI\%libdhcp_lease_cmds.so: Lease Commands for Easier Lease Management\fP section describes commands used to retrieve, update, and delete leases using various identifiers, such as \fBhw\-address\fP and \fBclient\-id\fP\&. \fI\%libdhcp_lease_cmds.so\fP does not natively support querying for leases by flexible identifier. However, when \fBreplace\-client\-id\fP is set to \fBtrue\fP, it makes it possible to query for leases using a value derived from the flexible identifier. In DHCPv4, the query looks similar to this: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqlease4\-get\(dq, \(dqarguments\(dq: { \(dqidentifier\-type\(dq: \(dqclient\-id\(dq, \(dqidentifier\(dq: \(dq00:54:64:45:66\(dq, \(dqsubnet\-id\(dq: 44 } } .EE .UNINDENT .UNINDENT .sp where the hexadecimal value of \(dq54:64:45:66\(dq is a flexible identifier computed for the client. .sp In DHCPv6, the corresponding query looks something like this: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqlease6\-get\(dq, \(dqarguments\(dq: { \(dqidentifier\-type\(dq: \(dqduid\(dq, \(dqidentifier\(dq: \(dq00:00:54:64:45:66\(dq, \(dqsubnet\-id\(dq: 10 } } .EE .UNINDENT .UNINDENT .SS The \fBignore\-iaid\fP Flag .sp When \fBignore\-iaid\fP is set to \fBtrue\fP (the default value is \fBfalse\fP), \fI\%libdhcp_flex_id.so\fP causes the Kea DHCPv6 server to ignore the IAID value from incoming IPv6 packets. This parameter is ignored by the Kea DHCPv4 server. .sp If the packet contains only one IA_NA, the IAID value will be changed to \fB0\fP and stored as such in the lease storage. Similarly, if the packet contains only one IA_PD, the IAID value will be changed to \fB0\fP and stored as such in the lease storage. The IAID is restored to its initial value in the response back to the client. The change is visible in the identifier expression if the IAID is part of the expression. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 To avoid lease conflicts, if the incoming packet contains more than one IA_NA, the IAID value is not changed on any of the IA_NAs. Similarly, if the incoming packet contains more than one IA_PD, the IAID value is not changed on any of the IA_PDs. .UNINDENT .UNINDENT .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 This functionality breaks RFC compliance and should be enabled only if required. When enabled, a warning message is issued at configure time. .UNINDENT .UNINDENT .SS \fBlibdhcp_flex_option.so\fP: Flexible Option Actions for Option Value Settings .sp This library allows administrators to define an action to take, for a given option, based upon on the result of an expression. These actions are carried out during the final stages of constructing a query response packet, just before it is sent to the client. The three actions currently supported are \fBadd\fP, \fBsupersede\fP, and \fBremove\fP\&. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 \fI\%libdhcp_flex_option.so\fP is part of the open source code and is available to every Kea user. .UNINDENT .UNINDENT .sp The syntax used for the action expressions is the same syntax used for client classification and the Flexible Identifier hook library; see either \fI\%Using Expressions in Classification\fP or \fI\%libdhcp_flex_id.so: Flexible Identifier for Host Reservations\fP for a detailed description of the syntax. .sp The \fBadd\fP and \fBsupersede\fP actions use an expression returning a string, and do nothing if the string is empty. The \fBremove\fP application uses an expression returning \fBtrue\fP or \fBfalse\fP, and does nothing on \fBfalse\fP\&. When it is necessary to set an option to the empty value this mechanism does not work, but a client class can be used instead. .sp The \fBadd\fP action adds an option only when the option does not already exist and the expression does not evaluate to the empty string. The \fBsupersede\fP action is similar, but it overwrites the option value if it already exists. The \fBremove\fP action removes the option from the response packet if it already exists and the expression evaluates to true. .sp The option to which an action applies may be specified by either its numeric code or its name; either the code or the name must be specified. The option space is DHCPv4 or DHCPv6, depending on the server where the hook library is loaded. .sp \fI\%libdhcp_flex_option.so\fP can be loaded by either the \fI\%kea\-dhcp4\fP or \fI\%kea\-dhcp6\fP process. It takes a mandatory \fBoptions\fP parameter with a list of per\-option parameter maps, with \fBcode\fP, \fBname\fP, \fBadd\fP, \fBsupersede\fP, and \fBremove\fP actions. Action entries take a string value representing an expression. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp4\(dq: { \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dq/usr/local/lib/libdhcp_flex_option.so\(dq, \(dqparameters\(dq: { \(dqoptions\(dq: [ { \(dqcode\(dq: 67, \(dqadd\(dq: \(dqifelse(option[host\-name].exists,concat(option[host\-name].text,\(aq.boot\(aq),\(aq\(aq)\(dq } ] } } ] } } .EE .UNINDENT .UNINDENT .sp If (and only if) the \fBquery\fP includes a \fBhost\-name\fP option (code 12), a \fBboot\-file\-name\fP option (code 67) is added to the response with the host name followed by \fB\&.boot\fP for content. .sp A commonly discussed use case is modifying the DHCPv4 subnet mask option (code 1). The following example demonstrates that capability, as all ingress packets identified by the gateway address 192.168.0.1 are met with a /32 subnet mask in the response: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp4\(dq: { \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dq/usr/local/lib/libdhcp_flex_option.so\(dq, \(dqparameters\(dq: { \(dqoptions\(dq: [ { \(dqcode\(dq: 1, \(dqsupersede\(dq: \(dqifelse(pkt4.giaddr==192.168.0.1, \(aq255.255.255.255\(aq, \(aq\(aq)\(dq } ] } } ] } } .EE .UNINDENT .UNINDENT .sp The Flexible Option library supports both DHCPv4 and DHCPv6. .sp The \fBadd\fP and \fBsupersede\fP actions take an optional \fBcsv\-format\fP boolean parameter. If not specified or set to \fBfalse\fP, the option data is set using the raw value of the evaluated expression. When it is configured to \fBtrue\fP, this value is parsed using the option definition from the option data specified in the configuration file. This eases option setting for options using complex record formats or fully qualified domain names. .sp For instance, if the expression evaluation returns \(dqexample.com\(dq and the option is defined with the \fBfqdn\fP type, the domain name is encoded into DNS binary format. .sp Since Kea 2.1.4, the \fBclient\-class\fP parameter specifies a class guard, and takes a client\-class name. If not empty, the client\(aqs packet needs to belong to tne specified class for this entry to be used. .sp It is also possible to have multiple entries for the same option, but each entry must have exactly one action. If the option is not defined in \fBdhcp4\fP for DHCPv4 or \fBdhcp6\fP for DHCPv6, the location of the option definition can be specified using its name, with the new \fBspace\fP parameter. .sp Since Kea 2.1.4, sub\-options are supported with a new entry, \fBsub\-options\fP, which replaces the action in the configuration of the container option, i.e. the option where sub\-options are located. .sp The \fBsub\-options\fP parameter takes a list of sub\-option entries, each containing: .INDENT 0.0 .IP \(bu 2 \fBcode\fP \- specifies the sub\-option code; either the \fBcode\fP or \fBname\fP must be specified. If both are given, they must match or the configuration is rejected at load time. .IP \(bu 2 \fBname\fP \- specifies the sub\-option name; either the \fBcode\fP or \fBname\fP must be specified. If both are given, they must match or the configuration is rejected at load time. .IP \(bu 2 \fBspace\fP \- specifies the space where the sub\-option can be defined. This parameter is optional, because it can be found in the container option definition. The configuration is rejected if no valid space name is available at load time. Note that vendor spaces are supported for the DHCPv4 \fBvivso\-suboptions\fP and for the DHCPv6 \fBvendor\-opts\fP, both pre\-defined (e.g. DoCSIS vendor id 4491) or custom. .IP \(bu 2 \fBadd\fP \- (action) adds a sub\-option only if it does not already exist and the expression does not evaluate to the empty string. .IP \(bu 2 \fBsupersede\fP \- (action) adds or overwrites a sub\-option if the expression does not evaluate to the empty string. .IP \(bu 2 \fBremove\fP \- (action) removes a sub\-option if it already exists and the expression evaluates to true. .IP \(bu 2 \fBcontainer\-add\fP \- a boolean value that specifies whether the container option should be created, if it does not exist in the \fBadd\fP and \fBsupersede\fP action. If not specified, it defaults to \fBtrue\fP\&. .IP \(bu 2 \fBcontainer\-remove\fP \- a boolean value that specifies whether the container option should be deleted, if it remains empty after the removal of a sub\-option by the \fBremove\fP action. If not specified, it defaults to \fBtrue\fP\&. .IP \(bu 2 \fBcsv\-format\fP \- a boolean value that specifies whether the raw value of the evaluated expression is used (false, default) or parsed using the sub\-option definition (true). .IP \(bu 2 \fBclient\-class\fP \- specifies whether the sub\-option entry must be skipped when the \fBquery\fP does not belong to the specified client class. Note that the similar parameter in the container option entry applies to the whole \fBsub\-options\fP list. .UNINDENT .sp For instance, this configuration adds a string sub\-option in the DHCPv4 \fBvendor\-encapsulated\-options\fP (code 43) option. This option encapsulates the \fBvendor\-encapsulated\-options\fP space. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp4\(dq: { \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dq/usr/local/lib/libdhcp_flex_option.so\(dq, \(dqparameters\(dq: { \(dqoptions\(dq: [ { \(dqcode\(dq: 43, \(dqsub\-options\(dq: [ { \(dqcode\(dq: 1, \(dqadd\(dq: \(dq\(aqfoobar\(aq\(dq } ] } ] } } ] } } .EE .UNINDENT .UNINDENT .SS \fBlibddns_gss_tsig.so\fP: Sign DNS Updates With GSS\-TSIG .sp This hook library allows the \fI\%kea\-dhcp\-ddns\fP server to use GSS\-TSIG to sign DNS updates. For a full discussion of GSS\-TSIG in Kea, please see \fI\%GSS\-TSIG\fP\&. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 \fI\%libddns_gss_tsig.so\fP is part of the open source code and is available to every Kea user. It was previously available only to ISC customers with a paid support contract. .UNINDENT .UNINDENT .SS \fBlibdhcp_ha.so\fP: High Availability Outage Resilience for Kea Servers .sp This hook library can be loaded on a pair of DHCPv4 or DHCPv6 servers, to increase the reliability of the DHCP service in the event of an outage on one server. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 \fI\%libdhcp_ha.so\fP is part of the open source code and is available to every Kea user. It was previously available only to ISC customers with a paid support contract. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 This library can only be loaded by the \fI\%kea\-dhcp4\fP or \fI\%kea\-dhcp6\fP process. .UNINDENT .UNINDENT .sp High Availability (HA) of the DHCP service is provided by running multiple cooperating server instances. If any of these instances becomes unavailable for any reason (DHCP software crash, Control Agent software crash, power outage, hardware failure), a surviving server instance can continue providing reliable service to clients. Many DHCP server implementations include the \(dqDHCP Failover\(dq protocol, whose most significant features are communication between the servers, partner failure detection, and lease synchronization between the servers. However, the DHCPv4 failover standardization process was never completed by the IETF. The DHCPv6 failover standard (RFC 8156) was published, but it is complex and difficult to use, has significant operational constraints, and is different from its v4 counterpart. Although it may be useful to use a \(dqstandard\(dq failover protocol, most Kea users are simply interested in a working solution which guarantees high availability of the DHCP service. Therefore, the Kea HA hook library derives major concepts from the DHCP failover protocol but uses its own solutions for communication and configuration. It offers its own state machine, which greatly simplifies its implementation and generally fits better into Kea, and it provides the same features in both DHCPv4 and DHCPv6. This document intentionally uses the term \(dqhigh availability\(dq rather than \(dqfailover\(dq to emphasize that it is not the failover protocol implementation. .sp The following sections describe the configuration and operation of the Kea HA hook library. .SS Supported Configurations .sp The Kea HA hook library supports three configurations, also known as HA modes: \fBload\-balancing\fP, \fBhot\-standby\fP, and \fBpassive\-backup\fP\&. In the \fBload\-balancing\fP mode, two servers respond to DHCP requests. The \fBload\-balancing\fP function is implemented as described in \X'tty: link https://tools.ietf.org/html/rfc3074'\fI\%RFC 3074\fP\X'tty: link', with each server responding to half the received DHCP queries. When one of the servers allocates a lease for a client, it notifies the partner server over the control channel (via the RESTful API), so the partner can save the lease information in its own database. If the communication with the partner is unsuccessful, the DHCP query is dropped and the response is not returned to the DHCP client. If the lease update is successful, the response is returned to the DHCP client by the server which has allocated the lease. By exchanging lease updates, both servers get a copy of all leases allocated by the entire HA setup, and either server can be switched to handle the entire DHCP traffic if its partner becomes unavailable. .sp In the \fBload\-balancing\fP configuration, one of the servers must be designated as \fBprimary\fP and the other as \fBsecondary\fP\&. Functionally, there is no difference between the two during normal operation. However, this distinction is required when the two servers are started at (nearly) the same time and have to synchronize their lease databases. The primary server synchronizes the database first. The secondary server waits for the primary server to complete the lease database synchronization before it starts the synchronization. .sp In the \fBhot\-standby\fP configuration, one of the servers is designated as \fBprimary\fP and the other as \fBstandby\fP\&. During normal operation, the primary server is the only one that responds to DHCP requests. The standby server receives lease updates from the primary over the control channel; however, it does not respond to any DHCP queries as long as the primary is running or, more accurately, until the standby considers the primary to be offline. If the standby server detects the failure of the primary, it starts responding to all DHCP queries. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Operators often wonder whether to use \fBload\-balancing\fP or \fBhot\-standby\fP mode. The \fBload\-balancing\fP mode has the benefit of splitting the DHCP load between two instances, reducing the traffic processed by each of them. However, it is not always clear to the operators that using the \fBload\-balancing\fP mode requires manually splitting the address pools between two Kea instances using client classification, to preclude both servers from allocating the same address to different clients. Such a split is not needed in the \fBhot\-standby\fP mode. Thus, the benefit of using \fBhot\-standby\fP over \fBload\-balancing\fP is that the former has a simpler configuration. Conversely, \fBload\-balancing\fP has higher performance potential at the cost of more complex configuration. See \fI\%Load\-Balancing Configuration\fP for details on how to split the pools using client classification. .UNINDENT .UNINDENT .sp In the configurations described above, both the primary and secondary/standby are referred to as \fBactive\fP servers, because they receive lease updates and can automatically react to the partner\(aqs failures by responding to the DHCP queries which would normally be handled by the partner. The HA hook library supports another server type/role: \fBbackup\fP\&. The use of a backup server is optional, and can be implemented in both \fBload\-balancing\fP and \fBhot\-standby\fP setup, in addition to the active servers. There is no limit on the number of backup servers in the HA setup; however, the presence of backup servers may increase the latency of DHCP responses, because not only do active servers send lease updates to each other, but also to the backup servers. The active servers do not expect acknowledgments from the backup servers before responding to the DHCP clients, so the overhead of sending lease updates to the backup servers is minimized. .sp In the last supported configuration, \fBpassive\-backup\fP, there is only one active server and typically one or more backup servers. A \fBpassive\-backup\fP configuration with no backup servers is also accepted, but it is no different than running a single server with no HA function at all. .sp The \fBpassive\-backup\fP configuration is used in situations when an administrator wants to take advantage of the backup server(s) as an additional storage for leases without running the full\-blown failover setup. In this case, if the primary server fails, the DHCP service is lost; it requires the administrator to manually restart the primary to resume DHCP service. The administrator may also configure one of the backup servers to provide DHCP service to the clients, as these servers should have accurate or nearly accurate information about the allocated leases. The major advantage of the \fBpassive\-backup\fP mode is that it provides some redundancy of the lease information but with better performance of the primary server responding to the DHCP queries. The primary server does not have to wait for acknowledgments to the lease updates from the backup servers before it sends a response to the DHCP client. This reduces the response time compared to the \fBload\-balancing\fP and \fBhot\-standby\fP cases, in which the server responding to the DHCP query has to wait for the acknowledgment from the other active server before it can respond to the client. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 An interesting use case for a single active server running in the \fBpassive\-backup\fP mode is a notification service, in which software pretending to be a backup server receives live notifications about allocated and deleted leases from the primary server and can display them on a monitoring screen, trigger alerts, etc. .UNINDENT .UNINDENT .SS Clocks on Active Servers .sp Synchronized clocks are essential for the HA setup to operate reliably. The servers share lease information \- via lease updates and during synchronization of the databases \- including the time when the lease was allocated and when it expires. Some clock skew between the servers participating in the HA setup usually exists; this is acceptable as long as the clock skew is relatively low, compared to the lease lifetimes. However, if the clock skew becomes too high, the different lease expiration times on different servers may cause the HA system to malfunction. For example, one server may consider a lease to be expired when it is actually still valid. The lease reclamation process may remove a name associated with this lease from the DNS, causing problems when the client later attempts to renew the lease. .sp Each active server monitors the clock skew by comparing its current time with the time returned by its partner in response to the \fI\%ha\-heartbeat\fP command. This gives a good approximation of the clock skew, although it does not take into account the time between the partner sending the response and the receipt of this response by the server which sent the \fI\%ha\-heartbeat\fP command. If the clock skew exceeds 30 seconds, a warning log message is issued. The administrator may correct this problem by synchronizing the clocks (e.g. using NTP); the servers should notice the clock skew correction and stop issuing the warning. .sp If the clock skew is not corrected and exceeds 60 seconds, the HA service on each of the servers is terminated, i.e. the state machine enters the \fBterminated\fP state. The servers will continue to respond to DHCP clients (as in the \fBload\-balancing\fP or \fBhot\-standby\fP mode), but will exchange neither lease updates nor heartbeats and their lease databases will diverge. In this case, the administrator should synchronize the clocks and restart the servers. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 It is possible to restart the servers one at a time, in no particular order. The clocks must be in sync before restarting the servers. A restarted server remains in the \fBwaiting\fP state until the partner is also restarted. If the partner is not restarted within 10 minutes, the restarted server transitions back to the \fBterminated\fP state to continue serving the DHCP clients. Restart both servers to resume the normal HA service. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The clock skew is only assessed between two active servers, and only the active servers enter the \fBterminated\fP state if the skew is too high. The clock skew between active and backup servers is not assessed, because active servers do not exchange heartbeat messages with backup servers. .UNINDENT .UNINDENT .SS HTTPS Support .sp Since Kea 1.9.7, the High Availability hook library supports HTTPS via TLS, as described in \fI\%TLS/HTTPS Support\fP\&. .sp The HTTPS configuration parameters are: .INDENT 0.0 .IP \(bu 2 \fBtrust\-anchor\fP \- specifies the name of a file or directory where the certification authority certificate of a Control Agent can be found. .IP \(bu 2 \fBcert\-file\fP \- specifies the name of the file containing the end\-entity certificate to use. .IP \(bu 2 \fBkey\-file\fP \- specifies the private key of the end\-entity certificate to use. .UNINDENT .sp These parameters can be configured at the global and peer levels. When configured at both levels the peer value is used, allowing common values to be shared. .sp The three parameters must be either all not specified (HTTPS disabled) or all specified (HTTPS enabled). Specification of the empty string is considered not specified; this can be used, for instance, to disable HTTPS for a particular peer when it is enabled at the global level. .sp As the High Availability hook library is an HTTPS client, there is no \fBcert\-required\fP parameter in this hook configuration. This parameter can be set in the Control Agent to require and verify a client certificate in client\-server communication. It does not affect communication between HA peers at the client side; see below for information on the server side. .sp Before Kea 2.1.7 using HTTPS in the HA setup required use of the Control Agent on all peers. (See \fI\%TLS/HTTPS Support\fP for Control Agent TLS configuration). .sp Since Kea 2.1.7 the HTTPS server side is supported: .INDENT 0.0 .IP \(bu 2 the peer entry for the server name is used for the TLS setting. .IP \(bu 2 the new \fBrequire\-client\-certs\fP parameter specifies whether client certificates are required and verified, i.e. like \fBcert\-required\fP\&. It defaults to \fBtrue\fP and is an HA config (vs. peer config) parameter. .UNINDENT .sp Kea 2.1.7 added a new security feature with the \fBrestrict\-commands\fP HA config parameter: when set to \fBtrue\fP, commands which are not used by the hook are rejected. The default is \fBtrue\fP since Kea 3.0.0. .sp The following is an example of an HA server pair and Control Agent configuration for \fBhot\-standby\fP with TLS. .sp Server 1: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp4\(dq: { \(dqhooks\-libraries\(dq: [{ \(dqlibrary\(dq: \(dq/usr/lib/kea/hooks/libdhcp_lease_cmds.so\(dq, \(dqparameters\(dq: { } }, { \(dqlibrary\(dq: \(dq/usr/lib/kea/hooks/libdhcp_ha.so\(dq, \(dqparameters\(dq: { \(dqhigh\-availability\(dq: [{ \(dqthis\-server\-name\(dq: \(dqserver1\(dq, \(dqtrust\-anchor\(dq: \(dq/usr/lib/kea/CA.pem\(dq, \(dqcert\-file\(dq: \(dq/usr/lib/kea/server1_cert.pem\(dq, \(dqkey\-file\(dq: \(dq/usr/lib/kea/server1_key.pem\(dq, \(dqmode\(dq: \(dqhot\-standby\(dq, \(dqheartbeat\-delay\(dq: 10000, \(dqmax\-response\-delay\(dq: 60000, \(dqmax\-ack\-delay\(dq: 5000, \(dqmax\-unacked\-clients\(dq: 5, \(dqpeers\(dq: [{ \(dqname\(dq: \(dqserver1\(dq, \(dqurl\(dq: \(dqhttp://192.168.56.33:8005/\(dq, \(dqrole\(dq: \(dqprimary\(dq, \(dqauto\-failover\(dq: true }, { \(dqname\(dq: \(dqserver2\(dq, \(dqurl\(dq: \(dqhttp://192.168.56.66:8005/\(dq, \(dqrole\(dq: \(dqstandby\(dq, \(dqauto\-failover\(dq: true }] }] } }], \(dqsubnet4\(dq: [{ \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq192.0.3.0/24\(dq, \(dqpools\(dq: [{ \(dqpool\(dq: \(dq192.0.3.100 \- 192.0.3.250\(dq }] }] } } .EE .UNINDENT .UNINDENT .sp Server 2: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp4\(dq: { \(dqhooks\-libraries\(dq: [{ \(dqlibrary\(dq: \(dq/usr/lib/kea/hooks/libdhcp_lease_cmds.so\(dq, \(dqparameters\(dq: { } }, { \(dqlibrary\(dq: \(dq/usr/lib/kea/hooks/libdhcp_ha.so\(dq, \(dqparameters\(dq: { \(dqhigh\-availability\(dq: [{ \(dqthis\-server\-name\(dq: \(dqserver2\(dq, \(dqtrust\-anchor\(dq: \(dq/usr/lib/kea/CA.pem\(dq, \(dqcert\-file\(dq: \(dq/usr/lib/kea/server2_cert.pem\(dq, \(dqkey\-file\(dq: \(dq/usr/lib/kea/server2_key.pem\(dq, \(dqmode\(dq: \(dqhot\-standby\(dq, \(dqheartbeat\-delay\(dq: 10000, \(dqmax\-response\-delay\(dq: 60000, \(dqmax\-ack\-delay\(dq: 5000, \(dqmax\-unacked\-clients\(dq: 5, \(dqpeers\(dq: [{ \(dqname\(dq: \(dqserver1\(dq, \(dqurl\(dq: \(dqhttp://192.168.56.33:8005/\(dq, \(dqrole\(dq: \(dqprimary\(dq, \(dqauto\-failover\(dq: true }, { \(dqname\(dq: \(dqserver2\(dq, \(dqurl\(dq: \(dqhttp://192.168.56.66:8005/\(dq, \(dqrole\(dq: \(dqstandby\(dq, \(dqauto\-failover\(dq: true }] }] } }], \(dqsubnet4\(dq: [{ \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq192.0.3.0/24\(dq, \(dqpools\(dq: [{ \(dqpool\(dq: \(dq192.0.3.100 \- 192.0.3.250\(dq }] }] } } .EE .UNINDENT .UNINDENT .sp Control Agent on Server 1: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqControl\-agent\(dq: { \(dqhttp\-host\(dq: \(dq192.168.56.33\(dq, \(dqhttp\-port\(dq: 8000, \(dqcontrol\-sockets\(dq: { \(dqdhcp4\(dq: { \(dqsocket\-type\(dq: \(dqunix\(dq, \(dqsocket\-name\(dq: \(dq/var/run/kea/control_socket\(dq } }, \(dqtrust\-anchor\(dq: \(dq/var/lib/kea/CA.pem\(dq, \(dqcert\-file\(dq: \(dq/var/lib/kea/server1_cert.pem\(dq, \(dqkey\-file\(dq: \(dq/var/lib/kea/server1_key.pem\(dq, \(dqcert\-required\(dq: true } } .EE .UNINDENT .UNINDENT .sp Control Agent on Server 2: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqControl\-agent\(dq: { \(dqhttp\-host\(dq: \(dq192.168.56.66\(dq, \(dqhttp\-port\(dq: 8000, \(dqcontrol\-sockets\(dq: { \(dqdhcp4\(dq: { \(dqsocket\-type\(dq: \(dqunix\(dq, \(dqsocket\-name\(dq: \(dq/var/run/kea/control_socket\(dq } }, \(dqtrust\-anchor\(dq: \(dq/var/lib/kea/CA.pem\(dq, \(dqcert\-file\(dq: \(dq/var/lib/kea/server2_cert.pem\(dq, \(dqkey\-file\(dq: \(dq/var/lib/kea/server2_key.pem\(dq, \(dqcert\-required\(dq: true } } .EE .UNINDENT .UNINDENT .SS Server States .sp A DHCP server operating within an HA setup runs a state machine, and the state of the server can be retrieved by its peers using the \fI\%ha\-heartbeat\fP command sent over the RESTful API. If the partner server does not respond to the \fI\%ha\-heartbeat\fP command within the specified amount of time, the communication is considered interrupted and the server may, depending on the configuration, use additional measures (described later in this document) to verify that the partner is still operating. If it finds that the partner is not operating, the server transitions to the \fBpartner\-down\fP state to handle all the DHCP traffic directed to the system. .sp In this case, the surviving server continues to send the \fI\%ha\-heartbeat\fP command to detect when the partner wakes up. At that time, the partner synchronizes the lease database. When it is again ready to operate, the surviving server returns to normal operation, i.e. the \fBload\-balancing\fP or \fBhot\-standby\fP state. .sp The following is the list of all possible server states: .INDENT 0.0 .IP \(bu 2 \fBbackup\fP \- normal operation of the backup server. In this state it receives lease updates from the active server(s). .IP \(bu 2 \fBcommunication\-recovery\fP \- an active server running in \fBload\-balancing\fP mode may transition to this state when it experiences communication issues with a partner server over the control channel. This is an intermediate state between the \fBload\-balancing\fP and \fBpartner\-down\fP states. In this state the server continues to respond to DHCP queries but does not send lease updates to the partner; lease updates are queued and are sent when normal communication is resumed. If communication does not resume within the time specified, the primary server then transitions to the \fBpartner\-down\fP state. The \fBcommunication\-recovery\fP state was introduced to ensure reliable DHCP service when both active servers remain operational but the communication between them is interrupted for a prolonged period of time. Either server can be configured to never enter this state by setting the \fBdelayed\-updates\-limit\fP to 0 (please refer to \fI\%Load\-Balancing Configuration\fP, later in this chapter, for details on this parameter). Disabling entry into the \fBcommunication\-recovery\fP state causes the server to begin testing for the \fBpartner\-down\fP state as soon as the server is unable to communicate with its partner. .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 In Kea 1.9.4, with the introduction of \fBdelayed\-updates\-limit\fP, the default server\(aqs behavior in \fBload\-balancing\fP mode changed. When a server experiences communication issues with its partner, it now enters the \fBcommunication\-recovery\fP state and queues lease updates until communication is resumed. Prior to Kea 1.9.4, a server that could not communicate with its partner in \fBload\-balancing\fP mode would immediately begin the transition to the \fBpartner\-down\fP state. .UNINDENT .UNINDENT .INDENT 0.0 .IP \(bu 2 \fBhot\-standby\fP \- normal operation of the active server running in the \fBhot\-standby\fP mode; both the primary and the standby server are in this state during their normal operation. The primary server responds to DHCP queries and sends lease updates to the standby server and to any backup servers that are present. .IP \(bu 2 \fBload\-balancing\fP \- normal operation of the active server running in the \fBload\-balancing\fP mode; both the primary and the secondary server are in this state during their normal operation. Both servers respond to DHCP queries and send lease updates to each other and to any backup servers that are present. .IP \(bu 2 \fBin\-maintenance\fP \- an active server transitions to this state as a result of being notified by its partner that the administrator requested maintenance of the HA setup. The administrator requests the maintenance by sending the \fI\%ha\-maintenance\-start\fP command to the server which is supposed to take over the responsibility for responding to the DHCP clients while the other server is taken offline for maintenance. If the server is in the \fBin\-maintenance\fP state it can be safely shut down. The partner transitions to the \fBpartner\-down\fP state immediately after discovering that the server in maintenance has been shut down. .IP \(bu 2 \fBpartner\-down\fP \- an active server transitions to this state after detecting that its partner (another active server) is offline. The server does not transition to this state if only a backup server is unavailable. In the \fBpartner\-down\fP state the active server responds to all DHCP queries, including those queries which are normally handled by the server that is now unavailable. .IP \(bu 2 \fBpartner\-in\-maintenance\fP \- an active server transitions to this state after receiving a \fI\%ha\-maintenance\-start\fP command from the administrator. The server in this state becomes responsible for responding to all DHCP requests. The server sends a \fI\%ha\-maintenance\-notify\fP command to the partner, which should enter the \fBin\-maintenance\fP state. The server remaining in the \fBpartner\-in\-maintenance\fP state keeps sending lease updates to the partner until it finds that the partner has stopped responding to those lease updates, heartbeats, or any other commands. In this case, the server in the \fBpartner\-in\-maintenance\fP state transitions to the \fBpartner\-down\fP state and keeps responding to the queries, but no longer sends lease updates. .IP \(bu 2 \fBpassive\-backup\fP \- a primary server running in the \fBpassive\-backup\fP HA mode transitions to this state immediately after it boots up. The primary server in this state responds to all DHCP traffic and sends lease updates to the backup servers it is connected to. By default, the primary server does not wait for acknowledgments from the backup servers and responds to a DHCP query right after sending lease updates to all backup servers. If any of the lease updates fail, a backup server misses the lease update but the DHCP client is still provisioned. This default configuration can be changed by setting the \fBwait\-backup\-ack\fP configuration parameter to \fBtrue\fP, in which case the primary server always waits for the acknowledgements and drops the DHCP query if sending any of the corresponding lease updates fails. This improves lease database consistency between the primary and the secondary. However, if a communication failure between the active server and any of the backups occurs, it effectively causes the failure of the DHCP service from the DHCP clients\(aq perspective. .IP \(bu 2 \fBready\fP \- an active server transitions to this state after synchronizing its lease database with an active partner. This state indicates to the partner (which may be in the \fBpartner\-down\fP state) that it should return to normal operation. If and when it does, the server in the \fBready\fP state also starts normal operation. .IP \(bu 2 \fBsyncing\fP \- an active server transitions to this state to fetch leases from the active partner and update the local lease database. When in this state, the server issues the \fI\%dhcp\-disable\fP command to disable the DHCP service of the partner from which the leases are fetched. The DHCP service is disabled for a maximum time of 60 seconds, after which it is automatically re\-enabled, in case the syncing partner was unable to re\-enable the service. If the synchronization completes successfully, the synchronizing server issues the \fI\%ha\-sync\-complete\-notify\fP command to notify the partner. In most states, the partner re\-enables its DHCP service to continue responding to the DHCP queries. In the \fBpartner\-down\fP state, the partner first ensures that communication between the servers is re\-established before enabling the DHCP service. The syncing operation is synchronous; the server waits for an answer from the partner and does nothing else while the lease synchronization takes place. A server that is configured not to synchronize the lease database with its partner, i.e. when the \fBsync\-leases\fP configuration parameter is set to \fBfalse\fP, will never transition to this state. Instead, it transitions directly from the \fBwaiting\fP state to the \fBready\fP state. .IP \(bu 2 \fBterminated\fP \- an active server transitions to this state when the High Availability hook library is unable to further provide reliable service and a manual intervention of the administrator is required to correct the problem. Various issues with the HA setup may cause the server to transition to this state. While in this state, the server continues responding to DHCP clients based on the HA mode selected (\fBload\-balancing\fP or \fBhot\-standby\fP), but lease updates are not exchanged and heartbeats are not sent. Once a server has entered the \fBterminated\fP state, it remains in this state until it is restarted. The administrator must correct the issue which caused this situation prior to restarting the server (e.g. synchronize the clocks); otherwise, the server will return to the \fBterminated\fP state once it finds that the issue persists. .IP \(bu 2 \fBwaiting\fP \- each started server instance enters this state. A backup server transitions directly from this state to the \fBbackup\fP state. An active server sends a heartbeat to its partner to check its state; if the partner appears to be unavailable, the server transitions to the \fBpartner\-down\fP state. If the partner is available, the server transitions to the \fBsyncing\fP or \fBready\fP state, depending on the setting of the \fBsync\-leases\fP configuration parameter. If both servers appear to be in the \fBwaiting\fP state (concurrent startup), the primary server transitions to the next state first. The secondary or standby server remains in the \fBwaiting\fP state until the primary transitions to the \fBready\fP state. .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Currently, restarting the HA service from the \fBterminated\fP state requires restarting the DHCP server or reloading its configuration. .UNINDENT .UNINDENT .sp Whether the server responds to DHCP queries and which queries it responds to is a matter of the server\(aqs state, if no administrative action is performed to configure the server otherwise. The following table provides the default behavior for various states. .sp The \fBDHCP Service Scopes\fP denote which group of received DHCP queries the server responds to in the given state. The HA configuration must specify a unique name for each server within the HA setup. This document uses the following convention within the provided examples: \(dqserver1\(dq for a primary server, \(dqserver2\(dq for the secondary or standby server, and \(dqserver3\(dq for the backup server. In real life any names can be used as long as they remain unique. .sp An in\-depth explanation of the scopes can be found below. .SS Default behavior of the server in various HA states .TS box center; l|l|l|l. T{ State T} T{ Server Type T} T{ DHCP Service T} T{ DHCP Service Scopes T} _ T{ backup T} T{ backup server T} T{ disabled T} T{ none T} _ T{ communication\-recovery T} T{ primary or secondary (load\-balancing mode only) T} T{ enabled T} T{ \(dqHA_server1\(dq or \(dqHA_server2\(dq T} _ T{ hot\-standby T} T{ primary or standby (hot\-standby mode) T} T{ enabled T} T{ \(dqHA_server1\(dq if primary, none otherwise T} _ T{ load\-balancing T} T{ primary or secondary (load\-balancing mode) T} T{ enabled T} T{ \(dqHA_server1\(dq or \(dqHA_server2\(dq T} _ T{ in\-maintenance T} T{ active server T} T{ disabled T} T{ none T} _ T{ partner\-down T} T{ active server T} T{ enabled T} T{ all scopes T} _ T{ partner\-in\-maintenance T} T{ active server T} T{ enabled T} T{ all scopes T} _ T{ passive\-backup T} T{ active server T} T{ enabled T} T{ all scopes T} _ T{ ready T} T{ active server T} T{ disabled T} T{ none T} _ T{ syncing T} T{ active server T} T{ disabled T} T{ none T} _ T{ terminated T} T{ active server T} T{ enabled T} T{ same as in the load\-balancing or hot\-standby state T} _ T{ waiting T} T{ any server T} T{ disabled T} T{ none T} .TE .sp In the \fBload\-balancing\fP mode there are two scopes specified for the active servers: \(dqHA_server1\(dq and \(dqHA_server2\(dq. The DHCP queries load\-balanced to \fBserver1\fP belong to the \(dqHA_server1\(dq scope and the queries load\-balanced to \fBserver2\fP belong to the \(dqHA_server2\(dq scope. If either server is in the \fBpartner\-down\fP state, the active partner is responsible for serving both scopes. .sp In the \fBhot\-standby\fP mode, there is only one scope \- \(dqHA_server1\(dq \- because only \fBserver1\fP is responding to DHCP queries. If that server becomes unavailable, \fBserver2\fP becomes responsible for this scope. .sp The backup servers do not have their own scopes. In some cases they can be used to respond to queries belonging to the scopes of the active servers. Also, a backup server which is neither in the \fBpartner\-down\fP state nor in normal operation serves no scopes. .sp The scope names can be used to associate pools, subnets, and networks with certain servers, so that only these servers can allocate addresses or prefixes from those pools, subnets, or networks. This is done via the client classification mechanism (see \fI\%Load Balancing With Advanced Classification\fP for more details). .SS Scope Transition in a Partner\-Down Case .sp When one of the servers finds that its partner is unavailable, it starts serving clients from both its own scope and the scope of the unavailable partner. This is straightforward for new clients, i.e. those sending DHCPDISCOVER (DHCPv4) or Solicit (DHCPv6), because those requests are not sent to any particular server. The available server responds to all such queries when it is in the \fBpartner\-down\fP state. .sp When a client renews a lease, it sends its DHCPREQUEST (DHCPv4) or Renew (DHCPv6) message directly to the server which has allocated the lease being renewed. If this server is no longer available, the client will get no response. In that case, the client continues to use its lease and attempts to renew until the rebind timer (T2) elapses. The client then enters the rebinding phase, in which it sends a DHCPREQUEST (DHCPv4) or Rebind (DHCPv6) message to any available server. The surviving server receives the rebinding request and typically extends the lifetime of the lease. The client then continues to contact that new server to renew its lease as appropriate. .sp If and when the other server once again becomes available, both active servers will eventually transition to the \fBload\-balancing\fP or \fBhot\-standby\fP state, in which they will again be responsible for their own scopes. Some clients belonging to the scope of the restarted server will try to renew their leases via the surviving server, but this server will no longer respond to them; the client will eventually transition back to the correct server via the rebinding mechanism. .SS Load\-Balancing Configuration .sp The following is the configuration snippet to enable high availability on the primary server within the \fBload\-balancing\fP configuration. The same configuration should be applied on the secondary and backup servers, with the only difference that \fBthis\-server\-name\fP should be set to \(dqserver2\(dq and \(dqserver3\(dq on those servers, respectively. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Remember that \fBload\-balancing\fP mode requires the address pools and delegated prefix pools to be split between the active servers. During normal operation, the servers use non\-overlapping pools to avoid allocating the same lease to different clients by both instances. A server only uses the pool fragments owned by the partner when the partner is not running. See the notes in \fI\%Supported Configurations\fP highlighting differences between the \fBload\-balancing\fP and \fBhot\-standby\fP modes. The semantics of pool partitioning is explained further in this section. The \fI\%Load Balancing With Advanced Classification\fP section provides advanced pool\-partitioning examples. .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqhooks\-libraries\(dq: [{ \(dqlibrary\(dq: \(dq/usr/lib/kea/hooks/libdhcp_lease_cmds.so\(dq, \(dqparameters\(dq: { } }, { \(dqlibrary\(dq: \(dq/usr/lib/kea/hooks/libdhcp_ha.so\(dq, \(dqparameters\(dq: { \(dqhigh\-availability\(dq: [{ \(dqthis\-server\-name\(dq: \(dqserver1\(dq, \(dqmode\(dq: \(dqload\-balancing\(dq, \(dqheartbeat\-delay\(dq: 10000, \(dqmax\-response\-delay\(dq: 60000, \(dqmax\-ack\-delay\(dq: 5000, \(dqmax\-unacked\-clients\(dq: 5, \(dqmax\-rejected\-lease\-updates\(dq: 10, \(dqdelayed\-updates\-limit\(dq: 100, \(dqpeers\(dq: [{ \(dqname\(dq: \(dqserver1\(dq, \(dqurl\(dq: \(dqhttp://192.168.56.33:8005/\(dq, \(dqrole\(dq: \(dqprimary\(dq, \(dqauto\-failover\(dq: true }, { \(dqname\(dq: \(dqserver2\(dq, \(dqurl\(dq: \(dqhttp://192.168.56.66:8005/\(dq, \(dqrole\(dq: \(dqsecondary\(dq, \(dqauto\-failover\(dq: true }, { \(dqname\(dq: \(dqserver3\(dq, \(dqurl\(dq: \(dqhttp://192.168.56.99:8005/\(dq, \(dqrole\(dq: \(dqbackup\(dq, \(dqbasic\-auth\-user\(dq: \(dqfoo\(dq, \(dqbasic\-auth\-password\(dq: \(dq1234\(dq, \(dqauto\-failover\(dq: false }] }] } }], \(dqsubnet4\(dq: [{ \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq192.0.3.0/24\(dq, \(dqpools\(dq: [{ \(dqpool\(dq: \(dq192.0.3.100 \- 192.0.3.150\(dq, \(dqclient\-classes\(dq: [ \(dqHA_server1\(dq ] }, { \(dqpool\(dq: \(dq192.0.3.200 \- 192.0.3.250\(dq, \(dqclient\-classes\(dq: [ \(dqHA_server2\(dq ] }], \(dqoption\-data\(dq: [{ \(dqname\(dq: \(dqrouters\(dq, \(dqdata\(dq: \(dq192.0.3.1\(dq }], \(dqrelay\(dq: { \(dqip\-address\(dq: \(dq10.1.2.3\(dq } }] } .EE .UNINDENT .UNINDENT .sp Two hook libraries must be loaded to enable HA: \fI\%libdhcp_lease_cmds.so\fP and \fI\%libdhcp_ha.so\fP\&. The latter implements the HA feature, while the former enables control commands required by HA to fetch and manipulate leases on the remote servers. In the example provided above, it is assumed that Kea libraries are installed in the \fB/usr/lib\fP directory. If Kea is not installed in the \fB/usr\fP directory, the hook libraries\(aq locations must be updated accordingly. .sp The HA configuration is specified within the scope of \fI\%libdhcp_ha.so\fP\&. Note that while the top\-level parameter \fBhigh\-availability\fP is a list, only a single entry is currently supported. .sp The following are the global parameters which control the server\(aqs behavior with respect to HA: .INDENT 0.0 .IP \(bu 2 \fBthis\-server\-name\fP \- is a unique identifier of the server within this HA setup. It must match one of the servers specified within the \fBpeers\fP list. .IP \(bu 2 \fBmode\fP \- specifies an HA mode of operation. The currently supported modes are \fBload\-balancing\fP and \fBhot\-standby\fP\&. .IP \(bu 2 \fBheartbeat\-delay\fP \- specifies a duration in milliseconds between sending the last heartbeat (or other command sent to the partner) and the next heartbeat. Heartbeats are sent periodically to gather the status of the partner and to verify whether the partner is still operating. The default value of this parameter is 10000 ms. .IP \(bu 2 \fBmax\-response\-delay\fP \- specifies a duration in milliseconds since the last successful communication with the partner, after which the server assumes that communication with the partner is interrupted. This duration should be greater than the \fBheartbeat\-delay\fP; typically it should be a multiple of \fBheartbeat\-delay\fP\&. When the server detects that communication is interrupted, it may transition to the \fBpartner\-down\fP state (when \fBmax\-unacked\-clients\fP is 0) or trigger the failure\-detection procedure using the values of the two parameters below. The default value of this parameter is 60000 ms. .IP \(bu 2 \fBmax\-ack\-delay\fP \- is one of the parameters controlling partner failure\-detection. When communication with the partner is interrupted, the server examines the values of the \(dqsecs\(dq field (DHCPv4) or \(dqelapsed time\(dq option (DHCPv6), which denote how long the DHCP client has been trying to communicate with the DHCP server. This parameter specifies the maximum time in milliseconds for the client to try to communicate with the DHCP server, after which this server assumes that the client failed to communicate with the DHCP server (is unacknowledged or \(dqunacked\(dq). The default value of this parameter is 10000. .IP \(bu 2 \fBmax\-unacked\-clients\fP \- specifies how many \(dqunacked\(dq clients are allowed (see \fBmax\-ack\-delay\fP) before this server assumes that the partner is offline and transitions to the \fBpartner\-down\fP state. The special value of 0 is allowed for this parameter, which disables the failure\-detection mechanism. In this case, a server that cannot communicate with its partner over the control channel assumes that the partner server is down and transitions to the \fBpartner\-down\fP state immediately. The default value of this parameter is 10. .IP \(bu 2 \fBmax\-rejected\-lease\-updates\fP \- specifies how many lease updates for distinct clients can fail, due to a conflict between the lease and the partner configuration or state, before the server transitions to the \fBterminated\fP state. Conflict can be a sign of a misconfiguration; usually, a small number of conflicted leases are acceptable because they affect only a few devices. However, if the conflicts occur for many devices (e.g., an entire subnet), the HA service becomes unreliable and should be terminated, and the problem must be manually corrected by an administrator. It is up to the administrator to select the highest acceptable value of \fBmax\-rejected\-lease\-updates\fP\&. The default value is 10. The special value of 0 configures the server to never terminate the HA service due to lease conflicts. If the value is 1, the server transitions to the \fBterminated\fP state when the first conflict occurs. This parameter does not pertain to conflicting lease updates sent to the backup servers. .IP \(bu 2 \fBdelayed\-updates\-limit\fP \- specifies the maximum number of lease updates which can be queued while the server is in the \fBcommunication\-recovery\fP state. This parameter was introduced in Kea 1.9.4. The special value of 0 configures the server to never transition to the \fBcommunication\-recovery\fP state and the server behaves as in earlier Kea versions, i.e. if the server cannot reach its partner, it goes straight into the \fBpartner\-down\fP state. The default value of this parameter is 100. .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The \fBmax\-rejected\-lease\-updates\fP parameter was introduced in Kea 2.3.1. Previously, the server did not differentiate between a lease update failure due to a non\-functioning partner and a failure due to a conflict (e.g., configuration issues). As a result, the server could sometimes transition to the \fBpartner\-down\fP state even though the partner was operating normally, but only certain leases had issues. Conflicts should no longer cause such a transition. However, depending on the \fBmax\-rejected\-lease\-updates\fP setting, too many conflicts can lead to termination of the High Availability service. In that case, both servers continue to respond to DHCP queries but no longer send lease updates. .UNINDENT .UNINDENT .sp The values of \fBmax\-ack\-delay\fP and \fBmax\-unacked\-clients\fP must be selected carefully, taking into account the specifics of the network in which the DHCP servers are operating. The server in question may not respond to some DHCP clients following administrative policy, or the server may drop malformed queries from clients. Therefore, selecting too low a value for the \fBmax\-unacked\-clients\fP parameter may result in a transition to the \fBpartner\-down\fP state even though the partner is still operating. On the other hand, selecting too high a value may result in never transitioning to the \fBpartner\-down\fP state if the DHCP traffic in the network is very low (e.g. at night), because the number of distinct clients trying to communicate with the server could be lower than the \fBmax\-unacked\-clients\fP setting. .sp In some cases it may be useful to disable the failure\-detection mechanism altogether, if the servers are located very close to each other and network partitioning is unlikely, i.e. failure to respond to heartbeats is only possible when the partner is offline. In such cases, set \fBmax\-unacked\-clients\fP to 0. .sp The \fBdelayed\-updates\-limit\fP parameter is used to enable or disable the \fBcommunication\-recovery\fP procedure, and controls the server\(aqs behavior in the \fBcommunication\-recovery\fP state. This parameter can only be used in the \fBload\-balancing\fP mode. .sp If a server in the \fBload\-balancing\fP state experiences communication issues with its partner (a heartbeat or lease\-update failure), the server transitions to the \fBcommunication\-recovery\fP state. In this state, the server keeps responding to DHCP queries but does not send lease updates to the partner. The lease updates are queued until communication is re\-established, to ensure that DHCP service remains available even in the event of the communication loss between the partners. There may appear to be communication loss when either one of the servers has terminated, or when both servers remain available but cannot communicate with each other. In the former case, the surviving server will follow the normal procedure and should eventually transition to the \fBpartner\-down\fP state. In the latter case, both servers should transition to the \fBcommunication\-recovery\fP state and should never transition to the \fBpartner\-down\fP state (if \fBmax\-unacked\-clients\fP is set to a non\-zero value), because all DHCP queries are answered and neither server would see any unacked DHCP queries. .sp Introduction of the \fBcommunication\-recovery\fP procedure was motivated by issues which may appear when two servers remain online but the communication between them remains interrupted for a period of time. In earlier Kea versions, the servers having communication issues used to drop DHCP packets before transitioning to the \fBpartner\-down\fP state. In some cases they both transitioned to the \fBpartner\-down\fP state, which could potentially result in allocations of the same IP addresses or delegated prefixes to different clients by both servers. By entering the intermediate \fBcommunication\-recovery\fP state, these problems are avoided. .sp If a server in the \fBcommunication\-recovery\fP state re\-establishes communication with its partner, it tries to send the partner all of the outstanding lease updates it has queued. This is done synchronously and may take a considerable amount of time before the server transitions to the \fBload\-balancing\fP state and resumes normal operation. The maximum number of lease updates which can be queued in the \fBcommunication\-recovery\fP state is controlled by \fBdelayed\-updates\-limit\fP\&. If the limit is exceeded, the server stops queuing lease updates and performs a full database synchronization after re\-establishing the connection with the partner, instead of sending outstanding lease updates before transitioning to the \fBload\-balancing\fP state. Even if the limit is exceeded, the server in the \fBcommunication\-recovery\fP state remains responsive to DHCP clients. .sp It may be preferable to set higher values of \fBdelayed\-updates\-limit\fP when there is a risk of prolonged communication interruption between the servers and when the lease database is large, to avoid costly lease\-database synchronization. On the other hand, if the lease database is small, the time required to send outstanding lease updates may be longer than the lease\-database synchronization. In such cases it may be better to use a lower value, e.g. 10. The default value of 100 is a reasonable compromise and should work well in most deployments with moderate traffic. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 This parameter is new and values for it that work well in some environments may not work well in others. Feedback from users will help us build a better working set of recommendations. .UNINDENT .UNINDENT .sp The \fBpeers\fP parameter contains a list of servers within this HA setup. This configuration must contain at least one primary and one secondary server. It may also contain an unlimited number of backup servers. In this example, there is one backup server which receives lease updates from the active servers. .sp Since Kea version 1.9.0, basic HTTP authentication is available to protect the Kea control agent against local attackers. .sp These are the parameters specified for each of the peers within this list: .INDENT 0.0 .IP \(bu 2 \fBname\fP \- specifies a unique name for the server. .IP \(bu 2 \fBurl\fP \- specifies the URL to be used to contact this server over the control channel. Other servers use this URL to send control commands to that server. .IP \(bu 2 \fBbasic\-auth\-user\fP \- specifies the user ID for basic HTTP authentication. If not specified or specified as an empty string, no authentication header is added to HTTP transactions. It must not contain the colon (:) character. .IP \(bu 2 \fBbasic\-auth\-password\fP \- specifies the password for basic HTTP authentication. This parameter is ignored when the user ID is not specified or is empty. The password is optional; if not specified, an empty password is used. .IP \(bu 2 \fBbasic\-auth\-password\-file\fP \- is an alternative to \fBbasic\-auth\-password\fP: instead of presenting the password in the configuration file it is specified in the file indicated by this parameter. .IP \(bu 2 \fBrole\fP \- denotes the role of the server in the HA setup. The following roles are supported in the \fBload\-balancing\fP configuration: \fBprimary\fP, \fBsecondary\fP, and \fBbackup\fP\&. There must be exactly one primary and one secondary server in the \fBload\-balancing\fP setup. .IP \(bu 2 \fBauto\-failover\fP \- a boolean value which denotes whether a server detecting a partner\(aqs failure should automatically start serving the partner\(aqs clients. The default value of this parameter is \fBtrue\fP\&. .UNINDENT .sp In our example configuration above, both active servers can allocate leases from the subnet \(dq192.0.3.0/24\(dq. This subnet contains two address pools: \(dq192.0.3.100 \- 192.0.3.150\(dq and \(dq192.0.3.200 \- 192.0.3.250\(dq, which are associated with HA server scopes using client classification. When \fBserver1\fP processes a DHCP query, it uses the first pool for lease allocation. Conversely, when \fBserver2\fP processes a DHCP query it uses the second pool. If either of the servers is in the \fBpartner\-down\fP state, the other can serve leases from both pools; it selects the pool which is appropriate for the received query. In other words, if the query would normally be processed by \fBserver2\fP but this server is not available, \fBserver1\fP allocates the lease from the pool of \(dq192.0.3.200 \- 192.0.3.250\(dq. The Kea control agent in front of \fBserver3\fP requires basic HTTP authentication, and authorizes the user ID \(dqfoo\(dq with the password \(dq1234\(dq. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The \fBurl\fP schema can be \fBhttp\fP or \fBhttps\fP, but since Kea version 1.9.6 the \fBhttps\fP schema requires a TLS setup. The hostname part must be an IPv4 address or an IPv6 address between square brackets, e.g. \fBhttp://[2001:db8::1]:8080/\fP\&. Names are not accepted. .UNINDENT .UNINDENT .SS Load Balancing With Advanced Classification .sp In the previous section, we provided an example of a \fBload\-balancing\fP configuration with client classification limited to the \(dqHA_server1\(dq and \(dqHA_server2\(dq classes, which are dynamically assigned to the received DHCP queries. In many cases, HA is needed in deployments which already use some other client classification. .sp Suppose there is a system which classifies devices into two groups: \(dqphones\(dq and \(dqlaptops\(dq, based on some classification criteria specified in the Kea configuration file. Both types of devices are allocated leases from different address pools. Introducing HA in \fBload\-balancing\fP mode results in a further split of each of those pools, as each server allocates leases for some phones and some laptops. This requires each of the existing pools to be split between \(dqHA_server1\(dq and \(dqHA_server2\(dq, so we end up with the following classes: .INDENT 0.0 .IP \(bu 2 \(dqphones_server1\(dq .IP \(bu 2 \(dqlaptops_server1\(dq .IP \(bu 2 \(dqphones_server2\(dq .IP \(bu 2 \(dqlaptops_server2\(dq .UNINDENT .sp The corresponding server configuration, using advanced classification (and the \fBmember\fP expression), is provided below. For brevity\(aqs sake, the HA hook library configuration has been removed from this example. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp4\(dq: { \(dqclient\-classes\(dq: [{ \(dqname\(dq: \(dqphones\(dq, \(dqtest\(dq: \(dqsubstring(option[60].hex,0,6) == \(aqAastra\(aq\(dq }, { \(dqname\(dq: \(dqlaptops\(dq, \(dqtest\(dq: \(dqnot member(\(aqphones\(aq)\(dq }, { \(dqname\(dq: \(dqphones_server1\(dq, \(dqtest\(dq: \(dqmember(\(aqphones\(aq) and member(\(aqHA_server1\(aq)\(dq }, { \(dqname\(dq: \(dqphones_server2\(dq, \(dqtest\(dq: \(dqmember(\(aqphones\(aq) and member(\(aqHA_server2\(aq)\(dq }, { \(dqname\(dq: \(dqlaptops_server1\(dq, \(dqtest\(dq: \(dqmember(\(aqlaptops\(aq) and member(\(aqHA_server1\(aq)\(dq }, { \(dqname\(dq: \(dqlaptops_server2\(dq, \(dqtest\(dq: \(dqmember(\(aqlaptops\(aq) and member(\(aqHA_server2\(aq)\(dq }], \(dqhooks\-libraries\(dq: [{ \(dqlibrary\(dq: \(dq/usr/lib/kea/hooks/libdhcp_lease_cmds.so\(dq, \(dqparameters\(dq: { } }, { \(dqlibrary\(dq: \(dq/usr/lib/kea/hooks/libdhcp_ha.so\(dq, \(dqparameters\(dq: { \(dqhigh\-availability\(dq: [{ }] } }], \(dqsubnet4\(dq: [{ \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq192.0.3.0/24\(dq, \(dqpools\(dq: [{ \(dqpool\(dq: \(dq192.0.3.100 \- 192.0.3.125\(dq, \(dqclient\-classes\(dq: [ \(dqphones_server1\(dq ] }, { \(dqpool\(dq: \(dq192.0.3.126 \- 192.0.3.150\(dq, \(dqclient\-classes\(dq: [ \(dqlaptops_server1\(dq ] }, { \(dqpool\(dq: \(dq192.0.3.200 \- 192.0.3.225\(dq, \(dqclient\-classes\(dq: [ \(dqphones_server2\(dq ] }, { \(dqpool\(dq: \(dq192.0.3.226 \- 192.0.3.250\(dq, \(dqclient\-classes\(dq: [ \(dqlaptops_server2\(dq ] }], \(dqoption\-data\(dq: [{ \(dqname\(dq: \(dqrouters\(dq, \(dqdata\(dq: \(dq192.0.3.1\(dq }], \(dqrelay\(dq: { \(dqip\-address\(dq: \(dq10.1.2.3\(dq } }] } } .EE .UNINDENT .UNINDENT .sp The configuration provided above splits the address range into four pools: two pools dedicated to \(dqHA_server1\(dq and two to \(dqHA_server2\(dq. Each server can assign leases to both phones and laptops. Both groups of devices are assigned addresses from different pools. The \(dqHA_server1\(dq and \(dqHA_server2\(dq classes are built\-in (see \fI\%Built\-in Client Classes\fP) and do not need to be declared. They are assigned dynamically by the HA hook library as a result of the \fBload\-balancing\fP algorithm. \(dqphones_*\(dq and \(dqlaptop_*\(dq evaluate to \fBtrue\fP when the query belongs to a given combination of other classes, e.g. \(dqHA_server1\(dq and \(dqphones\(dq. The pool is selected accordingly as a result of such an evaluation. .sp Consult \fI\%Client Classification\fP for details on how to use the \fBmember\fP expression and class dependencies. .SS Hot\-Standby Configuration .sp The following is an example configuration of the primary server in a \fBhot\-standby\fP configuration: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqhooks\-libraries\(dq: [{ \(dqlibrary\(dq: \(dq/usr/lib/kea/hooks/libdhcp_lease_cmds.so\(dq, \(dqparameters\(dq: { } }, { \(dqlibrary\(dq: \(dq/usr/lib/kea/hooks/libdhcp_ha.so\(dq, \(dqparameters\(dq: { \(dqhigh\-availability\(dq: [{ \(dqthis\-server\-name\(dq: \(dqserver1\(dq, \(dqmode\(dq: \(dqhot\-standby\(dq, \(dqheartbeat\-delay\(dq: 10000, \(dqmax\-response\-delay\(dq: 60000, \(dqmax\-ack\-delay\(dq: 5000, \(dqmax\-unacked\-clients\(dq: 5, \(dqmax\-rejected\-lease\-updates\(dq: 10, \(dqpeers\(dq: [{ \(dqname\(dq: \(dqserver1\(dq, \(dqurl\(dq: \(dqhttp://192.168.56.33:8005/\(dq, \(dqrole\(dq: \(dqprimary\(dq, \(dqauto\-failover\(dq: true }, { \(dqname\(dq: \(dqserver2\(dq, \(dqurl\(dq: \(dqhttp://192.168.56.66:8005/\(dq, \(dqrole\(dq: \(dqstandby\(dq, \(dqauto\-failover\(dq: true }, { \(dqname\(dq: \(dqserver3\(dq, \(dqurl\(dq: \(dqhttp://192.168.56.99:8005/\(dq, \(dqbasic\-auth\-user\(dq: \(dqfoo\(dq, \(dqbasic\-auth\-password\(dq: \(dq1234\(dq, \(dqrole\(dq: \(dqbackup\(dq, \(dqauto\-failover\(dq: false }] }] } }], \(dqsubnet4\(dq: [{ \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq192.0.3.0/24\(dq, \(dqpools\(dq: [{ \(dqpool\(dq: \(dq192.0.3.100 \- 192.0.3.250\(dq, \(dqclient\-classes\(dq: [ \(dqHA_server1\(dq ] }], \(dqoption\-data\(dq: [{ \(dqname\(dq: \(dqrouters\(dq, \(dqdata\(dq: \(dq192.0.3.1\(dq }], \(dqrelay\(dq: { \(dqip\-address\(dq: \(dq10.1.2.3\(dq } }] } .EE .UNINDENT .UNINDENT .sp This configuration is very similar to the \fBload\-balancing\fP configuration described in \fI\%Load\-Balancing Configuration\fP, with a few notable differences. .sp The \fBmode\fP is now set to \fBhot\-standby\fP, in which only one server responds to DHCP clients. If the primary server is online, it responds to all DHCP queries. The \fBstandby\fP server takes over all DHCP traffic only if it discovers that the primary is unavailable. .sp In this mode, the non\-primary active server is called \fBstandby\fP and that is its role. .sp Finally, because there is always only one server responding to DHCP queries, there is only one scope \- \(dqHA_server1\(dq \- in use within pool definitions. In fact, the \fBclient\-class\fP parameter could be removed from this configuration without harm, because there can be no conflicts in lease allocations by different servers as they do not allocate leases concurrently. The \fBclient\-class\fP remains in this example mostly for demonstration purposes, to highlight the differences between the \fBhot\-standby\fP and \fBload\-balancing\fP modes of operation. .SS Passive\-Backup Configuration .sp The following is an example configuration file for the primary server in a \fBpassive\-backup\fP configuration: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp4\(dq: { \(dqhooks\-libraries\(dq: [{ \(dqlibrary\(dq: \(dq/usr/lib/kea/hooks/libdhcp_lease_cmds.so\(dq, \(dqparameters\(dq: { } }, { \(dqlibrary\(dq: \(dq/usr/lib/kea/hooks/libdhcp_ha.so\(dq, \(dqparameters\(dq: { \(dqhigh\-availability\(dq: [{ \(dqthis\-server\-name\(dq: \(dqserver1\(dq, \(dqmode\(dq: \(dqpassive\-backup\(dq, \(dqwait\-backup\-ack\(dq: false, \(dqpeers\(dq: [{ \(dqname\(dq: \(dqserver1\(dq, \(dqurl\(dq: \(dqhttp://192.168.56.33:8005/\(dq, \(dqrole\(dq: \(dqprimary\(dq }, { \(dqname\(dq: \(dqserver2\(dq, \(dqurl\(dq: \(dqhttp://192.168.56.66:8005/\(dq, \(dqrole\(dq: \(dqbackup\(dq }, { \(dqname\(dq: \(dqserver3\(dq, \(dqurl\(dq: \(dqhttp://192.168.56.99:8005/\(dq, \(dqbasic\-auth\-user\(dq: \(dqfoo\(dq, \(dqbasic\-auth\-password\(dq: \(dq1234\(dq, \(dqrole\(dq: \(dqbackup\(dq }] }] } }], \(dqsubnet4\(dq: [{ \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq192.0.3.0/24\(dq, \(dqpools\(dq: [{ \(dqpool\(dq: \(dq192.0.3.100 \- 192.0.3.250\(dq }], \(dqoption\-data\(dq: [{ \(dqname\(dq: \(dqrouters\(dq, \(dqdata\(dq: \(dq192.0.3.1\(dq }], \(dqrelay\(dq: { \(dqip\-address\(dq: \(dq10.1.2.3\(dq } }] } } .EE .UNINDENT .UNINDENT .sp The configurations of three peers are included: one for the primary and two for the backup servers. .sp Many of the parameters present in the \fBload\-balancing\fP and \fBhot\-standby\fP configuration examples are not relevant in the \fBpassive\-backup\fP mode, thus they are not specified here. For example: \fBheartbeat\-delay\fP, \fBmax\-unacked\-clients\fP, \fBmax\-rejected\-lease\-updates\fP, and others related to the failover mechanism should not be specified in the \fBpassive\-backup\fP mode. .sp The \fBwait\-backup\-ack\fP is a boolean parameter not present in previous examples. It defaults to \fBfalse\fP and must not be modified in the \fBload\-balancing\fP and \fBhot\-standby\fP modes. In the \fBpassive\-backup\fP mode this parameter can be set to \fBtrue\fP, which causes the primary server to expect acknowledgments to the lease updates from the backup servers prior to responding to the DHCP client. It ensures that the lease has propagated to all servers before the client is given the lease, but it poses a risk of losing a DHCP service if there is a communication problem with one of the backup servers. This setting also increases the latency of the DHCP response, because of the time that the primary spends waiting for the acknowledgements. We recommend that the \fBwait\-backup\-ack\fP setting be left at its default value (\fBfalse\fP) if the DHCP service reliability is more important than consistency of the lease information between the primary and the backups, and in all cases when the DHCP service latency should be minimal. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Currently, active servers place lease updates to be sent to peers onto internal queues (one queue per peer/URL). In \fBpassive\-backup\fP mode, active servers do not wait for lease updates to be acknowledged; thus during times of heavy client traffic it is possible for the number of lease updates queued for transmission to accumulate faster than they can be delivered. As client traffic lessens the queues begin to empty. Since Kea 2.0.0, active servers monitor the size of these queues and emit periodic warnings (see HTTP_CLIENT_QUEUE_SIZE_GROWING in \fI\%Kea Messages Manual\fP) if they perceive a queue as growing too quickly. The warnings cease once the queue size begins to shrink. These messages are intended as a bellwether and seeing them sporadically during times of heavy traffic load does not necessarily indicate a problem. If, however, they occur continually during times of routine traffic load, they likely indicate potential mismatches in server capabilities and/or configuration; this should be investigated, as the size of the queues may eventually impair an active server\(aqs ability to respond to clients in a timely manner. .UNINDENT .UNINDENT .SS Lease Information Sharing .sp An HA\-enabled server informs its active partner about allocated or renewed leases by sending appropriate control commands, and the partner updates the lease information in its own database. When the server starts up for the first time or recovers after a failure, it synchronizes its lease database with its partner. These two mechanisms guarantee consistency of the lease information between the servers and allow the designation of one of the servers to handle the entire DHCP traffic load if the other server becomes unavailable. .sp In some cases, though, it is desirable to disable lease updates and/or database synchronization between the active servers, if the exchange of information about the allocated leases is performed using some other mechanism. Kea supports various database types that can be used to store leases, including MySQL and PostgreSQL. Those databases include built\-in solutions for data replication which are often used by Kea administrators to provide redundancy. .sp The HA hook library supports such scenarios by disabling lease updates over the control channel and/or lease\-database synchronization, leaving the server to rely on the database replication mechanism. This is controlled by the two boolean parameters \fBsend\-lease\-updates\fP and \fBsync\-leases\fP, whose values default to \fBtrue\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dq/usr/lib/kea/hooks/libdhcp_lease_cmds.so\(dq, \(dqparameters\(dq: { } }, { \(dqlibrary\(dq: \(dq/usr/lib/kea/hooks/libdhcp_ha.so\(dq, \(dqparameters\(dq: { \(dqhigh\-availability\(dq: [ { \(dqthis\-server\-name\(dq: \(dqserver1\(dq, \(dqmode\(dq: \(dqload\-balancing\(dq, \(dqsend\-lease\-updates\(dq: false, \(dqsync\-leases\(dq: false, \(dqpeers\(dq: [ { \(dqname\(dq: \(dqserver1\(dq, \(dqurl\(dq: \(dqhttp://192.168.56.33:8005/\(dq, \(dqrole\(dq: \(dqprimary\(dq }, { \(dqname\(dq: \(dqserver2\(dq, \(dqurl\(dq: \(dqhttp://192.168.56.66:8005/\(dq, \(dqrole\(dq: \(dqsecondary\(dq } ] } ] } } ], ... } .EE .UNINDENT .UNINDENT .sp In the most typical use case, both parameters are set to the same value, i.e. both are \fBfalse\fP if database replication is in use, or both are \fBtrue\fP otherwise. Introducing two separate parameters to control lease updates and lease\-database synchronization is aimed at possible special use cases; for example, when synchronization is performed by copying a lease file (therefore \fBsync\-leases\fP is set to \fBfalse\fP), but lease updates should be conducted as usual (\fBsend\-lease\-updates\fP is set to \fBtrue\fP). It should be noted that Kea does not natively support such use cases, but users may develop their own scripts and tools around Kea to provide such mechanisms. The HA hook library configuration is designed to maximize flexibility of administration. .SS Controlling Lease\-Page Size Limit .sp An HA\-enabled server initiates synchronization of the lease database after downtime or upon receiving the \fI\%ha\-sync\fP command. The server uses the commands \fI\%lease4\-get\-page\fP and \fI\%lease6\-get\-page\fP to fetch leases from its partner server (lease queries). The size of the results page (the maximum number of leases to be returned in a single response to one of these commands) can be controlled via configuration of the HA hook library. Increasing the page size decreases the number of lease queries sent to the partner server, but it causes the partner server to generate larger responses, which lengthens transmission time as well as increases memory and CPU utilization on both servers. Decreasing the page size helps to decrease resource utilization, but requires more lease queries to be issued to fetch the entire lease database. .sp The default value of the \fBsync\-page\-limit\fP command controlling the page size is 10000. This means that the entire lease database can be fetched with a single command if the size of the database is equal to or less than 10000 lines. .SS Timeouts .sp In deployments with a large number of clients connected to the network, lease\-database synchronization after a server failure may be a time\-consuming operation. The synchronizing server must gather all leases from its partner, which yields a large response over the RESTful interface. The server receives leases using the paging mechanism described in \fI\%Controlling Lease\-Page Size Limit\fP\&. Before the page of leases is fetched, the synchronizing server sends a \fI\%dhcp\-disable\fP command to disable the DHCP service on the partner server. If the service is already disabled, this command resets the timeout for the DHCP service being disabled, which by default is set to 60 seconds. If fetching a single page of leases takes longer than the specified time, the partner server assumes that the synchronizing server has died and resumes its DHCP service. The connection of the synchronizing server with its partner is also protected by the timeout. If the synchronization of a single page of leases takes longer than the specified time, the synchronizing server terminates the connection and the synchronization fails. Both timeout values are controlled by a single configuration parameter, \fBsync\-timeout\fP\&. The following configuration snippet demonstrates how to modify the timeout for automatic re\-enabling of the DHCP service on the partner server and how to increase the timeout for fetching a single page of leases from 60 seconds to 90 seconds: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dq/usr/lib/kea/hooks/libdhcp_lease_cmds.so\(dq, \(dqparameters\(dq: { } }, { \(dqlibrary\(dq: \(dq/usr/lib/kea/hooks/libdhcp_ha.so\(dq, \(dqparameters\(dq: { \(dqhigh\-availability\(dq: [ { \(dqthis\-server\-name\(dq: \(dqserver1\(dq, \(dqmode\(dq: \(dqload\-balancing\(dq, \(dqsync\-timeout\(dq: 90000, \(dqpeers\(dq: [ { \(dqname\(dq: \(dqserver1\(dq, \(dqurl\(dq: \(dqhttp://192.168.56.33:8005/\(dq, \(dqrole\(dq: \(dqprimary\(dq }, { \(dqname\(dq: \(dqserver2\(dq, \(dqurl\(dq: \(dqhttp://192.168.56.66:8005/\(dq, \(dqrole\(dq: \(dqsecondary\(dq } ] } ] } } ], ... } .EE .UNINDENT .UNINDENT .sp It is important to note that extending this \fBsync\-timeout\fP value may sometimes be insufficient to prevent issues with timeouts during lease\-database synchronization. The control commands travel via the Control Agent, which also monitors incoming (with a synchronizing server) and outgoing (with a DHCP server) connections for timeouts. The DHCP server also monitors the connection from the Control Agent for timeouts. Those timeouts cannot currently be modified via configuration; extending these timeouts is only possible by modifying them in the Kea code and recompiling the server. The relevant constants are located in the Kea source at: \fBsrc/lib/config/timeouts.h\fP\&. .SS Pausing the HA State Machine .sp The \fBhigh\-availability\fP state machine includes many different states described in detail in \fI\%Server States\fP\&. The server enters each state when certain conditions are met, most often taking into account the partner server\(aqs state. In some states the server performs specific actions, e.g. synchronization of the lease database in the \fBsyncing\fP state, or responding to DHCP queries according to the configured mode of operation in the \fBload\-balancing\fP and \fBhot\-standby\fP states. .sp By default, transitions between the states are performed automatically and the server administrator has no direct control over when the transitions take place; in most cases, the administrator does not need such control. In some situations, however, the administrator may want to \(dqpause\(dq the HA state machine in a selected state to perform some additional administrative actions before the server transitions to the next state. .sp Consider a server failure which results in the loss of the entire lease database. Typically, the server rebuilds its lease database when it enters the \fBsyncing\fP state by querying the partner server for leases, but it is possible that the partner was also experiencing a failure and lacks lease information. In this case, it may be required to reconstruct lease databases on both servers from some external source, e.g. a backup server. If the lease database is to be reconstructed via the RESTful API, the servers should be started in the initial, i.e. \fBwaiting\fP, state and remain in this state while leases are being added. In particular, the servers should not attempt to synchronize their lease databases nor start serving DHCP clients. .sp The HA hook library provides configuration parameters and a command to control pausing and resuming the HA state machine. The following configuration causes the HA state machine to pause in the \fBwaiting\fP state after server startup. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dq/usr/lib/kea/hooks/libdhcp_lease_cmds.so\(dq, \(dqparameters\(dq: { } }, { \(dqlibrary\(dq: \(dq/usr/lib/kea/hooks/libdhcp_ha.so\(dq, \(dqparameters\(dq: { \(dqhigh\-availability\(dq: [ { \(dqthis\-server\-name\(dq: \(dqserver1\(dq, \(dqmode\(dq: \(dqload\-balancing\(dq, \(dqpeers\(dq: [ { \(dqname\(dq: \(dqserver1\(dq, \(dqurl\(dq: \(dqhttp://192.168.56.33:8005/\(dq, \(dqrole\(dq: \(dqprimary\(dq }, { \(dqname\(dq: \(dqserver2\(dq, \(dqurl\(dq: \(dqhttp://192.168.56.66:8005/\(dq, \(dqrole\(dq: \(dqsecondary\(dq } ], \(dqstate\-machine\(dq: { \(dqstates\(dq: [ { \(dqstate\(dq: \(dqwaiting\(dq, \(dqpause\(dq: \(dqonce\(dq } ] } } ] } } ], ... } .EE .UNINDENT .UNINDENT .sp The \fBpause\fP parameter value \fBonce\fP denotes that the state machine should be paused upon the first transition to the \fBwaiting\fP state; later transitions to this state will not cause the state machine to pause. Two other supported values of the \fBpause\fP parameter are \fBalways\fP and \fBnever\fP\&. The latter is the default value for each state, which instructs the server never to pause the state machine. .sp In order to \(dqunpause\(dq the state machine, the \fI\%ha\-continue\fP command must be sent to the paused server. This command does not take any arguments. See \fI\%Control Commands for High Availability\fP for details about commands specific to \fI\%libdhcp_ha.so\fP\&. .sp It is possible to configure the state machine to pause in more than one state. Consider the following configuration: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dq/usr/lib/kea/hooks/libdhcp_lease_cmds.so\(dq, \(dqparameters\(dq: { } }, { \(dqlibrary\(dq: \(dq/usr/lib/kea/hooks/libdhcp_ha.so\(dq, \(dqparameters\(dq: { \(dqhigh\-availability\(dq: [ { \(dqthis\-server\-name\(dq: \(dqserver1\(dq, \(dqmode\(dq: \(dqload\-balancing\(dq, \(dqpeers\(dq: [ { \(dqname\(dq: \(dqserver1\(dq, \(dqurl\(dq: \(dqhttp://192.168.56.33:8005/\(dq, \(dqrole\(dq: \(dqprimary\(dq }, { \(dqname\(dq: \(dqserver2\(dq, \(dqurl\(dq: \(dqhttp://192.168.56.66:8005/\(dq, \(dqrole\(dq: \(dqsecondary\(dq } ], \(dqstate\-machine\(dq: { \(dqstates\(dq: [ { \(dqstate\(dq: \(dqready\(dq, \(dqpause\(dq: \(dqalways\(dq }, { \(dqstate\(dq: \(dqpartner\-down\(dq, \(dqpause\(dq: \(dqonce\(dq } ] } } ] } } ], ... } .EE .UNINDENT .UNINDENT .sp This configuration instructs the server to pause the state machine every time it transitions to the \fBready\fP state and upon the first transition to the \fBpartner\-down\fP state. .sp Refer to \fI\%Server States\fP for a complete list of server states. The state machine can be paused in any of the supported states; however, it is not practical to pause in the \fBbackup\fP or \fBterminated\fP states because the server never transitions out of these states anyway. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 In the \fBsyncing\fP state the server is paused before it makes an attempt to synchronize the lease database with a partner. To pause the state machine after lease\-database synchronization, use the \fBready\fP state instead. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The state of the HA state machine depends on the state of the cooperating server. Therefore, pausing the state machine of one server may affect the operation of the partner server. For example: if the primary server is paused in the \fBwaiting\fP state, the partner server will also remain in the \fBwaiting\fP state until the state machine of the primary server is resumed and that server transitions to the \fBready\fP state. .UNINDENT .UNINDENT .SS Control Agent Configuration .sp The \fI\%The Kea Control Agent\fP describes in detail the Kea daemon, which provides a RESTful interface to control the Kea servers. The same functionality is used by the High Availability hook library to establish communication between the HA peers. Therefore, the HA library requires that the Control Agent (CA) be started for each DHCP instance within the HA setup. If the Control Agent is not started, the peers cannot communicate with a particular DHCP server (even if the DHCP server itself is online) and may eventually consider this server to be offline. .sp The following is an example configuration for the CA running on the same machine as the primary server. This configuration is valid for both the \fBload\-balancing\fP and the \fBhot\-standby\fP cases presented in previous sections. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqControl\-agent\(dq: { \(dqhttp\-host\(dq: \(dq192.168.56.33\(dq, // If enabling HA and multi\-threading, the 8000 port is used by the HA // hook library http listener. When using HA hook library with // multi\-threading to function, make sure the port used by dedicated // listener is different (e.g. 8001) than the one used by CA. Note // the commands should still be sent via CA. The dedicated listener // is specifically for HA updates only. \(dqhttp\-port\(dq: 8000, \(dqcontrol\-sockets\(dq: { \(dqdhcp4\(dq: { \(dqsocket\-type\(dq: \(dqunix\(dq, \(dqsocket\-name\(dq: \(dqkea\-dhcp4\-ctrl.sock\(dq }, \(dqdhcp6\(dq: { \(dqsocket\-type\(dq: \(dqunix\(dq, \(dqsocket\-name\(dq: \(dqkea\-dhcp6\-ctrl.sock\(dq } } } } .EE .UNINDENT .UNINDENT .sp Since Kea 1.9.0, basic HTTP authentication is supported. .SS Multi\-Threaded Configuration (HA+MT) .sp It is possible to configure HA to use direct multi\-threaded communication between peers. We refer to this mode as HA+MT. With HA+MT enabled, each peer runs its own dedicated, internal HTTP listener (i.e. server) which receives and responds to commands directly, thus eliminating the need for an agent to carry out the HA protocol between peers. In addition, both the listener and client components use multi\-threading to support multiple concurrent connections between peers. By eliminating the agent and executing multiple command exchanges in parallel, HA throughput between peers improves considerably over earlier versions of Kea in most situations. .sp The following parameters have been added to the HA configuration, to support HA+MT operation: .INDENT 0.0 .IP \(bu 2 \fBenable\-multi\-threading\fP \- enables or disables multi\-threading HA peer communication (HA+MT). Kea core multi\-threading must be enabled for HA+MT to operate. When \fBfalse\fP, the server relies on \fI\%kea\-ctrl\-agent\fP for communication with its peer, and uses single\-threaded HTTP client processing. The default is \fBtrue\fP\&. .IP \(bu 2 \fBhttp\-dedicated\-listener\fP \- enables or disables the creation of a dedicated, internal HTTP listener through which the server receives HA messages from its peers. The internal listener replaces the role of \fI\%kea\-ctrl\-agent\fP traffic, allowing peers to send their HA commands directly to each other. The listener listens on the peer\(aqs \fBurl\fP\&. When \fBfalse\fP, the server relies on \fI\%kea\-ctrl\-agent\fP\&. This parameter has been provided largely for flexibility and testing; running HA+MT without dedicated listeners enabled will substantially limit HA throughput. The default is \fBtrue\fP\&. .IP \(bu 2 \fBhttp\-listener\-threads\fP \- indicates the maximum number of threads the dedicated listener should use. A value of \fB0\fP instructs the server to use the same number of threads that the Kea core is using for DHCP multi\-threading. The default is \fB0\fP\&. .IP \(bu 2 \fBhttp\-client\-threads\fP \- indicates the maximum number of threads that should be used to send HA messages to its peers. A value of \fB0\fP instructs the server to use the same number of threads that the Kea core is using for DHCP multi\-threading. The default is \fB0\fP\&. .UNINDENT .sp These parameters are grouped together under a map element, \fBmulti\-threading\fP, as illustrated below: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dq/usr/lib/kea/hooks/libdhcp_lease_cmds.so\(dq, \(dqparameters\(dq: { } }, { \(dqlibrary\(dq: \(dq/usr/lib/kea/hooks/libdhcp_ha.so\(dq, \(dqparameters\(dq: { \(dqhigh\-availability\(dq: [ { \(dqthis\-server\-name\(dq: \(dqserver1\(dq, \(dqmulti\-threading\(dq: { \(dqenable\-multi\-threading\(dq: true, \(dqhttp\-dedicated\-listener\(dq: true, \(dqhttp\-listener\-threads\(dq: 4, \(dqhttp\-client\-threads\(dq: 4 }, \(dqpeers\(dq: [ // This is the configuration of this server instance. { \(dqname\(dq: \(dqserver1\(dq, // This specifies the URL of our server instance. // Since the HA+MT uses a direct connection, the // DHCPv4 server open its own socket. Note that it // must be different than the one used by the CA // (typically 8000). In this example, 8005 is used. \(dqurl\(dq: \(dqhttp://192.0.2.1:8005/\(dq, // This server is primary. The other one must be // secondary. \(dqrole\(dq: \(dqprimary\(dq }, // This is the configuration of our HA peer. { \(dqname\(dq: \(dqserver2\(dq, // This specifies the URL of our server instance. // Since the HA+MT uses a direct connection, the // DHCPv4 server open its own socket. Note that it // must be different than the one used by the CA // (typically 8000). In this example, 8005 is used. \(dqurl\(dq: \(dqhttp://192.0.2.2:8005/\(dq, // The partner is a secondary. This server is a // primary as specified in the previous \(dqpeers\(dq // entry and in \(dqthis\-server\-name\(dq before that. \(dqrole\(dq: \(dqsecondary\(dq }, ... ], ... }, ... ] } }, ... ], ... } .EE .UNINDENT .UNINDENT .sp In the example above, HA+MT is enabled with four threads for the listener and four threads for the client. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 It is essential to configure the ports correctly. One common mistake is to configure CA to listen on port 8000 and also configure dedicated listeners on port 8000. In such a configuration, the communication will still work over CA, but it will be slow and the DHCP server will fail to bind sockets. Administrators should ensure that dedicated listeners use a different port (8001 is a suggested alternative); if ports are misconfigured or the ports dedicated to CA are used, the performance bottlenecks caused by the single\-threaded nature of CA and the sequential nature of the UNIX socket that connects CA to DHCP servers will nullify any performance gains offered by HA+MT. .UNINDENT .UNINDENT .SS Parked\-Packet Limit .sp Refer to \fI\%Parked\-Packet Limit\fP for a basic introduction to packet parking. .sp The HA hook library uses this mechanism. When an HA server needs to send a lease update to its peers to notify them of the change to the lease, it parks the client response until the peers acknowledge the lease update. At that point, the server unparks the response and sends it to the client. This applies to client queries that cause lease changes, such as DHCPREQUEST for DHCPv4 and Request, Renew, and Rebind for DHCPv6. It does not apply to DHCPDISCOVERs (v4) or Solicits (v6). .SS Controlled Shutdown and Maintenance of DHCP Servers .sp Having a pair of servers providing High Availability allows for controlled shutdown and maintenance of those servers without disrupting the DHCP service. For example, an administrator can perform an upgrade of one of the servers while the other one continues to respond to DHCP queries. When the first server is upgraded and back online, the upgrade can be performed for the second server. .sp A typical problem reported with early versions of the High Availability hook library was that the administrator did not have direct control over the state of the DHCP server. Shutting down one of the servers for maintenance did not necessarily cause the other server to start responding to all DHCP queries, because the failure\-detection algorithm described in \fI\%Scope Transition in a Partner\-Down Case\fP requires that the partner not respond for a configured period of time and, depending on the configuration, may also require that a number of DHCP requests not be responded to for a specified period of time. The maintenance procedure, however, requires that the administrator be able to instruct one of the servers to instantly start serving all DHCP clients, and the other server to instantly stop serving any DHCP clients, so it can be safely shut down. .sp The maintenance feature of the High Availability hook library addresses this situation. The \fI\%ha\-maintenance\-start\fP command allows the administrator to put the pairs of the active servers into a state in which one of them is responding to all DHCP queries and the other one is awaiting shutdown. .sp Suppose that the HA setup includes two active servers, \fBserver1\fP and \fBserver2\fP, and the latter needs to be shut down for maintenance. The administrator can send the \fI\%ha\-maintenance\-start\fP command to \fBserver1\fP, as this is the server which is going to handle the DHCP traffic while the other one is offline. \fBserver1\fP responds with an error if its state or the partner\(aqs state does not allow for a maintenance shutdown: for example, if maintenance is not supported for the backup server or if the server is in the \fBterminated\fP state. Also, an error is returned if the \fI\%ha\-maintenance\-start\fP request was already sent to the other server. .sp Upon receiving the \fI\%ha\-maintenance\-start\fP command, \fBserver1\fP sends the \fI\%ha\-maintenance\-notify\fP command to \fBserver2\fP to put it in the \fBin\-maintenance\fP state. If \fBserver2\fP confirms, \fBserver1\fP transitions to the \fBpartner\-in\-maintenance\fP state. This is similar to the \fBpartner\-down\fP state, except that in the \fBpartner\-in\-maintenance\fP state \fBserver1\fP continues to send lease updates to \fBserver2\fP until the administrator shuts down \fBserver2\fP\&. \fBserver1\fP now responds to all DHCP queries. .sp The administrator can now safely shut down \fBserver2\fP in the \fBin\-maintenance\fP state and perform any necessary maintenance actions. While \fBserver2\fP is offline, \fBserver1\fP will obviously not be able to communicate with its partner, so it will immediately transition to the \fBpartner\-down\fP state; it will continue to respond to all DHCP queries but will no longer send lease updates to \fBserver2\fP\&. Restarting \fBserver2\fP after the maintenance will trigger normal state negotiation, lease\-database synchronization, and, ultimately, a transition to the normal \fBload\-balancing\fP or \fBhot\-standby\fP state. Maintenance can then be performed on \fBserver1\fP, after sending the \fI\%ha\-maintenance\-start\fP command to \fBserver2\fP\&. .sp If the \fI\%ha\-maintenance\-start\fP command was sent to the server and the server has transitioned to the \fBpartner\-in\-maintenance\fP state, it is possible to transition both it and its partner back to their previous states to resume the normal operation of the HA pair. This is achieved by sending the \fI\%ha\-maintenance\-cancel\fP command to the server that is in the \fBpartner\-in\-maintenance\fP state. However, if the server has already transitioned to the \fBpartner\-down\fP state as a result of detecting that the partner is offline, canceling the maintenance is no longer possible. In that case, it is necessary to restart the other server and allow it to complete its normal state negotiation process. .sp If the server has many relationships with different partners, the \fBha\-maintenance\-start\fP command attempts to transition all of the relationships into the \fBpartner\-in\-maintenance\fP state by sending \fBha\-maintenance\-notify\fP to all partner servers. If this step fails for any server, an error is returned. If that happens, the \fBha\-maintenance\-cancel\fP command can be used to resume normal operations and fix the issue. .SS Control Commands for High Availability .sp Even though the HA hook library is designed to automatically resolve issues with DHCP service interruptions by redirecting the DHCP traffic to a surviving server and synchronizing the lease database as needed, it may be useful for the administrator to have more control over both servers\(aq behavior. In particular, it may be useful to be able to trigger lease\-database synchronization on demand, or to manually set the HA scopes that are being served. .sp The backup server can sometimes be used to handle DHCP traffic if both active servers are down. The backup server does not perform the failover function automatically; thus, in order to use the backup server to respond to DHCP queries, the server administrator must enable this function manually. .sp The following sections describe commands supported by the HA hook library which are available for the administrator. .SS The \fBha\-sync\fP Command .sp The \fI\%ha\-sync\fP command instructs the server to synchronize its local lease database with the selected peer. The server fetches all leases from the peer and updates any locally stored leases which are older than those fetched. It also creates new leases when any of those fetched do not exist in the local database. All leases that are not returned by the peer but are in the local database are preserved. The database synchronization is unidirectional; only the database on the server to which the command has been sent is updated. To synchronize the peer\(aqs database, a separate \fI\%ha\-sync\fP command must be issued to that peer. .sp Database synchronization may be triggered for both active and backup server types. The \fI\%ha\-sync\fP command has the following structure (in a DHCPv4 example): .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqha\-sync\(dq, \(dqservice\(dq: [ \(dqdhcp4 \(dq], \(dqarguments\(dq: { \(dqserver\-name\(dq: \(dqserver2\(dq, \(dqmax\-period\(dq: 60 } } .EE .UNINDENT .UNINDENT .sp When the server receives this command it first disables the DHCP service of the server from which it will be fetching leases, by sending the \fI\%dhcp\-disable\fP command to that server. The \fBmax\-period\fP parameter specifies the maximum duration (in seconds) for which the DHCP service should be disabled. If the DHCP service is successfully disabled, the synchronizing server fetches leases from the remote server by issuing one or more \fI\%lease4\-get\-page\fP commands. When the lease\-database synchronization is complete, the synchronizing server sends the \fI\%dhcp\-enable\fP command to the peer to re\-enable its DHCP service. .sp The \fBmax\-period\fP value should be sufficiently long to guarantee that it does not elapse before the synchronization is completed. Otherwise, the DHCP server will automatically enable its DHCP function while the synchronization is still in progress. If the DHCP server subsequently allocates any leases during the synchronization, those new (or updated) leases will not be fetched by the synchronizing server, leading to database inconsistencies. .SS The \fBha\-scopes\fP Command .sp This command allows an administrator to modify the HA scopes being served. It can be useful when recovering from a failure or when performing maintenance. Consult \fI\%Load\-Balancing Configuration\fP and \fI\%Hot\-Standby Configuration\fP to learn which scopes are available for the different HA modes of operation. .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 The \fI\%ha\-scopes\fP command can put Kea servers into conflicting states, which can lead to unexpected behavior. Changing scopes does not automatically change the state of the server or its relationship with a partner. .sp For example, when we add primary scopes to the standby server it will start responding to DHCP traffic for those scopes. This can lead to a situation where both servers are responding to the same traffic, which can lead to IP address collisions. .UNINDENT .UNINDENT .sp The \fI\%ha\-scopes\fP command has the following structure; using an example in DHCPv4.: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqha\-scopes\(dq, \(dqservice\(dq: [ \(dqdhcp4\(dq ], \(dqarguments\(dq: { \(dqscopes\(dq: [ \(dqHA_server1\(dq, \(dqHA_server2\(dq ], \(dqserver\-name\(dq: \(dqserver2\(dq } } .EE .UNINDENT .UNINDENT .sp This command configures the server to handle traffic from both the \(dqHA_server1\(dq and \(dqHA_server2\(dq scopes. To disable all scopes specify an empty list: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqha\-scopes\(dq, \(dqservice\(dq: [ \(dqdhcp4 \(dq], \(dqarguments\(dq: { \(dqscopes\(dq: [ ], \(dqserver\-name\(dq: \(dqserver2\(dq } } .EE .UNINDENT .UNINDENT .sp The optional \fBserver\-name\fP parameter specifies the name of one of the partners in the HA relationship that this command pertains to. This parameter can be omitted if the server receiving this command has only one HA relationship in its configuration. .SS The \fBha\-continue\fP Command .sp This command is used to resume the operation of the paused HA state machine, as described in \fI\%Pausing the HA State Machine\fP\&. It takes no arguments, so the command structure is simply: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqha\-continue\(dq, \(dqservice\(dq: [ \(dqdhcp4\(dq ], \(dqarguments\(dq: { \(dqscopes\(dq: [ ], \(dqserver\-name\(dq: \(dqserver2\(dq } } .EE .UNINDENT .UNINDENT .sp The optional \fBserver\-name\fP parameter specifies the name of one of the partners in the HA relationship that this command pertains to. This parameter can be omitted if the server receiving this command has only one HA relationship in its configuration. .SS The \fBha\-heartbeat\fP Command .sp The \fI\%Server States\fP section describes how the \fI\%ha\-heartbeat\fP command is used by a pair of active HA servers to detect one partner\(aqs failure. This command, however, can also be sent by the system administrator to one or both servers to check their HA state. This allows a monitoring system to be deployed on the HA enabled servers to periodically check whether they are operational or whether any manual intervention is required. The \fI\%ha\-heartbeat\fP command takes no arguments: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqha\-heartbeat\(dq, \(dqservice\(dq: [ \(dqdhcp4\(dq ], \(dqarguments\(dq: { \(dqscopes\(dq: [ ], \(dqserver\-name\(dq: \(dqserver2\(dq } } .EE .UNINDENT .UNINDENT .sp The optional \fBserver\-name\fP parameter specifies the name of one of the partners in the HA relationship that this command pertains to. This parameter can be omitted if the server receiving this command has only one HA relationship in its configuration. .sp Upon successful communication with the server, a response similar to this should be returned: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dqHA peer status returned.\(dq, \(dqarguments\(dq: { \(dqstate\(dq: \(dqpartner\-down\(dq, \(dqdate\-time\(dq: \(dqThu, 07 Nov 2019 08:49:37 GMT\(dq, \(dqscopes\(dq: [ \(dqserver1\(dq ], \(dqunsent\-update\-count\(dq: 123 } } .EE .UNINDENT .UNINDENT .sp The returned \fBstate\fP value should be one of the values listed in \fI\%Server States\fP\&. In the example above, the \fBpartner\-down\fP state is returned, which indicates that the server which responded to the command believes that its partner is offline; thus, it is serving all DHCP requests sent to the servers. To ensure that the partner is indeed offline, the administrator should send the \fI\%ha\-heartbeat\fP command to the second server. If sending the command fails, e.g. due to an inability to establish a TCP connection to the Control Agent, or if the Control Agent reports issues with communication with the DHCP server, it is very likely that the server is not running. .sp The \fBdate\-time\fP parameter conveys the server\(aqs notion of time. .sp The \fBunsent\-update\-count\fP value is a cumulative count of all unsent lease updates since the server was booted; its value is set to 0 when the server is started. It is never reset to 0 during the server\(aqs operation, even after the partner synchronizes the database. It is incremented by the partner sending the heartbeat response when it cannot send the lease update. For example, suppose the failure is a result of a temporary communication interruption. In that case, the partner receiving the \fBpartner\-down\fP heartbeat response tracks the value changes and can determine, once communication is reestablished, whether there are any new lease updates that it did not receive. If the values on both servers do not match, it is an indication that the partner should synchronize its lease database. A non\-zero value itself is not an indication of any present issues with lease updates, but a constantly incrementing value is. .sp The typical response returned by one server when both are operational is: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dqHA peer status returned.\(dq, \(dqarguments\(dq: { \(dqstate\(dq: \(dqload\-balancing\(dq, \(dqdate\-time\(dq: \(dqThu, 07 Nov 2019 08:49:37 GMT\(dq, \(dqscopes\(dq: [ \(dqserver1\(dq ], \(dqunsent\-update\-count\(dq: 0 } } .EE .UNINDENT .UNINDENT .sp In most cases, the \fI\%ha\-heartbeat\fP command should be sent to both HA\-enabled servers to verify the state of the entire HA setup. In particular, if one of the servers indicates that it is in the \fBload\-balancing\fP state, it means that this server is operating as if its partner is functional. When a partner goes down, it takes some time for the surviving server to realize it. The \fI\%Scope Transition in a Partner\-Down Case\fP section describes the algorithm which the surviving server follows before it transitions to the \fBpartner\-down\fP state. If the \fI\%ha\-heartbeat\fP command is sent during the time window between the failure of one of the servers and the transition of the surviving server to the \fBpartner\-down\fP state, the response from the surviving server does not reflect the failure. Resending the command detects the failure once the surviving server has entered the \fBpartner\-down\fP state. .SS The \fBstatus\-get\fP Command .sp \fI\%status\-get\fP is a general\-purpose command supported by several Kea daemons, not only the DHCP servers. However, when sent to a DHCP server with HA enabled, it can be used to get insight into the details of the HA\-specific server status. Not only does the response contain the status information of the server receiving this command, but also the information about its partner if it is available. .sp The following is an example response to the \fI\%status\-get\fP command, including the HA status of two \fBload\-balancing\fP servers: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dq\(dq, \(dqarguments\(dq: { \(dqpid\(dq: 1234, \(dquptime\(dq: 3024, \(dqreload\(dq: 1111, \(dqhigh\-availability\(dq: [ { \(dqha\-mode\(dq: \(dqload\-balancing\(dq, \(dqha\-servers\(dq: { \(dqlocal\(dq: { \(dqrole\(dq: \(dqprimary\(dq, \(dqscopes\(dq: [ \(dqserver1\(dq ], \(dqserver\-name\(dq: \(dqserver1\(dq, \(dqstate\(dq: \(dqload\-balancing\(dq, \(dqsystem\-time\(dq: \(dq2024\-01\-01 12:00:00\(dq }, \(dqremote\(dq: { \(dqage\(dq: 10, \(dqanalyzed\-packets\(dq: 8, \(dqclock\-skew\(dq: 0, \(dqcommunication\-interrupted\(dq: true, \(dqconnecting\-clients\(dq: 2, \(dqin\-touch\(dq: true, \(dqlast\-scopes\(dq: [ \(dqserver2\(dq ], \(dqlast\-state\(dq: \(dqload\-balancing\(dq, \(dqrole\(dq: \(dqsecondary\(dq, \(dqserver\-name\(dq: \(dqserver2\(dq, \(dqsystem\-time\(dq: \(dq2024\-01\-01 12:00:00\(dq, \(dqunacked\-clients\(dq: 1, \(dqunacked\-clients\-left\(dq: 2 } } } ], \(dqmulti\-threading\-enabled\(dq: true, \(dqthread\-pool\-size\(dq: 4, \(dqpacket\-queue\-size\(dq: 64, \(dqpacket\-queue\-statistics\(dq: [ 0.2, 0.1, 0.1 ], \(dqsockets\(dq: { \(dqstatus\(dq: \(dqready\(dq } } } .EE .UNINDENT .UNINDENT .sp The \fBhigh\-availability\fP argument is a list which currently comprises only one element. .sp The \fBha\-servers\fP map contains two structures: \fBlocal\fP and \fBremote\fP\&. The former contains the status information of the server which received the command, while the latter contains the status information known to the local server about the partner. The \fBrole\fP of the partner server is gathered from the local configuration file, and thus should always be available. The remaining status information, such as \fBlast\-scopes\fP and \fBlast\-state\fP, is not available until the local server communicates with the remote by successfully sending the \fI\%ha\-heartbeat\fP command. If at least one such communication has taken place, the returned value of the \fBin\-touch\fP parameter is set to \fBtrue\fP\&. By examining this value, the command\(aqs sender can determine whether the information about the remote server is reliable. .sp The \fBlast\-scopes\fP and \fBlast\-state\fP parameters contain information about the HA scopes served by the partner and its state. This information is gathered during the \fI\%ha\-heartbeat\fP command exchange, so it may not be accurate if a communication problem occurs between the partners and this status information is not refreshed. In such a case, it may be useful to send the \fI\%status\-get\fP command to the partner server directly to check its current state. The \fBage\fP parameter specifies the age of the information from the partner, in seconds. .sp The \fBcommunication\-interrupted\fP boolean value indicates whether the server receiving the \fI\%status\-get\fP command (the local server) has been unable to communicate with the partner longer than the duration specified as \fBmax\-response\-delay\fP\&. In such a situation, the active servers are considered to be in the \fBcommunication\-interrupted\fP state. At this point, the local server may start monitoring the DHCP traffic directed to the partner to see if the partner is responding to this traffic. More about the failover procedure can be found in \fI\%Load\-Balancing Configuration\fP\&. .sp The \fBsystem\-time\fP parameter holds the UTC time when skew between local and partner node was last calculated. It is displayed in \fB%Y\-%m\-%d %H:%M:%S\fP format for each active node: local, and remote, respectively. The \fBclock\-skew\fP parameter is available in the \fBremote\fP map and holds the difference in seconds between the two times. Local time is subtracted from the partner\(aqs time. A positive value means that the partner is ahead, while a negative value means that the partner is behind. Both \fBsystem\-time\fP and \fBclock\-skew\fP parameters can be null if the clock skew was not calculated yet. .sp The \fBconnecting\-clients\fP, \fBunacked\-clients\fP, \fBunacked\-clients\-left\fP, and \fBanalyzed\-packets\fP parameters were introduced along with the \fBcommunication\-interrupted\fP parameter and they convey useful information about the state of the DHCP traffic monitoring in the \fBcommunication\-interrupted\fP state. Once the server leaves the \fBcommunication\-interrupted\fP state, these parameters are all reset to 0. .sp These parameters have the following meaning in the \fBcommunication\-interrupted\fP state: .INDENT 0.0 .IP \(bu 2 \fBconnecting\-clients\fP \- this is the number of different clients which have attempted to get a lease from the remote server. These clients are differentiated by their MAC address and client identifier (in DHCPv4) or DUID (in DHCPv6). This number includes \(dqunacked\(dq clients (for which the \(dqsecs\(dq field or \(dqelapsed time\(dq value exceeded the \fBmax\-response\-delay\fP). .IP \(bu 2 \fBunacked\-clients\fP \- this is the number of different clients which have been considered \(dqunacked\(dq, i.e. the clients which have been trying to get the lease longer than the value of the \(dqsecs\(dq field, or for which the \(dqelapsed time\(dq exceeded the \fBmax\-response\-delay\fP setting. .IP \(bu 2 \fBunacked\-clients\-left\fP \- this indicates the number of additional clients which have to be considered \(dqunacked\(dq before the server enters the \fBpartner\-down\fP state. This value decreases when the \fBunacked\-clients\fP value increases. The local server enters the \fBpartner\-down\fP state when this value decreases to 0. .IP \(bu 2 \fBanalyzed\-packets\fP \- this is the total number of packets directed to the partner server and analyzed by the local server since entering the communication interrupted state. It includes retransmissions from the same clients. .UNINDENT .sp Monitoring these values helps to predict when the local server will enter the \fBpartner\-down\fP state or to understand why the server has not yet entered this state. .sp The \fBha\-mode\fP parameter returns the HA mode of operation selected using the \fBmode\fP parameter in the configuration file. It can hold one of the following values: \fBload\-balancing\fP, \fBhot\-standby\fP, or \fBpassive\-backup\fP\&. .sp The \fI\%status\-get\fP response has the format described above only in the \fBload\-balancing\fP and \fBhot\-standby\fP modes. In the \fBpassive\-backup\fP mode the \fBremote\fP map is not included in the response because in this mode there is only one active server (local). The response includes no information about the status of the backup servers. .SS The \fBha\-maintenance\-start\fP Command .sp This command initiates the transition of the server\(aqs partners into the \fBin\-maintenance\fP state, and the transition of the server receiving the command into the \fBpartner\-in\-maintenance\fP state, in each HA relationship. See the \fI\%Controlled Shutdown and Maintenance of DHCP Servers\fP section for details. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqha\-maintenance\-start\(dq, \(dqservice\(dq: [ \(dqdhcp4\(dq ] } .EE .UNINDENT .UNINDENT .SS The \fBha\-maintenance\-cancel\fP Command .sp This command is used to cancel the maintenance previously initiated using the \fI\%ha\-maintenance\-start\fP command. The server receiving this command first sends \fI\%ha\-maintenance\-notify\fP, with the \fBcancel\fP flag set to \fBtrue\fP, to its partners. Next, the server reverts from the \fBpartner\-in\-maintenance\fP state to its previous state. See the \fI\%Controlled Shutdown and Maintenance of DHCP Servers\fP section for details. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqha\-maintenance\-cancel\(dq, \(dqservice\(dq: [ \(dqdhcp4\(dq ] } .EE .UNINDENT .UNINDENT .SS The \fBha\-maintenance\-notify\fP Command .sp This command is sent by the server receiving the \fI\%ha\-maintenance\-start\fP or the \fI\%ha\-maintenance\-cancel\fP command to its partner, to cause the partner to transition to the \fBin\-maintenance\fP state or to revert from this state to a previous state. See the \fI\%Controlled Shutdown and Maintenance of DHCP Servers\fP section for details. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqha\-maintenance\-notify\(dq, \(dqservice\(dq: [ \(dqdhcp4\(dq ], \(dqarguments\(dq: { \(dqcancel\(dq: false, \(dqstate\(dq: \(dqready\(dq, \(dqserver\-name\(dq: \(dqserver2\(dq } } .EE .UNINDENT .UNINDENT .sp The \fBstate\fP argument informs the recipient about the state of the sending server. The recipient can instantly resume the operation of the state machine without sending a heartbeat to check the partner\(aqs state. .sp The optional \fBserver\-name\fP parameter specifies the name of one of the partners in the HA relationship that this command pertains to. This parameter can be omitted if the server receiving this command has only one HA relationship in its configuration. .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 The \fI\%ha\-maintenance\-notify\fP command is not meant to be used by system administrators. It is used for internal communication between a pair of HA\-enabled DHCP servers. Direct use of this command is not supported and may produce unintended consequences. .UNINDENT .UNINDENT .SS The \fBha\-reset\fP Command .sp This command causes the server to reset its High Availability state machine by transitioning it to the \fBwaiting\fP state. A partner in the \fBcommunication\-recovery\fP state may send this command to cause the server to synchronize its lease database. Database synchronization is required when the partner has failed to send all lease database updates after re\-establishing connection after a temporary connection failure. It is also required when the \fBdelayed\-updates\-limit\fP is exceeded, when the server is in the \fBcommunication\-recovery\fP state. .sp A server administrator may send this command to reset a misbehaving state machine. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqha\-reset\(dq, \(dqservice\(dq: [ \(dqdhcp4\(dq ], \(dqarguments\(dq: { \(dqserver\-name\(dq: \(dqserver2\(dq } } .EE .UNINDENT .UNINDENT .sp The optional \fBserver\-name\fP parameter specifies the name of one of the partners in the HA relationship that this command pertains to. This parameter can be omitted if the server receiving this command has only one HA relationship in its configuration. .sp It elicits the response: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dqHA state machine reset.\(dq } .EE .UNINDENT .UNINDENT .sp If the server receiving this command is already in the \fBwaiting\fP state, the command has no effect. .SS The \fBha\-sync\-complete\-notify\fP Command .sp A server sends this command to its partner to signal that it has completed lease\-database synchronization. The partner may enable its DHCP service if it can allocate new leases in its current state. The partner does not enable the DHCP service in the \fBpartner\-down\fP state until it sends a successful \fI\%ha\-heartbeat\fP test to its partner server. If the connection is still unavailable, the server in the \fBpartner\-down\fP state enables its own DHCP service to continue responding to clients. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqha\-sync\-complete\-notify\(dq, \(dqservice\(dq: [ \(dqdhcp4\(dq ], \(dqarguments\(dq: { \(dqorigin\-id\(dq: 2000, \(dqserver\-name\(dq: \(dqserver2\(dq } } .EE .UNINDENT .UNINDENT .sp The optional \fBserver\-name\fP parameter specifies the name of one of the partners in the HA relationship that this command pertains to. This parameter can be omitted if the server receiving this command has only one HA relationship in its configuration. .sp The \fBorigin\-id\fP parameter is used to select the HA service for which the receiving server should enable the DHCP service when it receives this notification. This is the same origin the sending server used previously to disable the DHCP service before synchronization. The \fBorigin\-id\fP parameter deprecates the \fBorigin\fP parameter used in some earlier Kea versions. .sp It elicits the response: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dqServer successfully notified about the synchronization completion.\(dq } .EE .UNINDENT .UNINDENT .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 The \fI\%ha\-sync\-complete\-notify\fP command is not meant to be used by system administrators. It is used for internal communication between a pair of HA\-enabled DHCP servers. Direct use of this command is not supported and may produce unintended consequences. .UNINDENT .UNINDENT .SS Hub and Spoke Configuration .sp A hub\-and\-spoke arrangement, with one central server and multiple branch servers, is a common way to ensure resiliency of the DHCP servers. The branch servers are the primary servers in the \fBhot\-standby\fP mode and respond to the local DHCP traffic in their respective locations. The central server acts as a standby server for each branch server. It maintains independent state machines with the branch servers, called relationships. If one of the branch servers experiences a failure, the central server can take over its DHCP traffic. In this case, one of the central server\(aqs relationships is in the \fBpartner\-down\fP state. The remaining relationships may still be in the \fBhot\-standby\fP state and not actively respond to DHCP traffic. When the branch server becomes active again, it synchronizes the lease database with the central server and the central server becomes fully passive again. In rare cases, if multiple branch servers stop, the central server takes responsibility for all their traffic, and potentially all DHCP traffic in the entire network if every branch server is down. A simple hub\-and\-spoke arrangement consisting of two branch servers and one central server is shown below. .INDENT 0.0 .INDENT 3.5 .sp .EX +\-\-\-\-\- Central Server \-\-\-\-\-\-+ | | +\-\-\-\-\-\-\-\-\-\-+ relationship 1 | +\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-+ | relationship 2 +\-\-\-\-\-\-\-\-\-\-+ | Server 1 |===================| Server 2 | Server 4 |===================| Server 3 | +\-\-\-\-\-\-\-\-\-\-+ | +\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-+ | +\-\-\-\-\-\-\-\-\-\-+ | | +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ .EE .UNINDENT .UNINDENT .sp Each branch server\(aqs configuration comprises a set of subnets appropriate for the branch server; different branch servers serve different subnets. The central server\(aqs configuration includes all subnets of the branch servers, so that it can respond to DHCP traffic directed to any branch servers that fail. The subnets in the central server must be grouped into relationships as in the snippet below: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp6\(dq: { \(dqinterfaces\-config\(dq: { \(dqinterfaces\(dq: [ \(dqenp0s8\(dq, \(dqenp0s9\(dq ] }, \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dq/usr/lib/kea/hooks/libdhcp_lease_cmds.so\(dq, \(dqparameters\(dq: {} }, { \(dqlibrary\(dq: \(dq/usr/lib/kea/hooks/libdhcp_ha.so\(dq, \(dqparameters\(dq: { \(dqhigh\-availability\(dq: [ { \(dqthis\-server\-name\(dq: \(dqserver2\(dq, \(dqmode\(dq: \(dqhot\-standby\(dq, \(dqmulti\-threading\(dq: { \(dqenable\-multi\-threading\(dq: true, \(dqhttp\-dedicated\-listener\(dq: true, \(dqhttp\-listener\-threads\(dq: 4, \(dqhttp\-client\-threads\(dq: 4 }, \(dqpeers\(dq: [ { \(dqname\(dq: \(dqserver1\(dq, \(dqurl\(dq: \(dqhttp://192.168.56.66:8007/\(dq, \(dqrole\(dq: \(dqprimary\(dq, \(dqauto\-failover\(dq: true }, { \(dqname\(dq: \(dqserver2\(dq, \(dqurl\(dq: \(dqhttp://192.168.56.33:8007/\(dq, \(dqrole\(dq: \(dqstandby\(dq, \(dqauto\-failover\(dq: true } ] }, { \(dqthis\-server\-name\(dq: \(dqserver4\(dq, \(dqmode\(dq: \(dqhot\-standby\(dq, \(dqmulti\-threading\(dq: { \(dqenable\-multi\-threading\(dq: true, \(dqhttp\-dedicated\-listener\(dq: true, \(dqhttp\-listener\-threads\(dq: 4, \(dqhttp\-client\-threads\(dq: 4 }, \(dqpeers\(dq: [ { \(dqname\(dq: \(dqserver3\(dq, \(dqurl\(dq: \(dqhttp://192.168.57.99:8007/\(dq, \(dqrole\(dq: \(dqprimary\(dq, \(dqauto\-failover\(dq: true }, { \(dqname\(dq: \(dqserver4\(dq, \(dqurl\(dq: \(dqhttp://192.168.57.33:8007/\(dq, \(dqrole\(dq: \(dqstandby\(dq, \(dqauto\-failover\(dq: true } ] } ] } } ], \(dqsubnet6\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq2001:db8:1::/64\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8:1::/80\(dq } ], \(dqinterface\(dq: \(dqenp0s8\(dq, \(dquser\-context\(dq: { \(dqha\-server\-name\(dq: \(dqserver2\(dq } }, { \(dqid\(dq: 2, \(dqsubnet\(dq: \(dq2001:db8:2::/64\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8:2::/80\(dq } ], \(dqinterface\(dq: \(dqenp0s9\(dq, \(dquser\-context\(dq: { \(dqha\-server\-name\(dq: \(dqserver4\(dq } } ] } } .EE .UNINDENT .UNINDENT .sp The peer names in the relationships must be unique. The user context for each subnet contains the \fBha\-server\-name\fP parameter, associating a subnet with a relationship. The \fBha\-server\-name\fP can be any of the peer names in the relationship. For example, if a relationship contains peer names \fBserver1\fP and \fBserver2\fP, it does not matter whether the \fBha\-server\-name\fP is \fBserver1\fP or \fBserver2\fP\&. In both cases, it associates a subnet with that relationship. .sp It is not required to specify the \fBha\-server\-name\fP in the branch servers, assuming that the branch servers only contain the subnets they serve. Consider the following configuration for branch \fBserver3\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp6\(dq: { \(dqinterfaces\-config\(dq: { \(dqinterfaces\(dq: [ \(dqenp0s8\(dq ] }, \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dq/usr/lib/kea/hooks/libdhcp_lease_cmds.so\(dq, \(dqparameters\(dq: {} }, { \(dqlibrary\(dq: \(dq/usr/lib/kea/hooks/libdhcp_ha.so\(dq, \(dqparameters\(dq: { \(dqhigh\-availability\(dq: [ { \(dqthis\-server\-name\(dq: \(dqserver3\(dq, \(dqmode\(dq: \(dqhot\-standby\(dq, \(dqmulti\-threading\(dq: { \(dqenable\-multi\-threading\(dq: true, \(dqhttp\-dedicated\-listener\(dq: true, \(dqhttp\-listener\-threads\(dq: 4, \(dqhttp\-client\-threads\(dq: 4 }, \(dqpeers\(dq: [ { \(dqname\(dq: \(dqserver3\(dq, \(dqurl\(dq: \(dqhttp://192.168.57.99:8007/\(dq, \(dqrole\(dq: \(dqprimary\(dq, \(dqauto\-failover\(dq: true }, { \(dqname\(dq: \(dqserver4\(dq, \(dqurl\(dq: \(dqhttp://192.168.57.33:8007/\(dq, \(dqrole\(dq: \(dqstandby\(dq, \(dqauto\-failover\(dq: true } ] } ] } } ], \(dqsubnet6\(dq: [ { \(dqid\(dq: 2, \(dqsubnet\(dq: \(dq2001:db8:2::/64\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8:2::/80\(dq } ], \(dqinterface\(dq: \(dqenp0s8\(dq, \(dquser\-context\(dq: { \(dqha\-server\-name\(dq: \(dqserver3\(dq } } ] } } .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Even though it is possible to omit the \fBha\-server\-name\fP user context parameters in the branch servers, we recommend including them. The servers fetch all leases from the partners during the database synchronization; if the subnets are not explicitly associated with the relationship, the branch server inserts all fetched leases from the central server (including those from other relationships) into its database. Specifying the \fBha\-server\-name\fP parameter for each configured subnet in the branch server guarantees that only the leases belonging to its relationship are inserted into the branch server\(aqs database. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The peer names in the branch servers must match the peer names in the respective central server\(aqs relationships, because these names are used for signaling between the HA partners. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The hub\-and\-spoke configuration is currently incompatible with the \fBreselect\-subnet\-address\fP and \fBreselect\-subnet\-pool\fP parameters of the \fI\%libdhcp_radius.so\fP\&. The High Availability hook library uses an originally selected subnet for choosing an HA relationship to process a packet. The subnet reselection may interfere with this choice. See the \fI\%RADIUS Hook Library Configuration\fP for details. .UNINDENT .UNINDENT .SS \fBlibdhcp_host_cache.so\fP: Host Cache Reservations for Improved Performance .sp Some database backends, such as RADIUS, are slow and may take a long time to respond. Since Kea in general is synchronous, backend performance directly affects DHCP performance. To minimize the impact and improve performance, the Host Cache library provides a way to cache information from the database locally. This includes negative caching, i.e. the ability to remember that there is no client information in the database. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 \fI\%libdhcp_host_cache.so\fP is part of the open source code and is available to every Kea user. It was previously available only to ISC customers with a paid support contract. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 This library can only be loaded by the \fI\%kea\-dhcp4\fP or \fI\%kea\-dhcp6\fP process. .UNINDENT .UNINDENT .sp In principle, this hook library can be used with any backend that may introduce performance degradation (MySQL, PostgreSQL or RADIUS). Host Cache must be loaded for the RADIUS accounting mechanism to work. .sp The Host Cache hook library is very simple. It takes only one optional parameter (\fBmaximum\fP), which defines the maximum number of hosts to be cached. If not specified, the default value of 0 is used, which means there is no limit. This hook library can be loaded the same way as any other hook library; for example, this configuration could be used: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp4\(dq: { # Your regular DHCPv4 configuration parameters here. \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dq/usr/local/lib/kea/hooks/libdhcp_host_cache.so\(dq, \(dqparameters\(dq: { # Tells Kea to never cache more than 1000 hosts. \(dqmaximum\(dq: 1000 } } ], \&... } .EE .UNINDENT .UNINDENT .sp Once loaded, the Host Cache hook library provides a number of new commands which can be used either over the control channel (see \fI\%Using the Control Channel\fP) or the RESTful API (see \fI\%Overview of the Kea Control Agent\fP). An example RESTful API client is described in \fI\%Overview of the Kea Shell\fP\&. The following sections describe the commands available. .SS The \fBcache\-flush\fP Command .sp This command allows removal of a specified number of cached host entries. It takes one parameter, which defines the number of hosts to be removed. An example usage looks as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqcache\-flush\(dq, \(dqarguments\(dq: 1000 } .EE .UNINDENT .UNINDENT .sp This command removes 1000 hosts; to delete \fIall\fP cached hosts, use \fI\%cache\-clear\fP instead. The hosts are stored in FIFO (first\-in, first\-out) order, so the oldest entries are always removed. .SS The \fBcache\-clear\fP Command .sp This command allows removal of all cached host entries. An example usage looks as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqcache\-clear\(dq } .EE .UNINDENT .UNINDENT .sp This command removes all hosts. To delete only a certain number of cached hosts, please use \fI\%cache\-flush\fP instead. .SS The \fBcache\-size\fP Command .sp This command returns the number of host entries. An example usage looks as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqcache\-size\(dq } .EE .UNINDENT .UNINDENT .SS The \fBcache\-write\fP Command .sp In general, the cache content is considered a runtime state and the server can be shut down or restarted as usual; the cache is then repopulated after restart. However, there are some cases when it is useful to store the contents of the cache. One such case is RADIUS, where the cached hosts also retain additional cached RADIUS attributes; there is no easy way to obtain this information again, because renewing clients send their packet to the DHCP server directly. Another use case is when an administrator wants to restart the server and, for performance reasons, wants it to start with a hot (populated) cache. .sp This command allows writing the contents of the in\-memory cache to a file on disk. It takes one parameter, which defines the filename. An example usage looks as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqcache\-write\(dq, \(dqarguments\(dq: \(dq/usr/local/var/lib/kea/kea\-host\-cache.json\(dq } .EE .UNINDENT .UNINDENT .sp This causes the contents to be stored in the \fB/usr/local/var/lib/kea/kea\-host\-cache.json\fP file. That file can then be loaded with the \fI\%cache\-load\fP command or processed by any other tool that is able to understand JSON format. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 As of Kea 2.7.9, the cache file may only be written to the data directory determined during compilation: \fB\(dq[kea\-install\-dir]/var/lib/kea\(dq\fP\&. This path may be overridden at startup by setting the environment variable \fBKEA_DHCP_DATA_DIR\fP to the desired path. For ease of use in specifying a custom file name simply omit the path portion from \fBfilename\fP\&. .UNINDENT .UNINDENT .SS The \fBcache\-load\fP Command .sp See the previous section for a discussion of use cases where it may be useful to write and load contents of the host cache to disk. .sp This command allows the contents of a file on disk to be loaded into an in\-memory cache. It takes one parameter, which defines the filename. An example usage looks as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqcache\-load\(dq, \(dqarguments\(dq: \(dq/usr/local/share/kea/kea\-host\-cache.json\(dq } .EE .UNINDENT .UNINDENT .sp This command stores the contents to the \fB/usr/local/share/kea/kea\-host\-cache.json\fP file. That file can then be loaded with the \fI\%cache\-load\fP command or processed by any other tool that is able to understand JSON format. .SS The \fBcache\-get\fP Command .sp This command is similar to \fI\%cache\-write\fP, but instead of writing the cache contents to disk, it returns the contents to whoever sent the command. .sp This command allows the contents of a file on disk to be loaded into an in\-memory cache. It takes one parameter, which defines the filename. An example usage looks as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqcache\-get\(dq } .EE .UNINDENT .UNINDENT .sp This command returns all the cached hosts; the response may be large. .SS The \fBcache\-get\-by\-id\fP Command .sp This command is similar to \fI\%cache\-get\fP, but instead of returning the whole content it returns only the entries matching the given identifier. .sp It takes one parameter, which defines the identifier of wanted cached host reservations. An example usage looks as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqcache\-get\-by\-id\(dq, \(dqarguments\(dq: { \(dqhw\-address\(dq: \(dq01:02:03:04:05:06\(dq } } .EE .UNINDENT .UNINDENT .sp This command returns all the cached hosts with the given hardware address. .SS The \fBcache\-insert\fP Command .sp This command may be used to manually insert a host into the cache; there are very few use cases when this command might be useful. This command expects its arguments to follow the usual syntax for specifying host reservations (see \fI\%Host Reservations in DHCPv4\fP or \fI\%Host Reservations in DHCPv6\fP), with one difference: the \fBsubnet\-id\fP value must be explicitly specified. .sp An example command to insert an IPv4 host into the host cache looks as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqcache\-insert\(dq, \(dqarguments\(dq: { \(dqhw\-address\(dq: \(dq01:02:03:04:05:06\(dq, \(dqsubnet\-id4\(dq: 4, \(dqsubnet\-id6\(dq: 0, \(dqip\-address\(dq: \(dq192.0.2.100\(dq, \(dqhostname\(dq: \(dqsomehost.example.org\(dq, \(dqclient\-classes4\(dq: [ ], \(dqclient\-classes6\(dq: [ ], \(dqoption\-data4\(dq: [ ], \(dqoption\-data6\(dq: [ ], \(dqnext\-server\(dq: \(dq192.0.0.2\(dq, \(dqserver\-hostname\(dq: \(dqserver\-hostname.example.org\(dq, \(dqboot\-file\-name\(dq: \(dqbootfile.efi\(dq, \(dqhost\-id\(dq: 0 } } .EE .UNINDENT .UNINDENT .sp An example command to insert an IPv6 host into the host cache looks as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqcache\-insert\(dq, \(dqarguments\(dq: { \(dqhw\-address\(dq: \(dq01:02:03:04:05:06\(dq, \(dqsubnet\-id4\(dq: 0, \(dqsubnet\-id6\(dq: 6, \(dqip\-addresses\(dq: [ \(dq2001:db8::cafe:babe\(dq ], \(dqprefixes\(dq: [ \(dq2001:db8:dead:beef::/64\(dq ], \(dqhostname\(dq: \(dq\(dq, \(dqclient\-classes4\(dq: [ ], \(dqclient\-classes6\(dq: [ ], \(dqoption\-data4\(dq: [ ], \(dqoption\-data6\(dq: [ ], \(dqnext\-server\(dq: \(dq0.0.0.0\(dq, \(dqserver\-hostname\(dq: \(dq\(dq, \(dqboot\-file\-name\(dq: \(dq\(dq, \(dqhost\-id\(dq: 0 } } .EE .UNINDENT .UNINDENT .SS The \fBcache\-remove\fP Command .sp Sometimes it is useful to remove a single entry from the host cache: for example, consider a situation where the device is active, Kea has already provided configuration, and the host entry is in cache. As a result of administrative action (e.g. the customer hasn\(aqt paid their bills or has been upgraded to better service), the information in the backend database (e.g. MySQL or RADIUS) is being updated. However, since the cache is in use, Kea does not notice the change as the cached values are used. The \fI\%cache\-remove\fP command can solve this problem by removing a cached entry after administrative changes. .sp The \fI\%cache\-remove\fP command works similarly to the \fI\%reservation\-get\fP command. It allows querying by two parameters: either \fBsubnet\-id4\fP or \fBsubnet\-id6\fP; or \fBip\-address\fP (may be an IPv4 or IPv6 address), \fBhw\-address\fP (specifies a hardware/MAC address), \fBduid\fP, \fBcircuit\-id\fP, \fBclient\-id\fP, or \fBflex\-id\fP\&. .sp An example command to remove an IPv4 host with reserved address 192.0.2.1 from a subnet with a \fBsubnet\-id\fP 123 looks as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqcache\-remove\(dq, \(dqarguments\(dq: { \(dqip\-address\(dq: \(dq192.0.2.1\(dq, \(dqsubnet\-id\(dq: 123 } } .EE .UNINDENT .UNINDENT .sp Another example that removes an IPv6 host identifier by DUID and specific \fBsubnet\-id\fP is: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqcache\-remove\(dq, \(dqarguments\(dq: { \(dqduid\(dq: \(dq00:01:ab:cd:f0:a1:c2:d3:e4\(dq, \(dqsubnet\-id\(dq: 123 } } .EE .UNINDENT .UNINDENT .SS \fBlibdhcp_host_cmds.so\fP: Host Commands .sp Kea can store host reservations in a database; in many larger deployments, it is useful to be able to manage that information while the server is running. The Host Commands library provides management commands for adding, querying, and deleting host reservations in a safe way without restarting the server. In particular, it validates the parameters, so an attempt to insert incorrect data \- such as adding a host with a conflicting identifier in the same subnet \- is rejected. Those commands are exposed via the command channel (JSON over UNIX sockets) and the Control Agent (JSON over a RESTful interface). .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 \fI\%libdhcp_host_cmds.so\fP is part of the open source code and is available to every Kea user. It was previously available only to ISC customers with a paid support contract. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 This library can only be loaded by the \fI\%kea\-dhcp4\fP or \fI\%kea\-dhcp6\fP process. .UNINDENT .UNINDENT .sp Currently, the following commands are supported: .INDENT 0.0 .IP \(bu 2 \fI\%reservation\-add\fP, which adds a new host reservation. .IP \(bu 2 \fI\%reservation\-get\fP, which returns an existing reservation if specified criteria are matched. .IP \(bu 2 \fI\%reservation\-get\-all\fP, which returns all reservations in a specified subnet. .IP \(bu 2 \fI\%reservation\-get\-page\fP, a variant of \fI\%reservation\-get\-all\fP that returns reservations by pages, either all or in a specified subnet. .IP \(bu 2 \fI\%reservation\-get\-by\-address\fP, which returns all reservations with a specified IP address or a delegated prefix (without a prefix length), and optionally a subnet id. .IP \(bu 2 \fI\%reservation\-get\-by\-hostname\fP, which returns all reservations with a specified hostname and optionally in a subnet. .IP \(bu 2 \fI\%reservation\-get\-by\-id\fP, which returns all reservations with a specified identifier (since Kea version 1.9.0). .IP \(bu 2 \fI\%reservation\-del\fP, which attempts to delete a reservation matching specified criteria. .IP \(bu 2 \fI\%reservation\-update\fP, which updates (replaces) an existing reservation matching the given identifiers in a subnet. .UNINDENT .sp To use the commands that change reservation information (i.e. \fI\%reservation\-add\fP, \fI\%reservation\-del\fP, and \fI\%reservation\-update\fP) to modify data stored in the host database, the hosts database must be specified and it must not operate in read\-only mode (for details, see the \fBhosts\-databases\fP descriptions in \fI\%DHCPv4 Hosts Database Configuration\fP and \fI\%DHCPv6 Hosts Database Configuration\fP). If the \fBhosts\-databases\fP are not specified or are running in read\-only mode, \fI\%libdhcp_host_cmds.so\fP will load, but any attempts to use \fI\%reservation\-add\fP, \fI\%reservation\-del\fP, and \fI\%reservation\-update\fP to modify data in that database will fail. .sp These commands can also modify hosts from the JSON configuration independently from the hosts database. The changes provided in the JSON configuration are volatile and can be made permanent by sending the \fI\%config\-write\fP command. .sp For a description of proposed future commands, see the \X'tty: link https://gitlab.isc.org/isc-projects/kea/wikis/designs/commands'\fI\%Control API Requirements\fP\X'tty: link' document. .sp All host commands use JSON syntax. They can be issued either using the control channel (see \fI\%Management API\fP) or via the Control Agent (see \fI\%The Kea Control Agent\fP). .sp The library can be loaded similarly to other hook libraries. It does not take any parameters, and it supports both the DHCPv4 and DHCPv6 servers. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dq/path/libdhcp_host_cmds.so\(dq }, ... ] } .EE .UNINDENT .UNINDENT .SS The \fBsubnet\-id\fP Parameter .sp Before examining the individual commands, it is worth discussing the parameter \fBsubnet\-id\fP\&. Currently, this parameter is mandatory for all of the commands supplied by this library, with the exception of \fI\%reservation\-get\-by\-hostname\fP and \fI\%reservation\-get\-by\-address\fP, where it is optional. \fBsubnet\-id\fP is also optional in \fI\%reservation\-get\-page\fP, and it is forbidden in \fI\%reservation\-get\-by\-id\fP\&. .sp Reservations can be specified globally, and are not necessarily specific to any subnet. When reservations are supplied via the configuration file, the ID of the containing subnet (or lack thereof) is implicit in the configuration structure. However, when managing reservations using host commands, it is necessary to explicitly identify the scope to which the reservation belongs. This is done via the \fBsubnet\-id\fP parameter. For global reservations, use a value of zero (0). For reservations scoped to a specific subnet, use that subnet\(aqs ID. See also the note in \fI\%The reservation\-add Command\fP about the \fI\%reservation\-add\fP command for an empty (i.e. with no reserved address or prefix) reservation. .sp On the other hand, when the \fBsubnet\-id\fP is not specified in the command parameters, it is added to each host in responses. If the \fBsubnet\-id\fP has the unused special value, this means the host entry belongs only to the other IP version (i.e. IPv6 in the DHCPv4 server or IPv4 in the DHCPv6 server) and this entry is ignored. .SS The \fBoperation\-target\fP Parameter .sp Most host commands accept the \fBoperation\-target\fP parameter, which selects the host data source. The commands may process data from the server configuration (i.e., memory operation target), a database (database target), or both (all sources). The operation\-target parameter is optional. By default, the commands that only read the data use all data sources (memory and database); the commands that modify the state (i.e. \fI\%reservation\-add\fP, \fI\%reservation\-del\fP, and \fI\%reservation\-update\fP) only use the database target. .sp The \fBoperation\-target\fP parameter accepts the following values: .INDENT 0.0 .IP \(bu 2 \fBmemory\fP \- query or update the runtime server configuration .IP \(bu 2 \fBdatabase\fP \- query or update host database(s) .IP \(bu 2 \fBall\fP \- query or update both runtime configuration and host database(s) .IP \(bu 2 \fBdefault\fP \- query or update a default host data source \- it is command\-specific .UNINDENT .SS The \fBreservation\-add\fP Command .sp \fI\%reservation\-add\fP allows for the insertion of a new host. It takes a set of arguments that vary depending on the nature of the host reservation. Any parameters allowed in the configuration file that pertain to host reservation are permitted here. For details regarding IPv4 reservations, see \fI\%Host Reservations in DHCPv4\fP; for IPv6 reservations, see \fI\%Host Reservations in DHCPv6\fP\&. The \fBsubnet\-id\fP is mandatory. Use a value of zero (0) to add a global reservation, or the ID of the subnet to which the reservation should be added. The command can be as simple as having only the two mandatory entries: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqreservation\-add\(dq, \(dqarguments\(dq: { \(dqreservation\(dq: { \(dqsubnet\-id\(dq: 1, \(dqhw\-address\(dq: \(dq1a:1b:1c:1d:1e:1f\(dq } } } .EE .UNINDENT .UNINDENT .sp In that case, however, it does not assign any resources to the host. An IPv4 address can be assigned as in this example: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqreservation\-add\(dq, \(dqarguments\(dq: { \(dqreservation\(dq: { \(dqsubnet\-id\(dq: 1, \(dqhw\-address\(dq: \(dq1a:1b:1c:1d:1e:1f\(dq, \(dqip\-address\(dq: \(dq192.0.2.202\(dq } } } .EE .UNINDENT .UNINDENT .sp It can also take many more parameters, such as: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqreservation\-add\(dq, \(dqarguments\(dq: { \(dqreservation\(dq: { \(dqsubnet\-id\(dq: 1, \(dqclient\-id\(dq: \(dq01:0a:0b:0c:0d:0e:0f\(dq, \(dqip\-address\(dq: \(dq192.0.2.205\(dq, \(dqnext\-server\(dq: \(dq192.0.2.1\(dq, \(dqserver\-hostname\(dq: \(dqhal9000\(dq, \(dqboot\-file\-name\(dq: \(dq/dev/null\(dq, \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqdomain\-name\-servers\(dq, \(dqdata\(dq: \(dq10.1.1.202,10.1.1.203\(dq } ], \(dqclient\-classes\(dq: [ \(dqspecial_snowflake\(dq, \(dqoffice\(dq ] } } } .EE .UNINDENT .UNINDENT .sp Here is an example of a complex IPv6 reservation: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqreservation\-add\(dq, \(dqarguments\(dq: { \(dqreservation\(dq: { \(dqsubnet\-id\(dq: 1, \(dqduid\(dq: \(dq01:02:03:04:05:06:07:08:09:0A\(dq, \(dqip\-addresses\(dq: [ \(dq2001:db8:1:cafe::1\(dq ], \(dqprefixes\(dq: [ \(dq2001:db8:2:abcd::/64\(dq ], \(dqhostname\(dq: \(dqfoo.example.com\(dq, \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqvendor\-opts\(dq, \(dqdata\(dq: \(dq4491\(dq }, { \(dqname\(dq: \(dqtftp\-servers\(dq, \(dqspace\(dq: \(dqvendor\-4491\(dq, \(dqdata\(dq: \(dq3000:1::234\(dq } ] } } } .EE .UNINDENT .UNINDENT .sp The command accepts the \fBoperation\-target\fP argument. By default, it adds the reservation to the hosts database only. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqreservation\-add\(dq, \(dqarguments\(dq: { \(dqreservation\(dq: {}, \(dqoperation\-target\(dq: \(dqall\(dq } } .EE .UNINDENT .UNINDENT .sp The command returns a status that indicates either success (result 0) or failure (result 1). A failed command always includes a text parameter that explains the cause of the failure. Here\(aqs an example of a successful addition: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dqHost added.\(dq } .EE .UNINDENT .UNINDENT .sp And here\(aqs an example of a failure: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 1, \(dqtext\(dq: \(dqMandatory \(aqsubnet\-id\(aq parameter missing.\(dq } .EE .UNINDENT .UNINDENT .sp As \fI\%reservation\-add\fP is expected to store the host, the \fBhosts\-databases\fP parameter must be specified in the configuration, and databases must not run in read\-only mode. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Since kea version 2.7.0 an empty reservation is implicitly global, i.e. if no \fBsubnet\-id\fP entry is present and for DHCPv4 \fBip\-address\fP or for DHCPv6 \fBip\-addresses\fP and \fBprefixes\fP do not specify a reserved address or prefix the command is valid and adds a global (subnet\-id 0) host reservation. .UNINDENT .UNINDENT .SS The \fBreservation\-get\fP Command .sp \fI\%reservation\-get\fP can be used to query the host database and retrieve existing reservations. This command supports two types of parameters: (\fBsubnet\-id\fP, \fBaddress\fP) or (\fBsubnet\-id\fP, \fBidentifier\-type\fP, \fBidentifier\fP). The first type of query is used when the address (either IPv4 or IPv6) is known, but the details of the reservation are not. One common use for this type of query is to find out whether a given address is reserved. The second query uses identifiers. For maximum flexibility, Kea stores the host identifying information as a pair of values: the type and the actual identifier. Currently supported identifiers are \fB\(dqhw\-address\(dq\fP, \fB\(dqduid\(dq\fP, \fB\(dqcircuit\-id\(dq\fP, \fB\(dqclient\-id\(dq\fP, and \fB\(dqflex\-id\(dq\fP\&. The \fBsubnet\-id\fP is mandatory. Use a value of zero (0) to fetch a global reservation, or the ID of the subnet to which the reservation belongs. .sp An example command for getting a host reservation by a (\fBsubnet\-id\fP, \fBaddress\fP) pair looks as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqreservation\-get\(dq, \(dqarguments\(dq: { \(dqsubnet\-id\(dq: 1, \(dqip\-address\(dq: \(dq192.0.2.202\(dq } } .EE .UNINDENT .UNINDENT .sp An example query by (\fBsubnet\-id\fP, \fBidentifier\-type\fP, \fBidentifier\fP) looks as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqreservation\-get\(dq, \(dqarguments\(dq: { \(dqsubnet\-id\(dq: 4, \(dqidentifier\-type\(dq: \(dqhw\-address\(dq, \(dqidentifier\(dq: \(dq01:02:03:04:05:06\(dq } } .EE .UNINDENT .UNINDENT .sp The command accepts the \fBoperation\-target\fP argument. By default, it gets the reservation from both the JSON configuration and the hosts database. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqreservation\-get\(dq, \(dqarguments\(dq: { \(dqsubnet\-id\(dq: 1, \(dqip\-address\(dq: \(dq192.0.2.202\(dq, \(dqoperation\-target\(dq: \(dqdatabase\(dq } } .EE .UNINDENT .UNINDENT .sp Command \fI\%reservation\-get\fP typically returns the result 0 when a query was conducted properly. In particular, 0 is returned when the host was not found. If the query was successful, the host parameters are returned. An example of a query that did not find the host looks as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dqHost not found.\(dq } .EE .UNINDENT .UNINDENT .sp Here\(aqs an example of a result returned when the host was found successfully: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqarguments\(dq: { \(dqboot\-file\-name\(dq: \(dqbootfile.efi\(dq, \(dqclient\-classes\(dq: [ ], \(dqhostname\(dq: \(dqsomehost.example.org\(dq, \(dqhw\-address\(dq: \(dq01:02:03:04:05:06\(dq, \(dqip\-address\(dq: \(dq192.0.2.100\(dq, \(dqnext\-server\(dq: \(dq192.0.0.2\(dq, \(dqoption\-data\(dq: [ ], \(dqserver\-hostname\(dq: \(dqserver\-hostname.example.org\(dq, \(dqsubnet\-id\(dq: 4 }, \(dqresult\(dq: 0, \(dqtext\(dq: \(dqHost found.\(dq } .EE .UNINDENT .UNINDENT .sp An example result returned when the query was malformed might look like this: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 1, \(dqtext\(dq: \(dqNo \(aqip\-address\(aq provided and \(aqidentifier\-type\(aq is either missing or not a string.\(dq } .EE .UNINDENT .UNINDENT .SS The \fBreservation\-get\-all\fP Command .sp \fI\%reservation\-get\-all\fP can be used to query the host database and retrieve all reservations in a specified subnet. This command uses parameters providing the mandatory \fBsubnet\-id\fP\&. Global host reservations can be retrieved by using a \fBsubnet\-id\fP value of zero (0). .sp For instance, retrieving host reservations for the subnet 1: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqreservation\-get\-all\(dq, \(dqarguments\(dq: { \(dqsubnet\-id\(dq: 1 } } .EE .UNINDENT .UNINDENT .sp returns some IPv4 hosts: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqarguments\(dq: { \(dqhosts\(dq: [ { \(dqboot\-file\-name\(dq: \(dqbootfile.efi\(dq, \(dqclient\-classes\(dq: [ ], \(dqhostname\(dq: \(dqsomehost.example.org\(dq, \(dqhw\-address\(dq: \(dq01:02:03:04:05:06\(dq, \(dqip\-address\(dq: \(dq192.0.2.100\(dq, \(dqnext\-server\(dq: \(dq192.0.0.2\(dq, \(dqoption\-data\(dq: [ ], \(dqserver\-hostname\(dq: \(dqserver\-hostname.example.org\(dq, \(dqsubnet\-id\(dq: 1 }, { \(dqboot\-file\-name\(dq: \(dqbootfile.efi\(dq, \(dqclient\-classes\(dq: [ ], \(dqhostname\(dq: \(dqotherhost.example.org\(dq, \(dqhw\-address\(dq: \(dq01:02:03:04:05:ff\(dq, \(dqip\-address\(dq: \(dq192.0.2.200\(dq, \(dqnext\-server\(dq: \(dq192.0.0.2\(dq, \(dqoption\-data\(dq: [ ], \(dqserver\-hostname\(dq: \(dqserver\-hostname.example.org\(dq, \(dqsubnet\-id\(dq: 1 }, ... ] }, \(dqresult\(dq: 0, \(dqtext\(dq: \(dq72 IPv4 host(s) found.\(dq } .EE .UNINDENT .UNINDENT .sp The response returned by \fI\%reservation\-get\-all\fP can be very long. The DHCP server does not handle DHCP traffic while preparing a response to \fI\%reservation\-get\-all\fP, so if there are many reservations in a subnet, this may be disruptive; use with caution. For larger deployments, please consider using \fI\%reservation\-get\-page\fP instead. .sp The command accepts the \fBoperation\-target\fP argument. By default, it gets the reservation from both the JSON configuration and the hosts database. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqreservation\-get\-all\(dq, \(dqarguments\(dq: { \(dqsubnet\-id\(dq: 1, \(dqoperation\-target\(dq: \(dqdatabase\(dq } } .EE .UNINDENT .UNINDENT .sp For more information, see \fI\%The reservation\-get\-all Command\fP\&. .SS The \fBreservation\-get\-page\fP Command .sp \fI\%reservation\-get\-page\fP can be used to query the host database and retrieve all reservations in a specified subnet, by pages. This command uses parameters providing the mandatory \fBsubnet\-id\fP\&. Use a value of zero (0) to fetch global reservations. The second mandatory parameter is the page size limit. The optional \fBsource\-index\fP and \fBfrom\-host\-id\fP parameters, both of which default to 0, are used to chain page queries. Since Kea version 1.9.0, the \fBsubnet\-id\fP parameter is optional. .sp The usage of the \fBfrom\fP and \fBsource\-index\fP parameters requires additional explanation. For the first call, those parameters should not be specified (or should be specified as zeros). For any follow\-up calls, they should be set to the values returned in previous calls, in a next map holding \fBfrom\fP and \fBsource\-index\fP values. Subsequent calls should be issued until all reservations are returned. The end is reached once the returned list is empty, the count is 0, no next map is present, and result status 3 (empty) is returned. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The \fBfrom\fP and \fBsource\-index\fP parameters reflect the internal state of the search. There is no need to understand what they represent; it is simply a value that should be copied from one response to the next query. However, for those who are curious, the \fBfrom\fP field represents a 64\-bit representation of the host identifier used by a host backend. The \fBsource\-index\fP is an internal representation of multiple host backends: 0 is used to represent hosts defined in a configuration file, and 1 represents the first database backend. In some uncommon cases there may be more than one database backend configured, so potentially there may be a 2. In any case, Kea iterates over all backends configured. .UNINDENT .UNINDENT .sp For instance, retrieving host reservations for the subnet 1 and requesting the first page can be done by: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqreservation\-get\-page\(dq, \(dqarguments\(dq: { \(dqsubnet\-id\(dq: 1, \(dqlimit\(dq: 10 } } .EE .UNINDENT .UNINDENT .sp Since this is the first call, \fBsource\-index\fP and \fBfrom\fP should not be specified. They are set to their zero default values. .sp Some hosts are returned with information to get the next page: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqarguments\(dq: { \(dqcount\(dq: 72, \(dqhosts\(dq: [ { \(dqboot\-file\-name\(dq: \(dqbootfile.efi\(dq, \(dqclient\-classes\(dq: [ ], \(dqhostname\(dq: \(dqsomehost.example.org\(dq, \(dqhw\-address\(dq: \(dq01:02:03:04:05:06\(dq, \(dqip\-address\(dq: \(dq192.0.2.100\(dq, \(dqnext\-server\(dq: \(dq192.0.0.2\(dq, \(dqoption\-data\(dq: [ ], \(dqserver\-hostname\(dq: \(dqserver\-hostname.example.org\(dq }, { \(dqboot\-file\-name\(dq: \(dqbootfile.efi\(dq, \(dqclient\-classes\(dq: [ ], \(dqhostname\(dq: \(dqotherhost.example.org\(dq, \(dqhw\-address\(dq: \(dq01:02:03:04:05:ff\(dq, \(dqip\-address\(dq: \(dq192.0.2.200\(dq, \(dqnext\-server\(dq: \(dq192.0.0.2\(dq, \(dqoption\-data\(dq: [ ], \(dqserver\-hostname\(dq: \(dqserver\-hostname.example.org\(dq }, ... ], \(dqnext\(dq: { \(dqfrom\(dq: 1234567, \(dqsource\-index\(dq: 1 } }, \(dqresult\(dq: 0, \(dqtext\(dq: \(dq72 IPv4 host(s) found.\(dq } .EE .UNINDENT .UNINDENT .sp Note that the \fBfrom\fP and \fBsource\-index\fP fields were specified in the response in the next map. Those two must be copied to the next command, so Kea continues from the place where the last command finished. To get the next page the following command can be sent: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqreservation\-get\-page\(dq, \(dqarguments\(dq: { \(dqsubnet\-id\(dq: 1, \(dqsource\-index\(dq: 1, \(dqfrom\(dq: 1234567, \(dqlimit\(dq: 10 } } .EE .UNINDENT .UNINDENT .sp The response will contain a list of hosts with updated \fBsource\-index\fP and \fBfrom\fP fields. Continue calling the command until the last page is received. Its response will look like this: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqarguments\(dq: { \(dqcount\(dq: 0, \(dqhosts\(dq: [ ] }, \(dqresult\(dq: 3, \(dqtext\(dq: \(dq0 IPv4 host(s) found.\(dq } .EE .UNINDENT .UNINDENT .sp The command does not accept the \fBoperation\-target\fP argument. .sp This command is more complex than \fI\%reservation\-get\-all\fP, but it lets users retrieve larger host reservations lists in smaller chunks. For small deployments with few reservations, it is easier to use \fI\%reservation\-get\-all\fP\&. .SS The \fBreservation\-get\-by\-address\fP Command .sp \fI\%reservation\-get\-by\-address\fP can be used to query the host database and retrieve all reservations for a given IP address or a delegated prefix (without a prefix length), in a specified subnet or in all subnets. This command uses parameters providing the mandatory \fBip\-address\fP and the optional \fBsubnet\-id\fP and \fBoperation\-target\fP\&. .sp For instance, retrieving host reservations for the IPv4 address \(dq192.0.200.181\(dq in the subnet 1: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqreservation\-get\-by\-address\(dq, \(dqarguments\(dq: { \(dqip\-address\(dq: \(dq192.0.200.181\(dq, \(dqsubnet\-id\(dq: 1 }, \(dqservice\(dq: [ \(dqdhcp4\(dq ] } .EE .UNINDENT .UNINDENT .sp can return two IPv4 hosts: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqarguments\(dq: { \(dqhosts\(dq: [ { \(dqboot\-file\-name\(dq: \(dq\(dq, \(dqclient\-classes\(dq: [], \(dqhostname\(dq: \(dq\(dq, \(dqhw\-address\(dq: \(dq99:99:99:99:99:01\(dq, \(dqip\-address\(dq: \(dq192.0.200.181\(dq, \(dqnext\-server\(dq: \(dq0.0.0.0\(dq, \(dqoption\-data\(dq: [], \(dqserver\-hostname\(dq: \(dq\(dq, \(dqsubnet\-id\(dq: 1 }, { \(dqboot\-file\-name\(dq: \(dq\(dq, \(dqcircuit\-id\(dq: \(dq1234\(dq, \(dqclient\-classes\(dq: [], \(dqhostname\(dq: \(dq\(dq, \(dqip\-address\(dq: \(dq192.0.200.181\(dq, \(dqnext\-server\(dq: \(dq0.0.0.0\(dq, \(dqoption\-data\(dq: [], \(dqserver\-hostname\(dq: \(dq\(dq, \(dqsubnet\-id\(dq: 1 } ] }, \(dqresult\(dq: 0, \(dqtext\(dq: \(dq2 IPv4 host(s) found.\(dq } .EE .UNINDENT .UNINDENT .sp To search for all reservations in all subnets, simply skip the \fBsubnet\-id\fP parameter: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqreservation\-get\-by\-address\(dq, \(dqarguments\(dq: { \(dqip\-address\(dq: \(dq192.0.200.181\(dq }, \(dqservice\(dq: [ \(dqdhcp4\(dq ] } .EE .UNINDENT .UNINDENT .sp An example response could be: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqarguments\(dq: { \(dqhosts\(dq: [ { \(dqboot\-file\-name\(dq: \(dq\(dq, \(dqclient\-classes\(dq: [], \(dqhostname\(dq: \(dq\(dq, \(dqhw\-address\(dq: \(dq99:99:99:99:99:01\(dq, \(dqip\-address\(dq: \(dq192.0.200.181\(dq, \(dqnext\-server\(dq: \(dq0.0.0.0\(dq, \(dqoption\-data\(dq: [], \(dqserver\-hostname\(dq: \(dq\(dq, \(dqsubnet\-id\(dq: 1 }, { \(dqboot\-file\-name\(dq: \(dq\(dq, \(dqcircuit\-id\(dq: \(dq1234\(dq, \(dqclient\-classes\(dq: [], \(dqhostname\(dq: \(dq\(dq, \(dqip\-address\(dq: \(dq192.0.200.181\(dq, \(dqnext\-server\(dq: \(dq0.0.0.0\(dq, \(dqoption\-data\(dq: [], \(dqserver\-hostname\(dq: \(dq\(dq, \(dqsubnet\-id\(dq: 1 }, { \(dqboot\-file\-name\(dq: \(dq\(dq, \(dqclient\-classes\(dq: [], \(dqhostname\(dq: \(dq\(dq, \(dqhw\-address\(dq: \(dq99:99:99:99:99:02\(dq, \(dqip\-address\(dq: \(dq192.0.200.181\(dq, \(dqnext\-server\(dq: \(dq0.0.0.0\(dq, \(dqoption\-data\(dq: [], \(dqserver\-hostname\(dq: \(dq\(dq, \(dqsubnet\-id\(dq: 0 }, { \(dqboot\-file\-name\(dq: \(dq\(dq, \(dqclient\-classes\(dq: [], \(dqhostname\(dq: \(dq\(dq, \(dqhw\-address\(dq: \(dq99:99:99:99:99:03\(dq, \(dqip\-address\(dq: \(dq192.0.200.181\(dq, \(dqnext\-server\(dq: \(dq0.0.0.0\(dq, \(dqoption\-data\(dq: [], \(dqserver\-hostname\(dq: \(dq\(dq, \(dqsubnet\-id\(dq: 2 } ] }, \(dqresult\(dq: 0, \(dqtext\(dq: \(dq4 IPv4 host(s) found.\(dq } .EE .UNINDENT .UNINDENT .sp When using the command for retrieving DHCP6 host reservations, one can provide either an IPv6 address or a delegated prefix as the \fBip\-address\fP parameter. Please notice that this command does not take prefix length as a parameter in the current implementation. Thus, searching by an IP address \fB2001:db8:2:cafe::\fP can return host reservations with delegated prefixes of different lengths matching this search. For example: \fB2001:db8:2:cafe::/63\fP, \fB2001:db8:2:cafe::/64\fP, etc. Please consider the example below: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqreservation\-get\-by\-address\(dq, \(dqarguments\(dq: { \(dqip\-address\(dq: \(dq2001:db8:2:cafa::\(dq }, \(dqservice\(dq: [ \(dqdhcp6\(dq ] } .EE .UNINDENT .UNINDENT .sp Response: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqarguments\(dq: { \(dqhosts\(dq: [ { \(dqclient\-classes\(dq: [], \(dqduid\(dq: \(dq01:02:03:04:05:06:07:88:98:fa\(dq, \(dqhostname\(dq: \(dqfoo.example.com\(dq, \(dqip\-addresses\(dq: [ \(dq2001:db8:1:cafe::2\(dq ], \(dqoption\-data\(dq: [], \(dqprefixes\(dq: [ \(dq2001:db8:2:abcd::/64\(dq, \(dq2001:db8:2:cafa::/63\(dq ], \(dqsubnet\-id\(dq: 8 }, { \(dqclient\-classes\(dq: [], \(dqduid\(dq: \(dq01:02:03:04:05:06:07:88:98:fb\(dq, \(dqhostname\(dq: \(dqfoo.example.com\(dq, \(dqip\-addresses\(dq: [ \(dq2001:db8:1:cafe::2\(dq ], \(dqoption\-data\(dq: [], \(dqprefixes\(dq: [ \(dq2001:db8:2:abcd::/64\(dq, \(dq2001:db8:2:cafa::/64\(dq ], \(dqsubnet\-id\(dq: 8 } ] }, \(dqresult\(dq: 0, \(dqtext\(dq: \(dq2 IPv6 host(s) found.\(dq } .EE .UNINDENT .UNINDENT .sp The command accepts the \fBoperation\-target\fP argument. By default, it gets the reservation from both the JSON configuration and the hosts database. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqreservation\-get\-by\-address\(dq, \(dqarguments\(dq: { \(dqip\-address\(dq: \(dq192.0.200.181\(dq, \(dqsubnet\-id\(dq: 1, \(dqoperation\-target\(dq: \(dqdatabase\(dq }, \(dqservice\(dq: [ \(dqdhcp4\(dq ] } .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 This command is useful in specific cases. By default, having more than one host reservation for the same IP address in a given subnet is not allowed, as explained in \fI\%Multiple Reservations for the Same IPv4\fP or \fI\%Multiple Reservations for the Same IPv6\fP\&. That\(aqs why this command comes in handy when the \fBip\-reservations\-unique\fP boolean parameter is set to \fBfalse\fP\&. Another use case of this command is having overlapping subnets with the same IP address reservations (but with different identifiers) in different subnets. .UNINDENT .UNINDENT .SS The \fBreservation\-get\-by\-hostname\fP Command .sp \fI\%reservation\-get\-by\-hostname\fP can be used to query the host database and retrieve all reservations with a specified hostname or in a specified subnet. This command uses parameters providing the mandatory \fBhostname\fP and the optional \fBsubnet\-id\fP\&. Global host reservations can be retrieved by using a \fBsubnet\-id\fP value of zero (0). Hostname matching is case\-insensitive. .sp For instance, retrieving host reservations for \(dqfoobar\(dq in the subnet 1: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqreservation\-get\-by\-hostname\(dq, \(dqarguments\(dq: { \(dqhostname\(dq: \(dqfoobar.example.org\(dq, \(dqsubnet\-id\(dq: 1 } } .EE .UNINDENT .UNINDENT .sp returns some IPv4 hosts: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqarguments\(dq: { \(dqhosts\(dq: [ { \(dqboot\-file\-name\(dq: \(dqbootfile.efi\(dq, \(dqclient\-classes\(dq: [ ], \(dqhostname\(dq: \(dqfoobar.example.org\(dq, \(dqhw\-address\(dq: \(dq01:02:03:04:05:06\(dq, \(dqip\-address\(dq: \(dq192.0.2.100\(dq, \(dqnext\-server\(dq: \(dq192.0.0.2\(dq, \(dqoption\-data\(dq: [ ], \(dqserver\-hostname\(dq: \(dqserver\-hostname.example.org\(dq }, { \(dqboot\-file\-name\(dq: \(dqbootfile.efi\(dq, \(dqclient\-classes\(dq: [ ], \(dqhostname\(dq: \(dqfoobar.example.org\(dq, \(dqhw\-address\(dq: \(dq01:02:03:04:05:ff\(dq, \(dqip\-address\(dq: \(dq192.0.2.200\(dq, \(dqnext\-server\(dq: \(dq192.0.0.2\(dq, \(dqoption\-data\(dq: [ ], \(dqserver\-hostname\(dq: \(dqserver\-hostname.example.org\(dq }, ... ] }, \(dqresult\(dq: 0, \(dqtext\(dq: \(dq5 IPv4 host(s) found.\(dq } .EE .UNINDENT .UNINDENT .sp The response returned by \fI\%reservation\-get\-by\-hostname\fP can be long, particularly when responses are not limited to a subnet. .sp The command accepts the \fBoperation\-target\fP argument. By default, it gets the reservation from both the JSON configuration and the hosts database. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqreservation\-get\-by\-hostname\(dq, \(dqarguments\(dq: { \(dqhostname\(dq: \(dqfoobar.example.org\(dq, \(dqsubnet\-id\(dq: 1, \(dqoperation\-target\(dq: \(dqdatabase\(dq } } .EE .UNINDENT .UNINDENT .sp For more information, see \fI\%The reservation\-get\-by\-hostname Command\fP\&. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 When using MySQL as the host backend, this command relies on the fact that the hostname column in the hosts table uses a case\-insensitive collation, as explained in the \fI\%MySQL\fP section of \fI\%Kea Database Administration\fP\&. .UNINDENT .UNINDENT .SS The \fBreservation\-get\-by\-id\fP Command .sp \fI\%reservation\-get\-by\-id\fP can be used to query the host database and retrieve all reservations with a specified identifier (\fBidentifier\-type\fP and \fBidentifier\fP parameters), independently of subnets. The syntax for parameters is the same as for \fI\%reservation\-get\fP\&. The \fBsubnet\-id\fP parameter cannot be used, to avoid confusion. This command is available since Kea version 1.9.0. .sp For instance, retrieving host reservations for the 01:02:03:04:05:06 MAC address: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqreservation\-get\-by\-id\(dq, \(dqarguments\(dq: { \(dqidentifier\-type\(dq: \(dqhw\-address\(dq, \(dqidentifier\(dq: \(dq01:02:03:04:05:06\(dq } } .EE .UNINDENT .UNINDENT .sp returns some IPv4 hosts: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqarguments\(dq: { \(dqhosts\(dq: [ { \(dqboot\-file\-name\(dq: \(dqbootfile.efi\(dq, \(dqclient\-classes\(dq: [ ], \(dqhostname\(dq: \(dqfoo.example.org\(dq, \(dqhw\-address\(dq: \(dq01:02:03:04:05:06\(dq, \(dqip\-address\(dq: \(dq192.0.2.100\(dq, \(dqnext\-server\(dq: \(dq192.0.0.2\(dq, \(dqoption\-data\(dq: [ ], \(dqserver\-hostname\(dq: \(dqserver\-hostname.example.org\(dq, \(dqsubnet\-id\(dq: 123 }, { \(dqboot\-file\-name\(dq: \(dqbootfile.efi\(dq, \(dqclient\-classes\(dq: [ ], \(dqhostname\(dq: \(dqbar.example.org\(dq, \(dqhw\-address\(dq: \(dq01:02:03:04:05:06\(dq, \(dqip\-address\(dq: \(dq192.0.2.200\(dq, \(dqnext\-server\(dq: \(dq192.0.0.2\(dq, \(dqoption\-data\(dq: [ ], \(dqserver\-hostname\(dq: \(dqserver\-hostname.example.org\(dq, \(dqsubnet\-id\(dq: 345 }, ... ] }, \(dqresult\(dq: 0, \(dqtext\(dq: \(dq5 IPv4 host(s) found.\(dq } .EE .UNINDENT .UNINDENT .sp The response returned by \fI\%reservation\-get\-by\-id\fP can be long, particularly when responses are not limited to a subnet. .sp The command accepts the \fBoperation\-target\fP argument. By default, it gets the reservation from both the JSON configuration and the hosts database. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqreservation\-get\-by\-id\(dq, \(dqarguments\(dq: { \(dqidentifier\-type\(dq: \(dqhw\-address\(dq, \(dqidentifier\(dq: \(dq01:02:03:04:05:06\(dq, \(dqoperation\-target\(dq: \(dqdatabase\(dq } } .EE .UNINDENT .UNINDENT .sp For more information, see \fI\%The reservation\-get\-by\-id Command\fP\&. .SS The \fBreservation\-del\fP Command .sp \fI\%reservation\-del\fP can be used to delete a reservation from the host database and/or JSON configuration. This command supports two types of parameters: (\fBsubnet\-id\fP, \fBaddress\fP) or (\fBsubnet\-id\fP, \fBidentifier\-type\fP, \fBidentifier\fP). The first type of query is used when the address (either IPv4 or IPv6) is known, but the details of the reservation are not. One common use for this type of query is to remove a reservation (e.g. a specific address should no longer be reserved). The second query uses identifiers. For maximum flexibility, Kea stores the host identifying information as a pair of values: the type and the actual identifier. Currently supported identifiers are \fB\(dqhw\-address\(dq\fP, \fB\(dqduid\(dq\fP, \fB\(dqcircuit\-id\(dq\fP, \fB\(dqclient\-id\(dq\fP, and \fB\(dqflex\-id\(dq\fP\&. The \fBsubnet\-id\fP is mandatory. Use a value of zero (0) to delete a global reservation, or the ID of the subnet from which the reservation should be deleted. .sp An example command for deleting a host reservation by (\fBsubnet\-id\fP, \fBaddress\fP) pair looks as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqreservation\-del\(dq, \(dqarguments\(dq: { \(dqsubnet\-id\(dq: 1, \(dqip\-address\(dq: \(dq192.0.2.202\(dq } } .EE .UNINDENT .UNINDENT .sp An example deletion by (\fBsubnet\-id\fP, \fBidentifier\-type\fP, \fBidentifier\fP) looks as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqreservation\-del\(dq, \(dqarguments\(dq: { \(dqsubnet\-id\(dq: 4, \(dqidentifier\-type\(dq: \(dqhw\-address\(dq, \(dqidentifier\(dq: \(dq01:02:03:04:05:06\(dq } } .EE .UNINDENT .UNINDENT .sp Command \fI\%reservation\-del\fP returns a result of 0 when the host deletion was successful, or 1 if it failed. Descriptive text is provided in the event of an error. Here are some examples of possible results: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 1, \(dqtext\(dq: \(dqHost not deleted (not found).\(dq } .EE .UNINDENT .UNINDENT .sp or .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dqHost deleted.\(dq } .EE .UNINDENT .UNINDENT .sp or .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 1, \(dqtext\(dq: \(dqUnable to delete a host because there is no hosts\-database configured.\(dq } .EE .UNINDENT .UNINDENT .sp The command accepts the \fBoperation\-target\fP argument. By default, it removes the reservation from the hosts database only. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqreservation\-del\(dq, \(dqarguments\(dq: { \(dqsubnet\-id\(dq: 4, \(dqidentifier\-type\(dq: \(dqhw\-address\(dq, \(dqidentifier\(dq: \(dq01:02:03:04:05:06\(dq, \(dqoperation\-target\(dq: \(dqmemory\(dq } } .EE .UNINDENT .UNINDENT .SS The \fBreservation\-update\fP Command .sp \fI\%reservation\-update\fP allows for the update of an existing host. It takes the same set of arguments as \fI\%reservation\-add\fP, and also requires a host identifier and a subnet ID to identify the host that is being updated. The command can be as simple as having only the two mandatory entries: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqreservation\-update\(dq, \(dqarguments\(dq: { \(dqreservation\(dq: { \(dqsubnet\-id\(dq: 1, \(dqhw\-address\(dq: \(dq1a:1b:1c:1d:1e:1f\(dq } } } .EE .UNINDENT .UNINDENT .sp In that case, however, it does not assign any resources to the host. An IPv4 address can be assigned as in this example: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqreservation\-update\(dq, \(dqarguments\(dq: { \(dqreservation\(dq: { \(dqsubnet\-id\(dq: 1, \(dqhw\-address\(dq: \(dq1a:1b:1c:1d:1e:1f\(dq, \(dqip\-address\(dq: \(dq192.0.2.202\(dq } } } .EE .UNINDENT .UNINDENT .sp It can also take many more parameters, such as: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqreservation\-update\(dq, \(dqarguments\(dq: { \(dqreservation\(dq: { \(dqsubnet\-id\(dq: 1, \(dqclient\-id\(dq: \(dq01:0a:0b:0c:0d:0e:0f\(dq, \(dqip\-address\(dq: \(dq192.0.2.205\(dq, \(dqnext\-server\(dq: \(dq192.0.2.1\(dq, \(dqserver\-hostname\(dq: \(dqhal9000\(dq, \(dqboot\-file\-name\(dq: \(dq/dev/null\(dq, \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqdomain\-name\-servers\(dq, \(dqdata\(dq: \(dq10.1.1.202,10.1.1.203\(dq } ], \(dqclient\-classes\(dq: [ \(dqoffice\(dq, \(dqspecial_snowflake\(dq ] } } } .EE .UNINDENT .UNINDENT .sp Here is an example of a complex IPv6 reservation update: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqreservation\-update\(dq, \(dqarguments\(dq: { \(dqreservation\(dq: { \(dqsubnet\-id\(dq: 1, \(dqduid\(dq: \(dq01:02:03:04:05:06:07:08:09:0A\(dq, \(dqip\-addresses\(dq: [ \(dq2001:db8:1:cafe::1\(dq ], \(dqprefixes\(dq: [ \(dq2001:db8:2:abcd::/64\(dq ], \(dqhostname\(dq: \(dqfoo.example.com\(dq, \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqvendor\-opts\(dq, \(dqdata\(dq: \(dq4491\(dq }, { \(dqname\(dq: \(dqtftp\-servers\(dq, \(dqspace\(dq: \(dqvendor\-4491\(dq, \(dqdata\(dq: \(dq3000:1::234\(dq } ] } } } .EE .UNINDENT .UNINDENT .sp The command returns a status that indicates either success (result \fB0\fP) or failure (result \fB1\fP), and a text parameter that confirms success or explains the cause of the failure. Here\(aqs an example of a successful update: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dqHost updated.\(dq } .EE .UNINDENT .UNINDENT .sp And here\(aqs an example of a failure: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 1, \(dqtext\(dq: \(dqMandatory \(aqsubnet\-id\(aq parameter missing.\(dq } .EE .UNINDENT .UNINDENT .sp The command accepts the \fBoperation\-target\fP argument. By default, it adds the reservation to the hosts database only. As \fI\%reservation\-update\fP is expected to store the host, the \fBhosts\-databases\fP parameter must be specified in the configuration, and databases must not run in read\-only mode if the operation target is not the JSON configuration. .sp As with other update and set commands, this command overwrites all the contents of the entry. If the host previously had a resource assigned to it, and the \fI\%reservation\-update\fP command is missing the resource, it is deleted from the database. If an incremental update of the host is desired, this can be achieved by issuing a \fI\%reservation\-get\-by\-id\fP to get the current state of the host, selecting the host from the response, modifying it to the required outcome, and then issuing the \fI\%reservation\-update\fP command with the resulting host attached. .SS General Mentions .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The host backends for the host cache and RADIUS hook libraries do not respond to commands that return a collection of host reservations, such as \fI\%reservation\-get\-all\fP\&. Commands returning one host entry or dedicated host cache commands should be used instead. .UNINDENT .UNINDENT .SS \fBlibdhcp_lease_cmds.so\fP: Lease Commands for Easier Lease Management .sp Kea allows users to store lease information in several backends (memfile, MySQL, and PostgreSQL), and the Lease Commands library provides an interface that can manipulate leases in a unified, safe way. In particular, it allows things that were previously impossible: lease manipulation in memfile while Kea is running, sanity check changes, lease existence checks, and removal of all leases belonging to a specific subnet. The hook library can also catch more obscure errors, like an attempt to add a lease with a \fBsubnet\-id\fP that does not exist in the configuration, or configuring a lease to use an address that is outside of the subnet to which it is supposed to belong. The library also provides a non\-programmatic way to manage user contexts associated with leases. .sp As of Kea 2.7.7, the library also provides support for \fBbinding\-variables\fP\&. Binding variables allow the user to store custom values for each lease. They are discussed here: \fI\%Binding Variables\fP\&. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 \fI\%libdhcp_lease_cmds.so\fP is part of the open source code and is available to every Kea user. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 This library can only be loaded by the \fI\%kea\-dhcp4\fP or the \fI\%kea\-dhcp6\fP process. .UNINDENT .UNINDENT .sp There are many situations where an administrative command may be useful; for example, during migration between servers or different vendors, when a certain network is being retired, or when a device has been disconnected and the system administrator knows that it will not be coming back. The \fBget\fP queries may be useful for automating certain management and monitoring tasks, and they can also act as preparatory steps for lease updates and removals. .sp This library provides the following commands: .INDENT 0.0 .IP \(bu 2 \fI\%lease4\-add\fP \- adds a new IPv4 lease. .IP \(bu 2 \fI\%lease6\-add\fP \- adds a new IPv6 lease. .IP \(bu 2 \fI\%lease6\-bulk\-apply\fP \- creates, updates, and/or deletes multiple IPv6 leases in a single transaction. .IP \(bu 2 \fI\%lease4\-get\fP \- checks whether an IPv4 lease with the specified parameters exists and returns it if it does. .IP \(bu 2 \fI\%lease6\-get\fP \- checks whether an IPv6 lease with the specified parameters exists and returns it if it does. .IP \(bu 2 \fI\%lease4\-get\-all\fP \- returns all IPv4 leases or all IPv4 leases for the specified subnets. .IP \(bu 2 \fI\%lease6\-get\-all\fP \- returns all IPv6 leases or all IPv6 leases for the specified subnets. .IP \(bu 2 \fI\%lease4\-get\-page\fP \- returns a set (\(dqpage\(dq) of leases from the list of all IPv4 leases in the database. By iterating through the pages it is possible to retrieve all the leases. .IP \(bu 2 \fI\%lease6\-get\-page\fP \- returns a set (\(dqpage\(dq) of leases from the list of all IPv6 leases in the database. By iterating through the pages it is possible to retrieve all the leases. .IP \(bu 2 \fI\%lease4\-get\-by\-hw\-address\fP \- returns all IPv4 leases with the specified hardware address. .IP \(bu 2 \fI\%lease4\-get\-by\-client\-id\fP \- returns all IPv4 leases with the specified \fBclient\-id\fP\&. .IP \(bu 2 \fI\%lease6\-get\-by\-duid\fP \- returns all IPv6 leases with the specified DUID. .IP \(bu 2 \fI\%lease4\-get\-by\-hostname\fP \- returns all IPv4 leases with the specified hostname. .IP \(bu 2 \fI\%lease6\-get\-by\-hostname\fP \- returns all IPv6 leases with the specified hostname. .IP \(bu 2 \fI\%lease4\-del\fP \- deletes an IPv4 lease with the specified parameters. .IP \(bu 2 \fI\%lease6\-del\fP \- deletes an IPv6 lease with the specified parameters. .IP \(bu 2 \fI\%lease4\-update\fP \- updates (replaces) an existing IPv4 lease. .IP \(bu 2 \fI\%lease6\-update\fP \- updates (replaces) an existing IPv6 lease. .IP \(bu 2 \fI\%lease4\-wipe\fP \- removes all leases from a specific IPv4 subnet or from all subnets. .IP \(bu 2 \fI\%lease6\-wipe\fP \- removes all leases from a specific IPv6 subnet or from all subnets. .IP \(bu 2 \fI\%lease4\-resend\-ddns\fP \- resends a request to update DNS entries for an existing lease. .IP \(bu 2 \fI\%lease6\-resend\-ddns\fP \- resends a request to update DNS entries for an existing lease. .IP \(bu 2 \fI\%lease4\-write\fP \- writes the IPv4 memfile lease database into a file. .IP \(bu 2 \fI\%lease6\-write\fP \- writes the IPv6 memfile lease database into a file. .UNINDENT .sp All commands use JSON syntax and can be issued either using the control channel (see \fI\%Management API\fP) or Control Agent (see \fI\%The Kea Control Agent\fP). .sp The library can be loaded in the same way as other hook libraries, and it does not take any parameters. It supports both the DHCPv4 and DHCPv6 servers. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dq/path/libdhcp_lease_cmds.so\(dq }, ... ] } .EE .UNINDENT .UNINDENT .SS The \fBlease4\-add\fP, \fBlease6\-add\fP Commands .sp The \fI\%lease4\-add\fP and \fI\%lease6\-add\fP commands allow a new lease to be created. Typically Kea creates a lease when it first sees a new device; however, sometimes it may be convenient to create the lease manually. The \fI\%lease4\-add\fP command requires at least two parameters: an IPv4 address and an identifier, i.e. hardware (MAC) address. A third parameter, \fBsubnet\-id\fP, is optional. If the \fBsubnet\-id\fP is not specified or the specified value is 0, Kea tries to determine the value by running a subnet\-selection procedure. If specified, however, its value must match the existing subnet. The simplest successful call might look as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqlease4\-add\(dq, \(dqarguments\(dq: { \(dqip\-address\(dq: \(dq192.0.2.202\(dq, \(dqhw\-address\(dq: \(dq1a:1b:1c:1d:1e:1f\(dq } } .EE .UNINDENT .UNINDENT .sp The \fI\%lease6\-add\fP command requires three parameters: an IPv6 address, an IAID value (identity association identifier, a value sent by clients), and a DUID. As with \fI\%lease4\-add\fP, the \fBsubnet\-id\fP parameter is optional. If the \fBsubnet\-id\fP is not specified or the provided value is 0, Kea tries to determine the value by running a subnet\-selection procedure. If specified, however, its value must match the existing subnet. For example: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqlease6\-add\(dq, \(dqarguments\(dq: { \(dqsubnet\-id\(dq: 66, \(dqip\-address\(dq: \(dq2001:db8::3\(dq, \(dqduid\(dq: \(dq1a:1b:1c:1d:1e:1f:20:21:22:23:24\(dq, \(dqiaid\(dq: 1234 } } .EE .UNINDENT .UNINDENT .sp The \fI\%lease6\-add\fP command can also be used to add leases for IPv6 prefixes. In this case there are three additional parameters that must be specified: \fBsubnet\-id\fP, \fBtype\fP (set to \(dqIA_PD\(dq), and prefix length. The actual prefix is set using the \fBip\-address\fP field. Note that Kea cannot guess \fBsubnet\-id\fP values for prefixes; they must be specified explicitly. For example, to configure a lease for prefix 2001:db8:abcd::/48, the following command can be used: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqlease6\-add\(dq, \(dqarguments\(dq: { \(dqsubnet\-id\(dq: 66, \(dqtype\(dq: \(dqIA_PD\(dq, \(dqip\-address\(dq: \(dq2001:db8:abcd::\(dq, \(dqprefix\-len\(dq: 48, \(dqduid\(dq: \(dq1a:1b:1c:1d:1e:1f:20:21:22:23:24\(dq, \(dqiaid\(dq: 1234 } } .EE .UNINDENT .UNINDENT .sp The commands can take several additional optional parameters: .INDENT 0.0 .IP \(bu 2 \fBvalid\-lft\fP \- specifies the lifetime of the lease, expressed in seconds. If not specified, the value configured in the subnet related to the specified \fBsubnet\-id\fP is used. .IP \(bu 2 \fBexpire\fP \- creates a timestamp of the lease expiration time, expressed in UNIX format (seconds since 1 Jan 1970). If not specified, the default value is the current time plus the lease lifetime (the value of \fBvalid\-lft\fP). .IP \(bu 2 \fBfqdn\-fwd\fP \- specifies whether the lease should be marked as if a forward DNS update were conducted. This only affects the data stored in the lease database, and no DNS update will be performed. If configured, a DNS update to remove the A or AAAA records will be conducted when the lease is removed due to expiration or being released by a client. If not specified, the default value is \fBfalse\fP\&. The hostname parameter must be specified if \fBfqdn\-fwd\fP is set to \fBtrue\fP\&. .IP \(bu 2 \fBfqdn\-rev\fP \- specifies whether the lease should be marked as if reverse DNS update were conducted. This only affects the data stored in the lease database, and no DNS update will be performed.. If configured, a DNS update to remove the PTR record will be conducted when the lease is removed due to expiration or being released by a client. If not specified, the default value is \fBfalse\fP\&. The hostname parameter must be specified if \fBfqdn\-fwd\fP is set to \fBtrue\fP\&. .IP \(bu 2 \fBhostname\fP \- specifies the hostname to be associated with this lease. Its value must be non\-empty if either \fBfqdn\-fwd\fP or \fBfqdn\-rev\fP are set to \fBtrue\fP\&. If not specified, the default value is an empty string. .IP \(bu 2 \fBhw\-address\fP \- optionally specifies a hardware (MAC) address for an IPv6 lease. It is a mandatory parameter for an IPv4 lease. .IP \(bu 2 \fBclient\-id\fP \- optionally specifies a client identifier for an IPv4 lease. .IP \(bu 2 \fBpreferred\-lft\fP \- optionally specifies a preferred lifetime for IPv6 leases. If not specified, the value configured for the subnet corresponding to the specified \fBsubnet\-id\fP is used. This parameter is not used when adding an IPv4 lease. .IP \(bu 2 \fBstate\fP \- specifies the state of an added lease, which can be 0 for \fBdefault\fP, 1 for \fBdeclined\fP, 2 for \fBexpired\-reclaimed\fP, and 3 for the \fBreleased\fP state. Any other value causes an error. Using 1 for a \fB\(dqIA_PD\(dq\fP lease type is illegal and will be rejected. .IP \(bu 2 \fBuser\-context\fP \- specifies the user context to be associated with this lease. It must be a JSON map. .UNINDENT .sp Here is an example of a fairly complex lease addition: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqlease6\-add\(dq, \(dqarguments\(dq: { \(dqsubnet\-id\(dq: 66, \(dqip\-address\(dq: \(dq2001:db8::3\(dq, \(dqduid\(dq: \(dq01:02:03:04:05:06:07:08\(dq, \(dqiaid\(dq: 1234, \(dqhw\-address\(dq: \(dq1a:1b:1c:1d:1e:1f\(dq, \(dqpreferred\-lft\(dq: 500, \(dqvalid\-lft\(dq: 1000, \(dqexpire\(dq: 12345678, \(dqfqdn\-fwd\(dq: true, \(dqfqdn\-rev\(dq: true, \(dqstate\(dq: 0, \(dqhostname\(dq: \(dqurania.example.org\(dq, \(dquser\-context\(dq: { \(dqversion\(dq: 1 } } } .EE .UNINDENT .UNINDENT .sp The command returns a status that indicates either success (result 0) or failure (result 1). A failed command always includes a text parameter that explains the cause of failure. For example: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dqLease added.\(dq } .EE .UNINDENT .UNINDENT .sp Example failure: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 1, \(dqtext\(dq: \(dqmissing parameter \(aqip\-address\(aq (:3:19)\(dq } .EE .UNINDENT .UNINDENT .SS The \fBlease6\-bulk\-apply\fP Command .sp The \fI\%lease6\-bulk\-apply\fP was implemented to address the performance penalty in High\-Availability mode when a single DHCPv6 transaction resulted in multiple lease updates sent to the partner, if multiple address and/or prefix leases were allocated. Consider the case when a DHCPv6 client requests the assignment of two IPv6 addresses and two IPv6 prefixes: it may result in the allocation of four leases. In addition, DHCPv6 may assign a different address than the one requested by the client during the renew or rebind stage, and delete the leases previously used by this client. There are six lease changes sent between the HA partners in this case. Sending these updates as individual commands, e.g. via \fI\%lease6\-update\fP, is highly inefficient and produces unnecessary delays in communication, both between the HA partners and in sending the response to the DHCPv6 client. .sp The \fI\%lease6\-bulk\-apply\fP command deals with this problem by aggregating all lease changes \- both deleted leases and new or updated leases \- in a single command. The receiving server iterates over the deleted leases and deletes them from its lease database. Next, it iterates over the new/updated leases and adds them to the database or updates them if they already exist. .sp Even though High Availability is the major application for this command, it can be freely used in all cases when it is desirable to send multiple lease changes in a single command. .sp In the following example, we delete two leases and add or update two other leases in the database: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqlease6\-bulk\-apply\(dq, \(dqarguments\(dq: { \(dqdeleted\-leases\(dq: [ { \(dqip\-address\(dq: \(dq2001:db8:abcd::\(dq, \(dqtype\(dq: \(dqIA_PD\(dq, ... }, { \(dqip\-address\(dq: \(dq2001:db8:abcd::234\(dq, \(dqtype\(dq: \(dqIA_NA\(dq, ... } ], \(dqleases\(dq: [ { \(dqsubnet\-id\(dq: 66, \(dqip\-address\(dq: \(dq2001:db8:cafe::\(dq, \(dqtype\(dq: \(dqIA_PD\(dq, ... }, { \(dqsubnet\-id\(dq: 66, \(dqip\-address\(dq: \(dq2001:db8:abcd::333\(dq, \(dqtype\(dq: \(dqIA_NA\(dq, ... } ] } } .EE .UNINDENT .UNINDENT .sp If any of the leases are malformed, no lease changes are applied to the lease database. If the leases are well\-formed but there is a failure to apply any of the lease changes to the database, the command continues to be processed for other leases. All the leases for which the command was unable to apply the changes in the database are listed in the response. For example: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dqBulk apply of 2 IPv6 leases completed\(dq, \(dqarguments\(dq: { \(dqfailed\-deleted\-leases\(dq: [ { \(dqip\-address\(dq: \(dq2001:db8:abcd::\(dq, \(dqtype\(dq: \(dqIA_PD\(dq, \(dqresult\(dq: 3, \(dqerror\-message\(dq: \(dqno lease found\(dq } ], \(dqfailed\-leases\(dq: [ { \(dqip\-address\(dq: \(dq2001:db8:cafe::\(dq, \(dqtype\(dq: \(dqIA_PD\(dq, \(dqresult\(dq: 1, \(dqerror\-message\(dq: \(dqunable to communicate with the lease database\(dq } ] } } .EE .UNINDENT .UNINDENT .sp The response above indicates that the hook library was unable to delete the lease for prefix \(dq2001:db8:abcd::\(dq and add or update the lease for prefix \(dq2001:db8:cafe::\(dq. However, there are two other lease changes which have been applied as indicated by the text message. The \fBresult\fP is the status constant that indicates the type of the error experienced for the particular lease. The meanings of the returned codes are the same as the results returned for the commands. In particular, the result of 1 indicates an error while processing the lease, e.g. a communication error with the database. The result of 3 indicates that an attempt to delete the lease was unsuccessful because such a lease doesn\(aqt exist (an empty result). .SS The \fBlease4\-get\fP, \fBlease6\-get\fP Commands .sp \fI\%lease4\-get\fP and \fI\%lease6\-get\fP can be used to query the lease database and retrieve existing leases. There are two types of parameters the \fI\%lease4\-get\fP command supports: (\fBaddress\fP) or (\fBsubnet\-id\fP, \fBidentifier\-type\fP, \fBidentifier\fP). There are also two types for \fI\%lease6\-get\fP: (\fBaddress\fP, \fBtype\fP) or (\fBsubnet\-id\fP, \fBidentifier\-type\fP, \fBidentifier\fP, \fBIAID\fP, \fBtype\fP). The first type of query is used when the address (either IPv4 or IPv6) is known, but the details of the lease are not; one common use case of this type of query is to find out whether a given address is being used. The second query uses identifiers; currently supported identifiers for leases are: \fB\(dqhw\-address\(dq\fP (IPv4 only), \fB\(dqclient\-id\(dq\fP (IPv4 only), and \fB\(dqduid\(dq\fP (IPv6 only). .sp An example \fI\%lease4\-get\fP command for getting a lease using an IPv4 address is: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqlease4\-get\(dq, \(dqarguments\(dq: { \(dqip\-address\(dq: \(dq192.0.2.1\(dq } } .EE .UNINDENT .UNINDENT .sp An example of the \fI\%lease6\-get\fP query is: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqlease6\-get\(dq, \(dqarguments\(dq: { \(dqip\-address\(dq: \(dq2001:db8:1234:ab::\(dq, \(dqtype\(dq: \(dqIA_PD\(dq } } .EE .UNINDENT .UNINDENT .sp An example query by \fB\(dqhw\-address\(dq\fP for an IPv4 lease looks as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqlease4\-get\(dq, \(dqarguments\(dq: { \(dqidentifier\-type\(dq: \(dqhw\-address\(dq, \(dqidentifier\(dq: \(dq08:08:08:08:08:08\(dq, \(dqsubnet\-id\(dq: 44 } } .EE .UNINDENT .UNINDENT .sp An example query by \fB\(dqclient\-id\(dq\fP for an IPv4 lease looks as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqlease4\-get\(dq, \(dqarguments\(dq: { \(dqidentifier\-type\(dq: \(dqclient\-id\(dq, \(dqidentifier\(dq: \(dq01:01:02:03:04:05:06\(dq, \(dqsubnet\-id\(dq: 44 } } .EE .UNINDENT .UNINDENT .sp An example query by (\fBsubnet\-id\fP, \fBidentifier\-type\fP, \fBidentifier\fP, \fBiaid\fP, \fBtype\fP) for an IPv6 lease is: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqlease6\-get\(dq, \(dqarguments\(dq: { \(dqidentifier\-type\(dq: \(dqduid\(dq, \(dqidentifier\(dq: \(dq08:08:08:08:08:08\(dq, \(dqiaid\(dq: 1234567, \(dqtype\(dq: \(dqIA_NA\(dq, \(dqsubnet\-id\(dq: 44 } } .EE .UNINDENT .UNINDENT .sp The \fBtype\fP is an optional parameter. Supported values are: \fBIA_NA\fP (non\-temporary address) and \fBIA_PD\fP (IPv6 prefix). If not specified, \fBIA_NA\fP is assumed. .sp \fI\%lease4\-get\fP and \fI\%lease6\-get\fP return an indication of the result of the operation and lease details, if found. The result has one of the following values: 0 (success), 1 (error), or 3 (empty). An empty result means that a query has been completed properly, but the object (a lease in this case) has not been found. The lease parameters, if found, are returned as arguments. \fBclient\-id\fP is not returned if empty. .sp An example result returned when the host was found: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqarguments\(dq: { \(dqclient\-id\(dq: \(dq42:42:42:42:42:42:42:42\(dq, \(dqcltt\(dq: 12345678, \(dqfqdn\-fwd\(dq: false, \(dqfqdn\-rev\(dq: true, \(dqhostname\(dq: \(dqmyhost.example.com.\(dq, \(dqhw\-address\(dq: \(dq08:08:08:08:08:08\(dq, \(dqip\-address\(dq: \(dq192.0.2.1\(dq, \(dqstate\(dq: 0, \(dqsubnet\-id\(dq: 44, \(dqvalid\-lft\(dq: 3600 }, \(dqresult\(dq: 0, \(dqtext\(dq: \(dqIPv4 lease found.\(dq } .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The client last transaction time (\fBcltt\fP field) is bound to the valid lifetime (\fBvalid\-lft\fP) and to the expire date (not reported here but stored in databases) by the equation cltt + valid\e_lft = expire .sp at the exception of the infinite valid lifetime coded by the 0xfffffff (4294967295) special value which makes the expire value to overflow on MySQL and old PostgreSQL backends where timestamps are 32 bit long. So in these lease databases the expire date is the same as the cltt i.e. cltt = expire when valid\e_lft = 4294967295 and the lease backend is MySQL or PostgreSQL. .UNINDENT .UNINDENT .SS The \fBlease4\-get\-all\fP, \fBlease6\-get\-all\fP Commands .sp \fI\%lease4\-get\-all\fP and \fI\%lease6\-get\-all\fP are used to retrieve all IPv4 or IPv6 leases, or all leases for the specified set of subnets. All leases are returned when there are no arguments specified with the command, as in the following example: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqlease4\-get\-all\(dq } .EE .UNINDENT .UNINDENT .sp If arguments are provided, it is expected that they contain the \fB\(dqsubnets\(dq\fP parameter, which is a list of subnet identifiers for which leases should be returned. For example, to retrieve all IPv6 leases belonging to the subnets with identifiers 1, 2, 3, and 4: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqlease6\-get\-all\(dq, \(dqarguments\(dq: { \(dqsubnets\(dq: [ 1, 2, 3, 4 ] } } .EE .UNINDENT .UNINDENT .sp The returned response contains a detailed list of leases in the following format: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqarguments\(dq: { \(dqleases\(dq: [ { \(dqcltt\(dq: 12345678, \(dqduid\(dq: \(dq42:42:42:42:42:42:42:42\(dq, \(dqfqdn\-fwd\(dq: false, \(dqfqdn\-rev\(dq: true, \(dqhostname\(dq: \(dqmyhost.example.com.\(dq, \(dqhw\-address\(dq: \(dq08:08:08:08:08:08\(dq, \(dqiaid\(dq: 1, \(dqip\-address\(dq: \(dq2001:db8:2::1\(dq, \(dqpreferred\-lft\(dq: 500, \(dqstate\(dq: 0, \(dqsubnet\-id\(dq: 44, \(dqtype\(dq: \(dqIA_NA\(dq, \(dqvalid\-lft\(dq: 3600 }, { \(dqcltt\(dq: 12345678, \(dqduid\(dq: \(dq21:21:21:21:21:21:21:21\(dq, \(dqfqdn\-fwd\(dq: false, \(dqfqdn\-rev\(dq: true, \(dqhostname\(dq: \(dq\(dq, \(dqiaid\(dq: 1, \(dqip\-address\(dq: \(dq2001:db8:0:0:2::\(dq, \(dqpreferred\-lft\(dq: 500, \(dqprefix\-len\(dq: 80, \(dqstate\(dq: 0, \(dqsubnet\-id\(dq: 44, \(dqtype\(dq: \(dqIA_PD\(dq, \(dqvalid\-lft\(dq: 3600 } ] }, \(dqresult\(dq: 0, \(dqtext\(dq: \(dq2 IPv6 lease(s) found.\(dq } .EE .UNINDENT .UNINDENT .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 The \fI\%lease4\-get\-all\fP and \fI\%lease6\-get\-all\fP commands may result in very large responses. This may have a negative impact on the DHCP server\(aqs responsiveness while the response is generated and transmitted over the control channel, as the server imposes no restriction on the number of leases returned as a result of this command. .UNINDENT .UNINDENT .SS The \fBlease4\-get\-page\fP, \fBlease6\-get\-page\fP Commands .sp The \fI\%lease4\-get\-all\fP and \fI\%lease6\-get\-all\fP commands may result in very large responses; generating such a response may consume CPU bandwidth as well as memory. It may even cause the server to become unresponsive. In the case of large lease databases it is usually better to retrieve leases in chunks, using the paging mechanism. \fI\%lease4\-get\-page\fP and \fI\%lease6\-get\-page\fP implement a paging mechanism for DHCPv4 and DHCPv6 servers, respectively. The following command retrieves the first 1024 IPv4 leases: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqlease4\-get\-page\(dq, \(dqarguments\(dq: { \(dqfrom\(dq: \(dqstart\(dq, \(dqlimit\(dq: 1024 } } .EE .UNINDENT .UNINDENT .sp The keyword \fBstart\fP denotes that the first page of leases should be retrieved. Alternatively, an IPv4 zero address can be specified to retrieve the first page: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqlease4\-get\-page\(dq, \(dqarguments\(dq: { \(dqfrom\(dq: \(dq0.0.0.0\(dq, \(dqlimit\(dq: 1024 } } .EE .UNINDENT .UNINDENT .sp Similarly, the IPv6 zero address can be specified in the \fI\%lease6\-get\-page\fP command: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqlease6\-get\-page\(dq, \(dqarguments\(dq: { \(dqfrom\(dq: \(dq::\(dq, \(dqlimit\(dq: 6 } } .EE .UNINDENT .UNINDENT .sp The response has the following structure: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqarguments\(dq: { \(dqleases\(dq: [ { \(dqip\-address\(dq: \(dq2001:db8:2::1\(dq, ... }, { \(dqip\-address\(dq: \(dq2001:db8:2::9\(dq, ... }, { \(dqip\-address\(dq: \(dq2001:db8:3::1\(dq, ... }, { \(dqip\-address\(dq: \(dq2001:db8:5::3\(dq, ... }, { \(dqip\-address\(dq: \(dq2001:db8:4::1\(dq, ... }, { \(dqip\-address\(dq: \(dq2001:db8:2::7\(dq, ... }, ... ], \(dqcount\(dq: 6 }, \(dqresult\(dq: 0, \(dqtext\(dq: \(dq6 IPv6 lease(s) found.\(dq } .EE .UNINDENT .UNINDENT .sp Note that the leases\(aq details were excluded from the response above for brevity. .sp Generally, the returned list is not sorted in any particular order. Some lease database backends may sort leases in ascending order of addresses, but the controlling client must not rely on this behavior. .sp The \fBcount\fP parameter contains the number of returned leases on the page. .sp To fetch the next page, the client must use the last address of the current page as an input to the next \fI\%lease4\-get\-page\fP or \fI\%lease6\-get\-page\fP command call. In this example it is: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqlease6\-get\-page\(dq, \(dqarguments\(dq: { \(dqfrom\(dq: \(dq2001:db8:2::7\(dq, \(dqcount\(dq: 6 } } .EE .UNINDENT .UNINDENT .sp because 2001:db8:2::7 is the last address on the current page. .sp The client may assume that it has reached the last page when the \fBcount\fP value is lower than that specified in the command; this includes the case when the \fBcount\fP is equal to 0, meaning that no leases were found. .SS The \fBlease4\-get\-by\-*\fP, \fBlease6\-get\-by\-*\fP Commands .sp \fBlease4\-get\-by\-*\fP and \fBlease6\-get\-by\-*\fP can be used to query the lease database and retrieve all existing leases matching a given feature (denoted by the \fB*\fP). These can include a specified hardware address (IPv4 only), \fBclient\-id\fP IPv4 only), \fBduid\fP (IPv6 only) identifiers, or hostname. .sp An example \fI\%lease4\-get\-by\-hw\-address\fP command for getting IPv4 leases with a given hardware address is: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqlease4\-get\-by\-hw\-address\(dq, \(dqarguments\(dq: { \(dqhw\-address\(dq: \(dq08:08:08:08:08:08\(dq } } .EE .UNINDENT .UNINDENT .sp An example of the \fI\%lease6\-get\-by\-hostname\fP is: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqlease6\-get\-by\-hostname\(dq, \(dqarguments\(dq: { \(dqhostname\(dq: \(dqmyhost.example.org\(dq } } .EE .UNINDENT .UNINDENT .sp The \fBby\fP key is the only parameter. The returned response contains a detailed list of leases in the same format as \fI\%lease4\-get\-all\fP or \fI\%lease6\-get\-all\fP\&. This list can be empty and is usually not large. .SS The \fBlease4\-del\fP, \fBlease6\-del\fP Commands .sp \fI\%lease4\-del\fP and \fI\%lease6\-del\fP can be used to delete a lease from the lease database. There are two types of parameters these commands support, similar to the \fI\%lease4\-get\fP and \fI\%lease6\-get\fP commands: (\fBaddress\fP) for both v4 and v6, (\fBsubnet\-id\fP, \fBidentifier\-type\fP, \fBidentifier\fP) for v4, and (\fBsubnet\-id\fP, \fBidentifier\-type\fP, \fBidentifier\fP, \fBtype\fP, \fBIAID\fP) for v6. The first type of query is used when the address (either IPv4 or IPv6) is known, but the details of the lease are not. One common use case is where an administrator wants a specified address to no longer be used. The second form of the command uses identifiers. For maximum flexibility, this interface uses identifiers as a pair of values: the type and the actual identifier. The currently supported identifiers are \fB\(dqhw\-address\(dq\fP (IPv4 only), \fB\(dqclient\-id\(dq\fP (IPv4 only), and \fB\(dqduid\(dq\fP (IPv6 only). .sp An example command for deleting an IPv4 lease by address is: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqlease4\-del\(dq, \(dqarguments\(dq: { \(dqip\-address\(dq: \(dq192.0.2.202\(dq } } .EE .UNINDENT .UNINDENT .sp An example IPv4 lease deletion by \fB\(dqhw\-address\(dq\fP is: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqlease4\-del\(dq, \(dqarguments\(dq: { \(dqidentifier\(dq: \(dq08:08:08:08:08:08\(dq, \(dqidentifier\-type\(dq: \(dqhw\-address\(dq, \(dqsubnet\-id\(dq: 44 } } .EE .UNINDENT .UNINDENT .sp The IPv6 address leases are deleted the same way, but using \fI\%lease6\-del\fP\&. The IPv6 prefix leases are also deleted using \fI\%lease6\-del\fP, but with some extra steps. The prefix should be referenced by its address and prefix length should be ignored. For example, to delete 2001:db8:1::/48, the following command can be used. The \fBsubnet\-id\fP parameter is optional. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqlease6\-del\(dq, \(dqarguments\(dq: { \(dqip\-address\(dq: \(dq2001:db8:1::\(dq, \(dqtype\(dq: \(dqIA_PD\(dq, \(dqsubnet\-id\(dq: 1 } } .EE .UNINDENT .UNINDENT .sp Another parameter called \fBupdate\-ddns\fP, when \fBtrue\fP, instructs the server to queue a request to \fI\%kea\-dhcp\-ddns\fP to remove DNS entries after the lease is successfully deleted if: .INDENT 0.0 .IP \(bu 2 DDNS updating is enabled (i.e. \fB\(dqdhcp\-ddns\(dq:{ \(dqenable\-updates\(dq: true }\fP). .IP \(bu 2 The lease\(aqs hostname is not empty. .IP \(bu 2 At least one of the lease\(aqs DNS direction flags (\fBfqdn_fwd\fP or \fBfqdn_rev\fP) is true. .UNINDENT .sp This parameter defaults to \fBfalse\fP\&. An example of its use is shown below: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqlease4\-del\(dq, \(dqarguments\(dq: { \(dqip\-address\(dq: \(dq192.0.2.202\(dq, \(dqupdate\-ddns\(dq: true } } .EE .UNINDENT .UNINDENT .sp Commands \fI\%lease4\-del\fP and \fI\%lease6\-del\fP return a result that indicates the outcome of the operation. It has one of the following values: 0 (success), 1 (error), or 3 (empty). The empty result means that a query has been completed properly, but the object (a lease, in this case) has not been found. .SS The \fBlease4\-update\fP, \fBlease6\-update\fP Commands .sp The \fI\%lease4\-update\fP and \fI\%lease6\-update\fP commands can be used to update existing leases. Since all lease database backends are indexed by IP addresses, it is not possible to update an address, but all other fields may be altered. If an address needs to be changed, please use \fI\%lease4\-del\fP / \fI\%lease6\-del\fP followed by \fI\%lease4\-add\fP / \fI\%lease6\-add\fP\&. .sp The \fBsubnet\-id\fP parameter is optional. If not specified, or if the specified value is 0, Kea tries to determine its value by running a subnet\-selection procedure. If specified, however, its value must match the existing subnet. .sp The optional boolean parameter \fB\(dqforce\-create\(dq\fP specifies whether the lease should be created if it does not exist in the database. It defaults to \fBfalse\fP, which indicates that the lease is not created if it does not exist. In such a case, an error is returned when trying to update a non\-existing lease. If the \fB\(dqforce\-create\(dq\fP parameter is set to \fBtrue\fP and the updated lease does not exist, the new lease is created as a result of receiving the \fI\%lease4\-update\fP / \fI\%lease6\-update\fP command. .sp An example of a command to update an IPv4 lease is: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqlease4\-update\(dq, \(dqarguments\(dq: { \(dqip\-address\(dq: \(dq192.0.2.1\(dq, \(dqhostname\(dq: \(dqnewhostname.example.org\(dq, \(dqhw\-address\(dq: \(dq1a:1b:1c:1d:1e:1f\(dq, \(dqsubnet\-id\(dq: 44, \(dqforce\-create\(dq: true } } .EE .UNINDENT .UNINDENT .sp An example of a command to update an IPv6 lease is: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqlease6\-update\(dq, \(dqarguments\(dq: { \(dqip\-address\(dq: \(dq2001:db8::1\(dq, \(dqduid\(dq: \(dq88:88:88:88:88:88:88:88\(dq, \(dqiaid\(dq: 7654321, \(dqhostname\(dq: \(dqnewhostname.example.org\(dq, \(dqsubnet\-id\(dq: 66, \(dqforce\-create\(dq: false } } .EE .UNINDENT .UNINDENT .sp As with other update commands, this command overwrites all the contents of the entry. If the lease previously had a resource assigned to it, and the \fI\%lease4\-update\fP / \fI\%lease6\-update\fP command is missing the resource, it is deleted from the lease database. If an incremental update of the lease is desired, then this can be achieved by issuing a \fI\%lease4\-get\fP / \fI\%lease6\-get\fP command to get the current state of the lease, selecting the lease from the response, modifying it to the required outcome, and then issuing the \fI\%lease4\-update\fP / \fI\%lease6\-update\fP command with the resulting lease attached. .SS The \fBlease4\-wipe\fP, \fBlease6\-wipe\fP Commands .sp \fI\%lease4\-wipe\fP and \fI\%lease6\-wipe\fP are designed to remove all leases associated with a given subnet. This administrative task is expected to be used when an existing subnet is being retired. The leases are not properly expired; no DNS updates are carried out, no log messages are created, and hooks are not called for the leases being removed. .sp An example of \fI\%lease4\-wipe\fP is: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqlease4\-wipe\(dq, \(dqarguments\(dq: { \(dqsubnet\-id\(dq: 44 } } .EE .UNINDENT .UNINDENT .sp An example of \fI\%lease6\-wipe\fP is: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqlease6\-wipe\(dq, \(dqarguments\(dq: { \(dqsubnet\-id\(dq: 66 } } .EE .UNINDENT .UNINDENT .sp The commands return a text description of the number of leases removed, plus the status code 0 (success) if any leases were removed or 3 (empty) if there were no leases. Status code 1 (error) may be returned if the parameters are incorrect or some other exception is encountered. .sp \fBsubnet\-id\fP 0 has a special meaning; it tells Kea to delete leases from all configured subnets. Also, the \fBsubnet\-id\fP parameter may be omitted. If not specified, leases from all subnets are wiped. .sp Note: currently only memfile lease storage supports this command. .SS The \fBlease4\-resend\-ddns\fP, \fBlease6\-resend\-ddns\fP Commands .sp \fI\%lease4\-resend\-ddns\fP and \fI\%lease6\-resend\-ddns\fP can be used to generate a request to \fI\%kea\-dhcp\-ddns\fP to update the DNS entries for an existing lease. The desired lease is selected by a single parameter, \fB\(dqip\-address\(dq\fP\&. For an update request to be generated, DDNS updating must be enabled and DNS entries must have already been made (or attempted) for the lease. In other words, all of the following must be true: .INDENT 0.0 .IP \(bu 2 DDNS updating must be enabled (i.e. \fB\(dqdhcp\-ddns\(dq:{ \(dqenable\-updates\(dq: true\(dq}\fP). .IP \(bu 2 The lease\(aqs hostname must not be empty. .IP \(bu 2 At least one of the lease\(aqs DNS direction flags (\fBfqdn_fwd\fP or \fBfqdn_rev\fP) must be true. .UNINDENT .sp An example \fI\%lease4\-resend\-ddns\fP command for getting a lease using an IPv4 address is: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqlease4\-resend\-ddns\(dq, \(dqarguments\(dq: { \(dqip\-address\(dq: \(dq192.0.2.1\(dq } } .EE .UNINDENT .UNINDENT .sp An example of the \fI\%lease6\-resend\-ddns\fP query is: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqlease6\-resend\-ddns\(dq, \(dqarguments\(dq: { \(dqip\-address\(dq: \(dq2001:db8:1::1\(dq } } .EE .UNINDENT .UNINDENT .sp Commands \fI\%lease4\-resend\-ddns\fP and \fI\%lease6\-resend\-ddns\fP return an indication of the result of the operation. It has one of the following values: 0 (success), 1 (error), or 3 (empty). An empty result means that a query has been completed properly, but the object (a lease in this case) has not been found. .sp A successful result does not mean that DNS has been successfully updated; it indicates that a request to update DNS has been successfully created and queued for transmission to \fI\%kea\-dhcp\-ddns\fP\&. .sp Here\(aqs an example of a result returned when the lease was found: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dqNCR generated for: 2001:db8:1::1, hostname: example.com.\(dq } .EE .UNINDENT .UNINDENT .SS The \fBlease4\-write\fP, \fBlease6\-write\fP Commands .sp \fI\%lease4\-write\fP and \fI\%lease6\-write\fP can be used for recovery in emergency situations where the memfile lease file is damaged, e.g. removed by accident or truncated by a full file system, but the in\-memory database is still valid. These commands are supported only by the memfile database backend and write the lease database into a CSV file. They take the path of the file as the \fBfilename\fP argument. If the specified output file is the same as the configured memfile one, the backend closes and reopens the file in an attempt to synchronize both the files and the in\-memory images of the lease database. The extension \fB\&.bak\fP and the server PID number are added to the previous filename: for example, \fB\&.bak14326\fP\&. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 As of Kea 2.7.9, the lease file may only be written to the data directory determined during compilation: \fB\(dq[kea\-install\-dir]/var/lib/kea\(dq\fP\&. This path may be overridden at startup by setting the environment variable \fBKEA_DHCP_DATA_DIR\fP to the desired path. If a path other than this value is used in \fBfilename\fP, Kea will emit an error and refuse to start or, if already running, log an unrecoverable error. For ease of use in specifying a custom file name simply omit the path portion from \fBfilename\fP\&. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 These commands do not replace the LFC mechanism; they should be used only in exceptional circumstances, such as when recovering after running out of disk space. .UNINDENT .UNINDENT .SS Binding Variables .sp Binding variables allow users to store custom values with each lease. The values are calculated using expressions and stored in the lease\(aqs \fBuser\-context\fP\&. The feature is similar to ISC DHCP\(aqs \fBset\fP statement. .sp They are configured as parameters for the lease\-cmds hook library. Each variable has the following parameters: .INDENT 0.0 .IP \(bu 2 .INDENT 2.0 .TP .B name The name of the variable that will appear in the \fBuser\-context\fP\&. The name must be unique within the list of binding variables.. .UNINDENT .IP \(bu 2 .INDENT 2.0 .TP .B expression The expression used to calculate the variable\(aqs value (see :ref: \fIclassification\-using\-expressions\fP). .UNINDENT .IP \(bu 2 .INDENT 2.0 .TP .B source The packet to use as input for the expression. It is either \fBquery\fP (the packet sent by the client) or \fBresponse\fP (the packet the server is sending in response). .UNINDENT .UNINDENT .sp The following example would store a user\-defined option sent by the client along with the domain\-name sent by the server for each DCHPv4 lease: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqhooks\-libraries\(dq: [{ \(dqlibrary\(dq: \(dq/path/libdhcp_lease_cmds.so\(dq, \(dqparameters\(dq: { \(dqbinding\-variables\(dq: [{ \(dqname\(dq: \(dqopt\-222\(dq, \(dqexpression\(dq: \(dqhexstring(option[222].hex, \(aq:\(aq)\(dq, \(dqsource\(dq: \(dqquery\(dq },{ \(dqname\(dq: \(dqdomain\-name\(dq, \(dqexpression\(dq: \(dqoption[15].text\(dq, \(dqsource\(dq: \(dqresponse\(dq }] } }] } .EE .UNINDENT .UNINDENT .sp The values are stored as name\-value pairs in the \fBISC\fP map in the lease\(aqs \fBuser\-context\fP contents would look similar to the following: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqISC\(dq: { \(dqbinding\-variables\(dq: [{ \(dqdomain\-name\(dq: \(dqexample.org\(dq, \(dqopt\-222\(dq: \(dq01:02:03:04\(dq } ]} } .EE .UNINDENT .UNINDENT .sp When stored in database back ends, the user\-context will not contain line breaks as shown above and would appear as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqISC\(dq: { \(dqbinding\-variables\(dq: { \(dqdomain\-name\(dq: \(dqexample.org\(dq, \(dqopt\-222\(dq: \(dq01:02:03:04\(dq } } } .EE .UNINDENT .UNINDENT .sp When using memfile lease storage, the \fBuser\-context\fP is output with commas replaced by the escape sequence \(dq,\(dq. This is necessary to prevent interference with the lease file parsing. The example output above would appear as follows in a memfile lease file: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqISC\(dq: { \(dqbinding\-variables\(dq: { \(dqdomain\-name\(dq: \(dqexample.org\(dq, \(dqopt\-222\(dq: \(dq01:02:03:04\(dq } } } .EE .UNINDENT .UNINDENT .sp Binding variable values are evaluated whenever a lease is assigned or renewed. For \fI\%kea\-dhcp4\fP, they are also added if \fBoffer\-lifetime\fP is greater than zero. The lease is only updated in the back end if the values have changed. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 When used in conjunction with the Ping Check hook library, the the lease\-cmds hook library should be listed after Ping Check in the server\(aqs \fBhooks\-libraries\fP section of the configuration. .sp When used in conjunction with the HA hook library, the lease\-cmds hook library must be listed before HA in the server\(aqs \fBhooks\-libraries\fP section of the configuration. This ensures that the binding variables are evaluated before HA sends lease updates to its peer(s). .UNINDENT .UNINDENT .SS \fBlibdhcp_lease_query.so\fP: Leasequery Support .sp This library provides support for DHCPv4 Leasequery as described in \X'tty: link https://tools.ietf.org/html/rfc4388'\fI\%RFC 4388\fP\X'tty: link'; and for DHCPv6 Leasequery as described in (\X'tty: link https://tools.ietf.org/html/rfc5007'\fI\%RFC 5007\fP\X'tty: link'). .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 \fI\%libdhcp_lease_query.so\fP is part of the open source code and is available to every Kea user. It was previously available only to ISC customers with a paid support contract. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 This library can only be loaded by the \fI\%kea\-dhcp4\fP or \fI\%kea\-dhcp6\fP process. .UNINDENT .UNINDENT .sp Kea version 2.3.4 added support for DHCPv6 Bulk Leasequery (\X'tty: link https://tools.ietf.org/html/rfc5460'\fI\%RFC 5460\fP\X'tty: link'); Kea version 2.3.5 added support for DHCPv4 Bulk Leasequery (\X'tty: link https://tools.ietf.org/html/rfc6926'\fI\%RFC 6926\fP\X'tty: link') using the memfile lease backend. .SS DHCPv4 Leasequery .sp DHCPv4 simple Leasequery provides a requester the ability to query for active lease information for either a single IP address or a single client. RFC 4388 calls for three such queries: .INDENT 0.0 .IP \(bu 2 Query by IP address .INDENT 2.0 .INDENT 3.5 The IP address of interest is contained within the \fBciaddr\fP field of the query. .UNINDENT .UNINDENT .IP \(bu 2 Query by hardware address .INDENT 2.0 .INDENT 3.5 The hardware address of interest is contained with the \fBchaddr\fP field of the query. .UNINDENT .UNINDENT .IP \(bu 2 Query by client identifier .INDENT 2.0 .INDENT 3.5 The client identifier of interest is sent in the \fBdhcp\-client\-identifier\fP option (61) of the query. .UNINDENT .UNINDENT .UNINDENT .sp The inbound DHCPLEASEQUERY packet must supply only one of the three values above. Queries which supply more than one of these values are dropped. .sp In addition, the query must contain the IP address of the requester in \fBgiaddr\fP\&. This value is used not only as the destination for the query response but also to validate the requester against a known list of IP addresses which are permitted to query. This list of valid requester addresses is specified as part of the Leasequery hook library\(aqs configuration (see the section on configuration below). .sp In response to a valid query, the server returns one of three message types: .INDENT 0.0 .IP \(bu 2 DHCPLEASEUNKNOWN .INDENT 2.0 .INDENT 3.5 Returned when the IP address of interest is not one the server knows about (query by IP address); or there are no active leases for the client of interest (query by hardware address or client ID). .UNINDENT .UNINDENT .IP \(bu 2 DHCPLEASEUNASSIGNED .INDENT 2.0 .INDENT 3.5 Returned when the IP address is one the server knows of but for which there are no active leases (applies only to query by IP address). .UNINDENT .UNINDENT .IP \(bu 2 DHCPLEASEACTIVE .INDENT 2.0 .INDENT 3.5 Returned when there is at least one active lease found matching the criteria. .UNINDENT .UNINDENT .UNINDENT .sp For both DHCPLEASEUNKNOWN and DHCPLEASEUNASSIGNED responses, the only information sent back to the requester in response is the query parameter itself (i.e. one of: IP address, hardware address, or client identifier). .sp For DHCPLEASEACTIVE the server provides the following information for the newest active lease that matches the criteria, in the response: .INDENT 0.0 .IP \(bu 2 \fBciaddr\fP \- set to the lease\(aqs IP address .IP \(bu 2 \fBchaddr\fP \- set to the lease\(aqs hardware address .UNINDENT .sp In addition, one or more of the following options are included: .SS DHCPLEASEACTIVE options .TS box center; l|l|l. T{ Option T} T{ Code T} T{ Content T} _ T{ dhcp\-client\-identifier T} T{ 61 T} T{ copied from the lease (if appropriate) T} _ T{ client\-last\-transaction\-time T} T{ 91 T} T{ the amount of time that has elapsed since the lease\(aqs client\-last\-transaction\-time (CLTT). This value is also used by the server to adjust lifetime and timer values. T} _ T{ dhcp\-lease\-time T} T{ 51 T} T{ lease\(aqs lifetime reduced by CLTT T} _ T{ dhcp\-renewal\-time T} T{ 58 T} T{ as controlled by kea\-dhcp4 configuration and then reduced by CLTT T} _ T{ dhcp\-rebind\-time T} T{ 59 T} T{ as dictated by kea\-dhcp4 configuration and then reduced by CLTT T} _ T{ dhcp\-agent\-options T} T{ 82 T} T{ if stored on the lease. (See \fI\%Storing Extended Lease Information\fP) T} _ T{ associated\-ip T} T{ 92 T} T{ a list of all other IP addresses for which the client has active leases. (Does not apply to query by IP address) T} .TE .sp The \fBdhcp\-server\-identifier\fP option (54) is returned in all responses in keeping with RFC 2131, section 4.3.1. .sp RFC 4388 allows requesters to ask for specific options via the \fBdhcp\-parameter\-request\-list\fP (PRL, option 55). This is not currently supported in Kea. .SS DHCPv4 Leasequery Configuration .sp Configuring the Leasequery hook library for use is straightforward. It supports a single parameter, \fBrequesters\fP, which is a list of IP addresses from which DHCPLEASEQUERY packets are accepted. In other words, it is a list of known requesters. The following code shows an example configuration with two requester addresses: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dqlib/kea/hooks/libdhcp_lease_query.so\(dq, \(dqparameters\(dq: { \(dqrequesters\(dq: [ \(dq192.0.1.1\(dq, \(dq10.0.0.2\(dq ] } } ], ... } .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 For security purposes, there is no way to specify wildcards. Each requester address must be explicitly listed. .UNINDENT .UNINDENT .SS DHCPv6 Leasequery .sp DHCPv6 simple Leasequery gives a requester the ability to query for active lease information for either a single IP address or a single client DUID. The query type and parameters are conveyed in an \fBlq\-query\fP option (44) attached to a \fBDHCPV6_LEASEQUERY\fP message: .INDENT 0.0 .IP \(bu 2 \fBquery\-type\fP .INDENT 2.0 .INDENT 3.5 This is either \fBquery\-by\-address\fP (1) or \fBquery\-by\-clientid\fP (2) .UNINDENT .UNINDENT .IP \(bu 2 \fBlink\-address\fP .INDENT 2.0 .INDENT 3.5 The global link address, when not empty, instructs the query to be limited to leases within that \(dqlink.\(dq Kea uses this value to select only leases that belong to subnets whose prefix matches this value. Active leases for prefix delegations for a matched subnet are included in the query reply, even if the delegated prefix itself falls outside the subnet prefix. .UNINDENT .UNINDENT .IP \(bu 2 \fBquery\-options\fP .INDENT 2.0 .INDENT 3.5 A single \fBiaaddr\fP option (12) must be supplied when querying by address. When querying by client ID, a single \fBclientid\fP option (1) must be supplied. RFC 5007 also calls for an optional, \fBoro\fP option (6), to request specific options be returned for matched leases. This is not currently implemented. .UNINDENT .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 \X'tty: link https://tools.ietf.org/html/rfc5007#section-3.3'\fI\%RFC 5007, Section 3.3\fP\X'tty: link' states that querying by IP address should return either a lease (e.g. binding) for the address itself or a lease for a delegated prefix that contains the address. .UNINDENT .UNINDENT .sp \fBDHCPV6_LEASEQUERY\fP queries are only honored if the source address of the query matches an entry in a list of known IP addresses which are permitted to query. This list of valid requester addresses is specified as part of the Leasequery hook library’s configuration (see the section on configuration below). Queries received from unknown requesters are logged and dropped. .sp In response to a valid query, the server carries out the requisite activities and returns a \fBDHCPV6_LEASEQUERY_REPLY\fP\&. All replies contain at least a \fBstatus\-code\fP option (13) that indicates the outcome of the query as detailed in the following table: .SS DHCPV6_LEASEQUERY_REPLY status option values per query outcome .TS box center; l|l|l|l. T{ Query Outcome T} T{ Status Label T} T{ Status Code T} T{ Status Text T} _ T{ Invalid query type field T} T{ STATUS_UnknownQueryType T} T{ 7 T} T{ \(dqunknown query\-type\(dq T} _ T{ Query by IP address that does not contain an address option T} T{ STATUS_Malformed T} T{ 10 T} T{ \(dqmissing D6O_IAADDR\(dq T} _ T{ Query by IP address for an address that does fall within any configured pools T} T{ STATUS_NotConfigured T} T{ 9 T} T{ \(dqaddress not in a configured pool\(dq T} _ T{ Query by IP address which found only an inactive lease (e.g. expired, declined, reclaimed\-expired) T} T{ STATUS_Success T} T{ 0 T} T{ \(dqinactive lease exists\(dq T} _ T{ Query by IP address that found no leases (active or otherwise) T} T{ STATUS_Success T} T{ 0 T} T{ \(dqno active lease\(dq T} _ T{ Query by IP address that found an active lease for the address T} T{ STATUS_Success T} T{ 0 T} T{ \(dqactive lease found\(dq T} _ T{ Query by Client ID that does not contain a client ID option T} T{ STATUS_Malformed T} T{ 10 T} T{ \(dqmissing D6O_CLIENTID\(dq T} _ T{ Query by Client ID with a link address that does not match any configured subnets T} T{ STATUS_NotConfigured T} T{ 9 T} T{ \(dqnot a configured link\(dq T} _ T{ Query by client ID which found no matching leases T} T{ STATUS_Success T} T{ 0 T} T{ \(dqno active leases\(dq T} _ T{ Query by client ID which found one or more active leases T} T{ STATUS_Success T} T{ 0 T} T{ \(dqactive lease(s) found\(dq T} .TE .sp For those scenarios where the query was either invalid or for which no matching active leases were found, the \fBDHCPV6_LEASEQUERY_REPLY\fP only contains the \fBstatus\-code\fP option (12) per the above table. .sp When a query finds active leases in more than one subnet and the query\(aqs \fBlink\-address\fP is empty, then, in addition to the status\-code, the \fBDHCPV6_LEASEQUERY_REPLY\fP contains an \fBlq\-client\-link\fP option (48). The \fBlq\-client\-link\fP contains a list of IPv6 addresses, one for each subnet in which a lease was found (see \X'tty: link https://tools.ietf.org/html/rfc5007#section-4.1.2.5'\fI\%RFC 5007, Section 4.1.2.5\fP\X'tty: link') If, however, the query\(aqs \fBlink\-address\fP is not empty, the list of queries is pruned to contain only leases that belong to that subnet. .sp When the query results in one or more active leases which all belong to a single subnet, in addition to the \fBstatus\-code\fP, the \fBDHCPV6_LEASEQUERY_REPLY\fP contains a \fBclient\-data\fP option (45) (see \X'tty: link https://tools.ietf.org/html/rfc5007#section-4.1.2.2'\fI\%RFC 5007, Section 4.1.2.2\fP\X'tty: link'). The client\-data option encapsulates the following options: .SS OPTION_CLIENT_DATA returned when active lease(s) are found .TS box center; l|l|l. T{ Option T} T{ Code T} T{ Content T} _ T{ clientid T} T{ 1 T} T{ copied from the lease (if one exists) T} _ T{ clt\-time T} T{ 46 T} T{ amount of time that has elapsed since the lease\(aqs client\-last\-transaction\-time (CLTT). This value will also be used by the server to adjust lifetime and timer values. T} _ T{ iaaddr T} T{ 5 T} T{ One option per matched address. Fields in each option: \- lease address \- valid lifetime reduced by CLTT \- preferred lifetime reduced by CLTT T} _ T{ iaprefix T} T{ 26 T} T{ One option per matched prefix. Fields in each option: \- prefix \- prefix length \- valid lifetime reduced by CLTT \- preferred lifetime reduced by CLTT T} .TE .sp If the lease with the most recent client\-last\-transaction\-time (CLTT) value has relay information in its user context (see \fI\%Storing Extended Lease Information\fP), then an \fBOPTION_LQ_RELAY_DATA\fP option is added to the reply (see \X'tty: link https://tools.ietf.org/html/rfc5007#section-4.1.2.4'\fI\%RFC 5007, Section 4.1.2.4\fP\X'tty: link'). .sp The relay information on the lease is a list with an entry for each relay layer the client packet (e.g. \fBDHCPV6_REQUEST\fP) traversed, with the first entry in the list being the outermost layer (closest to the server). The \fBpeer\-address\fP field of the \fBlq\-rely\-option\fP is set to the peer address of this relay. The list of relays is then used to construct a \fBDHCPV6_RELAY_FORW\fP message equivalent to that which contained the client packet, minus the client packet. This message is stored in the \fBDHCP\-relay\-message\fP field of the \fBlq\-relay\-data\fP option. .SS DHCPv6 Leasequery Configuration .sp Configuring the Leasequery hook library for use is straightforward. It supports a single parameter, \fBrequesters\fP, which is a list of IP addresses from which DHCPV6_LEASEQUERY packets are accepted. In other words, it is a list of known requesters. The following code shows an example configuration with two requester addresses: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dqlib/kea/hooks/libdhcp_lease_query.so\(dq, \(dqparameters\(dq: { \(dqrequesters\(dq: [ \(dq2001:db8:1::1\(dq, \(dq2001:db8:2::1\(dq ], \(dqprefix\-lengths\(dq: [ 72 ] } } ], ... } .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 For security purposes, there is no way to specify wildcards. Each requester address must be explicitly listed. .UNINDENT .UNINDENT .sp When a query by IP address does not match an existing address lease, a search for a matching delegated prefix is conducted. This is carried out by iterating over a list of prefix lengths in descending order, extracting a prefix of that length from the query address, and searching for a delegation matching the resulting prefix. This continues for each length in the list until a match is found or the list is exhausted. .sp By default, the list of prefix lengths to use in the search is determined dynamically after (re)configuration events. The resulting list contains unique values of \fBdelegated\-len\fP, gleaned from the currently configured set of PD pools. .sp There is an optional parameter, \fBprefix\-lengths\fP, which provides the ability to explicitly configure the list rather than having it be determined dynamically. This provides tighter control over which prefix lengths are searched. In the above example, the prefix\-length search is restricted to a single pass, using a length of 72, regardless of whether there are pools using other values for \fBdelegated\-len\fP\&. Specifying an empty list, as shown below: .INDENT 0.0 .INDENT 3.5 .sp .EX : \(dqprefix\-lengths\(dq: [ ] : .EE .UNINDENT .UNINDENT .sp disables the search for delegated prefixes for query by IP address. .SS DHCPv4 Bulk Leasequery .sp DHCPv4 Bulk Leasequery gives a requester the ability to query for active lease information over a TCP connection. This allows the server to return all leases matching a given query. .sp Two of the query types identified by RFC 4388 \- Query by MAC address and Query by Client\-identifier \- are Bulk Leasequery types specified by RFC 6926. That RFC also defines these new Bulk Leasequery types: .INDENT 0.0 .IP \(bu 2 Query by Relay Identifier .INDENT 2.0 .INDENT 3.5 The query carries an RAI (dhcp\-agent\-options (82)) option with a relay\-id (12) sub\-option. .UNINDENT .UNINDENT .IP \(bu 2 Query by Remote ID .INDENT 2.0 .INDENT 3.5 The query carries an RAI (dhcp\-agent\-options (82) option) with a remote\-id (2) sub\-option. .UNINDENT .UNINDENT .IP \(bu 2 Query for All Configured IP Addresses .INDENT 2.0 .INDENT 3.5 This query type is selected when no other query type is specified. .UNINDENT .UNINDENT .UNINDENT .sp RFC 6926 also defines new options for Bulk Leasequery: .INDENT 0.0 .IP \(bu 2 status\-code (151) .INDENT 2.0 .INDENT 3.5 This reply option carries a status code such as MalformedQuery or NotAllowed, with an optional text message. .UNINDENT .UNINDENT .IP \(bu 2 base\-time (152) .INDENT 2.0 .INDENT 3.5 This reply option carries the absolute current time that the response was created. All other time\-based reply options are related to this value. .UNINDENT .UNINDENT .IP \(bu 2 start\-time\-of\-state (153) .INDENT 2.0 .INDENT 3.5 This reply option carries the time of the lease\(aqs transition into its current state. .UNINDENT .UNINDENT .IP \(bu 2 query\-start\-time (154) .INDENT 2.0 .INDENT 3.5 This query option specifies a start\-query time; replies will only contain leases that are older than this value. .UNINDENT .UNINDENT .IP \(bu 2 query\-end\-time (155) .INDENT 2.0 .INDENT 3.5 This query option specifies an end\-query time; replies will only contain leases that are newer than this value. .UNINDENT .UNINDENT .IP \(bu 2 dhcp\-state (156) .INDENT 2.0 .INDENT 3.5 This reply option carries the lease state. .UNINDENT .UNINDENT .IP \(bu 2 data\-source (157) .INDENT 2.0 .INDENT 3.5 This reply option carries the source of the data as a remote flag. .UNINDENT .UNINDENT .UNINDENT .sp RFC 6926 reuses and extends the Virtual Subnet Selection option (221) defined in RFC 6607. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Kea does not yet support querying for all configured IP addresses, so the dhcp\-state option cannot be used, as only active leases can be returned in replies. Kea does not keep the start time of the lease\(aqs state, nor the local/remote information, so it cannot emit the corresponding start\-time\-of\-state and data\-source options. Kea does not support VPNs so the presence of option 221 in the query is considered a (NotAllowed) error. .UNINDENT .UNINDENT .SS DHCPv6 Bulk Leasequery .sp DHCPv6 Bulk Leasequery gives a requester the ability to query for active lease information over a TCP connection. This allows the server to return all active leases matching a query. .sp New query types are available: \fBquery\-by\-relay\-id\fP (3), \fBquery\-by\-link\-address\fP (4), and \fBquery\-by\-remote\-id\fP (5). .sp A new status code, \fBSTATUS_QueryTerminated\fP (11), has been defined but it is not yet used by the hook library. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Kea attempts to map link address parameters to the prefixes of configured subnets. If a given address falls outside all configured subnet prefixes, the query fails with a status code of \fBSTATUS_NotConfigured\fP\&. If the link address parameter for \fBquery\-by\-relay\-id\fP or \fBquery\-by\-remote\-id\fP is not \fB::\fP (i.e. not empty), only delegated prefixes that lie within matching subnet prefixes are returned. Currently, \fBquery\-by\-address\fP does not support finding delegated prefixes by specifying an address that lies within the prefix. .UNINDENT .UNINDENT .SS Bulk Leasequery Configuration .sp Bulk Leasequery configuration is specified via a new map parameter, \fBadvanced\fP, with these possible entries: .INDENT 0.0 .IP \(bu 2 \fBbulk\-query\-enabled\fP .INDENT 2.0 .INDENT 3.5 When \fBtrue\fP, Kea accepts connections from IP addresses in the requesters list and processes received bulk leasequeries. The default is \fBfalse\fP\&. .UNINDENT .UNINDENT .IP \(bu 2 \fBactive\-query\-enabled\fP .INDENT 2.0 .INDENT 3.5 This is an anticipated parameter: if set, it must be \fBfalse\fP\&. .UNINDENT .UNINDENT .IP \(bu 2 \fBextended\-info\-tables\-enabled\fP .INDENT 2.0 .INDENT 3.5 When \fBtrue\fP, the lease backend manages DHCPv6 lease extended info (relay info) in tables to support the new DHCPv6 Bulk Leasequery by\-relay\-id and by\-remote\-id types. The default is to use the same value as \fBbulk\-query\-enabled\fP\&. .UNINDENT .UNINDENT .IP \(bu 2 \fBlease\-query\-ip\fP .INDENT 2.0 .INDENT 3.5 This is the IP address upon which to listen for connections. The address must be of the same family as the server, e.g. IPv6 for the DHCPv6 server. .UNINDENT .UNINDENT .IP \(bu 2 \fBlease\-query\-port\fP .INDENT 2.0 .INDENT 3.5 This is the port upon which to listen. The default is 67 for IPv4 and 547 for IPv6, i.e. the same value as for the UDP DHCP service, but for TCP. .UNINDENT .UNINDENT .IP \(bu 2 \fBmax\-bulk\-query\-threads\fP .INDENT 2.0 .INDENT 3.5 This indicates the maximum number of threads that bulk leasequery processing should use. A value of 0 instructs the server to use the same number of threads that the Kea core is using for DHCP multi\-threading. The default is 0. .UNINDENT .UNINDENT .IP \(bu 2 \fBmax\-requester\-connections\fP .INDENT 2.0 .INDENT 3.5 This is the maximum number of concurrent requester connections. The default is 10; the value must be greater than 0. .UNINDENT .UNINDENT .IP \(bu 2 \fBmax\-concurrent\-queries\fP .INDENT 2.0 .INDENT 3.5 This is the maximum number of concurrent queries per connection. The value 0 allows Kea to determine the number, and is the default. .UNINDENT .UNINDENT .IP \(bu 2 \fBmax\-requester\-idle\-time\fP .INDENT 2.0 .INDENT 3.5 This is the amount of time that may elapse after receiving data from a requester before its connection is closed as idle, in seconds. The default is 300. .UNINDENT .UNINDENT .IP \(bu 2 \fBmax\-leases\-per\-fetch\fP .INDENT 2.0 .INDENT 3.5 This is the maximum number of leases to return in a single fetch. The default is 100. .UNINDENT .UNINDENT .UNINDENT .sp Once TLS is supported, we expect to implement common TLS parameters. .sp For instance, for DHCPv4: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dqlib/kea/hooks/libdhcp_lease_query.so\(dq, \(dqparameters\(dq: { \(dqrequesters\(dq: [ \(dq192.0.2.1\(dq, \(dq192.0.2.2\(dq ], \(dqadvanced\(dq : { \(dqbulk\-query\-enabled\(dq: true, \(dqactive\-query\-enabled\(dq: false, \(dqlease\-query\-ip\(dq: \(dq127.0.0.1\(dq, \(dqlease\-query\-tcp\-port\(dq: 67, \(dqmax\-bulk\-query\-threads\(dq: 0, \(dqmax\-requester\-connections\(dq: 10, \(dqmax\-concurrent\-queries\(dq: 4, \(dqmax\-requester\-idle\-time\(dq: 300, \(dqmax\-leases\-per\-fetch\(dq: 100 } } } ], ... } .EE .UNINDENT .UNINDENT .sp or for DHCPv6: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dqlib/kea/hooks/libdhcp_lease_query.so\(dq, \(dqparameters\(dq: { \(dqrequesters\(dq: [ \(dq2001:db8:1::1\(dq, \(dq2001:db8:2::1\(dq ], \(dqadvanced\(dq : { \(dqbulk\-query\-enabled\(dq: true, \(dqactive\-query\-enabled\(dq: false, \(dqextended\-info\-tables\-enabled\(dq: true, \(dqlease\-query\-ip\(dq: \(dq::1\(dq, \(dqlease\-query\-tcp\-port\(dq: 547, \(dqmax\-bulk\-query\-threads\(dq: 0, \(dqmax\-requester\-connections\(dq: 10, \(dqmax\-concurrent\-queries\(dq: 4, \(dqmax\-requester\-idle\-time\(dq: 300, \(dqmax\-leases\-per\-fetch\(dq: 100 } } } ], ... } .EE .UNINDENT .UNINDENT .SS Updating Existing Leases in SQL Lease Backends .sp Bulk Leasequery requires additions to the lease data that is stored. With SQL lease backends, leases created prior to the server being configured for bulk lease query do not contain the new data required. In order to populate this data, it is necessary to run these API commands: .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Existing leases must have been created by Kea with \fBstore\-extended\-info\fP enabled, in order for the new data from extended info to be extracted and stored. .UNINDENT .UNINDENT .sp For DHCPv4 lease data, the command is: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqextended\-info4\-upgrade\(dq } .EE .UNINDENT .UNINDENT .sp For DHCPv6 lease data, the command is: .sp For extended info used by relay ID and by remote ID, the command is: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqextended\-info6\-upgrade\(dq } .EE .UNINDENT .UNINDENT .sp In all cases, the response indicates whether it succeeded or failed and includes either the count of leases updated or the nature of the failure: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dqUpgraded 1000 leases\(dq } .EE .UNINDENT .UNINDENT .sp This \fBextended\-info6\-upgrade\fP command must be called when: .INDENT 0.0 .IP \(bu 2 the database schema was upgraded from 2.4.1 or older version. \fBextended\-info4\-upgrade\fP can be used when upgrading from 2.3.8 or older version. .IP \(bu 2 Bulk Leasequery was not enabled; tables are maintained only when v6 BLQ is enabled. .IP \(bu 2 data in tables does not seem to be consistent; tables are not maintained in an atomic way, so consistency is not guaranteed. For instance, when a database is shared between several servers, races can happen between updates. .UNINDENT .sp The operation of the extended info command is governed by the \fBextended\-info\-checks\fP parameter, under the \fBsanity\-checks\fP element. Please see \fI\%Sanity Checks in DHCPv4\fP or \fI\%Sanity Checks in DHCPv6\fP\&. .sp For large numbers of leases, this command may take some time to complete. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Both the \fBextended\-info4\-upgrade\fP and \fBextended\-info6\-upgrade\fP commands are intended for one\-time use after upgrading to a version of Kea that fully supports Bulk Leasequery in database backends. These commands are not meant for regular use and will be removed in future Kea versions. .UNINDENT .UNINDENT .SS \fBlibdhcp_legal_log.so\fP: Forensic Logging .sp The Forensic Logging hook library provides hooks that record a detailed log of assignments, renewals, releases, and other lease events into a set of log files. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 \fI\%libdhcp_legal_log.so\fP is part of the open source code and is available to every Kea user. It was previously available only to ISC customers with a paid support contract. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 This library can only be loaded by the \fI\%kea\-dhcp4\fP or \fI\%kea\-dhcp6\fP process. .UNINDENT .UNINDENT .sp In many legal jurisdictions, companies \- especially ISPs \- must record information about the addresses they have leased to DHCP clients. This library is designed to help with that requirement. If the information that it records is sufficient, it may be used directly. .sp If a jurisdiction requires that different information be saved, users may use the custom formatting capability to extract information from the inbound request packet, or from the outbound response packet. Administrators are advised to use this feature with caution, as it may affect server performance. The custom format cannot be used for control channel commands. .sp Alternatively, this library may be used as a template or an example for the user\(aqs own custom logging hook. The logging is done as a set of hooks to allow it to be customized to any particular need; modifying a hook library is easier and safer than updating the core code. In addition, by using the hooks features, users who do not need to log this information can leave it out and avoid any performance penalties. .SS Log File Naming .sp The names of the log files follow a set pattern. .sp If using \fBday\fP, \fBmonth\fP, or \fByear\fP as the time unit, the file name follows the format: .INDENT 0.0 .INDENT 3.5 .sp .EX path/base\-name.CCYYMMDD.txt .EE .UNINDENT .UNINDENT .sp where \fBCC\fP represents the century, \fBYY\fP represents the year, \fBMM\fP represents the month, and \fBDD\fP represents the day. .sp If using \fBsecond\fP as the time unit the file name follows the format: .INDENT 0.0 .INDENT 3.5 .sp .EX path/base\-name.TXXXXXXXXXXXXXXXXXXXX.txt .EE .UNINDENT .UNINDENT .sp where \fBXXXXXXXXXXXXXXXXXXXX\fP represents the time in seconds since the beginning of the UNIX epoch. .sp When using \fBsecond\fP as the time unit, the file is rotated when the \fBcount\fP number of seconds pass. In contrast, when using \fBday\fP, \fBmonth\fP, or \fByear\fP as the time unit, the file is rotated whenever the \fBcount\fP of day, month, or year starts, as applicable. .sp The \fB\(dqpath\(dq\fP and \fB\(dqbase\-name\(dq\fP are supplied in the configuration as described below; see \fI\%Configuring the Forensic Logging Hooks\fP\&. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 When running Kea servers for both DHCPv4 and DHCPv6, the log names must be distinct. See the examples in \fI\%Configuring the Forensic Logging Hooks\fP\&. .UNINDENT .UNINDENT .SS Configuring the Forensic Logging Hooks .sp To use this functionality, the hook library must be included in the configuration of the desired DHCP server modules. \fI\%libdhcp_legal_log.so\fP can save logs to a text file or to a database (created using \fI\%kea\-admin\fP; see \fI\%First\-Time Creation of the MySQL Database\fP and \fI\%First\-Time Creation of the PostgreSQL Database\fP). The library is installed alongside the Kea libraries in \fB[kea\-install\-dir]/var/log/kea\fP, where \fBkea\-install\-dir\fP is determined by the \fB\-\-prefix\fP meson setup option which defaults to \fB/usr/local\fP\&. Assuming the default value, \fI\%kea\-dhcp4\fP can be configured to load \fI\%libdhcp_legal_log.so\fP like this: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp4\(dq: { \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dq/usr/local/lib/kea/hooks/libdhcp_legal_log.so\(dq, \(dqparameters\(dq: { \(dqpath\(dq: \(dq/var/log/kea\(dq, \(dqbase\-name\(dq: \(dqkea\-forensic4\(dq } } ] } } .EE .UNINDENT .UNINDENT .sp For \fI\%kea\-dhcp6\fP, the configuration is: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp6\(dq: { \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dq/usr/local/lib/kea/hooks/libdhcp_legal_log.so\(dq, \(dqparameters\(dq: { \(dqpath\(dq: \(dq/var/log/kea\(dq, \(dqbase\-name\(dq: \(dqkea\-forensic6\(dq } } ] } } .EE .UNINDENT .UNINDENT .sp The hook library parameters for the text file configuration are: .INDENT 0.0 .IP \(bu 2 \fBpath\fP \- the directory in which the forensic file(s) will be written. The default value is \fB[kea\-install\-dir]/var/log/kea\fP\&. The directory must exist. .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 As of Kea 2.7.9, legal log files may only be written to the output directory determined during compilation as: \fB\(dq[kea\-install\-dir]/var/log/kea\(dq\fP\&. This path may be overridden at startup by setting the environment variable \fBKEA_LEGAL_LOG_DIR\fP to the desired path. If a path other than this value is used in \fBpath\fP, Kea will emit an error and refuse to start or if already running, log an unrecoverable error. For ease of use simply omit the \fBpath\fP parameter. .UNINDENT .UNINDENT .INDENT 0.0 .IP \(bu 2 \fBbase\-name\fP \- an arbitrary value which is used in conjunction with the current system date to form the current forensic file name. It defaults to \fBkea\-legal\fP\&. .IP \(bu 2 \fBtime\-unit\fP \- configures the time unit used to rotate the log file. Valid values are \fBsecond\fP, \fBday\fP, \fBmonth\fP, or \fByear\fP\&. It defaults to \fBday\fP\&. .IP \(bu 2 \fBcount\fP \- configures the number of time units that need to pass until the log file is rotated. It can be any positive number, or 0, which disables log rotation. It defaults to 1. .UNINDENT .sp If log rotation is disabled, a new file is created when the library is loaded; the new file name is different from any previous file name. .sp Additional actions can be performed just before closing the old file and after opening the new file. These actions must point to an external executable or script and are configured with the following settings: .INDENT 0.0 .IP \(bu 2 \fBprerotate\fP \- an external executable or script called with the name of the file that will be closed. Kea does not wait for the process to finish. .IP \(bu 2 \fBpostrotate\fP \- an external executable or script called with the name of the file that was opened. Kea does not wait for the process to finish. .UNINDENT .sp These executables must be stored in the \fB\(dq[kea\-install\-dir]/share/kea/scripts/\(dq\fP directory which can be overridden at startup by setting the environment variable \fBKEA_HOOK_SCRIPTS_PATH\fP to a different path. .sp Custom formatting can be enabled for logging information that can be extracted either from the client\(aqs request packet or from the server\(aqs response packet. Use with caution as this might affect server performance. The custom format cannot be used for control channel commands. Two parameters can be used towards this goal, either together or separately: .INDENT 0.0 .IP \(bu 2 \fBrequest\-parser\-format\fP \- an evaluated parsed expression used to extract and log data from the incoming packet. .IP \(bu 2 \fBresponse\-parser\-format\fP \- an evaluated parsed expression used to extract and log data from the server response packet. .UNINDENT .sp See \fI\%Using Expressions in Classification\fP for a list of expressions. If either \fBrequest\-parser\-format\fP or \fBresponse\-parser\-format\fP is configured, the default logging format is not used. If both of them are configured, the resulting log message is constructed by concatenating the data extracted from the request and the data extracted from the response. .sp The custom formatting permits logging on multiple lines using the hexstring 0x0a (ASCII code for new line). In the log file, each line is prepended with the log timestamp. For the database backend, the data is stored (including the newline character) in the same entry. .sp Examples: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp6\(dq: { \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dq/usr/local/lib/kea/hooks/libdhcp_legal_log.so\(dq, \(dqparameters\(dq: { \(dqpath\(dq: \(dq/var/log/kea\(dq, \(dqbase\-name\(dq: \(dqkea\-forensic6\(dq, \(dqrequest\-parser\-format\(dq: \(dq\(aqfirst line\(aq + 0x0a + \(aqsecond line\(aq\(dq, \(dqresponse\-parser\-format\(dq: \(dq\(aqalso second line\(aq + 0x0a + \(aqthird line\(aq\(dq } } ] } } .EE .UNINDENT .UNINDENT .sp Some data might be available in the request or only in the response; the data in the request packet might differ from that in the response packet. .sp The lease\-client context can only be printed using the default format, as this information is not directly stored in the request packet or in the response packet. .sp The \fBtimestamp\-format\fP parameter can be used to change the timestamp logged at the beginning of each line. Permissible formatting is the one supported by strftime plus the \(aq%Q\(aq extra format which adds the microseconds subunits. The default is: \(dq%Y\-%m\-%d %H:%M:%S %Z\(dq. This parameter has no effect for the database backends, where the timestamp is defined at the schema level. .sp Examples: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp6\(dq: { \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dq/usr/local/lib/kea/hooks/libdhcp_legal_log.so\(dq, \(dqparameters\(dq: { \(dqpath\(dq: \(dq/var/log/kea\(dq, \(dqbase\-name\(dq: \(dqkea\-forensic6\(dq, \(dqtimestamp\-format\(dq: \(dq%H%t%w %F%%\(dq } } ] } } .EE .UNINDENT .UNINDENT .sp Additional parameters for the database connection can be specified, e.g: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp6\(dq: { \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dq/usr/local/lib/kea/hooks/libdhcp_legal_log.so\(dq, \(dqparameters\(dq: { \(dqname\(dq: \(dqdatabase\-name\(dq, \(dqpassword\(dq: \(dq1234\(dq, \(dqtype\(dq: \(dqmysql\(dq, \(dquser\(dq: \(dquser\-name\(dq } } ] } } .EE .UNINDENT .UNINDENT .sp For more specific information about database\-related parameters, please refer to \fI\%Lease Database Configuration\fP and \fI\%Lease Database Configuration\fP\&. .sp If it is desired to restrict forensic logging to certain subnets, the \fB\(dqlegal\-logging\(dq\fP boolean parameter can be specified within a user context of these subnets. For example: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp4\(dq: { \(dqsubnet4\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.2.1 \- 192.0.2.200\(dq } ], \(dquser\-context\(dq: { \(dqlegal\-logging\(dq: false } } ] } } .EE .UNINDENT .UNINDENT .sp This configuration disables legal logging for the subnet \(dq192.0.2.0/24\(dq. If the \fB\(dqlegal\-logging\(dq\fP parameter is not specified, it defaults to \fBtrue\fP, which enables legal logging for the subnet. .sp The following example demonstrates how to selectively disable legal logging for an IPv6 subnet: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp6\(dq: { \(dqsubnet6\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq2001:db8:1::/64\(dq, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8:1::1\-2001:db8:1::ffff\(dq } ], \(dquser\-context\(dq: { \(dqlegal\-logging\(dq: false } } ] } } .EE .UNINDENT .UNINDENT .sp See \fI\%User Contexts in IPv4\fP and \fI\%User Contexts in IPv6\fP to learn more about user contexts in Kea configuration. .SS DHCPv4 Log Entries .sp For DHCPv4, the library creates entries based on DHCPREQUEST, DHCPDECLINE, and DHCPRELEASE messages, et al., and their responses. The resulting packets and leases are taken into account, intercepted through the following hook points: .INDENT 0.0 .IP \(bu 2 \fBpkt4_receive\fP .IP \(bu 2 \fBleases4_committed\fP .IP \(bu 2 \fBpkt4_send\fP .IP \(bu 2 \fBlease4_release\fP .IP \(bu 2 \fBlease4_decline\fP .UNINDENT .sp An entry is a single string with no embedded end\-of\-line markers and a prepended timestamp, and has the following sections: .INDENT 0.0 .INDENT 3.5 .sp .EX timestamp address duration device\-id {client\-info} {relay\-info} {user\-context} .EE .UNINDENT .UNINDENT .sp Where: .INDENT 0.0 .IP \(bu 2 \fBtimestamp\fP \- the date and time the log entry was written, in \(dq%Y\-%m\-%d %H:%M:%S %Z\(dq strftime format (\(dq%Z\(dq is the time zone name). .IP \(bu 2 \fBaddress\fP \- the leased IPv4 address given out, and whether it was assigned, renewed, or released. .IP \(bu 2 \fBduration\fP \- the lease lifetime expressed in days (if present), hours, minutes, and seconds. A lease lifetime of 0xFFFFFFFF will be denoted with the text \(dqinfinite duration.\(dq This information is not given when the lease is released. .IP \(bu 2 \fBdevice\-id\fP \- the client\(aqs hardware address shown as a numerical type and hex\-digit string. .IP \(bu 2 \fBclient\-info\fP \- the DHCP client id option (61) if present, shown as a hex string. When its content is printable it is displayed. .IP \(bu 2 \fBrelay\-info\fP \- for relayed packets, the \fBgiaddr\fP and the RAI \fBcircuit\-id\fP, \fBremote\-id\fP, and \fBsubscriber\-id\fP options (option 82 sub options: 1, 2 and 6), if present. The \fBcircuit\-id\fP and \fBremote\-id\fP are presented as hex strings. When their content is printable it is displayed. .IP \(bu 2 \fBuser\-context\fP \- the optional user context associated with the lease. .UNINDENT .sp For instance (line breaks are added here for readability; they are not present in the log file): .INDENT 0.0 .INDENT 3.5 .sp .EX 2018\-01\-06 01:02:03 CET Address: 192.2.1.100 has been renewed for 1 hrs 52 min 15 secs to a device with hardware address: hwtype=1 08:00:2b:02:3f:4e, client\-id: 17:34:e2:ff:09:92:54 connected via relay at address: 192.2.16.33, identified by circuit\-id: 68:6f:77:64:79 (howdy) and remote\-id: 87:f6:79:77:ef .EE .UNINDENT .UNINDENT .sp or for a release: .INDENT 0.0 .INDENT 3.5 .sp .EX 2018\-01\-06 01:02:03 CET Address: 192.2.1.100 has been released from a device with hardware address: hwtype=1 08:00:2b:02:3f:4e, client\-id: 17:34:e2:ff:09:92:54 connected via relay at address: 192.2.16.33, identified by circuit\-id: 68:6f:77:64:79 (howdy) and remote\-id: 87:f6:79:77:ef .EE .UNINDENT .UNINDENT .sp In addition to logging lease activity driven by DHCPv4 client traffic, the hook library also logs entries for the following lease management control channel commands: \fI\%lease4\-add\fP, \fI\%lease4\-update\fP, and \fI\%lease4\-del\fP\&. These cannot have custom formatting. Each entry is a single string with no embedded end\-of\-line markers, and it will typically have the following form: .sp \fBlease4\-add:\fP .INDENT 0.0 .INDENT 3.5 .sp .EX *timestamp* Administrator added a lease of address: *address* to a device with hardware address: *device\-id* .EE .UNINDENT .UNINDENT .sp Depending on the arguments of the add command, it may also include the client\-id and duration. .sp Example: .INDENT 0.0 .INDENT 3.5 .sp .EX 2018\-01\-06 01:02:03 CET Administrator added a lease of address: 192.0.2.202 to a device with hardware address: 1a:1b:1c:1d:1e:1f for 1 days 0 hrs 0 mins 0 secs .EE .UNINDENT .UNINDENT .sp \fBlease4\-update:\fP .INDENT 0.0 .INDENT 3.5 .sp .EX *timestamp* Administrator updated information on the lease of address: *address* to a device with hardware address: *device\-id* .EE .UNINDENT .UNINDENT .sp Depending on the arguments of the update command, it may also include the client\-id and lease duration. .sp Example: .INDENT 0.0 .INDENT 3.5 .sp .EX 2018\-01\-06 01:02:03 CET Administrator updated information on the lease of address: 192.0.2.202 to a device with hardware address: 1a:1b:1c:1d:1e:1f, client\-id: 1234567890 .EE .UNINDENT .UNINDENT .sp \fBlease4\-del:\fP deletes have two forms, one by address and one by identifier and identifier type: .INDENT 0.0 .INDENT 3.5 .sp .EX *timestamp* Administrator deleted the lease for address: *address* .EE .UNINDENT .UNINDENT .sp or .INDENT 0.0 .INDENT 3.5 .sp .EX *timestamp* Administrator deleted a lease for a device identified by: *identifier\-type* of *identifier* .EE .UNINDENT .UNINDENT .sp Currently only a type of \fB@b hw\-address\fP (hardware address) is supported. .sp Examples: .INDENT 0.0 .INDENT 3.5 .sp .EX 2018\-01\-06 01:02:03 CET Administrator deleted the lease for address: 192.0.2.202 2018\-01\-06 01:02:12 CET Administrator deleted a lease for a device identified by: hw\-address of 1a:1b:1c:1d:1e:1f .EE .UNINDENT .UNINDENT .sp If the High Availability hook library is enabled, the partner periodically sends lease commands in a similar format; the only difference is that the issuer of the command is \(dqHA partner\(dq instead of \(dqAdministrator.\(dq .INDENT 0.0 .INDENT 3.5 .sp .EX *timestamp* HA partner added ... .EE .UNINDENT .UNINDENT .sp or .INDENT 0.0 .INDENT 3.5 .sp .EX *timestamp* HA partner updated ... .EE .UNINDENT .UNINDENT .sp or .INDENT 0.0 .INDENT 3.5 .sp .EX *timestamp* HA partner deleted ... .EE .UNINDENT .UNINDENT .sp The \fBrequest\-parser\-format\fP and \fBresponse\-parser\-format\fP options can be used to extract and log data from the incoming packet and server response packet, respectively. The configured value is an evaluated parsed expression returning a string. A list of tokens is described in the server classification process. Use with caution as this might affect server performance. If either of them is configured, the default logging format is not used. If both of them are configured, the resulting log message is constructed by concatenating the logged data extracted from the request and the logged data extracted from the response. .sp The custom formatting permits logging on multiple lines using the hexstring 0x0a (ASCII code for new line). In the case of the log file, each line is prepended with the log timestamp. For the database backend, the data is stored (including the newline character) in the same entry. .sp Examples: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp4\(dq: { \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dq/usr/local/lib/kea/hooks/libdhcp_legal_log.so\(dq, \(dqparameters\(dq: { \(dqname\(dq: \(dqdatabase\-name\(dq, \(dqpassword\(dq: \(dq1234\(dq, \(dqtype\(dq: \(dqmysql\(dq, \(dquser\(dq: \(dquser\-name\(dq, \(dqrequest\-parser\-format\(dq: \(dq\(aqlog entry\(aq + 0x0a + \(aqsame log entry\(aq\(dq, \(dqresponse\-parser\-format\(dq: \(dq\(aqalso same log entry\(aq + 0x0a + \(aqagain same log entry\(aq\(dq } } ] } } .EE .UNINDENT .UNINDENT .sp Some data might be available in the request or in the response only, and some data might differ in the incoming packet from the one in the response packet. .sp Examples: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqrequest\-parser\-format\(dq: \(dqifelse(pkt4.msgtype == 4 or pkt4.msgtype == 7, \(aqAddress: \(aq + ifelse(option[50].exists, addrtotext(option[50].hex), addrtotext(pkt4.ciaddr)) + \(aq has been released from a device with hardware address: hwtype=\(aq + substring(hexstring(pkt4.htype, \(aq\(aq), 7, 1) + \(aq \(aq + hexstring(pkt4.mac, \(aq:\(aq) + ifelse(option[61].exists, \(aq, client\-id: \(aq + hexstring(option[61].hex, \(aq:\(aq), \(aq\(aq) + ifelse(pkt4.giaddr == 0.0.0.0, \(aq\(aq, \(aq connected via relay at address: \(aq + addrtotext(pkt4.giaddr) + ifelse(option[82].option[1].exists, \(aq, circuit\-id: \(aq + hexstring(option[82].option[1].hex, \(aq:\(aq), \(aq\(aq) + ifelse(option[82].option[2].exists, \(aq, remote\-id: \(aq + hexstring(option[82].option[2].hex, \(aq:\(aq), \(aq\(aq) + ifelse(option[82].option[6].exists, \(aq, subscriber\-id: \(aq + hexstring(option[82].option[6].hex, \(aq:\(aq), \(aq\(aq)), \(aq\(aq)\(dq, \(dqresponse\-parser\-format\(dq: \(dqifelse(pkt4.msgtype == 5, \(aqAddress: \(aq + addrtotext(pkt4.yiaddr) + \(aq has been assigned for \(aq + uint32totext(option[51].hex) + \(aq seconds to a device with hardware address: hwtype=\(aq + substring(hexstring(pkt4.htype, \(aq\(aq), 7, 1) + \(aq \(aq + hexstring(pkt4.mac, \(aq:\(aq) + ifelse(option[61].exists, \(aq, client\-id: \(aq + hexstring(option[61].hex, \(aq:\(aq), \(aq\(aq) + ifelse(pkt4.giaddr == 0.0.0.0, \(aq\(aq, \(aq connected via relay at address: \(aq + addrtotext(pkt4.giaddr) + ifelse(option[82].option[1].exists, \(aq, circuit\-id: \(aq + hexstring(option[82].option[1].hex, \(aq:\(aq), \(aq\(aq) + ifelse(option[82].option[2].exists, \(aq, remote\-id: \(aq + hexstring(option[82].option[2].hex, \(aq:\(aq), \(aq\(aq) + ifelse(option[82].option[6].exists, \(aq, subscriber\-id: \(aq + hexstring(option[82].option[6].hex, \(aq:\(aq), \(aq\(aq)), \(aq\(aq)\(dq } .EE .UNINDENT .UNINDENT .sp Details: .sp This will log the following data on request and renew: .INDENT 0.0 .INDENT 3.5 .sp .EX Address: 192.2.1.100 has been assigned for 6735 seconds to a device with hardware address: hwtype=1 08:00:2b:02:3f:4e, client\-id: 17:34:e2:ff:09:92:54 connected via relay at address: 192.2.16.33, circuit\-id: 68:6f:77:64:79, remote\-id: 87:f6:79:77:ef, subscriber\-id: 1a:2b:3c:4d:5e:6f .EE .UNINDENT .UNINDENT .sp This will log the following data on release and decline: .INDENT 0.0 .INDENT 3.5 .sp .EX Address: 192.2.1.100 has been released from a device with hardware address: hwtype=1 08:00:2b:02:3f:4e, client\-id: 17:34:e2:ff:09:92:54 connected via relay at address: 192.2.16.33, circuit\-id: 68:6f:77:64:79, remote\-id: 87:f6:79:77:ef, subscriber\-id: 1a:2b:3c:4d:5e:6f .EE .UNINDENT .UNINDENT .sp A similar result can be obtained by configuring only \fBrequest\-parser\-format\fP\&. .sp Examples: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqrequest\-parser\-format\(dq: \(dqifelse(pkt4.msgtype == 3, \(aqAddress: \(aq + ifelse(option[50].exists, addrtotext(option[50].hex), addrtotext(pkt4.ciaddr)) + \(aq has been assigned\(aq + ifelse(option[51].exists, \(aq for \(aq + uint32totext(option[51].hex) + \(aq seconds\(aq, \(aq\(aq) + \(aq to a device with hardware address: hwtype=\(aq + substring(hexstring(pkt4.htype, \(aq\(aq), 7, 1) + \(aq \(aq + hexstring(pkt4.mac, \(aq:\(aq) + ifelse(option[61].exists, \(aq, client\-id: \(aq + hexstring(option[61].hex, \(aq:\(aq), \(aq\(aq) + ifelse(pkt4.giaddr == 0.0.0.0, \(aq\(aq, \(aq connected via relay at address: \(aq + addrtotext(pkt4.giaddr) + ifelse(option[82].option[1].exists, \(aq, circuit\-id: \(aq + hexstring(option[82].option[1].hex, \(aq:\(aq), \(aq\(aq) + ifelse(option[82].option[2].exists, \(aq, remote\-id: \(aq + hexstring(option[82].option[2].hex, \(aq:\(aq), \(aq\(aq) + ifelse(option[82].option[6].exists, \(aq, subscriber\-id: \(aq + hexstring(option[82].option[6].hex, \(aq:\(aq), \(aq\(aq)), ifelse(pkt4.msgtype == 4 or pkt4.msgtype == 7, \(aqAddress: \(aq + ifelse(option[50].exists, addrtotext(option[50].hex), addrtotext(pkt4.ciaddr)) + \(aq has been released from a device with hardware address: hwtype=\(aq + substring(hexstring(pkt4.htype, \(aq\(aq), 7, 1) + \(aq \(aq + hexstring(pkt4.mac, \(aq:\(aq) + ifelse(option[61].exists, \(aq, client\-id: \(aq + hexstring(option[61].hex, \(aq:\(aq), \(aq\(aq) + ifelse(pkt4.giaddr == 0.0.0.0, \(aq\(aq, \(aq connected via relay at address: \(aq + addrtotext(pkt4.giaddr) + ifelse(option[82].option[1].exists, \(aq, circuit\-id: \(aq + hexstring(option[82].option[1].hex, \(aq:\(aq), \(aq\(aq) + ifelse(option[82].option[2].exists, \(aq, remote\-id: \(aq + hexstring(option[82].option[2].hex, \(aq:\(aq), \(aq\(aq) + ifelse(option[82].option[6].exists, \(aq, subscriber\-id: \(aq + hexstring(option[82].option[6].hex, \(aq:\(aq), \(aq\(aq)), \(aq\(aq))\(dq } .EE .UNINDENT .UNINDENT .sp Details: .SS DHCPv6 Log Entries .sp For DHCPv6, the library creates entries based on REQUEST, RENEW, RELEASE, and DECLINE messages, et al. and their responses. The resulting packets and leases are taken into account, intercepted through the following hook points: .INDENT 0.0 .IP \(bu 2 \fBpkt6_receive\fP .IP \(bu 2 \fBleases6_committed\fP .IP \(bu 2 \fBpkt6_send\fP .IP \(bu 2 \fBlease6_release\fP .IP \(bu 2 \fBlease6_decline\fP .UNINDENT .sp An entry is a single string with no embedded end\-of\-line markers and a prepended timestamp, and has the following sections: .INDENT 0.0 .INDENT 3.5 .sp .EX timestamp address duration device\-id {relay\-info}* {user\-context} .EE .UNINDENT .UNINDENT .sp Where: .INDENT 0.0 .IP \(bu 2 \fBtimestamp\fP \- the date and time the log entry was written, in \(dq%Y\-%m\-%d %H:%M:%S %Z\(dq strftime format (\(dq%Z\(dq is the time zone name). .IP \(bu 2 \fBaddress\fP \- the leased IPv6 address or prefix given out, and whether it was assigned, renewed, or released. .IP \(bu 2 \fBduration\fP \- the lease lifetime expressed in days (if present), hours, minutes, and seconds. A lease lifetime of 0xFFFFFFFF will be denoted with the text \(dqinfinite duration.\(dq This information is not given when the lease is released. .IP \(bu 2 \fBdevice\-id\fP \- the client\(aqs DUID and hardware address (if present). .IP \(bu 2 \fBrelay\-info\fP \- for relayed packets the content of relay agent messages, and the \fBremote\-id\fP (code 37), \fBsubscriber\-id\fP (code 38), and \fBinterface\-id\fP (code 18) options, if present. Note that the \fBinterface\-id\fP option, if present, identifies the whole interface on which the relay agent received the message. This typically translates to a single link in the network, but it depends on the specific network topology. Nevertheless, this is useful information to better pinpoint the location of the device, so it is recorded, if present. .IP \(bu 2 \fBuser\-context\fP \- the optional user context associated with the lease. .UNINDENT .sp For instance (line breaks are added here for readability; they are not present in the log file): .INDENT 0.0 .INDENT 3.5 .sp .EX 2018\-01\-06 01:02:03 PST Address:2001:db8:1:: has been assigned for 0 hrs 11 mins 53 secs to a device with DUID: 17:34:e2:ff:09:92:54 and hardware address: hwtype=1 08:00:2b:02:3f:4e (from Raw Socket) connected via relay at address: fe80::abcd for client on link address: 3001::1, hop count: 1, identified by remote\-id: 01:02:03:04:0a:0b:0c:0d:0e:0f and subscriber\-id: 1a:2b:3c:4d:5e:6f .EE .UNINDENT .UNINDENT .sp or for a release: .INDENT 0.0 .INDENT 3.5 .sp .EX 2018\-01\-06 01:02:03 PST Address:2001:db8:1:: has been released from a device with DUID: 17:34:e2:ff:09:92:54 and hardware address: hwtype=1 08:00:2b:02:3f:4e (from Raw Socket) connected via relay at address: fe80::abcd for client on link address: 3001::1, hop count: 1, identified by remote\-id: 01:02:03:04:0a:0b:0c:0d:0e:0f and subscriber\-id: 1a:2b:3c:4d:5e:6f .EE .UNINDENT .UNINDENT .sp In addition to logging lease activity driven by DHCPv6 client traffic, the hook library also logs entries for the following lease management control channel commands: \fI\%lease6\-add\fP, \fI\%lease6\-update\fP, and \fI\%lease6\-del\fP\&. Each entry is a single string with no embedded end\-of\-line markers, and it will typically have the following form: .sp \fBlease6\-add:\fP .INDENT 0.0 .INDENT 3.5 .sp .EX *timestamp* Administrator added a lease of address: *address* to a device with DUID: *DUID* .EE .UNINDENT .UNINDENT .sp Depending on the arguments of the add command, it may also include the hardware address and duration. .sp Example: .INDENT 0.0 .INDENT 3.5 .sp .EX 2018\-01\-06 01:02:03 PST Administrator added a lease of address: 2001:db8::3 to a device with DUID: 1a:1b:1c:1d:1e:1f:20:21:22:23:24 for 1 days 0 hrs 0 mins 0 secs .EE .UNINDENT .UNINDENT .sp \fBlease6\-update:\fP .INDENT 0.0 .INDENT 3.5 .sp .EX *timestamp* Administrator updated information on the lease of address: *address* to a device with DUID: *DUID* .EE .UNINDENT .UNINDENT .sp Depending on the arguments of the update command, it may also include the hardware address and lease duration. .sp Example: .INDENT 0.0 .INDENT 3.5 .sp .EX 2018\-01\-06 01:02:03 PST Administrator updated information on the lease of address: 2001:db8::3 to a device with DUID: 1a:1b:1c:1d:1e:1f:20:21:22:23:24, hardware address: 1a:1b:1c:1d:1e:1f .EE .UNINDENT .UNINDENT .sp \fBlease6\-del:\fP deletes have two forms, one by address and one by identifier and identifier type: .INDENT 0.0 .INDENT 3.5 .sp .EX *timestamp* Administrator deleted the lease for address: *address* .EE .UNINDENT .UNINDENT .sp or .INDENT 0.0 .INDENT 3.5 .sp .EX *timestamp* Administrator deleted a lease for a device identified by: *identifier\-type* of *identifier* .EE .UNINDENT .UNINDENT .sp Currently only a type of \fBDUID\fP is supported. .sp Examples: .INDENT 0.0 .INDENT 3.5 .sp .EX 2018\-01\-06 01:02:03 PST Administrator deleted the lease for address: 2001:db8::3 2018\-01\-06 01:02:11 PST Administrator deleted a lease for a device identified by: duid of 1a:1b:1c:1d:1e:1f:20:21:22:23:24 .EE .UNINDENT .UNINDENT .sp If the High Availability hook library is enabled, the partner periodically sends lease commands in a similar format; the only difference is that the issuer of the command is \(dqHA partner\(dq instead of \(dqAdministrator.\(dq .INDENT 0.0 .INDENT 3.5 .sp .EX *timestamp* HA partner added ... .EE .UNINDENT .UNINDENT .sp or .INDENT 0.0 .INDENT 3.5 .sp .EX *timestamp* HA partner updated ... .EE .UNINDENT .UNINDENT .sp or .INDENT 0.0 .INDENT 3.5 .sp .EX *timestamp* HA partner deleted ... .EE .UNINDENT .UNINDENT .sp The \fBrequest\-parser\-format\fP and \fBresponse\-parser\-format\fP options can be used to extract and log data from the incoming packet and server response packet, respectively. The configured value is an evaluated parsed expression returning a string. A list of tokens is described in the server classification process. Use with caution as this might affect server performance. If either of them is configured, the default logging format is not used. If both of them are configured, the resulting log message is constructed by concatenating the logged data extracted from the request and the logged data extracted from the response. .sp The custom formatting permits logging on multiple lines using the hexstring 0x0a (ASCII code for new line). In the case of the log file, each line is prepended with the log timestamp. For the database backend, the data is stored (including the newline character) in the same entry. .sp Examples: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp6\(dq: { \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dq/usr/local/lib/kea/hooks/libdhcp_legal_log.so\(dq, \(dqparameters\(dq: { \(dqname\(dq: \(dqdatabase\-name\(dq, \(dqpassword\(dq: \(dq1234\(dq, \(dqtype\(dq: \(dqmysql\(dq, \(dquser\(dq: \(dquser\-name\(dq, \(dqrequest\-parser\-format\(dq: \(dq\(aqlog entry\(aq + 0x0a + \(aqsame log entry\(aq\(dq, \(dqresponse\-parser\-format\(dq: \(dq\(aqalso same log entry\(aq + 0x0a + \(aqagain same log entry\(aq\(dq } } ] } } .EE .UNINDENT .UNINDENT .sp Some data might be available in the request or in the response only, and some data might differ in the incoming packet from the one in the response packet. .sp Notes: .sp In the case of IPv6, the packets can contain multiple IA_NA (3) or IA_PD (25) options, each containing multiple options, including OPTION_IAADDR (5) or OPTION_IAPREFIX (25) suboptions. To be able to print the current lease associated with the log entry, the forensic log hook library internally isolates the corresponding IA_NA or IA_PD option and respective suboption matching the current lease. The hook library will iterate over all new allocated addresses and all deleted addresses, making each address available for logging as the current lease for the respective logged entry. .sp They are accessible using the following parser expressions: .sp Current lease associated with OPTION_IAADDR: .INDENT 0.0 .INDENT 3.5 .sp .EX addrtotext(substring(option[3].option[5].hex, 0, 16)) .EE .UNINDENT .UNINDENT .sp Current lease associated with OPTION_IAPREFIX: .INDENT 0.0 .INDENT 3.5 .sp .EX addrtotext(substring(option[25].option[26].hex, 9, 16)) .EE .UNINDENT .UNINDENT .sp All other parameters of the options are available at their respective offsets in the option. Please read RFC8415 for more details. .sp Examples: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqrequest\-parser\-format\(dq: \(dqifelse(pkt6.msgtype == 8 or pkt6.msgtype == 9, ifelse(option[3].option[5].exists, \(aqAddress: \(aq + addrtotext(substring(option[3].option[5].hex, 0, 16)) + \(aq has been released from a device with DUID: \(aq + hexstring(option[1].hex, \(aq:\(aq) + ifelse(relay6[0].peeraddr == \(aq\(aq, \(aq\(aq, \(aq connected via relay at address: \(aq + addrtotext(relay6[0].peeraddr) + \(aq for client on link address: \(aq + addrtotext(relay6[0].linkaddr) + ifelse(relay6[0].option[37].exists, \(aq, remote\-id: \(aq + hexstring(relay6[0].option[37].hex, \(aq:\(aq), \(aq\(aq) + ifelse(relay6[0].option[38].exists, \(aq, subscriber\-id: \(aq + hexstring(relay6[0].option[38].hex, \(aq:\(aq), \(aq\(aq) + ifelse(relay6[0].option[18].exists, \(aq, connected at location interface\-id: \(aq + hexstring(relay6[0].option[18].hex, \(aq:\(aq), \(aq\(aq)), \(aq\(aq) + ifelse(option[25].option[26].exists, \(aqPrefix: \(aq + addrtotext(substring(option[25].option[26].hex, 9, 16)) + \(aq/\(aq + uint8totext(substring(option[25].option[26].hex, 8, 1)) + \(aq has been released from a device with DUID: \(aq + hexstring(option[1].hex, \(aq:\(aq) + ifelse(relay6[0].peeraddr == \(aq\(aq, \(aq\(aq, \(aq connected via relay at address: \(aq + addrtotext(relay6[0].peeraddr) + \(aq for client on link address: \(aq + addrtotext(relay6[0].linkaddr) + ifelse(relay6[0].option[37].exists, \(aq, remote\-id: \(aq + hexstring(relay6[0].option[37].hex, \(aq:\(aq), \(aq\(aq) + ifelse(relay6[0].option[38].exists, \(aq, subscriber\-id: \(aq + hexstring(relay6[0].option[38].hex, \(aq:\(aq), \(aq\(aq) + ifelse(relay6[0].option[18].exists, \(aq, connected at location interface\-id: \(aq + hexstring(relay6[0].option[18].hex, \(aq:\(aq), \(aq\(aq)), \(aq\(aq), \(aq\(aq)\(dq, \(dqresponse\-parser\-format\(dq: \(dqifelse(pkt6.msgtype == 7, ifelse(option[3].option[5].exists and not (substring(option[3].option[5].hex, 20, 4) == 0), \(aqAddress: \(aq + addrtotext(substring(option[3].option[5].hex, 0, 16)) + \(aq has been assigned for \(aq + uint32totext(substring(option[3].option[5].hex, 20, 4)) + \(aq seconds to a device with DUID: \(aq + hexstring(option[1].hex, \(aq:\(aq) + ifelse(relay6[0].peeraddr == \(aq\(aq, \(aq\(aq, \(aq connected via relay at address: \(aq + addrtotext(relay6[0].peeraddr) + \(aq for client on link address: \(aq + addrtotext(relay6[0].linkaddr) + ifelse(relay6[0].option[37].exists, \(aq, remote\-id: \(aq + hexstring(relay6[0].option[37].hex, \(aq:\(aq), \(aq\(aq) + ifelse(relay6[0].option[38].exists, \(aq, subscriber\-id: \(aq + hexstring(relay6[0].option[38].hex, \(aq:\(aq), \(aq\(aq) + ifelse(relay6[0].option[18].exists, \(aq, connected at location interface\-id: \(aq + hexstring(relay6[0].option[18].hex, \(aq:\(aq), \(aq\(aq)), \(aq\(aq) + ifelse(option[25].option[26].exists and not (substring(option[25].option[26].hex, 4, 4) == 0), \(aqPrefix: \(aq + addrtotext(substring(option[25].option[26].hex, 9, 16)) + \(aq/\(aq + uint8totext(substring(option[25].option[26].hex, 8, 1)) + \(aq has been assigned for \(aq + uint32totext(substring(option[25].option[26].hex, 4, 4)) + \(aq seconds to a device with DUID: \(aq + hexstring(option[1].hex, \(aq:\(aq) + ifelse(relay6[0].peeraddr == \(aq\(aq, \(aq\(aq, \(aq connected via relay at address: \(aq + addrtotext(relay6[0].peeraddr) + \(aq for client on link address: \(aq + addrtotext(relay6[0].linkaddr) + ifelse(relay6[0].option[37].exists, \(aq, remote\-id: \(aq + hexstring(relay6[0].option[37].hex, \(aq:\(aq), \(aq\(aq) + ifelse(relay6[0].option[38].exists, \(aq, subscriber\-id: \(aq + hexstring(relay6[0].option[38].hex, \(aq:\(aq), \(aq\(aq) + ifelse(relay6[0].option[18].exists, \(aq, connected at location interface\-id: \(aq + hexstring(relay6[0].option[18].hex, \(aq:\(aq), \(aq\(aq)), \(aq\(aq), \(aq\(aq)\(dq } .EE .UNINDENT .UNINDENT .sp Details: .sp This will log the following data on request, renew, and rebind for NA: .INDENT 0.0 .INDENT 3.5 .sp .EX Address: 2001:db8:1:: has been assigned for 713 seconds to a device with DUID: 17:34:e2:ff:09:92:54 connected via relay at address: fe80::abcd for client on link address: 3001::1, remote\-id: 01:02:03:04:0a:0b:0c:0d:0e:0f, subscriber\-id: 1a:2b:3c:4d:5e:6f, connected at location interface\-id: 72:65:6c:61:79:31:3a:65:74:68:30 .EE .UNINDENT .UNINDENT .sp This will log the following data on request, renew and rebind for PD: .INDENT 0.0 .INDENT 3.5 .sp .EX Prefix: 2001:db8:1::/64 has been assigned for 713 seconds to a device with DUID: 17:34:e2:ff:09:92:54 connected via relay at address: fe80::abcd for client on link address: 3001::1, remote\-id: 01:02:03:04:0a:0b:0c:0d:0e:0f, subscriber\-id: 1a:2b:3c:4d:5e:6f, connected at location interface\-id: 72:65:6c:61:79:31:3a:65:74:68:30 .EE .UNINDENT .UNINDENT .sp This will log the following data on release and decline for NA: .INDENT 0.0 .INDENT 3.5 .sp .EX Address: 2001:db8:1:: has been released from a device with DUID: 17:34:e2:ff:09:92:54 connected via relay at address: fe80::abcd for client on link address: 3001::1, remote\-id: 01:02:03:04:0a:0b:0c:0d:0e:0f, subscriber\-id: 1a:2b:3c:4d:5e:6f, connected at location interface\-id: 72:65:6c:61:79:31:3a:65:74:68:30 .EE .UNINDENT .UNINDENT .sp This will log the following data on release and decline for PD: .INDENT 0.0 .INDENT 3.5 .sp .EX Prefix: 2001:db8:1::/64 has been released from a device with DUID: 17:34:e2:ff:09:92:54 connected via relay at address: fe80::abcd for client on link address: 3001::1, remote\-id: 01:02:03:04:0a:0b:0c:0d:0e:0f, subscriber\-id: 1a:2b:3c:4d:5e:6f, connected at location interface\-id: 72:65:6c:61:79:31:3a:65:74:68:30 .EE .UNINDENT .UNINDENT .sp A similar result can be obtained by configuring only \fBrequest\-parser\-format\fP\&. .sp Examples: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqrequest\-parser\-format\(dq: \(dqifelse(pkt6.msgtype == 3 or pkt6.msgtype == 5 or pkt6.msgtype == 6, ifelse(option[3].option[5].exists, \(aqAddress: \(aq + addrtotext(substring(option[3].option[5].hex, 0, 16)) + \(aq has been assigned for \(aq + uint32totext(substring(option[3].option[5].hex, 20, 4)) + \(aq seconds to a device with DUID: \(aq + hexstring(option[1].hex, \(aq:\(aq) + ifelse(relay6[0].peeraddr == \(aq\(aq, \(aq\(aq, \(aq connected via relay at address: \(aq + addrtotext(relay6[0].peeraddr) + \(aq for client on link address: \(aq + addrtotext(relay6[0].linkaddr) + ifelse(relay6[0].option[37].exists, \(aq, remote\-id: \(aq + hexstring(relay6[0].option[37].hex, \(aq:\(aq), \(aq\(aq) + ifelse(relay6[0].option[38].exists, \(aq, subscriber\-id: \(aq + hexstring(relay6[0].option[38].hex, \(aq:\(aq), \(aq\(aq) + ifelse(relay6[0].option[18].exists, \(aq, connected at location interface\-id: \(aq + hexstring(relay6[0].option[18].hex, \(aq:\(aq), \(aq\(aq)), \(aq\(aq) + ifelse(option[25].option[26].exists, \(aqPrefix: \(aq + addrtotext(substring(option[25].option[26].hex, 9, 16)) + \(aq/\(aq + uint8totext(substring(option[25].option[26].hex, 8, 1)) + \(aq has been assigned for \(aq + uint32totext(substring(option[25].option[26].hex, 4, 4)) + \(aq seconds to a device with DUID: \(aq + hexstring(option[1].hex, \(aq:\(aq) + ifelse(relay6[0].peeraddr == \(aq\(aq, \(aq\(aq, \(aq connected via relay at address: \(aq + addrtotext(relay6[0].peeraddr) + \(aq for client on link address: \(aq + addrtotext(relay6[0].linkaddr) + ifelse(relay6[0].option[37].exists, \(aq, remote\-id: \(aq + hexstring(relay6[0].option[37].hex, \(aq:\(aq), \(aq\(aq) + ifelse(relay6[0].option[38].exists, \(aq, subscriber\-id: \(aq + hexstring(relay6[0].option[38].hex, \(aq:\(aq), \(aq\(aq) + ifelse(relay6[0].option[18].exists, \(aq, connected at location interface\-id: \(aq + hexstring(relay6[0].option[18].hex, \(aq:\(aq), \(aq\(aq)), \(aq\(aq), ifelse(pkt6.msgtype == 8 or pkt6.msgtype == 9, ifelse(option[3].option[5].exists, \(aqAddress: \(aq + addrtotext(substring(option[3].option[5].hex, 0, 16)) + \(aq has been released from a device with DUID: \(aq + hexstring(option[1].hex, \(aq:\(aq) + ifelse(relay6[0].peeraddr == \(aq\(aq, \(aq\(aq, \(aq connected via relay at address: \(aq + addrtotext(relay6[0].peeraddr) + \(aq for client on link address: \(aq + addrtotext(relay6[0].linkaddr) + ifelse(relay6[0].option[37].exists, \(aq, remote\-id: \(aq + hexstring(relay6[0].option[37].hex, \(aq:\(aq), \(aq\(aq) + ifelse(relay6[0].option[38].exists, \(aq, subscriber\-id: \(aq + hexstring(relay6[0].option[38].hex, \(aq:\(aq), \(aq\(aq) + ifelse(relay6[0].option[18].exists, \(aq, connected at location interface\-id: \(aq + hexstring(relay6[0].option[18].hex, \(aq:\(aq), \(aq\(aq)), \(aq\(aq) + ifelse(option[25].option[26].exists, \(aqPrefix: \(aq + addrtotext(substring(option[25].option[26].hex, 9, 16)) + \(aq/\(aq + uint8totext(substring(option[25].option[26].hex, 8, 1)) + \(aq has been released from a device with DUID: \(aq + hexstring(option[1].hex, \(aq:\(aq) + ifelse(relay6[0].peeraddr == \(aq\(aq, \(aq\(aq, \(aq connected via relay at address: \(aq + addrtotext(relay6[0].peeraddr) + \(aq for client on link address: \(aq + addrtotext(relay6[0].linkaddr) + ifelse(relay6[0].option[37].exists, \(aq, remote\-id: \(aq + hexstring(relay6[0].option[37].hex, \(aq:\(aq), \(aq\(aq) + ifelse(relay6[0].option[38].exists, \(aq, subscriber\-id: \(aq + hexstring(relay6[0].option[38].hex, \(aq:\(aq), \(aq\(aq) + ifelse(relay6[0].option[18].exists, \(aq, connected at location interface\-id: \(aq + hexstring(relay6[0].option[18].hex, \(aq:\(aq), \(aq\(aq)), \(aq\(aq), \(aq\(aq))\(dq } .EE .UNINDENT .UNINDENT .sp Details: .SS Database Backend .sp Log entries can be inserted into a database when Kea is configured with database backend support. Kea uses a table named \fBlogs\fP, that includes a timestamp generated by the database software, and a text log with the same format as files without the timestamp. .sp Please refer to \fI\%MySQL\fP for information on using a MySQL database; or to \fI\%PostgreSQL\fP for PostgreSQL database information. The \fBlogs\fP table is part of the Kea database schemas. .sp Configuration parameters are extended by standard lease database parameters as defined in \fI\%Lease Database Configuration\fP\&. The \fBtype\fP parameter should be \fBmysql\fP, \fBpostgresql\fP, \fBlogfile\fP or \fBsyslog\fP; when it is absent or set to \fBlogfile\fP, files are used. .sp No specific tools are provided to operate the database, but standard tools may be used, for example, to dump the logs table from a MYSQL database: .INDENT 0.0 .INDENT 3.5 .sp .EX $ mysql \-\-user keatest \-\-password 1234 \-e \(dqselect * from logs;\(dq +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-+ | timestamp | address | log | id | +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-+ | 2022\-03\-30 17:38:41 | 192.168.50.1 | Address: 192.168.50.1 has been assigned for 0 hrs 10 mins 0 secs to a device with hardware address: hwtype=1 ff:01:02:03:ff:04, client\-id: 00:01:02:03:04:05:06 | 31 | | 2022\-03\-30 17:38:43 | 192.168.50.1 | Address: 192.168.50.1 has been assigned for 0 hrs 10 mins 0 secs to a device with hardware address: hwtype=1 ff:01:02:03:ff:04, client\-id: 00:01:02:03:04:05:06 | 32 | | 2022\-03\-30 17:38:45 | 192.168.50.1 | Address: 192.168.50.1 has been assigned for 0 hrs 10 mins 0 secs to a device with hardware address: hwtype=1 ff:01:02:03:ff:04, client\-id: 00:01:02:03:04:05:06 | 33 | +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-+ .EE .UNINDENT .UNINDENT .sp Like all the other database\-centric features, forensic logging supports database connection recovery, which can be enabled by setting the \fBon\-fail\fP parameter. If not specified, the \fBon\-fail\fP parameter in forensic logging defaults to \fBserve\-retry\-continue\fP\&. This is different than for \fI\%libdhcp_lease_cmds.so\fP, \fI\%libdhcp_host_cmds.so\fP, and \fI\%libdhcp_cb_cmds.so\fP, where \fBon\-fail\fP defaults to \fBstop\-retry\-exit\fP\&. In this case, the server continues serving clients and does not shut down even if the recovery mechanism fails. If \fBon\-fail\fP is set to \fBserve\-retry\-exit\fP, the server will shut down if the connection to the database backend is not restored according to the \fBmax\-reconnect\-tries\fP and \fBreconnect\-wait\-time\fP parameters, but it continues serving clients while this mechanism is activated. .sp During server startup, the inability to connect to any of the configured backends is considered fatal only if \fBretry\-on\-startup\fP is set to \fBfalse\fP (the default). A fatal error is logged and the server exits, based on the idea that the configuration should be valid at startup. Exiting to the operating system allows nanny scripts to detect the problem. If \fBretry\-on\-startup\fP is set to \fBtrue\fP, the server starts reconnection attempts even at server startup or on reconfigure events, and honors the action specified in the \fBon\-fail\fP parameter. .SS Syslog Backend .sp Log entries can be inserted into syslog by setting the \fBtype\fP to \fBsyslog\fP\&. When syslog type is configured, the \fBpattern\fP parameter specifies the details that are used for logging. For more details see \fI\%Logging\fP\&. If not configured, it defaults to: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dq%\-5p [%c.%t] %m\en\(dq .EE .UNINDENT .UNINDENT .sp The \fBfacility\fP parameter specifies the syslog facility and it defaults to \fBlocal0\fP\&. .SS \fBlibdhcp_limits.so\fP: Limits to Manage Lease Allocation and Packet Processing .sp This hook library enables two types of limits: .INDENT 0.0 .IP 1. 3 Lease limiting: allow a maximum of \fBn\fP leases assigned at any one time. .IP 2. 3 Rate limiting: allow a maximum of \fBn\fP packets per \fBtime_unit\fP to receive a response. .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 \fI\%libdhcp_limits.so\fP is part of the open source code and is available to every Kea user. It was previously available only to ISC customers with a paid support contract. .UNINDENT .UNINDENT .SS Configuration .sp The following examples are for \fI\%kea\-dhcp6\fP, but they apply equally to \fI\%kea\-dhcp4\fP\&. The wildcards \fB\(dq\(dq\fP and \fB\(dq\(dq\fP need to be replaced with the respective keys and values for each limit type described in the sections following this one. .sp The library can be loaded by both \fI\%kea\-dhcp4\fP and \fI\%kea\-dhcp6\fP servers by adding its path in the \fB\(dqhooks\-libraries\(dq\fP element of the server\(aqs configuration. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp6\(dq: { \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dq/usr/local/lib/libdhcp_limits.so\(dq } ] } } .EE .UNINDENT .UNINDENT .sp This alone does not limit anything. The desired limits are added to the user context in the configuration portion of the element that identifies the clients to be limited: a client class or a subnet. Upon reconfiguration, if Kea picked up on the configured limits, it logs one line for each configured limit. The log message contains \fBLIMITS_CONFIGURED\fP in its identifier. .sp This is how a lease limit is defined for a client class: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp6\(dq: { \(dqclient\-classes\(dq: [ { \(dqname\(dq: \(dqcable\-modem\-1\(dq, \(dqtest\(dq: \(dqoption[123].hex == 0x000C4B1E\(dq, \(dquser\-context\(dq: { \(dqlimits\(dq: { \(dq\(dq: \(dq\(dq } } } ] } } .EE .UNINDENT .UNINDENT .sp This is how a lease limit is defined for a global subnet: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp6\(dq: { \(dqsubnet6\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq2001:db8::/64\(dq, \(dquser\-context\(dq: { \(dqlimits\(dq: { \(dq\(dq: \(dq\(dq } } } ] } } .EE .UNINDENT .UNINDENT .sp This is how a lease limit is defined for a subnet inside a shared network: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp6\(dq: { \(dqshared\-networks\(dq: [ { \(dqsubnet6\(dq: [ { \(dqid\(dq: 1, \(dqsubnet\(dq: \(dq2001:db8::/64\(dq, \(dquser\-context\(dq: { \(dqlimits\(dq: { \(dq\(dq: \(dq\(dq } } } ] } ] } } .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The Limits hook library uses the class name to identify a client class and the subnet ID to identify a subnet. Changing a test expression in a client class or the network range of a subnet while leaving the name or ID unchanged does not reset the lease count for the respective client class or subnet. To reset the lease count, change the client class name or the subnet ID. .UNINDENT .UNINDENT .SS Lease Limiting .sp It is possible to limit the number of leases that a group of clients can get from a Kea DHCP server or from a set of collaborating Kea DHCP servers. .sp The value of a lease limit can be specified as an unsigned integer in 32 bits, i.e. between \fB0\fP and \fB4,294,967,295\fP\&. Each lease type can be limited individually. IPv4 leases and IPv6 IA_NA leases are limited through the \fB\(dqaddress\-limit\(dq\fP configuration entry. IPv6 IA_PD leases are limited through the \fB\(dqprefix\-limit\(dq\fP configuration entry. Here are some examples: .INDENT 0.0 .IP \(bu 2 \fB\(dqaddress\-limit\(dq: 4\fP .IP \(bu 2 \fB\(dqprefix\-limit\(dq: 2\fP .UNINDENT .sp For lease limiting, client classes and the associated lease counts \- which are checked against the configured limits \- are updated for each lease in the following hook callouts: .INDENT 0.0 .IP \(bu 2 \fBlease4_select\fP .IP \(bu 2 \fBlease4_renew\fP .IP \(bu 2 \fBlease6_select\fP .IP \(bu 2 \fBlease6_renew\fP .IP \(bu 2 \fBlease6_rebind\fP .UNINDENT .sp As a result, classes for which \fB\(dqonly\-in\-additional\-list\(dq\fP is \(dqtrue\(dq cannot be lease\-limited. Please refer to \fI\%the classification steps\fP for more information on which client classes can be used to limit the number of leases. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Under load, a Kea DHCP server may allocate more leases than the limit strictly allows. This only has a chance of happening during high traffic surges, coming from clients belonging to the same class or the same subnet, depending on what is limited. Users may be interested in following the development of \X'tty: link https://gitlab.isc.org/isc-projects/kea/-/issues/2449'\fI\%atomic lease limits\fP\X'tty: link' in ISC\(aqs GitLab instance. .UNINDENT .UNINDENT .SS Rate Limiting .sp It is possible to limit the frequency or rate at which inbound packets receive a response. .sp The value of a rate limit can be specified in the format \fB\(dq

packets per \(dq\fP\&. \fB

\fP is any number that can be represented by an unsigned integer in 32 bits, i.e. between \fB0\fP and \fB4,294,967,295\fP\&. \fB\fP can be any of \fBsecond\fP, \fBminute\fP, \fBhour\fP, \fBday\fP, \fBweek\fP, \fBmonth\fP, or \fByear\fP\&. A \fBmonth\fP is considered to be 30 days for simplicity; similarly, a \fByear\fP is 365 days for limiting purposes. This syntax covers a wide range of rates, from one lease per year to four billion leases per second. This value is assigned to the \fB\(dqrate\-limit\(dq\fP configuration entry. Here are some examples: .INDENT 0.0 .IP \(bu 2 \fB\(dqrate\-limit\(dq: 1 packet per second\fP .IP \(bu 2 \fB\(dqrate\-limit\(dq: 4 packets per minute\fP .IP \(bu 2 \fB\(dqrate\-limit\(dq: 16 packets per hour\fP .UNINDENT .sp The configured value of \fB0\fP packets is a convenient way of disabling packet processing for certain clients entirely. As such, it means its literal value and is not a special value for disabling limiting altogether, as might be imagined. Disabling limiting entirely is achieved by removing the \fB\(dqrate\-limit\(dq\fP leaf configuration entry, the \fB\(dqlimits\(dq\fP map or user context around it, or the hook library configuration. The same applies to the value of \fB0\fP in lease limiting. However, that use case is best achieved with rate limiting; it puts less computational strain on Kea, since the action of dropping the request or sending a NAK is decided earlier. .sp In terms of rate limiting, client classes are evaluated at the \fBpkt4_receive\fP and the \fBpkt6_receive\fP callout, respectively, so that rate limits are checked as early as possible in the packet\-processing cycle. Thus, only those classes which are assigned to the packet solely via an independent test expression can be used. Classes that depend on host reservations or the special \fBBOOTP\fP or \fBKNOWN\fP classes, and classes that are marked with \fB\(dqonly\-in\-additional\-list\(dq: true\fP, cannot be rate limited. See \fI\%the classification steps\fP for more details on which client classes can be used to limit the packet rate. .sp Rate limits based on subnet are enforced only on the initially selected subnet for a given packet. If the selected subnet is subsequently changed, as may be the case for subnets in a shared network or when reselection is enabled in libraries such as the RADIUS hook, rate limits on the newly selected subnet are ignored. In other words, packets are gated only by the rate limit on the original subnet. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 It may seem logical to think that assigning a rate limit of \fBn\fP packets per time unit results in \fBn\fP DORA or \fBn\fP SARR exchanges. However, by default, all inbound packets are counted \- meaning that a full message exchange accounts for two packets. To achieve the effect of counting an exchange only once, use client\-class rate\-limiting with a test expression that binds \fBpkt4.msgtype\fP to DHCPDISCOVER messages or \fBpkt6.msgtype\fP to SOLICIT messages. .UNINDENT .UNINDENT .SS \fBlibdhcp_mysql.so\fP: Database Backend for MySQL .INDENT 0.0 .TP .B This hook library implements MySQL database storage for: .INDENT 7.0 .IP \(bu 2 Lease Backend .IP \(bu 2 Host Backend .IP \(bu 2 Configuration Backend .UNINDENT .UNINDENT .SS MySQL Configuration Backend .sp This hook library works in conjunction with \fI\%libdhcp_cb_cmds.so\fP to implement the API to create, read, update, and delete (CRUD) the configuration in a MySQL database. Please see \fI\%libdhcp_cb_cmds.so: Configuration Backend Commands\fP for more details. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 \fI\%libdhcp_mysql.so\fP is part of the open source code and is available to every Kea user. However, this hook library only works with \fI\%libdhcp_cb_cmds.so\fP, which allows easy configuration management with the use of API commands. \fI\%libdhcp_cb_cmds.so\fP is available only to ISC customers with a paid support contract; for more information on subscription options, please complete the form at \X'tty: link https://www.isc.org/contact'\fI\%https://www.isc.org/contact\fP\X'tty: link'\&. .UNINDENT .UNINDENT .SS \fBlibdhcp_perfmon.so\fP: Performance Monitoring .sp The Performance Monitoring (perfmon) hook library gives the Kea DHCPv4 and DHCPv6 server the ability to track and report performance\-related data. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 \fI\%libdhcp_perfmon.so\fP is part of the open source code and is available to every Kea user. .UNINDENT .UNINDENT .SS Overview .sp The perfmon library, added in Kea 2.5.6, can be loaded by the \fI\%kea\-dhcp4\fP or \fI\%kea\-dhcp6\fP daemon by adding it to the \fBhooks\-libraries\fP element of the server\(aqs configuration: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dq/usr/local/lib/libdhcp_perfmon.so\(dq, \(dqparameters\(dq: { ... } }, ... ], ... } .EE .UNINDENT .UNINDENT .sp The library tracks the lifecycle of client query packets as they are processed by Kea, from when the query was received by the kernel to when the response is ready to be sent. This tracking is driven by a packet event stack, which contains a list of event/timestamp pairs for significant milestones that occur during the processing of a client query. The list of possible events is shown below: .INDENT 0.0 .IP 1. 3 socket_received \- kernel placed the client query into the socket buffer .IP 2. 3 buffer_read \- server read the client query from the socket buffer .IP 3. 3 mt_queued \- server placed the client query into its thread\-pool work queue (multi\-threaded mode only) .IP 4. 3 process_started \- server has begun processing the query .IP 5. 3 process_completed \- server has constructed the response and is ready to send it .UNINDENT .sp This list is likely to expand over time; it will also be possible for hook developers to add their own events. This will be detailed in future releases. .SS Passive Event Logging .sp When the perfmon hook library is loaded, it logs the packet event stack contents for each client query that generates a response packet. The log entry contains client query identifiers, followed by the list of event/timestamp pairs in the order that they occurred. .sp For \fI\%kea\-dhcp4\fP, the log is identified by the label \fBPERFMON_DHCP4_PKT_EVENTS\fP, and emitted at logger debug level 50 or higher. For a DHCPDISCOVER it is emitted once the DHCPOFFER is ready to send, and looks similar to the following (see the second entry): .INDENT 0.0 .INDENT 3.5 .sp .EX 2024\-03\-20 10:52:20.069 INFO [kea\-dhcp4.leases/50033.140261252249344] DHCP4_LEASE_OFFER [hwtype=1 08:00:27:25:d3:f4], cid=[no info], tid=0xc288f9: lease 178.16.2.0 will be offered 2024\-03\-20 10:52:20.070 DEBUG [kea\-dhcp4.perfmon\-hooks/50033.140261252249344] PERFMON_DHCP4_PKT_EVENTS query: [hwtype=1 08:00:27:25:d3:f4], cid=[no info], tid=0xc288f9 events=[2024\-Mar\-20 14:52:20.067563 : socket_received, 2024\-Mar\-20 14:52:20.067810 : buffer_read, 2024\-Mar\-20 14:52:20.067897 : mt_queued, 2024\-Mar\-20 14:52:20.067952 : process_started, 2024\-Mar\-20 14:52:20.069614 : process_completed] .EE .UNINDENT .UNINDENT .sp For \fI\%kea\-dhcp6\fP, the log is identified by the label \fBPERFMON_DHCP6_PKT_EVENTS\fP, and emitted at logger debug level 50 or higher. For a DHCPV6_SOLICIT it is emitted once the DHCPV6_ADVERTISE is ready to send, and looks similar to the following (see the second entry): .INDENT 0.0 .INDENT 3.5 .sp .EX 2024\-03\-20 10:22:14.030 INFO [kea\-dhcp6.leases/47195.139913679886272] DHCP6_LEASE_ADVERT duid=[00:03:00:01:08:00:27:25:d3:f4], [no hwaddr info], tid=0xb54806: lease for address 3002:: and iaid=11189196 will be advertised 2024\-03\-20 10:22:14.031 DEBUG [kea\-dhcp6.perfmon\-hooks/47195.139913679886272] PERFMON_DHCP6_PKT_EVENTS query: duid=[00:03:00:01:08:00:27:25:d3:f4], [no hwaddr info], tid=0xb54806 events=[2024\-Mar\-20 14:22:14.028729 : socket_received, 2024\-Mar\-20 14:22:14.028924 : buffer_read, 2024\-Mar\-20 14:22:14.029005 : process_started, 2024\-Mar\-20 14:22:14.030566 : process_completed] .EE .UNINDENT .UNINDENT .SS Duration Monitoring .sp When monitoring is enabled, stack event data is aggregated over a specified interval. These aggregates are referred to as \(dqmonitored durations\(dq or simply \(dqdurations\(dq for ease. Durations are uniquely identified by a \(dqduration key\(dq which consists of the following values: .INDENT 0.0 .IP \(bu 2 query message type \- message type of the client query (e.g.DHCPDISCOVER, DHCPV6_REQUEST) .IP \(bu 2 response message type \- message type of the server response (e.g. DHCPOFFER, DHCPV6_REPLY) .IP \(bu 2 start event label \- event that defines the beginning of the task (e.g. socket_received, process_started) .IP \(bu 2 stop event label \- event that defines the end of the task (e.g. buffer_read, process_completed) .IP \(bu 2 subnet id \- subnet selected during message processing (or 0 for global durations) .UNINDENT .sp Once the server has finished constructing a response to a query, the query\(aqs event stack is processed into a series of updates to monitored durations. If, upon updating, a duration\(aqs sample interval is found to have been completed, it is sent to reporting and a new sample interval is begun. The interval width is dictated by configuration parameter \fBinterval\-width\-secs\fP\&. .sp The event stack for the multi\-threaded mode DHCPDISCOVER/DHCPOFFER cycle shown above contains the following events: .INDENT 0.0 .INDENT 3.5 .TS box center; l|l. T{ Event Timestamp T} T{ Event Label T} _ T{ 2024\-Mar\-20 14:52:20.067563 T} T{ socket_received T} _ T{ 2024\-Mar\-20 14:52:20.067810 T} T{ buffer_read T} _ T{ 2024\-Mar\-20 14:52:20.067897 T} T{ mt_queued T} _ T{ 2024\-Mar\-20 14:52:20.067952 T} T{ process_started T} _ T{ 2024\-Mar\-20 14:52:20.069614 T} T{ process_completed T} .TE .UNINDENT .UNINDENT .sp Assuming the selected subnet\(aqs ID was 100, the duration updates created by perfmon from these events are shown below: .INDENT 0.0 .INDENT 3.5 .TS box center; l|l. T{ Duration Keys for SubnetID 100 T} T{ Update in microseconds T} _ T{ DHCPDISCOVER.DHCPOFFER.socket_received\-buffer_read.100 T} T{ 247 T} _ T{ DHCPDISCOVER.DHCPOFFER.buffer_read\-mt_queue.100 T} T{ 87 T} _ T{ DHCPDISCOVER.DHCPOFFER.mt_queued\-process_started.100 T} T{ 55 T} _ T{ DHCPDISCOVER.DHCPOFFER.process_started\-process_completed.100 T} T{ 1662 T} _ T{ DHCPDISCOVER.DHCPOFFER.composite\-total_response.100 T} T{ 2051 T} .TE .UNINDENT .UNINDENT .sp Notice that in addition to the adjacent event updates, there is an additional duration update for the total duration of the entire stack whose key contains the event\-pair \fBcomposite\-total_response\fP\&. This tracks the total time to respond from when the query is received until the response is ready to send. Finally, there are also global duration updates for each of the above: .INDENT 0.0 .INDENT 3.5 .TS box center; l|l. T{ Global Duration Keys T} T{ Update in microseconds T} _ T{ DHCPDISCOVER.DHCPOFFER.socket_received\-buffer_read.0 T} T{ 247 T} _ T{ DHCPDISCOVER.DHCPOFFER.buffer_read\-mt_queue.0 T} T{ 87 T} _ T{ DHCPDISCOVER.DHCPOFFER.mt_queued\-process_started.0 T} T{ 55 T} _ T{ DHCPDISCOVER.DHCPOFFER.process_started\-process_completed.0 T} T{ 1662 T} _ T{ DHCPDISCOVER.DHCPOFFER.composite\-total_response.0 T} T{ 2051 T} .TE .UNINDENT .UNINDENT .SS Statistics Reporting .sp When enabled, perfmon reports a duration\(aqs data each time the duration completes a sampling interval (see \fBstats\-mgr\-reporting\fP under \fI\%Configuration\fP). Each statistic employs the following naming convention: .INDENT 0.0 .INDENT 3.5 .sp .EX {subnet\-id[x]}.perfmon.\-.\-. .EE .UNINDENT .UNINDENT .sp There is both a global and a subnet\-specific value for each. Currently, the only value reported for a given duration key is \fBmean\-usecs\fP; this statistic is the mean time between the duration\(aqs event pair over the most recently completed interval. In other words, if during a given interval there were seven occurrences (i.e. updates) totaling 3500us, the \fBmean\-usecs\fP reported would be 500us. Continuing with the example above, the statistics reported are named as follows for the subnet\-level values: .INDENT 0.0 .INDENT 3.5 .sp .EX subnet[100].perfmon.DHCPDISCOVER.DHCPOFFER.socket_received\-buffer_read.mean\-usecs subnet[100].perfmon.DHCPDISCOVER.DHCPOFFER.buffer_read\-mt_queue.mean\-usecs subnet[100].perfmon.DHCPDISCOVER.DHCPOFFER.mt_queued\-process_started.mean\-usecs subnet[100].perfmon.DHCPDISCOVER.DHCPOFFER.process_started\-process_completed.mean\-usecs subnet[100].perfmon.DHCPDISCOVER.DHCPOFFER.composite\-total_response.mean\-usecs .EE .UNINDENT .UNINDENT .sp and as shown for global values: .INDENT 0.0 .INDENT 3.5 .sp .EX perfmon.DHCPDISCOVER.DHCPOFFER.socket_received\-buffer_read.mean\-usecs perfmon.DHCPDISCOVER.DHCPOFFER.buffer_read\-mt_queue.mean\-usecs perfmon.DHCPDISCOVER.DHCPOFFER.mt_queued\-process_started.mean\-usecs perfmon.DHCPDISCOVER.DHCPOFFER.process_started\-process_completed.mean\-usecs perfmon.DHCPDISCOVER.DHCPOFFER.composite\-total_response.mean\-usecs .EE .UNINDENT .UNINDENT .sp The results are reported to StatsMgr, an internal Kea component that reports data as statistics that can be retrieved using statistics commands. They can be fetched using the commands \fI\%statistic\-get\-all\fP or \fI\%statistic\-get\fP\&. .SS Alarms .sp Alarms may be defined to watch specific durations. Each alarm defines a high\-water mark, \fBhigh\-water\-ms\fP, and a low\-water mark, \fBlow\-water\-ms\fP\&. If the reported mean value for the duration exceeds the high\-water mark a WARN level alarm log is emitted, at which point the alarm is considered \(dqtriggered.\(dq Once triggered, the WARN level log is repeated at the alarm report interval specified by \fBalarm\-report\-secs\fP, as long as the reported mean for the duration remains above the low\-water mark. Once the mean falls below the low\-water mark the alarm is cleared and an INFO level log is emitted. .sp The alarm\-triggered WARN log looks similar to the following: .INDENT 0.0 .INDENT 3.5 .sp .EX 2024\-03\-20 10:22:14.030 WARN [kea\-dhcp6.leases/47195.139913679886272] PERFMON_ALARM_TRIGGERED Alarm for DHCPDISCOVER.DHCPOFFER.composite\-total_response.0 has been triggered since 2024\-03\-20 10:18:20.070000, reported mean duration 00:00:00.700000 exceeds high\-water\-ms: 500 .EE .UNINDENT .UNINDENT .sp The alarm\-cleared INFO log looks like this: .INDENT 0.0 .INDENT 3.5 .sp .EX 2024\-03\-20 10:30:14.030 INFO [kea\-dhcp6.leases/47195.139913679886272] PERFMON_ALARM_CLEARED Alarm for DHCPDISCOVER.DHCPOFFER.composite\-total_response.0 has been cleared, reported mean duration 00:00:00.010000 is now below low\-water\-ms: 25 .EE .UNINDENT .UNINDENT .SS API Commands .SS The \fBperfmon\-control\fP Command .sp This command can be used to enable or disable active monitoring and statistics reporting at runtime without altering or reloading configuration. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqperfmon\-control\(dq, \(dqarguments\(dq: { \(dqenable\-monitoring\(dq: true, \(dqstats\-mgr\-reporting\(dq: false } } .EE .UNINDENT .UNINDENT .sp Regardless of the arguments (if any) supplied, the resulting values of both flags are always returned: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dqperfmon\-control success\(dq, \(dqarguments\(dq: { \(dqenable\-monitoring\(dq: true, \(dqstats\-mgr\-reporting\(dq: false } } .EE .UNINDENT .UNINDENT .SS The \fBperfmon\-get\-all\-durations\fP Command .sp This command fetches all monitored duration data currently held in memory by the Perfmon hook library. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqperfmon\-get\-all\-durations\(dq, \(dqarguments\(dq: { \(dqresult\-set\-format\(dq: true } } .EE .UNINDENT .UNINDENT .sp A result of 0 is returned if command succeeds along with monitored duration data, while a result of 1 is returned if command is invalid or command processing encounters an error. .sp The format of the monitored duration data returned is determined by the optional argument, \fBresult\-set\-format\fP\&. When false, (the default), the list of durations will be returned as a list of individual elements as shown below: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqarguments\(dq: { \(dqdurations\(dq: [{ \(dqduration\-key\(dq: { \(dqquery\-type\(dq: \(dqDHCPDISCOVER\(dq, \(dqresponse\-type\(dq: \(dqDHCPOFFER\(dq, \(dqstart\-event\(dq: \(dqbuffer_read\(dq, \(dqstop\-event\(dq: \(dqmt_queued\(dq, \(dqsubnet\-id\(dq: 0 }, \(dqmax\-duration\-usecs\(dq: 118, \(dqmin\-duration\-usecs\(dq: 31, \(dqoccurrences\(dq: 501, \(dqstart\-time\(dq: \(dq2024\-06\-12 17:52:06.814884\(dq, \(dqtotal\-duration\-usecs\(dq: 23951, \(dqmean\-duration\-usecs\(dq: 47 }, ... ], \(dqresult\-set\-format\(dq: false, \(dqinterval\-width\-secs\(dq: 5, \(dqtimestamp\(dq: \(dq2024\-06\-12 17:52:22.397233\(dq }, \(dqresult\(dq: 0, \(dqtext\(dq: \(dqperfmon\-get\-all\-durations: n found\(dq } .EE .UNINDENT .UNINDENT .sp When \fBresult\-set\-format\fP is true, the list of durations will be returned in a format similar to an SQL result set as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqarguments\(dq: { \(dqdurations\-result\-set\(dq: { \(dqcolumns\(dq: [ \(dqquery\-type\(dq, \(dqresponse\-type\(dq, \(dqstart\-event\(dq, \(dqend\-event\(dq, \(dqsubnet\-id\(dq, \(dqinterval\-start\(dq, \(dqoccurrence\(dq, \(dqmin\-duration\-usecs\(dq, \(dqmax\-duration\-usecs\(dq, \(dqtotal\-duration\-usecs\(dq, \(dqmean\-duration\-usecs\(dq ], \(dqrows\(dq: [ [ \(dqDHCPDISCOVER\(dq, \(dqDHCPOFFER\(dq, \(dqbuffer_read\(dq, \(dqmt_queued\(dq, 0, \(dq2024\-06\-12 17:52:06.814884\(dq, 501, 31, 118, 23951, 47 ], ... ] }, \(dqresult\-set\-format\(dq: true, \(dqinterval\-width\-secs\(dq: 5, \(dqtimestamp\(dq: \(dq2024\-06\-12 17:52:22.397233\(dq }, \(dqresult\(dq: 0, \(dqtext\(dq: \(dqperfmon\-get\-all\-durations: n found\(dq } .EE .UNINDENT .UNINDENT .sp The data values for each duration will be from the duration\(aqs last completed data interval. If a duration has no such interval, \fBinterval\-start\fP will be reported as \(dq\(dq and the remaining values will be zero. .SS Configuration .sp Use of the performance monitoring hook library is configured via several parameters: .INDENT 0.0 .IP \(bu 2 .INDENT 2.0 .TP .B enable\-monitoring This parameter enables event data aggregation for reporting, statistics, and alarms. It defaults to \fBfalse\fP\&. .UNINDENT .IP \(bu 2 .INDENT 2.0 .TP .B interval\-width\-secs This specifies the amount of time, in seconds, that individual task durations are accumulated into an aggregate before they are reported. The default is 60 seconds. .UNINDENT .IP \(bu 2 .INDENT 2.0 .TP .B stats\-mgr\-reporting This enables the reporting of aggregates to StatsMgr. It defaults to \fBtrue\fP\&. .UNINDENT .IP \(bu 2 .INDENT 2.0 .TP .B alarm\-report\-secs This specifies the amount of time, in seconds, between logging instances for an alarm once it has been triggered. It defaults to 300 seconds. .UNINDENT .IP \(bu 2 .INDENT 2.0 .TP .B alarms This is an optional list of alarms that monitor specific duration aggregates. Each alarm is defined by these four parameters: .UNINDENT .INDENT 2.0 .IP \(bu 2 .INDENT 2.0 .TP .B duration\-key Identifies the monitored duration for the following: .UNINDENT .INDENT 2.0 .IP \(bu 2 query\-type \- message type of the client query (e.g.DHCPDISCOVER, DHCPV6_REQUEST) .IP \(bu 2 response\-type \- message type of the server response (e.g. DHCPOFFER, DHCPV6_REPLY) .IP \(bu 2 start\-event \- event that defines the beginning of the task (e.g. socket_received, process_started) .IP \(bu 2 stop\-event \- event that defines the end of the task .IP \(bu 2 subnet\-id \- subnet selected during message processing (or 0 for global durations) .UNINDENT .IP \(bu 2 .INDENT 2.0 .TP .B enable\-alarm Enables or disables this alarm; defaults to \fBtrue\fP\&. .UNINDENT .IP \(bu 2 .INDENT 2.0 .TP .B high\-water\-ms Specifies the value, in milliseconds, over which the duration must occur to trigger this alarm; must be greater than zero. .UNINDENT .IP \(bu 2 .INDENT 2.0 .TP .B low\-water\-ms Specifies the value, in milliseconds, under which the duration must fall to clear this alarm; must be greater than zero but less than \fBhigh\-water\-ms\fP\&. .UNINDENT .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Passive event logging is always enabled, even without specifying the \(dqparameters\(dq section. .UNINDENT .UNINDENT .sp A sample configuration is shown below: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dqlib/kea/hooks/libdhcp_perfmon.so\(dq, \(dqparameters\(dq: { \(dqenable\-monitoring\(dq: true, \(dqinterval\-width\-secs\(dq: 5, \(dqstats\-mgr\-reporting\(dq: true, \(dqalarm\-report\-secs\(dq: 600, \(dqalarms\(dq: [ { \(dqduration\-key\(dq: { \(dqquery\-type\(dq: \(dqDHCPDISCOVER\(dq, \(dqresponse\-type\(dq: \(dqDHCPOFFER\(dq, \(dqstart\-event\(dq: \(dqprocess\-started\(dq, \(dqstop\-event\(dq: \(dqprocess\-completed\(dq, \(dqsubnet\-id\(dq: 0 }, \(dqenable\-alarm\(dq: true, \(dqhigh\-water\-ms\(dq: 500, \(dqlow\-water\-ms\(dq: 25 }] } }] } .EE .UNINDENT .UNINDENT .SS \fBlibdhcp_ping_check.so\fP: Ping Check .sp This hook library adds the ability to perform a \(dqping check\(dq of a candidate IPv4 address prior to offering it to a DHCP client. This feature is similar to a behavior available in ISC DHCP and one suggested in \X'tty: link https://tools.ietf.org/html/rfc2131'\fI\%RFC 2131\fP\X'tty: link', section 3.1, item 2. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 \fI\%libdhcp_ping_check.so\fP is part of the open source code and is available to every Kea user. It was previously available only to ISC customers with a paid support contract. .UNINDENT .UNINDENT .SS Overview .sp The Ping Check library, added in Kea 2.5.4, can be loaded by the \fI\%kea\-dhcp4\fP daemon by adding it to the \fBhooks\-libraries\fP element of the server\(aqs configuration: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dq/usr/local/lib/libdhcp_ping_check.so\(dq, \(dqparameters\(dq: { ... } }, ... ], ... } .EE .UNINDENT .UNINDENT .sp When the library is loaded, \fI\%kea\-dhcp4\fP conducts a ping check prior to offering a lease to a client if all of the following conditions are true: .INDENT 0.0 .IP 1. 3 The ping check hook library is loaded. .IP 2. 3 Ping checking is enabled. .IP 3. 3 The server is responding to a DHCPDISCOVER. .IP 4. 3 The candidate lease is neither active nor reserved. .IP 5. 3 Any of the following are true: .INDENT 3.0 .INDENT 3.5 a. This is the first offer of this lease to this client. This check can only be done if \fBoffer\-lifetime\fP is greater than zero (i.e. temporary allocation on DHCPDISCOVER is enabled). If \fBoffer\-lifetime\fP is zero ping checks are done for every DHCPOFFER, as the server has no way to know whether prior offers were made. .INDENT 0.0 .IP b. 3 The lease is being offered to a client other than its previous owner. .UNINDENT .sp c. The lease is being offered to its previous owner and more than the number of seconds specified by \fBping\-cltt\-secs\fP have elapsed since the CLTT of the original lease. .UNINDENT .UNINDENT .UNINDENT .sp When the ping check library is loaded, the \fI\%kea\-dhcp4\fP server responds to a DHCPDISCOVER by: .sp 1. Selecting a candidate IPv4 address through normal processes and using it to construct a DHCPOFFER. .sp 2. Parking the DHCPOFFER and requesting a ping check from the ping check hook library, via its \fBlease4_offer\fP callout. Refer to \fI\%Parked\-Packet Limit\fP for a basic introduction to packet parking. .sp 3. Testing the callout conditions described above: if they are not satisfied, it returns without conducting a check, and the server sends the DHCPOFFER to the client. Otherwise, the callout initiates a ping check for the lease address. .sp 4. Upon conclusion of the ping check, the server either sends the DHCPOFFER to the client, if the check concluded that the address is available, or discards the DHCPFOFFER and creates a DECLINED lease for the address. .sp Each ping check consists of the following steps: .sp 1. If the number of ECHO REPLYs sent is less than the configured minimum number to send, send an ICMP ECHO REQUEST to the lease address. Otherwise, conclude that the address is available. .sp 2. If no ECHO REPLY is received within a configurable amount of time, return to step 1. .INDENT 0.0 .IP 3. 3 Upon receipt of an ICMP ECHO REPLY, conclude that the lease is NOT available. .IP 4. 3 If any of the following occur: .INDENT 3.0 .INDENT 3.5 .INDENT 0.0 .IP a. 3 Receipt of an ICMP DESTINATION UNREACHABLE message .IP b. 3 Send failure of an ICMP ECHO REQUEST due to a network error (e.g. network is unreachable) .IP c. 3 Send failure of an ICMP ECHO REQUEST due to a permissions error (e.g. lease address is a broadcast address) .IP d. 3 Send failure of an ICMP ECHO REQUEST with socket buffer full error .UNINDENT .sp skip the address check and treat it as available. .UNINDENT .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 \(dqSocket buffer full\(dq errors indicate that the OS rate limits on ICMP are being exceeded. The server does not retry them, as this would likely only exacerbate the situation. If this occurs continuously, then the client load on the server may be too high to accommodate ping checking. Ping checking is not recommended for systems with high throughput demands. .UNINDENT .UNINDENT .SS Configuration .sp The ping check hook library currently supports the following configuration parameters that may be set at the global and subnet levels; subnet values override global values: .INDENT 0.0 .IP \(bu 2 \fBenable\-ping\-check\fP \- This parameter enables or disables ping checking at a given scope. .IP \(bu 2 \fBmin\-ping\-requests\fP \- This is the minimum number of ECHO REQUESTs sent without receiving a reply, before an address is declared available. The default is 1; it must be greater than zero. .IP \(bu 2 \fBreply\-timeout\fP \- This is the maximum amount of time to wait for a reply to a single ECHO REQUEST. Specified in milliseconds, it must be greater than zero; the default is 100. .IP \(bu 2 \fBping\-cltt\-secs\fP \- This specifies the number of seconds that must elapse after the lease\(aqs CLTT before a ping check is conducted, when the client is the lease\(aqs previous owner. The default value is 60 seconds. .UNINDENT .sp The following parameter is only supported at the global level: .INDENT 0.0 .IP \(bu 2 \fBping\-channel\-threads\fP \- In multi\-threaded mode, this is the number of threads in the channel\(aqs thread pool. The default is 0, which instructs the library to use the same number of threads as the Kea core. This value is ignored if given when Kea is in single\-threaded mode. .UNINDENT .sp The following configuration excerpt illustrates a global\-level configuration: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqhooks\-libraries\(dq: [{ \(dqlibrary\(dq: \(dqlib/kea/hooks/libdhcp_ping_check.so\(dq, \(dqparameters\(dq: { \(dqenable\-ping\-check\(dq : true, \(dqmin\-ping\-requests\(dq : 1, \(dqreply\-timeout\(dq : 100, \(dqping\-cltt\-secs\(dq : 60, \(dqping\-channel\-threads\(dq : 0 } }] } .EE .UNINDENT .UNINDENT .sp The following excerpt demonstrates a subnet\-level configuration: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqsubnet4\(dq: [{ \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq, \(dqpools\(dq: [{ \(dqpool\(dq: \(dq192.0.2.10 \- 192.0.2.20\(dq }], \(dquser\-context\(dq: { \(dqenable\-ping\-check\(dq : true, \(dqmin\-ping\-requests\(dq : 2, \(dqreply\-timeout\(dq : 250, \(dqping\-cltt\-secs\(dq : 120 } }] } .EE .UNINDENT .UNINDENT .SS \fBlibdhcp_pgsql.so\fP: Database Backend for PostgreSQL .INDENT 0.0 .TP .B This hook library implements PostgreSQL database storage for: .INDENT 7.0 .IP \(bu 2 Lease Backend .IP \(bu 2 Host Backend .IP \(bu 2 Configuration Backend .UNINDENT .UNINDENT .SS PostgreSQL Configuration Backend .sp This hook library works in conjunction with \fI\%libdhcp_cb_cmds.so\fP to implement the API to create, read, update, and delete (CRUD) the configuration in a PostgreSQL database. Please see \fI\%libdhcp_cb_cmds.so: Configuration Backend Commands\fP for more details. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 \fI\%libdhcp_pgsql.so\fP is part of the open source code and is available to every Kea user. However, this hook library only works with \fI\%libdhcp_cb_cmds.so\fP, which allows easy configuration management with the use of API commands. \fI\%libdhcp_cb_cmds.so\fP is available only to ISC customers with a paid support contract; for more information on subscription options, please complete the form at \X'tty: link https://www.isc.org/contact'\fI\%https://www.isc.org/contact\fP\X'tty: link'\&. .UNINDENT .UNINDENT .SS \fBlibdhcp_radius.so\fP: RADIUS Server Support .sp This hook library allows the Kea DHCP servers to use the RADIUS protocol to authorize DHCP clients through the access service, or for DHCP lease journaling through the accounting service. For details on RADIUS in Kea, please see \fI\%RADIUS\fP\&. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 \fI\%libdhcp_radius.so\fP is part of the open source code and is available to every Kea user. It was previously available only to ISC customers with a paid support contract. .UNINDENT .UNINDENT .SS \fBlibdhcp_rbac.so\fP: Role\-Based Access Control .SS Role\-Based Access Control (RBAC) Overview .sp Before the processing of commands in received HTTP requests, \fI\%libdhcp_rbac.so\fP takes specific parameters, e.g. the common\-name part of the client certificate subject name, to assign a role to the request. The configuration associated with this role is used to accept or reject the command. After processing, the response can be rewritten, e.g. parts can be removed. .INDENT 0.0 .TP .B Here is a summary of the steps in processing a request: .INDENT 7.0 .IP \(bu 2 The HTTP library records some information to be used later, e.g. the remote address. .IP \(bu 2 When TLS is required but the request was not protected by TLS, the request is rejected by sending an \(dqunauthorized\(dq response. .IP \(bu 2 The command is extracted from the request. .IP \(bu 2 A role is assigned using recorded information in the request. .IP \(bu 2 The role is used to accept (pass through) or reject (send a forbidden response to) the command. .UNINDENT .TP .B Here is a summary of the steps in processing a response: .INDENT 7.0 .IP \(bu 2 The information attached to the request is retrieved during the request processing (when the request was accepted). .IP \(bu 2 Request filters are applied to the response. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 \fI\%libdhcp_rbac.so\fP is available only to ISC customers with a paid support contract. For more information on subscription options, please complete the form at \X'tty: link https://www.isc.org/contact'\fI\%https://www.isc.org/contact\fP\X'tty: link'\&. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Since Kea 2.7.2 the RBAC is no longer limited to the Control Agent: it can be used by any other server supporting HTTP/HTTPS control sockets e.g. DHCPv4, DHCPv6 and DDNS servers. .UNINDENT .UNINDENT .SS Role\-Based Access Control Configuration .SS Role Assignment .sp Role assignment is governed by the configured role\-assignment method. .SS Role assignment methods .TS box center; l|l. T{ Name T} T{ Description T} _ T{ remote\-address T} T{ remote/client IP address T} _ T{ cert\-subject T} T{ common\-name part of the client certificate subject name T} _ T{ cert\-issuer T} T{ common\-name part of the client certificate issuer name T} _ T{ basic\-authentication T} T{ user ID of basic HTTP authentication T} _ T{ custom\-value T} T{ another role can be designed in external hooks T} .TE .SS Role Configuration .SS Role configuration parameters .TS box center; l|l. T{ Name T} T{ Description T} _ T{ name T} T{ the role name (with the exception of the default and unknown roles) T} _ T{ accept\-commands T} T{ the accept access list T} _ T{ reject\-commands T} T{ the reject access list T} _ T{ other\-commands T} T{ specifies what to do for commands not matching accept and reject lists (default: reject) T} _ T{ list\-match\-first T} T{ specifies what to do for commands matching both the accept and reject list by giving the list to check and apply first (default: accept) T} _ T{ response\-filters T} T{ the filters to apply to responses T} .TE .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The role assignment may fail with \fBcert\-subject\fP when the client certificate was not required, or it may have no subject common name and instead have a DNS alternative subject name. In this case, the role assignment returns the empty role and the \fBdefault\-role\fP entry is used. .sp The role assignment can return an unexpected value, e.g. with an unregistered role name or a typing error. In this case the \fBunknown\-role\fP entry is used. .sp The default for both \fBdefault\-role\fP and \fBunknown\-role\fP is to reject all commands. .UNINDENT .UNINDENT .SS API Commands .sp All commands of the REST API are described in files in the source directory \fBsrc/share/api\fP, or in installed Kea in \fB\&.../share/kea/api\fP\&. \fI\%libdhcp_rbac.so\fP reads these files to take the name, the access right (i.e. \fBread\fP or \fBwrite\fP), and the hook name. The access right can be modified in the file but changes are only applied after the server or agent restarts. Removing command definitions from \fB\&.../share/kea/api\fP has consequences: if the access control list is based on \fBread\fP or \fBwrite\fP and the definition file is missing, the server or agent always rejects such a command. If the access controls list is using \fBcommands\fP to specify the name of a command and the definition file from \fB\&.../share/kea/api\fP of this particular command is missing, the Control Agent logs an error on startup and exit. .SS Extra command\-definition parameters .TS box center; l|l. T{ Name T} T{ Description T} _ T{ name T} T{ (mandatory) the command name T} _ T{ access T} T{ (mandatory) the access right i.e. \fBread\fP or \fBwrite\fP T} _ T{ hook T} T{ (optional) the hook name (empty or not\-present for commands of servers or agents) T} .TE .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 These command description files are security\-sensitive, e.g. with too\-permissive access rights a local attacker may modify them and defeat the RBAC goal. .UNINDENT .UNINDENT .SS Access Control Lists .sp Access control lists can be specified using a name (string) or a single entry map. .SS Predefined named access list .TS box center; l|l. T{ Name T} T{ Description T} _ T{ ALL T} T{ matches everything T} _ T{ NONE T} T{ matches nothing T} _ T{ READ T} T{ matches commands with the read\-access right T} _ T{ WRITE T} T{ matches commands with the write\-access right T} .TE .sp Map access list specifications use a list type in the name of the single entry and parameter in the value. .SS Access list types .TS box center; l|l|l. T{ Name T} T{ Description T} T{ Parameter T} _ T{ not T} T{ logical not T} T{ access list T} _ T{ and T} T{ logical and T} T{ list of access lists T} _ T{ or T} T{ logical or T} T{ list of access lists T} _ T{ command T} T{ explicit list T} T{ list of command names T} _ T{ access T} T{ by access right T} T{ access right (\fBread\fP or \fBwrite\fP) T} _ T{ hook T} T{ by hook T} T{ hook name (can be empty) T} .TE .SS Response Filters .SS Predefined response filters .TS box center; l|l. T{ Name T} T{ Description T} _ T{ list\-commands T} T{ Removes not\-allowed commands from the list\-commands response T} .TE .SS Global Parameters .sp The global parameters are: .INDENT 0.0 .IP \(bu 2 \fBassign\-role\-method\fP: the name of the method which is used for role assignment. This parameter is mandatory. .IP \(bu 2 \fBapi\-files\fP: the path of the directory where the API files describing commands can be found. This parameter is mandatory. .IP \(bu 2 \fBrequire\-tls\fP: the specification of whether received requests on HTTP (vs HTTPS) are rejected. It defaults to \fBfalse\fP when the role\-assignment method is not based on certificates. .IP \(bu 2 \fBcommands\fP: the list of extra command configurations. .IP \(bu 2 \fBaccess\-control\-lists\fP: the named access control list definitions (each definition is a single entry map; the name of the entry is the name of the access list, and the value is the specification). The name is used in other parts of the configuration, such as \(dqaccept\-commands\(dq. .IP \(bu 2 \fBroles\fP: the role configurations. .IP \(bu 2 \fBdefault\-role\fP: the configuration of the default role (used when \(dq\(dq is assigned). .IP \(bu 2 \fBunknown\-role\fP: the configuration of the unknown role (used when the not\-empty assigned role has no configuration). .UNINDENT .SS Sample Configuration .sp A sample configuration is available in \fBdoc/examples/agent/rbac.json\fP in the Kea source and is copied below. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqControl\-agent\(dq: { // We need to specify where the agent should listen to incoming HTTP // queries. \(dqhttp\-host\(dq: \(dq127.0.0.1\(dq, // If enabling HA and multi\-threading, the 8000 port is used by the HA // hook library http listener. When using HA hook library with // multi\-threading to function, make sure the port used by dedicated // listener is different (e.g. 8001) than the one used by CA. Note // the commands should still be sent via CA. The dedicated listener // is specifically for HA updates only. \(dqhttp\-port\(dq: 8000, // TLS trust anchor (Certificate Authority). This is a file name or // (for OpenSSL only) a directory path. \(dqtrust\-anchor\(dq: \(dqmy\-ca\(dq, // TLS server certificate file name. \(dqcert\-file\(dq: \(dqmy\-cert\(dq, // TLS server private key file name. \(dqkey\-file\(dq: \(dqmy\-key\(dq, // TLS require client certificates flag. Default is true and means // require client certificates. False means they are optional. \(dqcert\-required\(dq: true, // Add hooks here. \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dq/opt/lib/libdhcp_rbac.so\(dq, \(dqparameters\(dq: { // This section configures the RBAC hook library. // Mandatory parameters. \(dqassign\-role\-method\(dq: \(dqcert\-subject\(dq, \(dqapi\-files\(dq: \(dq/opt/share/kea/api\(dq, // Optional parameters. \(dqrequire\-tls\(dq: true, \(dqcommands\(dq: [ { \(dqname\(dq: \(dqmy\-command\(dq, \(dqaccess\(dq: \(dqread\(dq, \(dqhook\(dq: \(dqmy\-hook\(dq } ], \(dqaccess\-control\-lists\(dq: [ { \(dqmy\-none\(dq: { \(dqnot\(dq: \(dqALL\(dq } },{ \(dqanother\-none\(dq: { \(dqand\(dq: [ \(dqALL\(dq, \(dqNONE\(dq ] } },{ \(dqmy\-read\(dq: { \(dqaccess\(dq: \(dqread\(dq } } ], \(dqroles\(dq: [ { \(dqname\(dq: \(dqkea\-client\(dq, \(dqaccept\-commands\(dq: { \(dqcommands\(dq: [ \(dqlist\-commands\(dq, \(dqstatus\-get\(dq ] }, \(dqreject\-commands\(dq: \(dqNONE\(dq, \(dqother\-commands\(dq: \(dqreject\(dq, \(dqlist\-match\-first\(dq: \(dqaccept\(dq, \(dqresponse\-filters\(dq: [ \(dqlist\-commands\(dq ] },{ \(dqname\(dq: \(dqadmin\(dq, \(dqaccept\-commands\(dq: \(dqALL\(dq, \(dqreject\-commands\(dq: { \(dqhook\(dq: \(dqcb_cmds\(dq }, \(dqlist\-match\-first\(dq: \(dqreject\(dq } ], \(dqdefault\-role\(dq: { \(dqaccept\-commands\(dq: \(dqNONE\(dq, \(dqreject\-commands\(dq: \(dqALL\(dq }, \(dqunknown\-role\(dq: { \(dqaccept\-commands\(dq: \(dqREAD\(dq, \(dqreject\-commands\(dq: \(dqWRITE\(dq } } } ] // Additional parameters, such as logging and others // omitted for clarity. } } .EE .UNINDENT .UNINDENT .SS Accept/Reject Algorithm .sp This is the pseudo\-code of the accept/reject decision algorithm which returns \fBtrue\fP (accept) or \fBfalse\fP (reject). .INDENT 0.0 .INDENT 3.5 .sp .EX bool match(command) { if (list\-match\-first == accept) { if (accept_list && accept_list\->match(command)) { return (true); } if (reject_list && reject_list\->match(command)) { return (false); } } else { if (reject_list && reject_list\->match(command)) { return (false); } if (accept_list && accept_list\->match(command)) { return (true); } } if (others == reject) { return (false); } else { return (true); } } .EE .UNINDENT .UNINDENT .SS Custom Hook Commands and Command Redefinition .sp It is possible to have a custom hook with new commands. In this case, Role Based Access Control can be used to manage a new command in two ways. .sp The \fBcommand\fP global parameter can be used to define its name, access type, and hook name: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommands\(dq: [ { \(dqname\(dq: \(dqmy\-new\-command\(dq, \(dqaccess\(dq: \(dqwrite\(dq, \(dqhook\(dq: \(dqmy\-custom\-hook\(dq } ], \&... } .EE .UNINDENT .UNINDENT .sp The new command can then be specified in \fBroles\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqroles\(dq: [ { \(dqname\(dq: \(dquser1\(dq, \(dqaccept\-commands\(dq: { \(dqcommands\(dq: [ \(dqmy\-new\-command\(dq ] }, \(dqreject\-commands\(dq: \(dqWRITE\(dq, \(dqlist\-match\-first\(dq: \(dqaccept\(dq }, { \(dqname\(dq: \(dquser2\(dq, \(dqaccept\-commands\(dq: { \(dqhook\(dq: \(dqmy\-custom\-hook\(dq }, \(dqreject\-commands\(dq: \(dqALL\(dq, \(dqlist\-match\-first\(dq: \(dqaccept\(dq } ], \&... } .EE .UNINDENT .UNINDENT .sp The second method is to create a custom file in \fB\&.../share/kea/api\fP and define the access type of the custom command(s). .sp It is also possible to redefine an existing command by removing its definition file from \fB\&.../share/kea/api\fP and defining it in the \fBcommands\fP global parameter: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommands\(dq: [ { \(dqname\(dq: \(dqdhcp\-disable\(dq, \(dqaccess\(dq: \(dqread\(dq, \(dqhook\(dq: \(dqmy\-custom\-hook\-3\(dq } ] } .EE .UNINDENT .UNINDENT .sp With this approach, an administrator can put the configurations of all existing commands inside the Control Agent\(aqs configuration file. .SS Extensive Example .sp Here is an extensive example for a role accepting all read commands, with the exception of \fI\%config\-get\fP, e.g. for hiding passwords. For any remote user who is not recognized as \(dquser1\(dq, all commands should be rejected. .sp The first option is to put the allowed commands in the \(dqaccept\-commands\(dq list and to reject anything else: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqroles\(dq: [ { \(dqname\(dq: \(dquser1\(dq, \(dqaccept\-commands\(dq: { \(dqand\(dq: [ \(dqREAD\(dq, { \(dqnot\(dq: { \(dqcommands\(dq: [ \(dqconfig\-get\(dq ] } } ] }, \(dqreject\-commands\(dq: \(dqALL\(dq, // This is the default but as the config relies on it // it is explicitly set. \(dqlist\-match\-first\(dq: \(dqaccept\(dq }, \&... ], \&... } .EE .UNINDENT .UNINDENT .sp A common alternative is not to set the \(dqreject\-commands\(dq list, i.e. leave it empty and rely on \(dqother\-commands\(dq to reject anything else. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqroles\(dq: [ { \(dqname\(dq: \(dquser2\(dq, \(dqaccept\-commands\(dq: { \(dqand\(dq: [ \(dqREAD\(dq, { \(dqnot\(dq: { \(dqcommands\(dq: [ \(dqconfig\-get\(dq ] } } ] }, // This is the default but as the config relies on it // it is explicitly set. \(dqother\-commands\(dq: \(dqreject\(dq }, \&... ], \&... } .EE .UNINDENT .UNINDENT .sp It is also possible to do the opposite, i.e. to set only the \(dqreject\-commands\(dq list: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqroles\(dq: [ { \(dqname\(dq: \(dquser3\(dq, \(dqreject\-commands\(dq: { \(dqor\(dq: [ \(dqWRITE\(dq, { \(dqcommands\(dq: [ \(dqconfig\-get\(dq ] } ] }, \(dqother\-commands\(dq: \(dqaccept\(dq }, \&... ], \&... } .EE .UNINDENT .UNINDENT .sp Or use both lists with the exception in the \(dqreject\-commands\(dq list, which must be checked first as \(dqconfig\-get\(dq has the read\-access right. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqroles\(dq: [ { \(dqname\(dq: \(dquser4\(dq, \(dqaccept\-commands\(dq: \(dqREAD\(dq, \(dqreject\-commands\(dq: { \(dqcommands\(dq: [ \(dqconfig\-get\(dq ] }, \(dqlist\-match\-first\(dq: \(dqreject\(dq }, \&... ], \&... } .EE .UNINDENT .UNINDENT .sp To check any configuration, it is a good idea to use the \(dqlist\-commands\(dq response filter, which shows errors such as missing (rejected) commands and extra (accepted) commands. .sp \fBaccess\-control\-lists\fP can be used for definitions of access control lists and later reused in \fBroles\fP: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqaccess\-control\-lists\(dq:[ { \(dqmy\-list\-one\(dq:{ \(dqor\(dq:[ { \(dqhook\(dq: \(dqsubnet_cmds\(dq }, { \(dqcommands\(dq:[ \(dqlist\-commands\(dq ] } ] } }, { \(dqmy\-list\-two\(dq:{ \(dqand\(dq:[ \(dqREAD\(dq, { \(dqnot\(dq:{ \(dqcommands\(dq:[ \(dqconfig\-get\(dq ] } } ] } }, { \(dqmy\-list\-three\(dq:{ \(dqor\(dq:[ { \(dqhook\(dq:\(dqsubnet_cmds\(dq }, { \(dqhook\(dq:\(dqclass_cmds\(dq }, { \(dqhook\(dq:\(dqlease_cmds\(dq } ] } } ], \(dqroles\(dq:[ { \(dqname\(dq:\(dqadmin\(dq, \(dqaccept\-commands\(dq:\(dqmy\-list\-one\(dq, \(dqreject\-commands\(dq:\(dqALL\(dq, \(dqlist\-match\-first\(dq:\(dqaccept\(dq }, { \(dqname\(dq:\(dqadmin2\(dq, \(dqaccept\-commands\(dq:\(dqmy\-list\-two\(dq, \(dqreject\-commands\(dq:\(dqALL\(dq, \(dqlist\-match\-first\(dq:\(dqaccept\(dq } ], \(dqunknown\-role\(dq:{ \(dqaccept\-commands\(dq:\(dqmy\-list\-three\(dq, \(dqreject\-commands\(dq:\(dqALL\(dq }, \&... } .EE .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS \fBlibdhcp_run_script.so\fP: Run Script Support for External Hook Scripts .sp The Run Script hook library adds support for calling an external script for specific packet\-processing hook points. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 \fI\%libdhcp_run_script.so\fP is part of the open source code and is available to every Kea user. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 This library can only be loaded by the \fI\%kea\-dhcp4\fP or \fI\%kea\-dhcp6\fP process. .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dq/usr/local/lib/libdhcp_run_script.so\(dq, \(dqparameters\(dq: { \(dqname\(dq: \(dq/full_path_to/script_name.sh\(dq, \(dqsync\(dq: false } } ] } .EE .UNINDENT .UNINDENT .sp The parameters contain the \fBname\fP, which indicates the full path to the external script to be called on each hook point, and also the \fBsync\fP option, to be able to wait synchronously for the script to finish execution. If the \fBsync\fP parameter is \fBfalse\fP, then the script will launch and Kea will not wait for the execution to finish, causing all the OUT parameters of the script (including the next step) to be ignored. .sp The external script must be stored in the \fB\(dq[kea\-install\-dir]/share/kea/scripts/\(dq\fP directory which can be overridden at startup by setting the environment variable \fBKEA_HOOK_SCRIPTS_PATH\fP to a different path. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The script inherits all privileges from the server which calls it. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Currently, enabling synchronous calls to external scripts is not supported. .UNINDENT .UNINDENT .sp This library has several hook\-point functions implemented, which are called at the specific packet\-processing stage. .sp The dhcpv4 hook points: .INDENT 0.0 .INDENT 3.5 .sp .EX lease4_renew lease4_expire lease4_recover leases4_committed lease4_release lease4_decline .EE .UNINDENT .UNINDENT .sp The dhcpv6 hook points: .INDENT 0.0 .INDENT 3.5 .sp .EX lease6_renew lease6_rebind lease6_expire lease6_recover leases6_committed lease6_release lease6_decline addr6_register .EE .UNINDENT .UNINDENT .sp Each hook point extracts the Kea internal data and exports it as string environment variables. These parameters are shared with the target script using the child process environment. The only parameter passed to the call of the target script is the name of the hook point. .sp An example of a script implementing all hook points is presented below: .INDENT 0.0 .INDENT 3.5 .sp .EX #!/bin/sh unknown_handle() { echo \(dqUnhandled function call ${*}\(dq exit 123 } lease4_renew () { ... } lease4_expire () { ... } lease4_recover () { ... } leases4_committed () { ... } lease4_release () { ... } lease4_decline () { ... } lease6_renew () { ... } lease6_rebind () { ... } lease6_expire () { ... } lease6_recover () { ... } leases6_committed () { ... } lease6_release () { ... } lease6_decline () { ... } addr6_register () { ... } case \(dq$1\(dq in \(dqlease4_renew\(dq) lease4_renew ;; \(dqlease4_expire\(dq) lease4_expire ;; \(dqlease4_recover\(dq) lease4_recover ;; \(dqleases4_committed\(dq) leases4_committed ;; \(dqlease4_release\(dq) lease4_release ;; \(dqlease4_decline\(dq) lease4_decline ;; \(dqlease6_renew\(dq) lease6_renew ;; \(dqlease6_rebind\(dq) lease6_rebind ;; \(dqlease6_expire\(dq) lease6_expire ;; \(dqlease6_recover\(dq) lease6_recover ;; \(dqleases6_committed\(dq) leases6_committed ;; \(dqlease6_release\(dq) lease6_release ;; \(dqlease6_decline\(dq) lease6_decline ;; \(dqaddr6_register\(dq) addr6_register ;; *) unknown_handle \(dq${@}\(dq ;; esac .EE .UNINDENT .UNINDENT .sp Available parameters for each hook point are presented below. .sp DHCPv4: .sp \fBlease4_renew\fP .INDENT 0.0 .INDENT 3.5 .sp .EX QUERY4_TYPE QUERY4_TXID QUERY4_LOCAL_ADDR QUERY4_LOCAL_PORT QUERY4_REMOTE_ADDR QUERY4_REMOTE_PORT QUERY4_IFACE_INDEX QUERY4_IFACE_NAME QUERY4_HOPS QUERY4_SECS QUERY4_FLAGS QUERY4_CIADDR QUERY4_SIADDR QUERY4_YIADDR QUERY4_GIADDR QUERY4_RELAYED QUERY4_HWADDR QUERY4_HWADDR_TYPE QUERY4_LOCAL_HWADDR QUERY4_LOCAL_HWADDR_TYPE QUERY4_REMOTE_HWADDR QUERY4_REMOTE_HWADDR_TYPE QUERY4_OPTION_82 QUERY4_OPTION_82_SUB_OPTION_1 QUERY4_OPTION_82_SUB_OPTION_2 SUBNET4_ID SUBNET4_NAME SUBNET4_PREFIX SUBNET4_PREFIX_LEN PKT4_CLIENT_ID PKT4_HWADDR PKT4_HWADDR_TYPE LEASE4_ADDRESS LEASE4_CLTT LEASE4_HOSTNAME LEASE4_HWADDR LEASE4_HWADDR_TYPE LEASE4_STATE LEASE4_SUBNET_ID LEASE4_VALID_LIFETIME LEASE4_CLIENT_ID .EE .UNINDENT .UNINDENT .sp \fBlease4_expire\fP .INDENT 0.0 .INDENT 3.5 .sp .EX LEASE4_ADDRESS LEASE4_CLTT LEASE4_HOSTNAME LEASE4_HWADDR LEASE4_HWADDR_TYPE LEASE4_STATE LEASE4_SUBNET_ID LEASE4_VALID_LIFETIME LEASE4_CLIENT_ID REMOVE_LEASE .EE .UNINDENT .UNINDENT .sp \fBlease4_recover\fP .INDENT 0.0 .INDENT 3.5 .sp .EX LEASE4_ADDRESS LEASE4_CLTT LEASE4_HOSTNAME LEASE4_HWADDR LEASE4_HWADDR_TYPE LEASE4_STATE LEASE4_SUBNET_ID LEASE4_VALID_LIFETIME LEASE4_CLIENT_ID .EE .UNINDENT .UNINDENT .sp \fBleases4_committed\fP .INDENT 0.0 .INDENT 3.5 .sp .EX QUERY4_TYPE QUERY4_TXID QUERY4_LOCAL_ADDR QUERY4_LOCAL_PORT QUERY4_REMOTE_ADDR QUERY4_REMOTE_PORT QUERY4_IFACE_INDEX QUERY4_IFACE_NAME QUERY4_HOPS QUERY4_SECS QUERY4_FLAGS QUERY4_CIADDR QUERY4_SIADDR QUERY4_YIADDR QUERY4_GIADDR QUERY4_RELAYED QUERY4_HWADDR QUERY4_HWADDR_TYPE QUERY4_LOCAL_HWADDR QUERY4_LOCAL_HWADDR_TYPE QUERY4_REMOTE_HWADDR QUERY4_REMOTE_HWADDR_TYPE QUERY4_OPTION_82 QUERY4_OPTION_82_SUB_OPTION_1 QUERY4_OPTION_82_SUB_OPTION_2 LEASES4_SIZE DELETED_LEASES4_SIZE .EE .UNINDENT .UNINDENT .sp If \fBLEASES4_SIZE\fP or \fBDELETED_LEASES4_SIZE\fP is non\-zero, then each lease has its own unique identifier, as shown below. The first index starts at 0. .INDENT 0.0 .INDENT 3.5 .sp .EX LEASES4_AT0_ADDRESS LEASES4_AT0_CLTT LEASES4_AT0_HOSTNAME LEASES4_AT0_HWADDR LEASES4_AT0_HWADDR_TYPE LEASES4_AT0_STATE LEASES4_AT0_SUBNET_ID LEASES4_AT0_VALID_LIFETIME LEASES4_AT0_CLIENT_ID DELETED_LEASES4_AT0_ADDRESS DELETED_LEASES4_AT0_CLTT DELETED_LEASES4_AT0_HOSTNAME DELETED_LEASES4_AT0_HWADDR DELETED_LEASES4_AT0_HWADDR_TYPE DELETED_LEASES4_AT0_STATE DELETED_LEASES4_AT0_SUBNET_ID DELETED_LEASES4_AT0_VALID_LIFETIME DELETED_LEASES4_AT0_CLIENT_ID .EE .UNINDENT .UNINDENT .sp \fBlease4_release\fP .INDENT 0.0 .INDENT 3.5 .sp .EX QUERY4_TYPE QUERY4_TXID QUERY4_LOCAL_ADDR QUERY4_LOCAL_PORT QUERY4_REMOTE_ADDR QUERY4_REMOTE_PORT QUERY4_IFACE_INDEX QUERY4_IFACE_NAME QUERY4_HOPS QUERY4_SECS QUERY4_FLAGS QUERY4_CIADDR QUERY4_SIADDR QUERY4_YIADDR QUERY4_GIADDR QUERY4_RELAYED QUERY4_HWADDR QUERY4_HWADDR_TYPE QUERY4_LOCAL_HWADDR QUERY4_LOCAL_HWADDR_TYPE QUERY4_REMOTE_HWADDR QUERY4_REMOTE_HWADDR_TYPE QUERY4_OPTION_82 QUERY4_OPTION_82_SUB_OPTION_1 QUERY4_OPTION_82_SUB_OPTION_2 LEASE4_ADDRESS LEASE4_CLTT LEASE4_HOSTNAME LEASE4_HWADDR LEASE4_HWADDR_TYPE LEASE4_STATE LEASE4_SUBNET_ID LEASE4_VALID_LIFETIME LEASE4_CLIENT_ID .EE .UNINDENT .UNINDENT .sp \fBlease4_decline\fP .INDENT 0.0 .INDENT 3.5 .sp .EX QUERY4_TYPE QUERY4_TXID QUERY4_LOCAL_ADDR QUERY4_LOCAL_PORT QUERY4_REMOTE_ADDR QUERY4_REMOTE_PORT QUERY4_IFACE_INDEX QUERY4_IFACE_NAME QUERY4_HOPS QUERY4_SECS QUERY4_FLAGS QUERY4_CIADDR QUERY4_SIADDR QUERY4_YIADDR QUERY4_GIADDR QUERY4_RELAYED QUERY4_HWADDR QUERY4_HWADDR_TYPE QUERY4_LOCAL_HWADDR QUERY4_LOCAL_HWADDR_TYPE QUERY4_REMOTE_HWADDR QUERY4_REMOTE_HWADDR_TYPE QUERY4_OPTION_82 QUERY4_OPTION_82_SUB_OPTION_1 QUERY4_OPTION_82_SUB_OPTION_2 LEASE4_ADDRESS LEASE4_CLTT LEASE4_HOSTNAME LEASE4_HWADDR LEASE4_HWADDR_TYPE LEASE4_STATE LEASE4_SUBNET_ID LEASE4_VALID_LIFETIME LEASE4_CLIENT_ID .EE .UNINDENT .UNINDENT .sp DHCPv6: .sp \fBlease6_renew\fP .INDENT 0.0 .INDENT 3.5 .sp .EX QUERY6_TYPE QUERY6_TXID QUERY6_LOCAL_ADDR QUERY6_LOCAL_PORT QUERY6_REMOTE_ADDR QUERY6_REMOTE_PORT QUERY6_IFACE_INDEX QUERY6_IFACE_NAME QUERY6_REMOTE_HWADDR QUERY6_REMOTE_HWADDR_TYPE QUERY6_PROTO QUERY6_CLIENT_ID LEASE6_ADDRESS LEASE6_CLTT LEASE6_HOSTNAME LEASE6_HWADDR LEASE6_HWADDR_TYPE LEASE6_STATE LEASE6_SUBNET_ID LEASE6_VALID_LIFETIME LEASE6_DUID LEASE6_IAID LEASE6_PREFERRED_LIFETIME LEASE6_PREFIX_LEN LEASE6_TYPE PKT6_IA_IAID PKT6_IA_IA_TYPE PKT6_IA_IA_T1 PKT6_IA_IA_T2 .EE .UNINDENT .UNINDENT .sp \fBlease6_rebind\fP .INDENT 0.0 .INDENT 3.5 .sp .EX QUERY6_TYPE QUERY6_TXID QUERY6_LOCAL_ADDR QUERY6_LOCAL_PORT QUERY6_REMOTE_ADDR QUERY6_REMOTE_PORT QUERY6_IFACE_INDEX QUERY6_IFACE_NAME QUERY6_REMOTE_HWADDR QUERY6_REMOTE_HWADDR_TYPE QUERY6_PROTO QUERY6_CLIENT_ID LEASE6_ADDRESS LEASE6_CLTT LEASE6_HOSTNAME LEASE6_HWADDR LEASE6_HWADDR_TYPE LEASE6_STATE LEASE6_SUBNET_ID LEASE6_VALID_LIFETIME LEASE6_DUID LEASE6_IAID LEASE6_PREFERRED_LIFETIME LEASE6_PREFIX_LEN LEASE6_TYPE PKT6_IA_IAID PKT6_IA_IA_TYPE PKT6_IA_IA_T1 PKT6_IA_IA_T2 .EE .UNINDENT .UNINDENT .sp \fBlease6_expire\fP .INDENT 0.0 .INDENT 3.5 .sp .EX LEASE6_ADDRESS LEASE6_CLTT LEASE6_HOSTNAME LEASE6_HWADDR LEASE6_HWADDR_TYPE LEASE6_STATE LEASE6_SUBNET_ID LEASE6_VALID_LIFETIME LEASE6_DUID LEASE6_IAID LEASE6_PREFERRED_LIFETIME LEASE6_PREFIX_LEN LEASE6_TYPE REMOVE_LEASE .EE .UNINDENT .UNINDENT .sp \fBlease6_recover\fP .INDENT 0.0 .INDENT 3.5 .sp .EX LEASE6_ADDRESS LEASE6_CLTT LEASE6_HOSTNAME LEASE6_HWADDR LEASE6_HWADDR_TYPE LEASE6_STATE LEASE6_SUBNET_ID LEASE6_VALID_LIFETIME LEASE6_DUID LEASE6_IAID LEASE6_PREFERRED_LIFETIME LEASE6_PREFIX_LEN LEASE6_TYPE .EE .UNINDENT .UNINDENT .sp \fBleases6_committed\fP .INDENT 0.0 .INDENT 3.5 .sp .EX QUERY6_TYPE QUERY6_TXID QUERY6_LOCAL_ADDR QUERY6_LOCAL_PORT QUERY6_REMOTE_ADDR QUERY6_REMOTE_PORT QUERY6_IFACE_INDEX QUERY6_IFACE_NAME QUERY6_REMOTE_HWADDR QUERY6_REMOTE_HWADDR_TYPE QUERY6_PROTO QUERY6_CLIENT_ID LEASES6_SIZE DELETED_LEASES6_SIZE .EE .UNINDENT .UNINDENT .sp If \fBLEASES6_SIZE\fP or \fBDELETED_LEASES6_SIZE\fP is non\-zero, then each lease has its own unique identifier, as shown below. The first index starts at 0. .INDENT 0.0 .INDENT 3.5 .sp .EX LEASES6_AT0_ADDRESS LEASES6_AT0_CLTT LEASES6_AT0_HOSTNAME LEASES6_AT0_HWADDR LEASES6_AT0_HWADDR_TYPE LEASES6_AT0_STATE LEASES6_AT0_SUBNET_ID LEASES6_AT0_VALID_LIFETIME LEASES6_AT0_DUID LEASES6_AT0_IAID LEASES6_AT0_PREFERRED_LIFETIME LEASES6_AT0_PREFIX_LEN LEASES6_AT0_TYPE DELETED_LEASES6_AT0_ADDRESS DELETED_LEASES6_AT0_CLTT DELETED_LEASES6_AT0_HOSTNAME DELETED_LEASES6_AT0_HWADDR DELETED_LEASES6_AT0_HWADDR_TYPE DELETED_LEASES6_AT0_STATE DELETED_LEASES6_AT0_SUBNET_ID DELETED_LEASES6_AT0_VALID_LIFETIME DELETED_LEASES6_AT0_DUID DELETED_LEASES6_AT0_IAID DELETED_LEASES6_AT0_PREFERRED_LIFETIME DELETED_LEASES6_AT0_PREFIX_LEN DELETED_LEASES6_AT0_TYPE .EE .UNINDENT .UNINDENT .sp \fBlease6_release\fP .INDENT 0.0 .INDENT 3.5 .sp .EX QUERY6_TYPE QUERY6_TXID QUERY6_LOCAL_ADDR QUERY6_LOCAL_PORT QUERY6_REMOTE_ADDR QUERY6_REMOTE_PORT QUERY6_IFACE_INDEX QUERY6_IFACE_NAME QUERY6_REMOTE_HWADDR QUERY6_REMOTE_HWADDR_TYPE QUERY6_PROTO QUERY6_CLIENT_ID LEASE6_ADDRESS LEASE6_CLTT LEASE6_HOSTNAME LEASE6_HWADDR LEASE6_HWADDR_TYPE LEASE6_STATE LEASE6_SUBNET_ID LEASE6_VALID_LIFETIME LEASE6_DUID LEASE6_IAID LEASE6_PREFERRED_LIFETIME LEASE6_PREFIX_LEN LEASE6_TYPE .EE .UNINDENT .UNINDENT .sp \fBlease6_decline\fP .INDENT 0.0 .INDENT 3.5 .sp .EX QUERY6_TYPE QUERY6_TXID QUERY6_LOCAL_ADDR QUERY6_LOCAL_PORT QUERY6_REMOTE_ADDR QUERY6_REMOTE_PORT QUERY6_IFACE_INDEX QUERY6_IFACE_NAME QUERY6_REMOTE_HWADDR QUERY6_REMOTE_HWADDR_TYPE QUERY6_PROTO QUERY6_CLIENT_ID LEASE6_ADDRESS LEASE6_CLTT LEASE6_HOSTNAME LEASE6_HWADDR LEASE6_HWADDR_TYPE LEASE6_STATE LEASE6_SUBNET_ID LEASE6_VALID_LIFETIME LEASE6_DUID LEASE6_IAID LEASE6_PREFERRED_LIFETIME LEASE6_PREFIX_LEN LEASE6_TYPE .EE .UNINDENT .UNINDENT .sp \fBaddr6_register\fP .INDENT 0.0 .INDENT 3.5 .sp .EX QUERY6_TYPE QUERY6_TXID QUERY6_LOCAL_ADDR QUERY6_LOCAL_PORT QUERY6_REMOTE_ADDR QUERY6_REMOTE_PORT QUERY6_IFACE_INDEX QUERY6_IFACE_NAME QUERY6_REMOTE_HWADDR QUERY6_REMOTE_HWADDR_TYPE QUERY6_PROTO QUERY6_CLIENT_ID ADDRESS6 OLD_LEASE6_ADDRESS OLD_LEASE6_CLTT OLD_LEASE6_HOSTNAME OLD_LEASE6_HWADDR OLD_LEASE6_HWADDR_TYPE OLD_LEASE6_STATE OLD_LEASE6_SUBNET_ID OLD_LEASE6_VALID_LIFETIME OLD_LEASE6_DUID OLD_LEASE6_IAID OLD_LEASE6_PREFERRED_LIFETIME OLD_LEASE6_PREFIX_LEN OLD_LEASE6_TYPE NEW_LEASE6_ADDRESS NEW_LEASE6_CLTT NEW_LEASE6_HOSTNAME NEW_LEASE6_HWADDR NEW_LEASE6_HWADDR_TYPE NEW_LEASE6_STATE NEW_LEASE6_SUBNET_ID NEW_LEASE6_VALID_LIFETIME NEW_LEASE6_DUID NEW_LEASE6_IAID NEW_LEASE6_PREFERRED_LIFETIME NEW_LEASE6_PREFIX_LEN NEW_LEASE6_TYPE .EE .UNINDENT .UNINDENT .sp The OLD_LEASE6 does not always exist. .sp The leases4_committed hook point needs for loops to handle the list of addresses. This can be achived in the following way: .INDENT 0.0 .INDENT 3.5 .sp .EX leases4_committed() { for i in $(seq 0 $((LEASES4_SIZE\-1))); do LEASE4_ADDRESS=$(eval \(dqecho \e$LEASES4_AT${i}_ADDRESS\(dq) ... done for i in $(seq 0 $((DELETED_LEASES4_SIZE\-1))); do DELETED_LEASE4_ADDRESS=$(eval \(dqecho \e$DELETED_LEASES4_AT${i}_ADDRESS\(dq) ... done exit 0 } .EE .UNINDENT .UNINDENT .sp The leases6_committed hook point needs for loops to handle the list of addresses. This can be achived in the following way: .INDENT 0.0 .INDENT 3.5 .sp .EX leases6_committed() { for i in $(seq 0 $((LEASES6_SIZE\-1))); do LEASE6_ADDRESS=$(eval \(dqecho \e$LEASES6_AT${i}_ADDRESS\(dq) ... done for i in $(seq 0 $((DELETED_LEASES6_SIZE\-1))); do DELETED_LEASE6_ADDRESS=$(eval \(dqecho \e$DELETED_LEASES6_AT${i}_ADDRESS\(dq) ... done exit 0 } .EE .UNINDENT .UNINDENT .SS \fBlibdhcp_stat_cmds.so\fP: Statistics Commands for Supplemental Lease Statistics .sp This library provides additional commands for retrieving lease statistics from Kea DHCP servers. These commands were added to address an issue with obtaining accurate lease statistics in deployments running multiple Kea servers that use a shared lease backend. The in\-memory statistics kept by individual servers only track lease changes made by that server; thus, in a deployment with multiple servers (e.g. two \fI\%kea\-dhcp6\fP servers using the same PostgreSQL database for lease storage), these statistics are incomplete. The MySQL and PostgreSQL backends in Kea track lease allocation changes as they occur via database triggers. Additionally, all the lease backends were extended to support retrieving lease statistics for a single subnet, a range of subnets, or all subnets. Finally, this library provides commands for retrieving these statistics. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 \fI\%libdhcp_stat_cmds.so\fP is part of the open source code and is available to every Kea user. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 This library can only be loaded by the \fI\%kea\-dhcp4\fP or \fI\%kea\-dhcp6\fP process. .UNINDENT .UNINDENT .sp The commands provided by this library are: .INDENT 0.0 .IP \(bu 2 \fI\%stat\-lease4\-get\fP \- fetches DHCPv4 lease statistics. .IP \(bu 2 \fI\%stat\-lease6\-get\fP \- fetches DHCPv6 lease statistics. .UNINDENT .sp The Statistics Commands library is part of the open source code and is available to every Kea user. .sp All commands use JSON syntax and can be issued directly to the servers via either the control channel (see \fI\%Management API\fP) or the Control Agent (see \fI\%The Kea Control Agent\fP). .sp This library is loaded in the same way as other libraries and currently has no parameters: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqDhcp6\(dq: { \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dq/path/libdhcp_stat_cmds.so\(dq }, ... ] } .EE .UNINDENT .UNINDENT .sp In a deployment with multiple Kea DHCP servers sharing a common lease storage, this hook library can be loaded by any or all of the servers. However, a server\(aqs response to a \fI\%stat\-lease4\-get\fP / \fI\%stat\-lease6\-get\fP command will only contain data for subnets known to that server. In other words, if a subnet does not appear in a server\(aqs configuration, Kea will not retrieve statistics for it. .SS The \fBstat\-lease4\-get\fP, \fBstat\-lease6\-get\fP Commands .sp The \fI\%stat\-lease4\-get\fP and \fI\%stat\-lease6\-get\fP commands fetch lease statistics for a range of known subnets. The range of subnets is determined through the use of optional command input parameters: .INDENT 0.0 .IP \(bu 2 \fBsubnet\-id\fP \- the ID of the subnet for which lease statistics should be fetched; used to get statistics for a single subnet. If the subnet does not exist, the command result code is 3 (i.e. \fBCONTROL_RESULT_EMPTY\fP). .IP \(bu 2 \fBsubnet\-range\fP \- a pair of subnet IDs which describe an inclusive range of subnets for which statistics should be retrieved. The range may include one or more IDs that correspond to no subnet; in this case, the command only outputs lease statistics for those that exist. However, if the range does not include any known subnets, the command result code is 3 (i.e. \fBCONTROL_RESULT_EMPTY\fP). .INDENT 2.0 .IP \(bu 2 \fBfirst\-subnet\-id\fP \- the ID of the first subnet in the range. .IP \(bu 2 \fBlast\-subnet\-id\fP \- the ID of the last subnet in the range. .UNINDENT .UNINDENT .sp The use of \fBsubnet\-id\fP and \fBsubnet\-range\fP are mutually exclusive. If no parameters are given, the result will contain data for all known subnets. Note that in configurations with many subnets, this can result in a large response. .sp The following command fetches lease statistics for all known subnets from a \fI\%kea\-dhcp4\fP server: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqstat\-lease4\-get\(dq } .EE .UNINDENT .UNINDENT .sp The following command fetches lease statistics for subnet ID 10 from a \fI\%kea\-dhcp6\fP server: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqstat\-lease6\-get\(dq, \(dqarguments\(dq: { \(dqsubnet\-id\(dq : 10 } } .EE .UNINDENT .UNINDENT .sp The following command fetches lease statistics for all subnets with IDs in the range 10 through 50 from a \fI\%kea\-dhcp4\fP server: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqstat\-lease4\-get\(dq, \(dqarguments\(dq: { \(dqsubnet\-range\(dq: { \(dqfirst\-subnet\-id\(dq: 10, \(dqlast\-subnet\-id\(dq: 50 } } } .EE .UNINDENT .UNINDENT .sp The response to either command will contain three elements: .INDENT 0.0 .IP \(bu 2 \fBresult\fP \- a numeric value indicating the outcome of the command where: .INDENT 2.0 .IP \(bu 2 \fB0\fP \- the command was successful; .IP \(bu 2 \fB1\fP \- an error occurred, and an explanation is the \(dqtext\(dq element; or .IP \(bu 2 \fB2\fP \- the fetch found no matching data. .UNINDENT .IP \(bu 2 \fBtext\fP \- an explanation of the command outcome. When the command succeeds, it contains the command name along with the number of rows returned. .IP \(bu 2 \fBarguments\fP \- a map containing the data returned by the command as the element \(dqresult\-set\(dq, which is patterned after SQL statement responses: .INDENT 2.0 .IP \(bu 2 \fBcolumns\fP \- a list of text column labels. .sp The columns returned for DHCPv4 are: .INDENT 2.0 .IP \(bu 2 \fBsubnet\-id\fP \- the ID of the subnet. .IP \(bu 2 \fBtotal\-addresses\fP \- the total number of addresses available for DHCPv4 management in the subnet. In other words, this is the count of all addresses in all the configured pools in the subnet. .IP \(bu 2 \fBcumulative\-assigned\-addresses\fP \- the cumulative number of addresses in the subnet that have been assigned to a client by the server since it started. .IP \(bu 2 \fBassigned\-addresses\fP \- the number of addresses in the subnet that are currently assigned to a client. .IP \(bu 2 \fBdeclined\-addresses\fP \- the number of addresses in the subnet that are currently declined and are thus unavailable for assignment. .UNINDENT .sp The columns returned for DHCPv6 are: .INDENT 2.0 .IP \(bu 2 \fBsubnet\-id\fP \- the ID of the subnet. .IP \(bu 2 \fBtotal\-nas\fP \- the number of NA addresses available for DHCPv6 management in the subnet. In other words, this is the count of all the NA addresses in all the configured NA pools in the subnet. .IP \(bu 2 \fBcumulative\-assigned\-nas\fP \- the cumulative number of NA addresses in the subnet that have been assigned to a client by the server since it started. .IP \(bu 2 \fBassigned\-nas\fP \- the number of NA addresses in the subnet that are currently assigned to a client. .IP \(bu 2 \fBdeclined\-addresses\fP \- the number of NA addresses that are currently declined and are thus unavailable for assignment. .IP \(bu 2 \fBtotal\-pds\fP \- the total number of PD prefixes available of DHCPv6 management in the subnet. In other words, this is the count of all prefixes in all the configured prefix pools in the subnet. .IP \(bu 2 \fBcumulative\-assigned\-pds\fP \- the cumulative number of PD prefixes in the subnet that have been assigned to a client by the server since it started. .IP \(bu 2 \fBassigned\-pds\fP \- the number of PD prefixes in the subnet that are currently assigned to a client. .UNINDENT .IP \(bu 2 \fBrows\fP \- a list of rows, one per subnet ID. Each row contains a data value corresponding to and in the same order as each column listed in \(dqcolumns\(dq for a given subnet. .IP \(bu 2 \fBtimestamp\fP \- the textual date and time the data were fetched, expressed as GMT. .UNINDENT .UNINDENT .sp The response to a DHCPv4 command might look as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dqstat\-lease4\-get: 2 rows found\(dq, \(dqarguments\(dq: { \(dqresult\-set\(dq: { \(dqcolumns\(dq: [ \(dqsubnet\-id\(dq, \(dqtotal\-addresses\(dq, \(dqcumulative\-assigned\-addresses\(dq, \(dqassigned\-addresses\(dq, \(dqdeclined\-addresses\(dq ], \(dqrows\(dq: [ [ 10, 256, 300, 111, 0 ], [ 20, 4098, 2034, 2034, 4 ] ], \(dqtimestamp\(dq: \(dq2018\-05\-04 15:03:37.000000\(dq } } } .EE .UNINDENT .UNINDENT .sp The response to a DHCPv6 command might look as follows, assuming subnet 10 has no prefix pools, subnet 20 has no NA pools, and subnet 30 has both NA and PD pools: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dqstat\-lease6\-get: 2 rows found\(dq, \(dqarguments\(dq: { \(dqresult\-set\(dq: { \(dqcolumns\(dq: [ \(dqsubnet\-id\(dq, \(dqtotal\-nas\(dq, \(dqcumulative\-assigned\-nas\(dq, \(dqassigned\-nas\(dq, \(dqdeclined\-addresses\(dq, \(dqtotal\-pds\(dq, \(dqcumulative\-assigned\-pds\(dq, \(dqassigned\-pds\(dq ], \(dqrows\(dq: [ [ 10, 4096, 5000, 2400, 3, 0, 0, 0], [ 20, 0, 0, 0, 0, 1048, 300, 233 ], [ 30, 256, 60, 60, 0, 1048, 15, 15 ] ], \(dqtimestamp\(dq: \(dq2018\-05\-04 15:03:37.000000\(dq } } } .EE .UNINDENT .UNINDENT .SS \fBlibdhcp_subnet_cmds.so\fP: Subnet Commands to Manage Subnets and Shared Networks .sp This library offers commands used to query and manipulate subnet and shared network configurations in Kea. These can be very useful in deployments with a large number of subnets being managed by the DHCP servers, when those subnets are frequently updated. The commands offer a lightweight approach for manipulating subnets without needing to fully reconfigure the server, and without affecting existing servers\(aq configurations. An ability to manage shared networks (listing, retrieving details, adding new ones, removing existing ones, and adding subnets to and removing them from shared networks) is also provided. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 \fI\%libdhcp_subnet_cmds.so\fP is part of the open source code and is available to every Kea user. It was previously available only to ISC customers with a paid support contract. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 This library can only be loaded by the \fI\%kea\-dhcp4\fP or \fI\%kea\-dhcp6\fP process. .UNINDENT .UNINDENT .sp The following commands are currently supported: .INDENT 0.0 .IP \(bu 2 \fI\%subnet4\-list\fP / \fI\%subnet6\-list\fP \- lists all configured subnets. .IP \(bu 2 \fI\%subnet4\-get\fP / \fI\%subnet6\-get\fP \- retrieves detailed information about a specified subnet. .IP \(bu 2 \fI\%subnet4\-add\fP / \fI\%subnet6\-add\fP \- adds a new subnet into the server\(aqs configuration. .IP \(bu 2 \fI\%subnet4\-update\fP / \fI\%subnet6\-update\fP \- updates (replaces) a single subnet in the server\(aqs configuration. .IP \(bu 2 \fI\%subnet4\-del\fP / \fI\%subnet6\-del\fP \- removes a subnet from the server\(aqs configuration. .IP \(bu 2 \fI\%subnet4\-delta\-add\fP / \fI\%subnet6\-delta\-add\fP \- updates (replaces) parts of a single subnet in the server\(aqs configuration. .IP \(bu 2 \fI\%subnet4\-delta\-del\fP / \fI\%subnet6\-delta\-del\fP \- removes parts of a single subnet in the server\(aqs configuration. .IP \(bu 2 \fI\%network4\-list\fP / \fI\%network6\-list\fP \- lists all configured shared networks. .IP \(bu 2 \fI\%network4\-get\fP / \fI\%network6\-get\fP \- retrieves detailed information about a specified shared network. .IP \(bu 2 \fI\%network4\-add\fP / \fI\%network6\-add\fP \- adds a new shared network to the server\(aqs configuration. .IP \(bu 2 \fI\%network4\-del\fP / \fI\%network6\-del\fP \- removes a shared network from the server\(aqs configuration. .IP \(bu 2 \fI\%network4\-subnet\-add\fP / \fI\%network6\-subnet\-add\fP \- adds an existing subnet to an existing shared network. .IP \(bu 2 \fI\%network4\-subnet\-del\fP / \fI\%network6\-subnet\-del\fP \- removes a subnet from an existing shared network and demotes it to a plain subnet. .UNINDENT .SS The \fBsubnet4\-list\fP Command .sp This command is used to list all currently configured subnets. Each subnet is returned with a subnet identifier, subnet prefix and shared network name, if available. To retrieve detailed information about the subnet, use the \fI\%subnet4\-get\fP command. .sp This command has a simple structure: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqsubnet4\-list\(dq } .EE .UNINDENT .UNINDENT .sp The list of subnets is returned in the following format: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dq2 IPv4 subnets found\(dq, \(dqarguments\(dq: { \(dqsubnets\(dq: [ { \(dqid\(dq: 10, \(dqshared\-network\-name\(dq: \(dqnet1\(dq, \(dqsubnet\(dq: \(dq10.0.0.0/8\(dq }, { \(dqid\(dq: 100, \(dqshared\-network\-name\(dq: null, \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq } ] } } .EE .UNINDENT .UNINDENT .sp If no IPv4 subnets are found, an error code is returned along with the error description. .SS The \fBsubnet6\-list\fP Command .sp This command is used to list all currently configured subnets. Each subnet is returned with a subnet identifier, subnet prefix and shared network name, if available. To retrieve detailed information about the subnet, use the \fI\%subnet6\-get\fP command. .sp This command has a simple structure: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqsubnet6\-list\(dq } .EE .UNINDENT .UNINDENT .sp The list of subnets is returned in the following format: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dq2 IPv6 subnets found\(dq, \(dqarguments\(dq: { \(dqsubnets\(dq: [ { \(dqid\(dq: 11, \(dqshared\-network\-name\(dq: null, \(dqsubnet\(dq: \(dq2001:db8:1::/64\(dq }, { \(dqid\(dq: 233, \(dqshared\-network\-name\(dq: \(dqsome\-net\(dq, \(dqsubnet\(dq: \(dq3000::/16\(dq } ] } } .EE .UNINDENT .UNINDENT .sp If no IPv6 subnets are found, an error code is returned along with the error description. .SS The \fBsubnet4\-get\fP Command .sp This command is used to retrieve detailed information about the specified subnet. This command usually follows \fI\%subnet4\-list\fP, which is used to discover available subnets with their respective subnet identifiers and prefixes. Any of those parameters can then be used in \fI\%subnet4\-get\fP to fetch subnet information: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqsubnet4\-get\(dq, \(dqarguments\(dq: { \(dqid\(dq: 10 } } .EE .UNINDENT .UNINDENT .sp or .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqsubnet4\-get\(dq, \(dqarguments\(dq: { \(dqsubnet\(dq: \(dq10.0.0.0/8\(dq } } .EE .UNINDENT .UNINDENT .sp If the subnet exists, the response will be similar to this: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dqInfo about IPv4 subnet 10.0.0.0/8 (id 10) returned\(dq, \(dqarguments\(dq: { \(dqsubnets\(dq: [ { \(dqsubnet\(dq: \(dq10.0.0.0/8\(dq, \(dqid\(dq: 1, \(dqoption\-data\(dq: [ { ... }, ... ], ... } ] } } .EE .UNINDENT .UNINDENT .SS The \fBsubnet6\-get\fP Command .sp This command is used to retrieve detailed information about the specified subnet. This command usually follows \fI\%subnet6\-list\fP, which is used to discover available subnets with their respective subnet identifiers and prefixes. Any of those parameters can be then used in \fI\%subnet6\-get\fP to fetch subnet information: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqsubnet6\-get\(dq, \(dqarguments\(dq: { \(dqid\(dq: 11 } } .EE .UNINDENT .UNINDENT .sp or .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqsubnet6\-get\(dq, \(dqarguments\(dq: { \(dqsubnet\(dq: \(dq2001:db8:1::/64\(dq } } .EE .UNINDENT .UNINDENT .sp If the subnet exists, the response will be similar to this: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dqInfo about IPv6 subnet 2001:db8:1::/64 (id 11) returned\(dq, \(dqarguments\(dq: { \(dqsubnets\(dq: [ { \(dqsubnet\(dq: \(dq2001:db8:1::/64\(dq, \(dqid\(dq: 1, \(dqoption\-data\(dq: [ { ... }, ... ], ... } ] } } .EE .UNINDENT .UNINDENT .SS The \fBsubnet4\-add\fP Command .sp This command is used to create and add a new subnet to the existing server configuration. This operation has no impact on other subnets. The subnet identifier must be specified and must be unique among all subnets. If the identifier or a subnet prefix is not unique, an error is reported and the subnet is not added. .sp The subnet information within this command has the same structure as the subnet information in the server configuration file, with the exception that static host reservations cannot be specified within \fI\%subnet4\-add\fP\&. The commands described in \fI\%libdhcp_host_cmds.so: Host Commands\fP should be used to add, remove, and modify static reservations. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqsubnet4\-add\(dq, \(dqarguments\(dq: { \(dqsubnet4\(dq: [ { \(dqid\(dq: 123, \(dqsubnet\(dq: \(dq10.20.30.0/24\(dq, ... } ] } } .EE .UNINDENT .UNINDENT .sp The response to this command has the following structure: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dqIPv4 subnet added\(dq, \(dqarguments\(dq: { \(dqsubnet4\(dq: [ { \(dqid\(dq: 123, \(dqsubnet\(dq: \(dq10.20.30.0/24\(dq } ] } } .EE .UNINDENT .UNINDENT .SS The \fBsubnet6\-add\fP Command .sp This command is used to create and add a new subnet to the existing server configuration. This operation has no impact on other subnets. The subnet identifier must be specified and must be unique among all subnets. If the identifier or a subnet prefix is not unique, an error is reported and the subnet is not added. .sp The subnet information within this command has the same structure as the subnet information in the server configuration file, with the exception that static host reservations cannot be specified within \fI\%subnet6\-add\fP\&. The commands described in \fI\%libdhcp_host_cmds.so: Host Commands\fP should be used to add, remove, and modify static reservations. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqsubnet6\-add\(dq, \(dqarguments\(dq: { \(dqsubnet6\(dq: [ { \(dqid\(dq: 234, \(dqsubnet\(dq: \(dq2001:db8:1::/64\(dq, ... } ] } } .EE .UNINDENT .UNINDENT .sp The response to this command has the following structure: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dqIPv6 subnet added\(dq, \(dqarguments\(dq: { \(dqsubnet6\(dq: [ { \(dqid\(dq: 234, \(dqsubnet\(dq: \(dq2001:db8:1::/64\(dq } ] } } .EE .UNINDENT .UNINDENT .sp As of Kea 2.6.0, Kea no longer automatically generates subnet IDS; they must be specified for \fI\%subnet4\-add\fP and \fI\%subnet6\-add\fP\&. If not specified, Kea tries to assign the next \fBsubnet\-id\fP value. This automatic ID value generator is simple; it returns the previous automatically assigned value, increased by 1. This works well, unless a subnet is manually created with a larger value than one previously used. For example, if \fI\%subnet4\-add\fP is called five times, each without an ID, Kea will assign IDs 1, 2, 3, 4, and 5 and everything will work properly. However, if \fI\%subnet4\-add\fP is called five times, with the first subnet having the \fBsubnet\-id\fP of value 3 and the remaining ones having no \fBsubnet\-id\fP, the operation will fail. The first command (with the explicit value) will use \fBsubnet\-id\fP 3; the second command will create a subnet with an ID of 1; the third will use a value of 2; and finally the fourth will have its \fBsubnet\-id\fP value auto\-generated as 3. However, since there is already a subnet with that ID, the process will fail. .sp The general recommendation is either never to use explicit values, so that auto\-generated values will always work; or always use explicit values, so that auto\-generation is never used. The two approaches can be mixed only if the administrator understands how internal automatic \fBsubnet\-id\fP generation works in Kea. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Subnet IDs must be greater than zero and less than 4294967295. .UNINDENT .UNINDENT .SS The \fBsubnet4\-update\fP Command .sp This command is used to update (overwrite) a single subnet in the existing server configuration. This operation has no impact on other subnets. The subnet identifier is used to identify the subnet to replace; it must be specified and must be unique among all subnets. The subnet prefix should not be updated. .sp The subnet information within this command has the same structure as the subnet information in the server configuration file, with the exception that static host reservations cannot be specified within \fI\%subnet4\-update\fP\&. The commands described in \fI\%libdhcp_host_cmds.so: Host Commands\fP should be used to update, remove, and modify static reservations. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqsubnet4\-update\(dq, \(dqarguments\(dq: { \(dqsubnet4\(dq: [ { \(dqid\(dq: 123, \(dqsubnet\(dq: \(dq10.20.30.0/24\(dq, ... } ] } } .EE .UNINDENT .UNINDENT .sp The response to this command has the following structure: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dqIPv4 subnet updated\(dq, \(dqarguments\(dq: { \(dqsubnet4\(dq: [ { \(dqid\(dq: 123, \(dqsubnet\(dq: \(dq10.20.30.0/24\(dq } ] } } .EE .UNINDENT .UNINDENT .sp As with other update commands, this command overwrites all the contents of the entry. If the IPv4 subnet previously had a resource assigned to it and the \fI\%subnet4\-update\fP command is missing the resource, it is deleted from the server configuration. If an incremental update of the subnet is desired, use \fI\%subnet4\-delta\-add\fP\&. .SS The \fBsubnet6\-update\fP Command .sp This command is used to update (overwrite) a single subnet in the existing server configuration. This operation has no impact on other subnets. The subnet identifier is used to identify the subnet to replace; it must be specified and must be unique among all subnets. The subnet prefix should not be updated. .sp The subnet information within this command has the same structure as the subnet information in the server configuration file, with the exception that static host reservations cannot be specified within \fI\%subnet6\-update\fP\&. The commands described in \fI\%libdhcp_host_cmds.so: Host Commands\fP should be used to update, remove, and modify static reservations. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqsubnet6\-update\(dq, \(dqarguments\(dq: { \(dqsubnet6\(dq: [ { \(dqid\(dq: 234, \(dqsubnet\(dq: \(dq2001:db8:1::/64\(dq, ... } ] } } .EE .UNINDENT .UNINDENT .sp The response to this command has the following structure: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dqIPv6 subnet updated\(dq, \(dqarguments\(dq: { \(dqsubnet6\(dq: [ { \(dqid\(dq: 234, \(dqsubnet\(dq: \(dq2001:db8:1::/64\(dq } ] } } .EE .UNINDENT .UNINDENT .sp As with other update commands, this command overwrites all the contents of the entry. If the IPv6 subnet previously had a resource assigned to it and the \fI\%subnet6\-update\fP command is missing the resource, it is deleted from the server configuration. If an incremental update of the subnet is desired, use \fI\%subnet6\-delta\-add\fP\&. .SS The \fBsubnet4\-del\fP Command .sp This command is used to remove a subnet from the server\(aqs configuration. This command has no effect on other configured subnets, but removing a subnet does have certain implications. .sp In most cases the server has assigned some leases to the clients belonging to the subnet. The server may also be configured with static host reservations which are associated with this subnet. The current implementation of the \fI\%subnet4\-del\fP command removes neither the leases nor the host reservations associated with a subnet. This is the safest approach because the server does not lose track of leases assigned to clients from this subnet. However, removal of the subnet may still cause configuration errors and conflicts. For example: after removal of the subnet, the server administrator may update a new subnet with the ID used previously for the removed subnet. This means that the existing leases and static reservations will be in conflict with this new subnet. Thus, we recommend that this command be used with extreme caution. .sp This command can also be used to completely delete an IPv4 subnet that is part of a shared network. To simply remove the subnet from a shared network and keep the subnet configuration, use the \fI\%network4\-subnet\-del\fP command instead. .sp The command has the following structure: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqsubnet4\-del\(dq, \(dqarguments\(dq: { \(dqid\(dq: 123 } } .EE .UNINDENT .UNINDENT .sp A successful response may look like this: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dqIPv4 subnet 192.0.2.0/24 (id 123) deleted\(dq, \(dqarguments\(dq: { \(dqsubnets\(dq: [ { \(dqid\(dq: 123, \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq } ] } } .EE .UNINDENT .UNINDENT .SS The \fBsubnet6\-del\fP Command .sp This command is used to remove a subnet from the server\(aqs configuration. This command has no effect on other configured subnets, but removing a subnet does have certain implications. .sp In most cases the server has assigned some leases to the clients belonging to the subnet. The server may also be configured with static host reservations which are associated with this subnet. The current implementation of the \fI\%subnet6\-del\fP command removes neither the leases nor the host reservations associated with a subnet. This is the safest approach because the server does not lose track of leases assigned to clients from this subnet. However, removal of the subnet may still cause configuration errors and conflicts. For example: after removal of the subnet, the server administrator may add a new subnet with the ID used previously for the removed subnet. This means that the existing leases and static reservations will be in conflict with this new subnet. Thus, we recommend that this command be used with extreme caution. .sp This command can also be used to completely delete an IPv6 subnet that is part of a shared network. To simply remove the subnet from a shared network and keep the subnet configuration, use the \fI\%network6\-subnet\-del\fP command instead. .sp The command has the following structure: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqsubnet6\-del\(dq, \(dqarguments\(dq: { \(dqid\(dq: 234 } } .EE .UNINDENT .UNINDENT .sp A successful response may look like this: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dqIPv6 subnet 2001:db8:1::/64 (id 234) deleted\(dq, \(dqsubnets\(dq: [ { \(dqid\(dq: 234, \(dqsubnet\(dq: \(dq2001:db8:1::/64\(dq } ] } .EE .UNINDENT .UNINDENT .SS The \fBsubnet4\-delta\-add\fP Command .sp This command is used to update a subnet by adding or overwriting its parts in the existing server configuration. This operation has no impact on other subnets. The subnet identifier is used to identify the subnet to update; it must be specified and must be unique among all subnets. The subnet prefix should not be updated. .sp The subnet information within this command has the same structure as the subnet information in the server configuration file, with the exception that static host reservations cannot be specified within \fI\%subnet4\-delta\-add\fP\&. The commands described in \fI\%libdhcp_host_cmds.so: Host Commands\fP should be used to update, remove, and modify static reservations. .sp The command uses keys to identify the respective object. The keys cannot be updated. Objects must first be deleted in order to add other objects with conflicting keys. The address pools are identified by the \fIpool\fP parameter; the options are identified by the \fIname\fP or \fIcode\fP, and \fIspace\fP parameters. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqsubnet4\-delta\-add\(dq, \(dqarguments\(dq: { \(dqsubnet4\(dq: [ { \(dqvalid\-lifetime\(dq: 120, \(dqid\(dq: 123, \(dqsubnet\(dq: \(dq10.20.30.0/24\(dq, \(dqoption\-data\(dq: [ { \(dqalways\-send\(dq: false, \(dqcode\(dq: 3, \(dqcsv\-format\(dq: true, \(dqdata\(dq: \(dq192.0.3.1\(dq, \(dqname\(dq: \(dqrouters\(dq, \(dqspace\(dq: \(dqdhcp4\(dq } ], \(dqpools\(dq: [ { \(dqpool\(dq: \(dq10.20.30.1\-10.20.30.10\(dq, \(dqoption\-data\(dq: [ { \(dqalways\-send\(dq: false, \(dqcode\(dq: 4, \(dqcsv\-format\(dq: true, \(dqdata\(dq: \(dq192.0.4.1\(dq, \(dqname\(dq: \(dqtime\-servers\(dq, \(dqspace\(dq: \(dqdhcp4\(dq } ] } ] } ] } } .EE .UNINDENT .UNINDENT .sp The response to this command has the following structure: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dqIPv4 subnet updated\(dq, \(dqarguments\(dq: { \(dqsubnet4\(dq: [ { \(dqid\(dq: 123, \(dqsubnet\(dq: \(dq10.20.30.0/24\(dq } ] } } .EE .UNINDENT .UNINDENT .sp The command updates subnet \(dq10.20.30.0/24\(dq with ID 123 by changing the valid lifetime, by adding or changing the subnet level option 3 (\(dqrouters\(dq), by adding or changing parameters of the pool \(dq10.20.30.1\-10.20.30.10\(dq, and by adding or changing the pool level option 4 (\(dqtime\-servers\(dq). .SS The \fBsubnet6\-delta\-add\fP Command .sp This command is used to update a subnet by adding or overwriting its parts in the existing server configuration. This operation has no impact on other subnets. The subnet identifier is used to identify the subnet to update; it must be specified and must be unique among all subnets. The subnet prefix should not be updated. .sp The subnet information within this command has the same structure as the subnet information in the server configuration file, with the exception that static host reservations cannot be specified within \fI\%subnet6\-delta\-add\fP\&. The commands described in \fI\%libdhcp_host_cmds.so: Host Commands\fP should be used to update, remove, and modify static reservations. .sp The command uses keys to identify the respective object. The keys cannot be updated. Objects must first be deleted in order to add other objects with conflicting keys. The address pools are identified by the \fIpool\fP parameter; the prefix pools are identified by the \fIprefix\fP, \fIprefix\-len\fP, and \fIdelegated\-len\fP parameters; and the options are identified by the \fIname\fP or \fIcode\fP, and \fIspace\fP parameters. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqsubnet6\-delta\-add\(dq, \(dqarguments\(dq: { \(dqsubnet6\(dq: [ { \(dqvalid\-lifetime\(dq: 120, \(dqid\(dq: 243, \(dqsubnet\(dq: \(dq2001:db8:1::/64\(dq, \(dqoption\-data\(dq: [ { \(dqalways\-send\(dq: false, \(dqcode\(dq: 23, \(dqcsv\-format\(dq: true, \(dqdata\(dq: \(dq3000::3:1\(dq, \(dqname\(dq: \(dqdns\-servers\(dq, \(dqspace\(dq: \(dqdhcp6\(dq } ], \(dqpd\-pools\(dq: [ { \(dqprefix\(dq: \(dq2001:db8:2::\(dq, \(dqprefix\-len\(dq: 48, \(dqdelegated\-len\(dq: 64, \(dqoption\-data\(dq: [ { \(dqalways\-send\(dq: false, \(dqcode\(dq: 22, \(dqcsv\-format\(dq: true, \(dqdata\(dq: \(dq3000::4:1\(dq, \(dqname\(dq: \(dqsip\-server\-addr\(dq, \(dqspace\(dq: \(dqdhcp6\(dq } ] } ], \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8:1::1\-2001:db8:1::10\(dq, \(dqoption\-data\(dq: [ { \(dqalways\-send\(dq: false, \(dqcode\(dq: 31, \(dqcsv\-format\(dq: true, \(dqdata\(dq: \(dq3000::5:1\(dq, \(dqname\(dq: \(dqsntp\-servers\(dq, \(dqspace\(dq: \(dqdhcp6\(dq } ] } ] } ] } } .EE .UNINDENT .UNINDENT .sp The response to this command has the following structure: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dqIPv6 subnet updated\(dq, \(dqarguments\(dq: { \(dqsubnet6\(dq: [ { \(dqid\(dq: 234, \(dqsubnet\(dq: \(dq2001:db8:1::/64\(dq } ] } } .EE .UNINDENT .UNINDENT .sp The command updates subnet \(dq2001:db8:1::/64\(dq with ID 243 by changing the valid lifetime, by adding or changing the subnet level option 23 (\(dqdns\-servers\(dq), by adding or changing parameters of the pool \(dq2001:db8:1::1\-2001:db8:1::10\(dq, by adding or changing the pool level option 31 (\(dqsntp\-servers\(dq), by adding or changing parameters of the pd\-pool \(dq2001:db8:2::\(dq with prefix\-len 48, and by adding or changing the pd\-pool level option 22 (\(dqsip\-server\-addr\(dq). .SS The \fBsubnet4\-delta\-del\fP Command .sp This command is used to update a subnet by removing its parts in the existing server configuration. This operation has no impact on other subnets. The subnet identifier is used to identify the subnet to update; it must be specified and must be unique among all subnets. The subnet prefix should not be updated. .sp The subnet information within this command has the same structure as the subnet information in the server configuration file, with the exception that static host reservations cannot be specified within \fI\%subnet4\-delta\-del\fP\&. The commands described in \fI\%libdhcp_host_cmds.so: Host Commands\fP should be used to update, remove, and modify static reservations. .sp The command is flexible and can delete part of the subnet by either specifying the entire object that needs to be deleted, or just the keys identifying the respective object. The address pools are identified by the \fIpool\fP parameter; and the options are identified by the \fIname\fP or \fIcode\fP, and \fIspace\fP parameters. The \fIspace\fP parameter can be omitted if the option belongs to the default \fIdhcp4\fP space. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqsubnet4\-delta\-del\(dq, \(dqarguments\(dq: { \(dqsubnet4\(dq: [ { \(dqvalid\-lifetime\(dq: 0, \(dqid\(dq: 123, \(dqsubnet\(dq: \(dq10.20.30.0/24\(dq, \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqrouters\(dq } ], \(dqpools\(dq: [ { \(dqoption\-data\(dq: [ { \(dqcode\(dq: 4 } ], \(dqpool\(dq: \(dq10.20.30.11\-10.20.30.20\(dq }, { \(dqpool\(dq: \(dq10.20.30.21\-10.20.30.30\(dq } ] } ] } } .EE .UNINDENT .UNINDENT .sp The response to this command has the following structure: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dqIPv4 subnet updated\(dq, \(dqarguments\(dq: { \(dqsubnet4\(dq: [ { \(dqid\(dq: 123, \(dqsubnet\(dq: \(dq10.20.30.0/24\(dq } ] } } .EE .UNINDENT .UNINDENT .sp The command updates subnet \(dq10.20.30.0/24\(dq with id 123 by removing the valid lifetime, removing the subnet level option 3 (\(dqrouters\(dq), by removing the pool \(dq10.20.30.21\-10.20.30.30\(dq and by removing the pool level option 4 (\(dqtime\-servers\(dq) in pool \(dq10.20.30.11\-10.20.30.20\(dq. The scalar values don\(aqt need to match what is configured, but still need to be present to maintain a valid json structure and to be a valid value to be able to be parsed. .SS The \fBsubnet6\-delta\-del\fP Command .sp This command is used to update a subnet by removing its parts in the existing server configuration. This operation has no impact on other subnets. The subnet identifier is used to identify the subnet to update; it must be specified and must be unique among all subnets. The subnet prefix should not be updated. .sp The subnet information within this command has the same structure as the subnet information in the server configuration file, with the exception that static host reservations cannot be specified within \fI\%subnet6\-delta\-del\fP\&. The commands described in \fI\%libdhcp_host_cmds.so: Host Commands\fP should be used to update, remove, and modify static reservations. .sp The command is flexible and can delete the part of the subnet by either specifying the entire object that needs to be deleted, or just the keys identifying the respective object. The address pools are identified by the \fIpool\fP parameter; the prefix pools are identified by the \fIprefix\fP, \fIprefix\-len\fP and \fIdelegated\-len\fP parameters; and the options are identified by the \fIname\fP or \fIcode\fP, and \fIspace\fP parameters. The \fIspace\fP parameter can be omitted if the option belongs to the default \fIdhcp6\fP space. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqsubnet6\-delta\-del\(dq, \(dqarguments\(dq: { \(dqsubnet6\(dq: [ { \(dqvalid\-lifetime\(dq: 0, \(dqid\(dq: 234, \(dqsubnet\(dq: \(dq2001:db8:1::/64\(dq, \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqdns\-servers\(dq } ], \(dqpd\-pools\(dq: [ { \(dqprefix\(dq: \(dq2001:db8:3::\(dq, \(dqprefix\-len\(dq: 48, \(dqdelegated\-len\(dq: 64, \(dqoption\-data\(dq: [ { \(dqcode\(dq: 22 } ] }, { \(dqprefix\(dq: \(dq2001:db8:4::\(dq, \(dqprefix\-len\(dq: 48, \(dqdelegated\-len\(dq: 64 } ], \(dqpools\(dq: [ { \(dqoption\-data\(dq: [ { \(dqcode\(dq: 31 } ], \(dqpool\(dq: \(dq2001:db8:1::11\-2001:db8:1::20\(dq }, { \(dqpool\(dq: \(dq2001:db8:1::21\-2001:db8:1::30\(dq } ] } ] } } .EE .UNINDENT .UNINDENT .sp The response to this command has the following structure: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dqIPv6 subnet updated\(dq, \(dqarguments\(dq: { \(dqsubnet6\(dq: [ { \(dqid\(dq: 234, \(dqsubnet\(dq: \(dq2001:db8:1::/64\(dq } ] } } .EE .UNINDENT .UNINDENT .sp The command updates subnet \(dq2001:db8:1::/64\(dq with id 243 by removing the valid lifetime, removing the subnet level option 23 (\(dqdns\-servers\(dq), by removing the pool \(dq2001:db8:1::21\-2001:db8:1::30\(dq, by removing the pool level option 31 (\(dqsntp\-servers\(dq) in pool \(dq2001:db8:1::11\-2001:db8:1::20\(dq, by removing the pd\-pool \(dq2001:db8:4::\(dq with prefix\-len 48, by removing the pd\-pool level option 22 (\(dqsip\-server\-addr\(dq) in pd\-pool \(dq2001:db8:3::\(dq with prefix\-len 48. The scalar values don\(aqt need to match what is configured, but still need to be present to maintain a valid json structure and to be a valid value to be able to be parsed. .SS The \fBnetwork4\-list\fP, \fBnetwork6\-list\fP Commands .sp These commands are used to retrieve the full list of currently configured shared networks. The list contains only very basic information about each shared network. If more details are needed, please use \fI\%network4\-get\fP or \fI\%network6\-get\fP to retrieve all information available. This command does not require any parameters and its invocation is very simple: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqnetwork4\-list\(dq } .EE .UNINDENT .UNINDENT .sp An example response for \fI\%network4\-list\fP looks as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqarguments\(dq: { \(dqshared\-networks\(dq: [ { \(dqname\(dq: \(dqfloor1\(dq }, { \(dqname\(dq: \(dqoffice\(dq } ] }, \(dqresult\(dq: 0, \(dqtext\(dq: \(dq2 IPv4 network(s) found\(dq } .EE .UNINDENT .UNINDENT .sp The \fI\%network6\-list\fP command uses exactly the same syntax for both the command and the response. .SS The \fBnetwork4\-get\fP, \fBnetwork6\-get\fP Commands .sp These commands are used to retrieve detailed information about shared networks, including subnets that are currently part of a given network. Both commands take one mandatory parameter, \fBname\fP, which specifies the name of the shared network. An example command to retrieve details about an IPv4 shared network with the name \(dqfloor13\(dq looks as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqnetwork4\-get\(dq, \(dqarguments\(dq: { \(dqname\(dq: \(dqfloor13\(dq } } .EE .UNINDENT .UNINDENT .sp An example response could look as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dqInfo about IPv4 shared network \(aqfloor13\(aq returned\(dq, \(dqarguments\(dq: { \(dqshared\-networks\(dq: [ { \(dqmatch\-client\-id\(dq: true, \(dqname\(dq: \(dqfloor13\(dq, \(dqoption\-data\(dq: [ ], \(dqrebind\-timer\(dq: 90, \(dqrelay\(dq: { \(dqip\-address\(dq: \(dq0.0.0.0\(dq }, \(dqrenew\-timer\(dq: 60, # Specify if the server should look up global reservations. \(dqreservations\-global\(dq: false, # Specify if the server should look up in\-subnet reservations. \(dqreservations\-in\-subnet\(dq: true, # Specify if the server can assume that all reserved addresses # are out\-of\-pool. \(dqreservations\-out\-of\-pool\(dq: false, \(dqsubnet4\(dq: [ { \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq, \(dqid\(dq: 5, ... # many other subnet\-specific details here }, { \(dqid\(dq: 6, \(dqsubnet\(dq: \(dq192.0.3.0/31\(dq, ... # many other subnet\-specific details here } ], \(dqvalid\-lifetime\(dq: 120 } ] } } .EE .UNINDENT .UNINDENT .sp The actual response contains many additional fields that are omitted here for clarity. The response format is exactly the same as used in \fI\%config\-get\fP, just limited to returning the shared network\(aqs information. .SS The \fBnetwork4\-add\fP, \fBnetwork6\-add\fP Commands .sp These commands are used to add a new shared network, which must have a unique name. This command requires one parameter, \fBshared\-networks\fP, which is a list and should contain exactly one entry that defines the network. The only mandatory element for a network is its name. Although it does not make operational sense, it is possible to add an empty shared network that does not have any subnets in it. That is allowed for testing purposes, but having empty networks (or networks with only one subnet) is discouraged in production environments. For details regarding syntax, see \fI\%Shared Networks in DHCPv4\fP and \fI\%Shared Networks in DHCPv6\fP\&. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 As opposed to parameter inheritance during the processing of a full new configuration, this command does not fully handle parameter inheritance. Any missing parameters will be filled with default values, rather than inherited from the global scope. .UNINDENT .UNINDENT .sp An example that showcases how to add a new IPv4 shared network looks as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqnetwork4\-add\(dq, \(dqarguments\(dq: { \(dqshared\-networks\(dq: [ { \(dqname\(dq: \(dqfloor13\(dq, \(dqsubnet4\(dq: [ { \(dqid\(dq: 100, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.2.2\-192.0.2.99\(dq } ], \(dqsubnet\(dq: \(dq192.0.2.0/24\(dq, \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqrouters\(dq, \(dqdata\(dq: \(dq192.0.2.1\(dq } ] }, { \(dqid\(dq: 101, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq192.0.3.2\-192.0.3.99\(dq } ], \(dqsubnet\(dq: \(dq192.0.3.0/24\(dq, \(dqoption\-data\(dq: [ { \(dqname\(dq: \(dqrouters\(dq, \(dqdata\(dq: \(dq192.0.3.1\(dq } ] } ] } ] } } .EE .UNINDENT .UNINDENT .sp Assuming there was no shared network with a name \(dqfloor13\(dq and no subnets with IDs 100 and 101 previously configured, the command will be successful and will return the following response: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqarguments\(dq: { \(dqshared\-networks\(dq: [ { \(dqname\(dq: \(dqfloor13\(dq } ] }, \(dqresult\(dq: 0, \(dqtext\(dq: \(dqA new IPv4 shared network \(aqfloor13\(aq added\(dq } .EE .UNINDENT .UNINDENT .sp The \fI\%network6\-add\fP command uses the same syntax for both the query and the response. However, there are some parameters that are IPv4\-only (e.g. \fBmatch\-client\-id\fP) and some that are IPv6\-only (e.g. \fBinterface\-id\fP). The same applies to subnets within the network. .SS The \fBnetwork4\-del\fP, \fBnetwork6\-del\fP Commands .sp These commands are used to delete existing shared networks. Both commands take exactly one parameter, \fBname\fP, that specifies the name of the network to be removed. An example invocation of the \fI\%network4\-del\fP command looks as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqnetwork4\-del\(dq, \(dqarguments\(dq: { \(dqname\(dq: \(dqfloor13\(dq } } .EE .UNINDENT .UNINDENT .sp Assuming such a network was configured, the response looks similar to the following: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqarguments\(dq: { \(dqshared\-networks\(dq: [ { \(dqname\(dq: \(dqfloor13\(dq } ] }, \(dqresult\(dq: 0, \(dqtext\(dq: \(dqIPv4 shared network \(aqfloor13\(aq deleted\(dq } .EE .UNINDENT .UNINDENT .sp The \fI\%network6\-del\fP command uses exactly the same syntax for both the command and the response. .sp If there are any subnets belonging to the shared network being deleted, they will be demoted to a plain subnet. There is an optional parameter called \fBsubnets\-action\fP that, if specified, takes one of two possible values: \fBkeep\fP (which is the default) and \fBdelete\fP\&. It controls whether the subnets are demoted to plain subnets or removed. An example usage in the \fI\%network6\-del\fP command that deletes the shared network and all subnets in it could look as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqnetwork4\-del\(dq, \(dqarguments\(dq: { \(dqname\(dq: \(dqfloor13\(dq, \(dqsubnets\-action\(dq: \(dqdelete\(dq } } .EE .UNINDENT .UNINDENT .sp Alternatively, to completely remove the subnets, it is possible to use the \fI\%subnet4\-del\fP or \fI\%subnet6\-del\fP commands. .SS The \fBnetwork4\-subnet\-add\fP, \fBnetwork6\-subnet\-add\fP Commands .sp These commands are used to add existing subnets to existing shared networks. There are several ways to add a new shared network. The system administrator can add the whole shared network at once, either by editing a configuration file or by calling the \fI\%network4\-add\fP or \fI\%network6\-add\fP command with the desired subnets in it. This approach works well for completely new shared subnets. However, there may be cases when an existing subnet is running out of addresses and needs to be extended with additional address space; in other words, another subnet needs to be added on top of it. For this scenario, a system administrator can use \fI\%network4\-add\fP or \fI\%network6\-add\fP, and then add an existing subnet to this newly created shared network using \fI\%network4\-subnet\-add\fP or \fI\%network6\-subnet\-add\fP\&. .sp The \fI\%network4\-subnet\-add\fP and \fI\%network6\-subnet\-add\fP commands take two parameters: \fBid\fP, which is an integer and specifies the ID of an existing subnet to be added to a shared network; and \fBname\fP, which specifies the name of the shared network to which the subnet will be added. The subnet must not belong to any existing network; to reassign a subnet from one shared network to another, use the \fI\%network4\-subnet\-del\fP or \fI\%network6\-subnet\-del\fP command commands first. .sp An example invocation of the \fI\%network4\-subnet\-add\fP command looks as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqnetwork4\-subnet\-add\(dq, \(dqarguments\(dq: { \(dqname\(dq: \(dqfloor13\(dq, \(dqid\(dq: 5 } } .EE .UNINDENT .UNINDENT .sp Assuming there is a network named \(dqfloor13\(dq, and there is a subnet with \fBsubnet\-id\fP 5 that is not a part of the existing network, the command will return a response similar to the following: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dqIPv4 subnet 10.0.0.0/8 (id 5) is now part of shared network \(aqfloor13\(aq\(dq } .EE .UNINDENT .UNINDENT .sp The \fI\%network6\-subnet\-add\fP command uses exactly the same syntax for both the command and the response. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 As opposed to parameter inheritance during the processing of a full new configuration or when adding a new shared network with new subnets, this command does not fully handle parameter inheritance. Any missing parameters will be filled with default values, rather than inherited from the global scope or from the shared network. .UNINDENT .UNINDENT .SS The \fBnetwork4\-subnet\-del\fP, \fBnetwork6\-subnet\-del\fP Commands .sp These commands are used to remove a subnet that is part of an existing shared network and demote it to a plain, stand\-alone subnet. To remove a subnet completely, use the \fI\%subnet4\-del\fP or \fI\%subnet6\-del\fP commands instead. The \fI\%network4\-subnet\-del\fP and \fI\%network6\-subnet\-del\fP commands take two parameters: \fBid\fP, which is an integer and specifies the ID of an existing subnet to be removed from a shared network; and \fBname\fP, which specifies the name of the shared network from which the subnet will be removed. .sp An example invocation of the \fI\%network4\-subnet\-del\fP command looks as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqnetwork4\-subnet\-del\(dq, \(dqarguments\(dq: { \(dqname\(dq: \(dqfloor13\(dq, \(dqid\(dq: 5 } } .EE .UNINDENT .UNINDENT .sp Assuming there was a subnet with \fBsubnet\-id\fP 5, that was part of a shared network named \(dqfloor13\(dq, the response would look similar to the following: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dqIPv4 subnet 10.0.0.0/8 (id 5) is now removed from shared network \(aqfloor13\(aq\(dq } .EE .UNINDENT .UNINDENT .sp The \fI\%network6\-subnet\-del\fP command uses exactly the same syntax for both the command and the response. .SS \fBlibdhcp_user_chk.so\fP: User Check .sp This library serves several purposes: .INDENT 0.0 .IP \(bu 2 To assign \(dqnew\(dq or \(dqunregistered\(dq users to a restricted subnet, while \(dqknown\(dq or \(dqregistered\(dq users are assigned to unrestricted subnets. .IP \(bu 2 To allow DHCP response options or vendor option values to be customized based on user identity. .IP \(bu 2 To provide a real\-time record of user registration activity, which can be sampled by an external consumer. .IP \(bu 2 To serve as a demonstration of various capabilities possible using the hooks interface. .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 \fI\%libdhcp_user_chk.so\fP is part of the open source code and is available to every Kea user. .UNINDENT .UNINDENT .sp Once loaded, the library allows the separation of incoming requests into known and unknown clients. For known clients, packets are processed as usual, although it is possible to override the sending of certain options on a per\-host basis. Clients that are not on the known hosts list are treated as unknown and are assigned to the last subnet defined in the configuration file. .sp As an example of a use case, this behavior may be implemented to put unknown users into a separate subnet that leads to a \(dqwalled garden,\(dq where they can only access a registration portal. Once they fill in necessary data, their details are added to the known clients file and they get a proper address after their device is restarted. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 This library was developed several years before the host reservation mechanism became available. Host reservation is much more powerful and flexible, but the ability of \fBuser_chk\fP to consult an external source of information about clients and alter Kea\(aqs behavior remains useful and of educational value. .UNINDENT .UNINDENT .sp The library reads the \fB/usr/local/share/kea/user_chk_registry.txt\fP file while being loaded and each time an incoming packet is processed. Each line of the file is expected to contain a self\-contained JSON snippet which must have the following two entries: .INDENT 0.0 .IP \(bu 2 \fBtype\fP \- whose value is \fB\(dqHW_ADDR\(dq\fP for IPv4 users or \fB\(dqDUID\(dq\fP for IPv6 users. .IP \(bu 2 \fBid\fP \- whose value is either the hardware address or the DUID from the request formatted as a string of hex digits, with or without \(dq:\(dq delimiters. .UNINDENT .sp and may have zero or more of the following entries: .INDENT 0.0 .IP \(bu 2 \fBbootfile\fP \- whose value is the pathname of the desired file. .IP \(bu 2 \fBtftp_server\fP \- whose value is the hostname or IP address of the desired server. .UNINDENT .sp A sample user registry file is shown below: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqtype\(dq : \(dqHW_ADDR\(dq, \(dqid\(dq : \(dq0c:0e:0a:01:ff:04\(dq, \(dqbootfile\(dq : \(dq/usr/local/share/kea/v4bootfile\(dq } { \(dqtype\(dq : \(dqHW_ADDR\(dq, \(dqid\(dq : \(dq0c:0e:0a:01:ff:06\(dq, \(dqtftp_server\(dq : \(dqtftp.v4.example.com\(dq } { \(dqtype\(dq : \(dqDUID\(dq, \(dqid\(dq : \(dq00:01:00:01:19:ef:e6:3b:00:0c:01:02:03:04\(dq, \(dqbootfile\(dq : \(dq/usr/local/share/kea/v6bootfile\(dq } { \(dqtype\(dq : \(dqDUID\(dq, \(dqid\(dq : \(dq00:01:00:01:19:ef:e6:3b:00:0c:01:02:03:06\(dq, \(dqtftp_server\(dq : \(dqtftp.v6.example.com\(dq } .EE .UNINDENT .UNINDENT .sp As with any other hook libraries provided by ISC, internals of the \fBuser_chk\fP code are well\-documented. Users may refer to the \X'tty: link https://reports.kea.isc.org/dev_guide/d8/db2/libdhcp_user_chk.html'\fI\%user_chk library section of the Kea Developer\(aqs Guide\fP\X'tty: link' for information on how the code works internally. That, together with the \X'tty: link https://reports.kea.isc.org/dev_guide/index.html#hooksFramework'\fI\%Hooks Framework section of the Kea Developer\(aqs Guide\fP\X'tty: link' should give users some pointers on how to extend this library and perhaps even write one from scratch. .SH STATISTICS .SS Statistics Overview .sp Both Kea DHCP servers support statistics gathering. A working DHCP server encounters various events that can cause certain statistics to be collected. For example, a DHCPv4 server may receive a packet (the \fBpkt4\-received\fP statistic increases by one) that after parsing is identified as a DHCPDISCOVER (\fBpkt4\-discover\-received\fP). The server processes it and decides to send a DHCPOFFER representing its answer (the \fBpkt4\-offer\-sent\fP and \fBpkt4\-sent statistics\fP increase by one). Such events happen frequently, so it is not uncommon for the statistics to have values in the high thousands. They can serve as an easy and powerful tool for observing a server\(aqs and a network\(aqs health. For example, if the \fBpkt4\-received\fP statistic stops growing, it means that the clients\(aq packets are not reaching the server. .sp There are four types of statistics: .INDENT 0.0 .IP \(bu 2 \fIinteger\fP \- this is the most common type. It is implemented as a 64\-bit integer (int64_t in C++), so it can hold any value between \-2^63 to 2^63\-1. .IP \(bu 2 \fIbig integer\fP \- this type is intended to hold large numbers. It is implemented as a 128\-bit integer (boost::multiprecision::int128_t in C++), so it can hold any value between \-2^127 to 2^127\-1. .IP \(bu 2 \fIfloating point\fP \- this type is intended to store floating\-point precision. It is implemented as a C++ double type. .IP \(bu 2 \fIduration\fP \- this type is intended for recording time periods. It uses the \(gaboost::posix_time::time_duration type, which stores hours, minutes, seconds, and microseconds. .IP \(bu 2 \fIstring\fP \- this type is intended for recording statistics in text form. It uses the C++ std::string type. .UNINDENT .sp During normal operation, the DHCPv4 and DHCPv6 servers gather statistics. For a list of DHCPv4 and DHCPv6 statistics, see \fI\%Statistics in the DHCPv4 Server\fP and \fI\%Statistics in the DHCPv6 Server\fP, respectively. .sp To extract data from the statistics module, the control channel can be used. See \fI\%Management API\fP for details. It is possible to retrieve a single statistic or all statistics, reset the statistics (i.e. set them to a neutral value, typically zero), or even completely remove a single statistic or all statistics. See the section \fI\%Commands for Manipulating Statistics\fP for a list of statistics\-oriented commands. .sp Statistics can be used by external tools to monitor Kea. One example of such a tool is Stork. See \fI\%Monitoring Kea With Stork\fP for details on how to use it and other data sources to retrieve statistics periodically to get better insight into Kea\(aqs health and operational status. .SS Statistics Lifecycle .sp All of the statistics supported by Kea\(aqs servers are initialized upon the servers\(aq startup and are returned in response to the commands such as \fI\%statistic\-get\-all\fP\&. The runtime statistics concerning DHCP packets processed are initially set to 0 and are reset upon the server restart. .sp Per\-subnet statistics are recalculated when reconfiguration takes place. .sp In general, once a statistic is initialized it is held in the manager until explicitly removed, via \fI\%statistic\-remove\fP or \fI\%statistic\-remove\-all\fP, or when the server is shut down. .sp Removing a statistic that is updated frequently makes little sense, as it will be re\-added when the server code next records that statistic. The \fI\%statistic\-remove\fP and \fI\%statistic\-remove\-all\fP commands are intended to remove statistics that are not expected to be observed in the near future. For example, a misconfigured device in a network may cause clients to report duplicate addresses, so the server will report increasing values of \fBpkt4\-decline\-received\fP\&. Once the problem is found and the device is removed, the system administrator may want to remove the \fBpkt4\-decline\-received\fP statistic so that it is no longer reported, until and unless a duplicate address is again detected. .SS Commands for Manipulating Statistics .sp There are several commands defined that can be used for accessing (\fB\-get\fP), resetting to zero or a neutral value (\fB\-reset\fP), or removing a statistic completely (\fB\-remove\fP). The statistics time\-based limit (\fB\-sample\-age\-set\fP) and size\-based limit (\fB\-sample\-count\-set\fP), which control how long or how many samples of a given statistic are retained, can also be changed. .sp The difference between \fB\-reset\fP and \fB\-remove\fP is somewhat subtle. The \fB\-reset\fP command sets the value of the statistic to zero or a neutral value, so that after this operation, the statistic has a value of 0 (integer), 0.0 (float), 0h0m0s0us (duration), or \(dq\(dq (string). When requested, a statistic with the values mentioned is returned. \fB\-remove\fP removes a statistic completely, so the statistic is no longer reported. However, the server code may add it back if there is a reason to record it. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The following sections describe commands that can be sent to the server; the examples are not fragments of a configuration file. For more information on sending commands to Kea, see \fI\%Management API\fP\&. .UNINDENT .UNINDENT .SS The \fBstatistic\-get\fP Command .sp The \fI\%statistic\-get\fP command retrieves a single statistic. It takes a single\-string parameter called \fBname\fP, which specifies the statistic name. An example command may look like this: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqstatistic\-get\(dq, \(dqarguments\(dq: { \(dqname\(dq: \(dqpkt4\-received\(dq } } .EE .UNINDENT .UNINDENT .sp The server returns details of the requested statistic, with a result of 0 indicating success and the specified statistic as the value of the \fBarguments\fP parameter. If the requested statistic is not found, the response contains an empty map, i.e. only { } as an argument, but the status code still indicates success (0). .sp Here is an example response: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqstatistic\-get\(dq, \(dqarguments\(dq: { \(dqpkt4\-received\(dq: [ [ 125, \(dq2019\-07\-30 10:11:19.498739\(dq ], [ 100, \(dq2019\-07\-30 10:11:19.498662\(dq ] ] }, \(dqresult\(dq: 0 } .EE .UNINDENT .UNINDENT .SS The \fBstatistic\-reset\fP Command .sp The \fI\%statistic\-reset\fP command sets the specified statistic to its neutral value: 0 for integer, 0.0 for float, 0h0m0s0us for time duration, and \(dq\(dq for string type. It takes a single\-string parameter called \fBname\fP, which specifies the statistic name. An example command may look like this: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqstatistic\-reset\(dq, \(dqarguments\(dq: { \(dqname\(dq: \(dqpkt4\-received\(dq } } .EE .UNINDENT .UNINDENT .sp If the specific statistic is found and the reset is successful, the server responds with a status of 0, indicating success, and an empty parameters field. If an error is encountered (e.g. the requested statistic was not found), the server returns a status code of 1 (error) and the text field contains the error description. .SS The \fBstatistic\-remove\fP Command .sp The \fI\%statistic\-remove\fP command deletes a single statistic. It takes a single\-string parameter called \fBname\fP, which specifies the statistic name. An example command may look like this: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqstatistic\-remove\(dq, \(dqarguments\(dq: { \(dqname\(dq: \(dqpkt4\-received\(dq } } .EE .UNINDENT .UNINDENT .sp If the specific statistic is found and its removal is successful, the server responds with a status of 0, indicating success, and an empty parameters field. If an error is encountered (e.g. the requested statistic was not found), the server returns a status code of 1 (error) and the text field contains the error description. .SS The \fBstatistic\-get\-all\fP Command .sp The \fI\%statistic\-get\-all\fP command retrieves all statistics recorded. An example command may look like this: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqstatistic\-get\-all\(dq, \(dqarguments\(dq: { } } .EE .UNINDENT .UNINDENT .sp The server responds with details of all recorded statistics, with a result set to 0 to indicate that it iterated over all statistics (even when the total number of statistics is zero). .sp Here is an example response returning all collected statistics: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqstatistic\-get\-all\(dq, \(dqarguments\(dq: { \(dqcumulative\-assigned\-addresses\(dq: [ [ 0, \(dq2023\-06\-13 20:42:46.836166\(dq ] ], \(dqdeclined\-addresses\(dq: [ [ 0, \(dq2023\-06\-13 20:42:46.836156\(dq ] ], \(dqpkt4\-ack\-received\(dq: [ [ 0, \(dq2023\-06\-13 20:42:46.616247\(dq ] ], \(dqpkt4\-ack\-sent\(dq: [ [ 0, \(dq2023\-06\-13 20:42:46.616290\(dq ] ], \(dqpkt4\-decline\-received\(dq: [ [ 0, \(dq2023\-06\-13 20:42:46.616296\(dq ] ], \(dqpkt4\-discover\-received\(dq: [ [ 0, \(dq2023\-06\-13 20:42:46.616303\(dq ] ], \(dqpkt4\-inform\-received\(dq: [ [ 0, \(dq2023\-06\-13 20:42:46.616308\(dq ] ], \(dqpkt4\-nak\-received\(dq: [ [ 0, \(dq2023\-06\-13 20:42:46.616312\(dq ] ], \(dqpkt4\-nak\-sent\(dq: [ [ 0, \(dq2023\-06\-13 20:42:46.616314\(dq ] ], \(dqpkt4\-offer\-received\(dq: [ [ 0, \(dq2023\-06\-13 20:42:46.616318\(dq ] ], \(dqpkt4\-offer\-sent\(dq: [ [ 0, \(dq2023\-06\-13 20:42:46.616323\(dq ] ], \(dqpkt4\-parse\-failed\(dq: [ [ 0, \(dq2023\-06\-13 20:42:46.616326\(dq ] ], \(dqpkt4\-receive\-drop\(dq: [ [ 0, \(dq2023\-06\-13 20:42:46.616330\(dq ] ], \(dqpkt4\-received\(dq: [ [ 0, \(dq2023\-06\-13 20:42:46.616335\(dq ] ], \(dqpkt4\-release\-received\(dq: [ [ 0, \(dq2023\-06\-13 20:42:46.616339\(dq ] ], \(dqpkt4\-request\-received\(dq: [ [ 0, \(dq2023\-06\-13 20:42:46.616343\(dq ] ], \(dqpkt4\-sent\(dq: [ [ 0, \(dq2023\-06\-13 20:42:46.616348\(dq ] ], \(dqpkt4\-unknown\-received\(dq: [ [ 0, \(dq2023\-06\-13 20:42:46.616354\(dq ] ], \(dqreclaimed\-declined\-addresses\(dq: [ [ 0, \(dq2023\-06\-13 20:42:46.836159\(dq ] ], \(dqreclaimed\-leases\(dq: [ [ 0, \(dq2023\-06\-13 20:42:46.836163\(dq ] ], \(dqsubnet[1].assigned\-addresses\(dq: [ [ 0, \(dq2023\-06\-13 20:42:46.836173\(dq ] ], \(dqsubnet[1].cumulative\-assigned\-addresses\(dq: [ [ 0, \(dq2023\-06\-13 20:42:46.836098\(dq ] ], \(dqsubnet[1].declined\-addresses\(dq: [ [ 0, \(dq2023\-06\-13 20:42:46.836178\(dq ] ], \(dqsubnet[1].pool[0].assigned\-addresses\(dq: [ [ 0, \(dq2023\-06\-13 20:42:46.836205\(dq ] ], \(dqsubnet[1].pool[0].cumulative\-assigned\-addresses\(dq: [ [ 0, \(dq2023\-06\-13 20:42:46.836137\(dq ] ], \(dqsubnet[1].pool[0].declined\-addresses\(dq: [ [ 0, \(dq2023\-06\-13 20:42:46.836213\(dq ] ], \(dqsubnet[1].pool[0].reclaimed\-declined\-addresses\(dq: [ [ 0, \(dq2023\-06\-13 20:42:46.836225\(dq ] ], \(dqsubnet[1].pool[0].reclaimed\-leases\(dq: [ [ 0, \(dq2023\-06\-13 20:42:46.836236\(dq ] ], \(dqsubnet[1].pool[0].total\-addresses\(dq: [ [ 11010049, \(dq2023\-06\-13 20:42:46.836128\(dq ] ], \(dqsubnet[1].reclaimed\-declined\-addresses\(dq: [ [ 0, \(dq2023\-06\-13 20:42:46.836186\(dq ] ], \(dqsubnet[1].reclaimed\-leases\(dq: [ [ 0, \(dq2023\-06\-13 20:42:46.836194\(dq ] ], \(dqsubnet[1].total\-addresses\(dq: [ [ 11010049, \(dq2023\-06\-13 20:42:46.836083\(dq ] ], \(dqsubnet[1].v4\-lease\-reuses\(dq: [ [ 0, \(dq2023\-06\-13 20:42:46.836105\(dq ] ], \(dqsubnet[1].v4\-reservation\-conflicts\(dq: [ [ 0, \(dq2023\-06\-13 20:42:46.836111\(dq ] ], \(dqv4\-allocation\-fail\(dq: [ [ 0, \(dq2023\-06\-13 20:42:46.616358\(dq ] ], \(dqv4\-allocation\-fail\-classes\(dq: [ [ 0, \(dq2023\-06\-13 20:42:46.616363\(dq ] ], \(dqv4\-allocation\-fail\-no\-pools\(dq: [ [ 0, \(dq2023\-06\-13 20:42:46.616368\(dq ] ], \(dqv4\-allocation\-fail\-shared\-network\(dq: [ [ 0, \(dq2023\-06\-13 20:42:46.616372\(dq ] ], \(dqv4\-allocation\-fail\-subnet\(dq: [ [ 0, \(dq2023\-06\-13 20:42:46.616376\(dq ] ], \(dqv4\-lease\-reuses\(dq: [ [ 0, \(dq2023\-06\-13 20:42:46.616410\(dq ] ], \(dqv4\-reservation\-conflicts\(dq: [ [ 0, \(dq2023\-06\-13 20:42:46.616412\(dq ] ] }, \(dqresult\(dq: 0 } .EE .UNINDENT .UNINDENT .sp or .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqstatistic\-get\-all\(dq, \(dqarguments\(dq: { \(dqcumulative\-assigned\-nas\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.196757\(dq ] ], \(dqcumulative\-assigned\-pds\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.196758\(dq ] ], \(dqcumulative\-registered\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.196758\(dq ] ], \(dqdeclined\-addresses\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.196754\(dq ] ], \(dqpkt6\-addr\-reg\-inform\-received\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.177731\(dq ] ], \(dqpkt6\-addr\-reg\-reply\-received\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.177731\(dq ] ], \(dqpkt6\-addr\-reg\-reply\-sent\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.177731\(dq ] ], \(dqpkt6\-advertise\-received\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.177731\(dq ] ], \(dqpkt6\-advertise\-sent\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.177739\(dq ] ], \(dqpkt6\-decline\-received\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.177739\(dq ] ], \(dqpkt6\-dhcpv4\-query\-received\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.177740\(dq ] ], \(dqpkt6\-dhcpv4\-response\-received\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.177740\(dq ] ], \(dqpkt6\-dhcpv4\-response\-sent\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.177741\(dq ] ], \(dqpkt6\-infrequest\-received\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.177742\(dq ] ], \(dqpkt6\-parse\-failed\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.177742\(dq ] ], \(dqpkt6\-rebind\-received\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.177743\(dq ] ], \(dqpkt6\-receive\-drop\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.177743\(dq ] ], \(dqpkt6\-received\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.177744\(dq ] ], \(dqpkt6\-release\-received\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.177744\(dq ] ], \(dqpkt6\-renew\-received\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.177745\(dq ] ], \(dqpkt6\-reply\-received\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.177745\(dq ] ], \(dqpkt6\-reply\-sent\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.177746\(dq ] ], \(dqpkt6\-request\-received\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.177747\(dq ] ], \(dqpkt6\-sent\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.177747\(dq ] ], \(dqpkt6\-solicit\-received\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.177748\(dq ] ], \(dqpkt6\-unknown\-received\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.177748\(dq ] ], \(dqreclaimed\-declined\-addresses\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.196755\(dq ] ], \(dqreclaimed\-leases\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.196756\(dq ] ], \(dqsubnet[1].assigned\-nas\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.196760\(dq ] ], \(dqsubnet[1].assigned\-pds\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.196761\(dq ] ], \(dqsubnet[1].cumulative\-assigned\-nas\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.196727\(dq ] ], \(dqsubnet[1].cumulative\-assigned\-pds\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.196729\(dq ] ], \(dqsubnet[1].cumulative\-registered\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.196727\(dq ] ], \(dqsubnet[1].declined\-addresses\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.196763\(dq ] ], \(dqsubnet[1].pd\-pool[0].assigned\-pds\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.196785\(dq ] ], \(dqsubnet[1].pd\-pool[0].cumulative\-assigned\-pds\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.196744\(dq ] ], \(dqsubnet[1].pd\-pool[0].reclaimed\-leases\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.196789\(dq ] ], \(dqsubnet[1].pd\-pool[0].total\-pds\(dq: [ [ 256, \(dq2023\-06\-13 21:28:57.196741\(dq ] ], \(dqsubnet[1].pool[0].assigned\-nas\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.196773\(dq ] ], \(dqsubnet[1].pool[0].cumulative\-assigned\-nas\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.196739\(dq ] ], \(dqsubnet[1].pool[0].declined\-addresses\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.196775\(dq ] ], \(dqsubnet[1].pool[0].reclaimed\-declined\-addresses\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.196779\(dq ] ], \(dqsubnet[1].pool[0].reclaimed\-leases\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.196783\(dq ] ], \(dqsubnet[1].pool[0].total\-nas\(dq: [ [ 281474976710656, \(dq2023\-06\-13 21:28:57.196736\(dq ] ], \(dqsubnet[1].reclaimed\-declined\-addresses\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.196766\(dq ] ], \(dqsubnet[1].reclaimed\-leases\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.196770\(dq ] ], \(dqsubnet[1].registered\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.196727\(dq ] ], \(dqsubnet[1].total\-nas\(dq: [ [ 281474976710656, \(dq2023\-06\-13 21:28:57.196720\(dq ] ], \(dqsubnet[1].total\-pds\(dq: [ [ 256, \(dq2023\-06\-13 21:28:57.196724\(dq ] ], \(dqsubnet[1].v6\-ia\-na\-lease\-reuses\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.196731\(dq ] ], \(dqsubnet[1].v6\-ia\-pd\-lease\-reuses\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.196733\(dq ] ], \(dqv6\-allocation\-fail\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.177749\(dq ] ], \(dqv6\-allocation\-fail\-classes\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.177755\(dq ] ], \(dqv6\-allocation\-fail\-no\-pools\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.177756\(dq ] ], \(dqv6\-allocation\-fail\-shared\-network\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.177756\(dq ] ], \(dqv6\-allocation\-fail\-subnet\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.177757\(dq ] ], \(dqv6\-ia\-na\-lease\-reuses\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.177757\(dq ] ], \(dqv6\-ia\-pd\-lease\-reuses\(dq: [ [ 0, \(dq2023\-06\-13 21:28:57.177758\(dq ] ] }, \(dqresult\(dq: 0 } .EE .UNINDENT .UNINDENT .sp or .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqstatistic\-get\-all\(dq, \(dqarguments\(dq: { \(dqncr\-error\(dq: [ [ 0, \(dq2023\-06\-13 21:42:54.627751\(dq ] ], \(dqncr\-invalid\(dq: [ [ 0, \(dq2023\-06\-13 21:42:54.627749\(dq ] ], \(dqncr\-received\(dq: [ [ 0, \(dq2023\-06\-13 21:42:54.627737\(dq ] ], \(dqqueue\-mgr\-queue\-full\(dq: [ [ 0, \(dq2023\-06\-13 21:42:54.627737\(dq ] ], \(dqupdate\-error\(dq: [ [ 0, \(dq2023\-06\-13 21:42:54.627759\(dq ] ], \(dqupdate\-sent\(dq: [ [ 0, \(dq2023\-06\-13 21:42:54.627752\(dq ] ], \(dqupdate\-signed\(dq: [ [ 0, \(dq2023\-06\-13 21:42:54.627753\(dq ] ], \(dqupdate\-success\(dq: [ [ 0, \(dq2023\-06\-13 21:42:54.627755\(dq ] ], \(dqupdate\-timeout\(dq: [ [ 0, \(dq2023\-06\-13 21:42:54.627757\(dq ] ], \(dqupdate\-unsigned\(dq: [ [ 0, \(dq2023\-06\-13 21:42:54.627754\(dq ] ] }, \(dqresult\(dq: 0 } .EE .UNINDENT .UNINDENT .SS The \fBstatistic\-reset\-all\fP Command .sp The \fI\%statistic\-reset\fP command sets all statistics to their neutral values: 0 for integer, 0.0 for float, 0h0m0s0us for time duration, and \(dq\(dq for string type. An example command may look like this: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqstatistic\-reset\-all\(dq, \(dqarguments\(dq: { } } .EE .UNINDENT .UNINDENT .sp If the operation is successful, the server responds with a status of 0, indicating success, and an empty parameters field. If an error is encountered, the server returns a status code of 1 (error) and the text field contains the error description. .SS The \fBstatistic\-remove\-all\fP Command .sp The \fI\%statistic\-remove\-all\fP command attempts to delete all statistics. An example command may look like this: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqstatistic\-remove\-all\(dq, \(dqarguments\(dq: { } } .EE .UNINDENT .UNINDENT .sp If the removal of all statistics is successful, the server responds with a status of 0, indicating success, and an empty parameters field. If an error is encountered, the server returns a status code of 1 (error) and the text field contains the error description. .SS The \fBstatistic\-sample\-age\-set\fP Command .sp The \fI\%statistic\-sample\-age\-set\fP command sets a time\-based limit on samples for a given statistic. It takes two parameters: a string called \fBname\fP, which specifies the statistic name, and an integer value called \fBduration\fP, which specifies the time limit for the given statistic in seconds. An example command may look like this: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqstatistic\-sample\-age\-set\(dq, \(dqarguments\(dq: { \(dqname\(dq: \(dqpkt4\-received\(dq, \(dqduration\(dq: 1245 } } .EE .UNINDENT .UNINDENT .sp If the command is successful, the server responds with a status of 0, indicating success, and an empty parameters field. If an error is encountered (e.g. the requested statistic was not found), the server returns a status code of 1 (error) and the text field contains the error description. .SS The \fBstatistic\-sample\-age\-set\-all\fP Command .sp The \fI\%statistic\-sample\-age\-set\-all\fP command sets time\-based limits on samples for all statistics. It takes a single\-integer parameter called \fBduration\fP, which specifies the time limit for the statistic in seconds. An example command may look like this: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqstatistic\-sample\-age\-set\-all\(dq, \(dqarguments\(dq: { \(dqduration\(dq: 1245 } } .EE .UNINDENT .UNINDENT .sp If the command is successful, the server responds with a status of 0, indicating success, and an empty parameters field. If an error is encountered, the server returns a status code of 1 (error) and the text field contains the error description. .SS The \fBstatistic\-sample\-count\-set\fP Command .sp The \fI\%statistic\-sample\-count\-set\fP command sets a size\-based limit on samples for a given statistic. An example command may look like this: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqstatistic\-sample\-count\-set\(dq, \(dqarguments\(dq: { \(dqname\(dq: \(dqpkt4\-received\(dq, \(dqmax\-samples\(dq: 100 } } .EE .UNINDENT .UNINDENT .sp If the command is successful, the server responds with a status of 0, indicating success, and an empty parameters field. If an error is encountered (e.g. the requested statistic was not found), the server returns a status code of 1 (error) and the text field contains the error description. .SS The \fBstatistic\-sample\-count\-set\-all\fP Command .sp The \fI\%statistic\-sample\-count\-set\-all\fP command sets size\-based limits on samples for all statistics. An example command may look like this: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqstatistic\-sample\-count\-set\-all\(dq, \(dqarguments\(dq: { \(dqmax\-samples\(dq: 100 } } .EE .UNINDENT .UNINDENT .sp If the command is successful, the server responds with a status of 0, indicating success, and an empty parameters field. If an error is encountered, the server returns a status code of 1 (error) and the text field contains the error description. .SS Time Series .sp With certain statistics, a single isolated data point may be useful. However, some statistics, such as received packet size, packet processing time, or number of database queries needed to process a packet, are not cumulative and it is useful to keep many data points, perhaps to do some statistical analysis afterwards. .sp Each Kea statistic holds 20 data points; setting such a limit prevents unlimited memory growth. There are two ways to define the limits: time\-based (e.g. keep samples from the last 5 minutes) and size\-based. The size\-based limit can be changed using one of two commands: \fI\%statistic\-sample\-count\-set\fP, to set a size limit for a single statistic, and \fI\%statistic\-sample\-count\-set\-all\fP, to set size\-based limits for all statistics. To set time\-based limits for a single statistic, use \fI\%statistic\-sample\-age\-set\fP; use \fI\%statistic\-sample\-age\-set\-all\fP to set time\-based limits for all statistics. For a given statistic only one type of limit can be active; storage is limited by either time or size, not both. .SH MANAGEMENT API .sp A classic approach to daemon configuration assumes that the server\(aqs configuration is stored in configuration files and, when the configuration is changed, the daemon is restarted. This approach has the significant disadvantage of introducing periods of downtime when client traffic is not handled. Another risk is that if the new configuration is invalid for any reason, the server may refuse to start, which will further extend the downtime period until the issue is resolved. .sp To avoid such problems, the DHCPv4, DHCPv6, and D2 servers in Kea include support for a mechanism that allows online reconfiguration without requiring server shutdown. Both servers can be instructed to open control sockets, which is a communications channel. The server is able to receive commands on that channel, act on them, and report back status. .sp The DHCPv4, DHCPv6, and D2 servers receive commands over the UNIX domain sockets. For details on how to configure these sockets, see \fI\%UNIX Control Socket\fP, \fI\%UNIX Control Socket\fP and \fI\%UNIX Control Socket\fP\&. While it is possible to control the servers directly using UNIX domain sockets, that requires that the controlling client be running on the same machine as the server. SSH is usually used to connect remotely to the controlled machine. .sp Network administrators usually prefer using some form of a RESTful API to control the servers, rather than using UNIX domain sockets directly. Therefore, Kea includes a component called the Control Agent (CA), which exposes a RESTful API to the controlling clients and can forward commands to the respective Kea services over the UNIX domain sockets. The CA configuration is described in \fI\%Configuration\fP\&. .sp The HTTP requests received by the CA contain the control commands encapsulated within HTTP requests. Simply speaking, the CA is responsible for stripping the HTTP layer from the received commands and forwarding the commands in a JSON format over the UNIX domain sockets to the respective services. Because the CA receives commands for all services, it requires additional \(dqforwarding\(dq information to be included in the client\(aqs messages. This forwarding information is carried within the \fBservice\fP parameter of the received command. If the \fBservice\fP parameter is not included, or if the parameter is a blank list, the CA assumes that the control command is targeted at the CA itself and attempts to respond. .sp Control connections over both HTTP and UNIX domain sockets are guarded with timeouts. The timeout value is set to 10 seconds and is not configurable. .sp This API can be used by external tools to manage and monitor Kea operation. An example of such a monitoring tool is ISC\(aqs Stork. For details, see \fI\%Monitoring Kea With Stork\fP\&. .SS Data Syntax .sp Communication over the control channel is conducted using JSON structures. If configured, Kea opens a socket and listens for incoming connections. A process connecting to this socket is expected to send JSON commands structured as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqfoo\(dq, \(dqservice\(dq: [ \(dqdhcp4\(dq ], \(dqarguments\(dq: { \(dqparam1\(dq: \(dqvalue1\(dq, \(dqparam2\(dq: \(dqvalue2\(dq, ... } } .EE .UNINDENT .UNINDENT .sp The same command sent over the RESTful interface to the CA has the following structure: .INDENT 0.0 .INDENT 3.5 .sp .EX POST / HTTP/1.1\er\en Content\-Type: application/json\er\en Content\-Length: 147\er\en\er\en { \(dqcommand\(dq: \(dqfoo\(dq, \(dqservice\(dq: [ \(dqdhcp4\(dq ], \(dqarguments\(dq: { \(dqparam1\(dq: \(dqvalue1\(dq, \(dqparam2\(dq: \(dqvalue2\(dq, ... } } .EE .UNINDENT .UNINDENT .sp The \fBcommand\fP parameter contains the name of the command to execute and it is mandatory. The \fBarguments\fP map contains the parameters required to carry out the given command. The exact content and format of the map are command\-specific. .sp The \fBservice\fP list contains the servers at which the control command is targeted. In the example above, the control command is targeted at the DHCPv4 server. In most cases, the CA simply forwards this command to the DHCPv4 server for processing via a UNIX domain socket. Sometimes, the command including a service value may also be processed by the CA, if the CA is running a hook library which handles such a command for the given server. As an example, the hook library loaded by the CA may perform some operations on the database, such as adding host reservations, modifying leases, etc. An advantage of performing DHCPv4\-specific administrative operations in the CA, rather than forwarding it to the DHCPv4 server, is the ability to perform these operations without disrupting the DHCPv4 service, since the DHCPv4 server does not have to stop processing DHCP messages to apply changes to the database. Nevertheless, these situations are rather rare; in most cases, when the \fBservice\fP parameter contains a name of the service, the commands are simply forwarded by the CA. The forwarded command includes the \fBservice\fP parameter, but this parameter is ignored by the receiving server. This parameter is only meaningful to the CA. .sp If the command received by the CA does not include a \fBservice\fP parameter or this list is empty, the CA simply processes this message on its own. For example, a \fI\%config\-get\fP command which includes no service parameter returns the Control Agent\(aqs own configuration. The \fI\%config\-get\fP command with a service value \(dqdhcp4\(dq is forwarded to the DHCPv4 server and returns the DHCPv4 server\(aqs configuration. .sp The following list shows the mapping of the values carried within the \fBservice\fP parameter to the servers to which the commands are forwarded: .INDENT 0.0 .IP \(bu 2 \fBdhcp4\fP \- the command is forwarded to the \fI\%kea\-dhcp4\fP server. .IP \(bu 2 \fBdhcp6\fP \- the command is forwarded to the \fI\%kea\-dhcp6\fP server. .IP \(bu 2 \fBd2\fP \- the command is forwarded to the \fI\%kea\-dhcp\-ddns\fP server. .UNINDENT .sp The server processing the incoming command sends a response of the form: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, // 0|1|2|3|4 \(dqtext\(dq: \(dqtextual description\(dq, \(dqarguments\(dq: { \(dqargument1\(dq: \(dqvalue1\(dq, \(dqargument2\(dq: \(dqvalue2\(dq, ... } } .EE .UNINDENT .UNINDENT .sp The \fBresult\fP value is a status code indicating a result of the command. The following general status codes are currently supported: .INDENT 0.0 .IP \(bu 2 \fB0\fP \- the command has been processed successfully. .IP \(bu 2 \fB1\fP \- a general error or failure has occurred during the command processing. .IP \(bu 2 \fB2\fP \- the specified command is unsupported by the server receiving it. .IP \(bu 2 \fB3\fP \- the requested operation has been completed but the requested resource was not found. This status code is returned when a command returns no resources or affects no resources. .IP \(bu 2 \fB4\fP \- the well\-formed command has been processed but the requested changes could not be applied, because they were in conflict with the server state or its notion of the configuration. .UNINDENT .sp For example, a well\-formed command that requests a subnet that exists in a server\(aqs configuration returns the result 0. If the server encounters an error condition, it returns 1. If the command asks for an IPv6 subnet, but was sent to a DHCPv4 server, it returns 2. If the query asks for a subnet with \fBsubnet\-id\fP that has matches, the result is 3. If the command attempts to update a lease but the specified \fBsubnet\-id\fP does not match the identifier in the server\(aqs configuration, the result is 4. .sp Hook libraries can sometimes return additional status codes specific to their use cases. .sp The \fBtext\fP field typically appears when the result is non\-zero and contains a description of the error encountered, but it often also appears for successful outcomes. The exact text is command\-specific, but in general uses plain English to describe the outcome of the command. The \fBarguments\fP map contains additional data values returned by the server which are specific to the command issued. The map may be present, but that depends on the specific command. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Since Kea 1.9.7, it is possible to put comments in commands as in the configuration file. For instance: .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqfoo\(dq, // service is a list \(dqservice\(dq: [ \(dqdhcp4\(dq ], # command arguments are here. \(dqarguments\(dq: { \(dqparam1\(dq: \(dqvalue1\(dq, ... /* \(dqparam2\(dq: \(dqvalue2\(dq, ... */ } } .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Since Kea 2.7.5 it is possible to specify extra HTTP headers which are added to HTTP responses. Each header is specified by its name and value with optionally a user context. For instance: .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqhttp\-headers\(dq: [ { \(dqname\(dq: \(dqStrict\-Transport\-Security\(dq, \(dqvalue\(dq: \(dqmax\-age=31536000\(dq } ], ... } .EE .UNINDENT .UNINDENT .sp adds a HSTS header declaring that HTTPS (vs HTTP) must be used for one year. .SS Control Agent Command Response Format .sp When sending commands via the Control Agent, it is possible to specify multiple services at which the command is targeted. CA forwards this command to each service individually. Thus, the CA response to the controlling client is always wrapped in an array (JSON list) of individual responses. For example, the response for a command sent to one service would be structured as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX [ { \(dqresult\(dq: 0, // 0|1|2|3|4 \(dqtext\(dq: \(dqtextual description\(dq, \(dqarguments\(dq: { \(dqargument1\(dq: \(dqvalue1\(dq, \(dqargument2\(dq: \(dqvalue2\(dq, ... } } ] .EE .UNINDENT .UNINDENT .sp If the command is sent to more than one service, the array would contain responses from each service, in the order they were requested: .INDENT 0.0 .INDENT 3.5 .sp .EX [ { \(dqresult\(dq: 0, // 0|1|2|3|4 \(dqtext\(dq: \(dqtextual description\(dq, \(dqarguments\(dq: { \(dqargument1\(dq: \(dqvalue1\(dq, \(dqargument2\(dq: \(dqvalue2\(dq, ... } }, { \(dqresult\(dq: 0, // 0|1|2|3|4 \(dqtext\(dq: \(dqtextual description\(dq, \(dqarguments\(dq: { \(dqargument1\(dq: \(dqvalue1\(dq, \(dqargument2\(dq: \(dqvalue2\(dq, ... } }, ... ] .EE .UNINDENT .UNINDENT .sp An exception to this are authentication or authorization errors which cause CA to reject the command entirely. The response to such an error is formatted as a single entry (JSON map) as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 403, \(dqtext\(dq: \(dqForbidden\(dq } .EE .UNINDENT .UNINDENT .sp These types of errors are possible on systems configured for either basic authentication or agents that load \fI\%libdhcp_rbac.so\fP\&. .SS Using the Control Channel .sp The easiest way to start interacting with the control API is to use common UNIX/Linux tools such as \fBsocat\fP and \fBcurl\fP\&. .sp In order to control the given Kea service via a UNIX domain socket, use \fBsocat\fP in interactive mode as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX $ socat UNIX:/path/to/the/kea/socket \- .EE .UNINDENT .UNINDENT .sp or in batch mode, include the \(dqignoreeof\(dq option as shown below to ensure \fBsocat\fP waits long enough for the server to respond: .INDENT 0.0 .INDENT 3.5 .sp .EX $ echo \(dq{ some command...}\(dq | socat UNIX:/path/to/the/kea/socket \-,ignoreeof .EE .UNINDENT .UNINDENT .sp where \fB/path/to/the/kea/socket\fP is the path specified in the \fBDhcp4/control\-socket/socket\-name\fP parameter in the Kea configuration file. Text passed to \fBsocat\fP is sent to Kea and the responses received from Kea are printed to standard output. This approach communicates with the specific server directly and bypasses the Control Agent. .sp It is also easy to open a UNIX socket programmatically. An example of a simple client written in C is available in the Kea Developer\(aqs Guide, in the Control Channel Overview chapter, in the \X'tty: link https://reports.kea.isc.org/dev_guide/d2/d96/ctrlSocket.html#ctrlSocketClient'\fI\%Using Control Channel\fP\X'tty: link' section. .sp To use Kea\(aqs RESTful API with \fBcurl\fP, use the following: .INDENT 0.0 .INDENT 3.5 .sp .EX $ curl \-X POST \-H \(dqContent\-Type: application/json\(dq \-d \(aq{ \(dqcommand\(dq: \(dqconfig\-get\(dq, \(dqservice\(dq: [ \(dqdhcp4\(dq ] }\(aq http://ca.example.org:8000/ .EE .UNINDENT .UNINDENT .sp This assumes that the Control Agent is running on host \fBca.example.org\fP and is running the RESTful service on port 8000. .SS Commands Supported by Both the DHCPv4 and DHCPv6 Servers .SS The \fBbuild\-report\fP Command .sp The \fI\%build\-report\fP command returns on the control channel what the command line \fB\-W\fP argument displays, i.e. the embedded content of the \fBconfig.report\fP file. This command does not take any parameters. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqbuild\-report\(dq } .EE .UNINDENT .UNINDENT .SS The \fBconfig\-get\fP Command .sp The \fI\%config\-get\fP command retrieves the current configuration used by the server. This command does not take any parameters. The configuration returned is roughly equal to the configuration that was loaded using the \fB\-c\fP command\-line option during server start\-up, or was later set using the \fI\%config\-set\fP command. However, there may be certain differences, as comments are not retained. If the original configuration used file inclusion, the returned configuration includes all parameters from all included files. In Kea 2.4.0 and later, the successful response also contains a SHA\-256 digest that can be used to easily determine whether a configuration has changed. .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 The returned configuration is not redacted, i.e. it contains database passwords in plain text, if those were specified in the original configuration. Care should be taken not to expose the command channel to unprivileged users. .UNINDENT .UNINDENT .sp An example command invocation looks like this: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqconfig\-get\(dq } .EE .UNINDENT .UNINDENT .SS The \fBconfig\-hash\-get\fP Command .sp The \fBconfig\-hash\-get\fP command retrieves the SHA\-256 hash of the current configuration used by the server. This command does not take any parameters. The returned hash can be used to detect configuration changes. .sp An example command invocation looks like this: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqconfig\-hash\-get\(dq } .EE .UNINDENT .UNINDENT .sp And the server\(aqs response: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqarguments\(dq: { \(dqhash\(dq: \(dq5C3C90EF7035249E2FF74D003C19F34EE0B83A3D329E741B52B2EF95A2C9CC5C\(dq } } .EE .UNINDENT .UNINDENT .sp In Kea 2.4.0 and later, \fBconfig\-set\fP and \fBconfig\-get\fP also return the SHA\-256 hash of the new or current configuration. This may be used to determine whether a configuration has changed. .SS The \fBconfig\-reload\fP Command .sp The \fI\%config\-reload\fP command instructs Kea to load again the configuration file that was used previously. This operation is useful if the configuration file has been changed by some external source; for example, a system administrator can tweak the configuration file and use this command to force Kea to pick up the changes. .sp Care should be taken when using this in conjunction with the \fI\%config\-set\fP command. Kea remembers the location of the configuration file it was started with, and this configuration can be significantly changed using the \fI\%config\-set\fP command. When \fI\%config\-reload\fP is issued after \fI\%config\-set\fP, Kea attempts to reload its original configuration from the file, possibly losing all changes introduced using \fI\%config\-set\fP or other commands. .sp The \fI\%config\-reload\fP command does not take any parameters. An example command invocation looks like this: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqconfig\-reload\(dq } .EE .UNINDENT .UNINDENT .sp If the configuration file is incorrect, reloading it can raise an error which leaves the server in an unusable state. See \fI\%The config\-set Command\fP to learn how to recover from a non\-working server. .SS The \fBconfig\-test\fP Command .sp The \fI\%config\-test\fP command instructs the server to check whether the new configuration supplied in the command\(aqs arguments can be loaded. The supplied configuration is expected to be the full configuration for the target server, along with an optional logger configuration. The configuration is sanity\-checked to the extent possible without the server actually attempting to load it; it is possible for a configuration which successfully passes this command to still fail in the \fI\%config\-set\fP command or at launch time. The structure of the command is as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqconfig\-test\(dq, \(dqarguments\(dq: { \(dq\(dq: { } } } .EE .UNINDENT .UNINDENT .sp where is the configuration element name for a given server, such as \(dqDhcp4\(dq or \(dqDhcp6\(dq. For example: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqconfig\-test\(dq, \(dqarguments\(dq: { \(dqDhcp6\(dq: { ... } } } .EE .UNINDENT .UNINDENT .sp The server\(aqs response contains a numeric code, \fBresult\fP (0 for success, non\-zero on failure), and a string, \fBtext\fP, describing the outcome: .INDENT 0.0 .INDENT 3.5 .sp .EX {\(dqresult\(dq: 0, \(dqtext\(dq: \(dqConfiguration seems sane...\(dq } or {\(dqresult\(dq: 1, \(dqtext\(dq: \(dqunsupported parameter: BOGUS (:16:26)\(dq } .EE .UNINDENT .UNINDENT .SS The \fBconfig\-write\fP Command .sp The \fI\%config\-write\fP command instructs the Kea server to write its current configuration to a file on disk. It takes one optional argument, called \(dqfilename\(dq, that specifies the name of the file to write the configuration to. If not specified, the name used when starting Kea (passed as a \fB\-c\fP argument) is used. If a relative path is specified, Kea writes its files only in the directory where it is running. .sp An example command invocation looks like this: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqconfig\-write\(dq, \(dqarguments\(dq: { \(dqfilename\(dq: \(dqconfig\-modified\-2017\-03\-15.json\(dq } } .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 As of Kea 2.7.9, the config file file may only be written to the same directory as the config file used when starting Kea (passed as a \fB\-c\fP argument). .UNINDENT .UNINDENT .SS The \fBleases\-reclaim\fP Command .sp The \fI\%leases\-reclaim\fP command instructs the server to reclaim all expired leases immediately. The command has the following JSON syntax: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqleases\-reclaim\(dq, \(dqarguments\(dq: { \(dqremove\(dq: true } } .EE .UNINDENT .UNINDENT .sp The \fBremove\fP boolean parameter is mandatory and indicates whether the reclaimed leases should be removed from the lease database (if \fBtrue\fP), or left in the \fBexpired\-reclaimed\fP state (if \fBfalse\fP). The latter facilitates lease affinity, i.e. the ability to re\-assign an expired lease to a returning client that previously used that lease. See \fI\%Configuring Lease Affinity\fP for details. Also, see \fI\%Lease Reclamation\fP for general information about the processing of expired leases (lease reclamation). .SS The \fBlist\-commands\fP Command .sp The \fI\%list\-commands\fP command retrieves a list of all commands supported by the server. It does not take any arguments. An example command may look like this: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqlist\-commands\(dq, \(dqarguments\(dq: { } } .EE .UNINDENT .UNINDENT .sp The server responds with a list of all supported commands. The arguments element is a list of strings, each of which conveys one supported command. .SS The \fBconfig\-set\fP Command .sp The \fI\%config\-set\fP command instructs the server to replace its current configuration with the new configuration supplied in the command\(aqs arguments. The supplied configuration is expected to be the full configuration for the target server, along with an optional logger configuration. While optional, the logger configuration is highly recommended, as without it the server reverts to its default logging configuration. The structure of the command is as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqconfig\-set\(dq, \(dqarguments\(dq: { \(dq\(dq: { } } } .EE .UNINDENT .UNINDENT .sp where is the configuration element name for a given server, such as \(dqDhcp4\(dq or \(dqDhcp6\(dq. For example: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqconfig\-set\(dq, \(dqarguments\(dq: { \(dqDhcp6\(dq: { ... } } } .EE .UNINDENT .UNINDENT .sp If the new configuration proves to be invalid, the server retains its current configuration; however, in some cases a fatal error message is logged indicating that the server is no longer providing any service: a working configuration must be loaded as soon as possible. If the control channel is dead, the configuration file can still be reloaded using the \fBSIGHUP\fP signal. If that is unsuccessful, restart the server. .sp Please note that the new configuration is retained in memory only; if the server is restarted or a configuration reload is triggered via a signal, the server uses the configuration stored in its configuration file. The server\(aqs response contains a numeric code, \fBresult\fP (0 for success, non\-zero on failure), and a string, \fBtext\fP, describing the outcome: .INDENT 0.0 .INDENT 3.5 .sp .EX {\(dqresult\(dq: 0, \(dqtext\(dq: \(dqConfiguration successful.\(dq } or {\(dqresult\(dq: 1, \(dqtext\(dq: \(dqunsupported parameter: BOGUS (:16:26)\(dq } .EE .UNINDENT .UNINDENT .sp In Kea 2.4.0 and later, the successful response from a DHCPv4, DHCPv6, or DHCP\-DDNS daemon also contains a SHA\-256 digest of the newly set configuration. The digest can be used to easily determine whether a configuration has changed. .SS The \fBshutdown\fP Command .sp The \fI\%shutdown\fP command instructs the server to initiate its shutdown procedure; it is the equivalent of sending a \fBSIGTERM\fP signal to the process. This command does not take any arguments. An example command may look like this: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqshutdown\(dq, \(dqarguments\(dq: { \(dqexit\-value\(dq: 3 } } .EE .UNINDENT .UNINDENT .sp The server responds with a confirmation that the shutdown procedure has been initiated. The optional parameter, \fBexit\-value\fP, specifies the numeric value with which the server process exits to the system. The default value is zero. .sp The DDNS daemon supports an extra parameter, \fBtype\fP, which controls the way the process cleans up on exit. The supported shutdown types are: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \(dqnormal\(dq \- stops the queue manager and finishes all current transactions before exiting. This is the default. .IP \(bu 2 \(dqdrain_first\(dq \- stops the queue manager but continues processing requests from the queue until it is empty. .IP \(bu 2 \(dqnow\(dq \- exits immediately. .UNINDENT .UNINDENT .UNINDENT .sp An example command may look like this: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqshutdown\(dq, \(dqarguments\(dq: { \(dqexit\-value\(dq: 3, \(dqtype\(dq: \(dqdrain_first\(dq } } .EE .UNINDENT .UNINDENT .SS The \fBdhcp\-disable\fP Command .sp The \fI\%dhcp\-disable\fP command globally disables the DHCP service. The server continues to operate, but it drops all received DHCP messages. This command is useful when the server\(aqs maintenance requires that the server temporarily stop allocating new leases and renew existing leases. It is also useful in failover\-like configurations during a synchronization of the lease databases at startup, or recovery after a failure. The optional parameter \fBmax\-period\fP specifies the time in seconds after which the DHCP service should be automatically re\-enabled, if the \fI\%dhcp\-enable\fP command is not sent before this time elapses. .sp Since Kea 1.9.4, there is an additional \fBorigin\fP parameter that specifies the command source. A server administrator should typically omit this parameter because the default value \(dquser\(dq indicates that the administrator sent the command. In Kea 2.5.5 through 2.5.7, this parameter was also used in communication between the HA partners to specify the identifier of an HA service sending the command in a numeric format. However, due to compatibility issues with older Kea versions that did not properly parse numeric values, it was necessary to introduce the new parameter, \fBorigin\-id\fP, in Kea 2.5.8. .sp It holds a numeric value representing the origin of the command. The same value can still be passed using the \fBorigin\fP parameter, but it can cause the aforementioned compatibility issues between HA partners running different Kea versions; if both are used, \fBorigin\-id\fP takes precedence. New Kea versions favor using \fBorigin\-id\fP in communication between the HA partners, but overall, it is recommended that both parameters be omitted and the default value used. .sp The following codes represent the supported origins in numeric format: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fB1\fP \- a user command; the same as specifying \fB\(dqorigin\(dq: \(dquser\(dq\fP\&. .IP \(bu 2 \fB2000\fP, \fB2001\fP, \fB2002\fP, etc. \- origins specified by HA partners where the increments above \fB2000\fP are distinct HA service identifiers used when the partners have many relationships. .UNINDENT .UNINDENT .UNINDENT .sp In the following example: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqdhcp\-disable\(dq, \(dqarguments\(dq: { \(dqmax\-period\(dq: 20, \(dqorigin\-id\(dq: 2002, \(dqorigin\(dq: \(dquser\(dq } } .EE .UNINDENT .UNINDENT .sp the effective origin is \fB2002\fP, which indicates it is an HA partner sending the command for the service with ID of \fB2\fP\&. The \fBorigin\fP parameter will be ignored in this case. .SS The \fBdhcp\-enable\fP Command .sp The \fI\%dhcp\-enable\fP command globally enables the DHCP service. .sp Since Kea 1.9.4, there is an additional \fBorigin\fP parameter that specifies the command source. A server administrator should typically omit this parameter because the default value \(dquser\(dq indicates that the administrator sent the command. In Kea 2.5.5 through 2.5.7, this parameter was also used in communication between the HA partners to specify the identifier of an HA service sending the command in a numeric format. However, due to compatibility issues with older Kea versions that did not properly parse numeric values, it was necessary to introduce the new parameter, \fBorigin\-id\fP, in Kea 2.5.8. .sp It holds a numeric value representing the origin of the command. The same value can still be passed using the \fBorigin\fP parameter, but it can cause the aforementioned compatibility issues between HA partners running different Kea versions.; if both are used, \fBorigin\-id\fP takes precedence. New Kea versions favor using \fBorigin\-id\fP in communication between the HA partners, but overall, it is recommended that both .sp The following codes represent the supported origins in numeric format: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fB1\fP \- a user command; the same as specifying \fB\(dqorigin\(dq: \(dquser\(dq\fP\&. .IP \(bu 2 \fB2000\fP, \fB2001\fP, \fB2002\fP, etc. \- origins specified by HA partners where the increments above \fB2000\fP are distinct HA service identifiers used when the partners have many relationships. .UNINDENT .UNINDENT .UNINDENT .sp In the following example: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqdhcp\-enable\(dq, \(dqarguments\(dq: { \(dqorigin\-id\(dq: 2002, \(dqorigin\(dq: \(dquser\(dq } } .EE .UNINDENT .UNINDENT .sp the effective origin is \fB2002\fP, which indicates it is an HA partner sending the command for the service with ID of \fB2\fP\&. The \fBorigin\fP parameter will be ignored in this case. .SS The \fBstatus\-get\fP Command .sp The \fI\%status\-get\fP command returns the server\(aqs runtime information: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fBpid\fP: the process ID. .IP \(bu 2 \fBuptime\fP: the number of seconds since the start of the server. .IP \(bu 2 \fBreload\fP: the number of seconds since the last configuration (re)load. .IP \(bu 2 \fBhigh\-availability\fP: HA\-specific status information about the DHCP servers configured to use the HA hook library: .INDENT 2.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fBlocal\fP: the state, the role (primary, secondary, ...), and the scopes (i.e. what the server is actually processing) of the local server. .IP \(bu 2 \fBremote\fP: the remote server\(aqs last known state, its served HA scopes, and the role of the remote server in the HA relationship. .UNINDENT .UNINDENT .UNINDENT .IP \(bu 2 \fBmulti\-threading\-enabled\fP: a flag indicating whether multi\-threading is enabled. .IP \(bu 2 \fBthread\-pool\-size\fP: the number of DHCP service threads. .IP \(bu 2 \fBpacket\-queue\-size\fP: the maximum size of the packet queue. There is one queue, regardless of the number of running threads. .IP \(bu 2 \fBpacket\-queue\-statistics\fP: the average queue size for the last 10, 100, and 1000 packets, using an approach similar to the UNIX \fBtop\fP command. The average queue size for the last 10 packets can be considered an instantaneous value, while the average for the last 1000 packets shows a longer\-term trend. .UNINDENT .UNINDENT .UNINDENT .sp The \fBhigh\-availability\fP information is returned only when the command is sent to the DHCP servers in an HA setup. This parameter is never returned when the \fI\%status\-get\fP command is sent to the Control Agent or DDNS daemon. .sp The \fBthread\-pool\-size\fP, \fBpacket\-queue\-size\fP and \fBpacket\-queue\-statistics\fP parameters are returned only when the command is sent to DHCP servers with multi\-threading enabled. These three parameters and \fBmulti\-threading\-enabled\fP are never returned when the \fI\%status\-get\fP command is sent to the Control Agent or DDNS daemon. .sp To learn more about the HA status information returned by the \fI\%status\-get\fP command, please refer to the \fI\%The status\-get Command\fP section. .SS The \fBserver\-tag\-get\fP Command: .sp The \fI\%server\-tag\-get\fP command returns the configured server tag of the DHCPv4 or DHCPv6 server (\fI\%Configuration Sharing and Server Tags\fP explains the server tag concept). .SS The \fBconfig\-backend\-pull\fP Command: .sp The \fI\%config\-backend\-pull\fP command triggers the polling of configuration backends (which must be configured for this command to have an effect), explained in \fI\%Enabling the Configuration Backend\fP\&. .SS The \fBversion\-get\fP Command .sp The \fI\%version\-get\fP command returns extended information about the Kea version; it is the same information available via the \fB\-V\fP command\-line argument. This command does not take any parameters. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqversion\-get\(dq } .EE .UNINDENT .UNINDENT .SS Commands Supported by the DHCPv4 Server .SS The \fBsubnet4\-select\-test\fP Command .sp The \fI\%subnet4\-select\-test\fP provides a way to test DHCPv4 subnet selection based on a set of input parameters typically supplied in a client packet. Recognized parameters take strings and are: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fBinterface\fP \- the incoming interface name .IP \(bu 2 \fBaddress\fP \- the client address .IP \(bu 2 \fBrelay\fP \- the relay/gateway address .IP \(bu 2 \fBlocal\fP \- the local/destination address .IP \(bu 2 \fBremote\fP \- the remote/source address .IP \(bu 2 \fBlink\fP \- the RAI link\-selection address .IP \(bu 2 \fBsubnet\fP \- the subnet\-selection address .IP \(bu 2 \fBclasses\fP \- (list of strings) client classes (allowing to select a guarded subnet) .UNINDENT .UNINDENT .UNINDENT .sp The RAI link\-selection is ignored when the \fBignore\-rai\-link\-selection\fP compatibility flag is \fBtrue\fP\&. When it is not ignored it has precedence over the subnet\-selection. .sp Outside of errors possible results are: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 (empty) \(dqno selected subnet\(dq .IP \(bu 2 \(dqselected shared network \(aq\(aq starting with subnet \(aq\(aq id \(dq .IP \(bu 2 \(dqselected subnet \(aq\(aq id \(dq .UNINDENT .UNINDENT .UNINDENT .SS The \fBsubnet4o6\-select\-test\fP Command .sp The \fI\%subnet4o6\-select\-test\fP provides a way to test DHCPv4\-over\-DHCPv6 subnet selection based on a set of input parameters typically supplied in a client packet. Recognized parameters take strings and are: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fBinterface\fP \- the incoming interface name of the DHCPv6 server .IP \(bu 2 \fBinterface\-id\fP \- the binary content of the interface\-id relay option .IP \(bu 2 \fBaddress\fP \- the client address .IP \(bu 2 \fBrelay\fP \- the relay/gateway address .IP \(bu 2 \fBlocal\fP \- the local/destination address .IP \(bu 2 \fBremote\fP \- the remote/source IPv6 address of the DHCPv6 server .IP \(bu 2 \fBlink\fP \- the first relay link IPv6 address .IP \(bu 2 \fBsubnet\fP \- the subnet\-selection address .IP \(bu 2 \fBclasses\fP \- (list of strings) client classes (allowing to select a guarded subnet) .UNINDENT .UNINDENT .UNINDENT .sp According to the code only \fBremote\fP, \fBinterface\-id\fP and \fBinterface\fP selectors are used. In DHCPv4\-over\-DHCPv6 implementation \fBinterface\fP and \fBremote\fP values are transmitted from the DHCPv6 server, \fBinterface\-id\fP and \fBlink\fP are carried in the relay info part of the DHCPv6 packet so are the same as for the DHCPv6 server. .sp Outside of errors possible results are: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 (empty) \(dqno selected subnet\(dq .IP \(bu 2 \(dqselected shared network \(aq\(aq starting with subnet \(aq\(aq id \(dq .IP \(bu 2 \(dqselected subnet \(aq\(aq id \(dq .UNINDENT .UNINDENT .UNINDENT .SS Commands Supported by the DHCPv6 Server .SS The \fBsubnet6\-select\-test\fP Command .sp The \fI\%subnet6\-select\-test\fP provides a way to test DHCPv6 subnet selection based on a set of input parameters typically supplied in a client packet. Recognized parameters take strings and are: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fBinterface\fP \- the incoming interface name .IP \(bu 2 \fBinterface\-id\fP \- the binary content of the interface\-id relay option .IP \(bu 2 \fBremote\fP \- the remote/source address .IP \(bu 2 \fBlink\fP \- the first relay link address .IP \(bu 2 \fBclasses\fP \- (list of strings) client classes (allowing to select a guarded subnet) .UNINDENT .UNINDENT .UNINDENT .sp Outside of errors possible results are: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 (empty) \(dqno selected subnet\(dq .IP \(bu 2 \(dqselected shared network \(aq\(aq starting with subnet \(aq\(aq id \(dq .IP \(bu 2 \(dqselected subnet \(aq\(aq id \(dq .UNINDENT .UNINDENT .UNINDENT .SS Commands Supported by the D2 Server .sp The D2 server supports only a subset of the DHCPv4/DHCPv6 server commands: .INDENT 0.0 .IP \(bu 2 \fI\%build\-report\fP .IP \(bu 2 \fI\%config\-get\fP .IP \(bu 2 \fI\%config\-hash\-get\fP .IP \(bu 2 \fI\%config\-reload\fP .IP \(bu 2 \fI\%config\-set\fP .IP \(bu 2 \fI\%config\-test\fP .IP \(bu 2 \fI\%config\-write\fP .IP \(bu 2 \fI\%list\-commands\fP .IP \(bu 2 \fI\%shutdown\fP .IP \(bu 2 \fI\%status\-get\fP .IP \(bu 2 \fI\%version\-get\fP .UNINDENT .SS Commands Supported by the Control Agent .sp The following commands, listed in \fI\%Commands Supported by Both the DHCPv4 and DHCPv6 Servers\fP, are also supported by the Control Agent; when the \fBservice\fP parameter is blank, the commands are handled by the CA and they relate to the CA process itself: .INDENT 0.0 .IP \(bu 2 \fI\%build\-report\fP .IP \(bu 2 \fI\%config\-get\fP .IP \(bu 2 \fI\%config\-hash\-get\fP .IP \(bu 2 \fI\%config\-reload\fP .IP \(bu 2 \fI\%config\-set\fP .IP \(bu 2 \fI\%config\-test\fP .IP \(bu 2 \fI\%config\-write\fP .IP \(bu 2 \fI\%list\-commands\fP .IP \(bu 2 \fI\%shutdown\fP .IP \(bu 2 \fI\%status\-get\fP .IP \(bu 2 \fI\%version\-get\fP .UNINDENT .SS Migration from the Control Agent .sp Since Kea version 2.7.2 DHCP servers support HTTP/HTTPS control channels so the Control Agent (CA) is no longer needed. .sp The DHCPv4, DHCPv6, and D2 servers extend the \fBcontrol\-socket\fP entry to \fBcontrol\-sockets\fP list. To migrate a CA configuration add an element to this list with: .INDENT 0.0 .IP \(bu 2 \fBsocket\-type\fP set to \fBhttp\fP or \fBhttps\fP .IP \(bu 2 \fBsocket\-address\fP with the content of CA \fBhttp\-host\fP .IP \(bu 2 \fBsocket\-port\fP with the content of CA \fBhttp\-port\fP .IP \(bu 2 \fBtrust\-anchor\fP (unchanged) .IP \(bu 2 \fBcert\-file\fP (unchanged) .IP \(bu 2 \fBkey\-file\fP (unchanged) .IP \(bu 2 \fBcert\-required\fP (unchanged) .IP \(bu 2 \fBauthentication\fP (unchanged) .UNINDENT .sp User context is supported too. Please look at respective HTTP control socket sections for defaults and other details (beware that two servers must use different address / port pairs): \fI\%HTTP/HTTPS Control Socket\fP, \fI\%HTTP/HTTPS Control Socket\fP and \fI\%HTTP/HTTPS Control Socket\fP .sp For compatibility the JSON result of these HTTP/HTTPS control sockets is still encapsulated into a list. .SH LOGGING .SS Logging Configuration .sp During its operation Kea may produce many log messages. They differ in severity (some are more important than others) and source (different components, like hooks, produce different messages). It is useful to understand which log messages are critical and which are not, and to configure logging appropriately. For example, debug\-level messages can be safely ignored in a typical deployment. They are, however, very useful when debugging a problem. .sp The logging system in Kea is configured through the \fBloggers\fP entry in the server section of the configuration file. .SS Loggers .sp Within Kea, a message is logged through an entity called a \(dqlogger.\(dq Different components log messages through different loggers, and each logger can be configured independently of the others. Some components, in particular the DHCP server processes, may use multiple loggers to log messages pertaining to different logical functions of the component. For example, the DHCPv4 server uses one logger for messages about packet reception and transmission, another logger for messages related to lease allocation, and so on. Some of the libraries used by the Kea server, such as libdhcpsrv, use their own loggers. .sp Users implementing hook libraries (code attached to the server at runtime) are responsible for creating the loggers used by those libraries. Such loggers should have unique names, different from the logger names used by Kea. That way, the messages produced by the hook library can be distinguished from messages issued by the core Kea code. Unique names also allow the hook loggers to be configured independently of loggers used by Kea. Whenever it makes sense, a hook library can use multiple loggers to log messages pertaining to different logical parts of the library. .sp In the server section of a configuration file, the configuration for zero or more loggers (including loggers used by the proprietary hook libraries) can be specified. If there are no loggers specified, the code uses default values; these cause Kea to log messages of INFO severity or greater to standard output. There is a small time window after Kea has been started but before it has read its configuration; logging in this short period can be controlled using environment variables. For details, see \fI\%Logging During Kea Startup\fP\&. .sp The three main elements of a logger configuration are: \fBname\fP (the component that is generating the messages), \fBseverity\fP (what to log), and \fBoutput_commands\fP (where to log). There is also a \fBdebuglevel\fP element, which is only relevant if debug\-level logging has been selected. .SS The \fBname\fP (string) Logger .sp Each logger in the system has a name: that of the component binary file using it to log messages. For instance, to configure logging for the DHCPv4 server, add an entry for a logger named “kea\-dhcp4”. This configuration will then be used by the loggers in the DHCPv4 server and all the libraries used by it, unless a library defines its own logger and there is a specific logger configuration that applies to that logger. .sp When tracking down an issue with the server\(aqs operation, use of DEBUG logging is required to obtain the verbose output needed for problem diagnosis. However, the high verbosity is likely to overwhelm the logging system in cases where the server is processing high\-volume traffic. To mitigate this problem, Kea can use multiple loggers, for different functional parts of the server, that can each be configured independently. If the user is reasonably confident that a problem originates in a specific function of the server, or that the problem is related to a specific type of operation, they may enable high verbosity only for the relevant logger, thereby limiting the DEBUG messages to the required minimum. .sp The loggers are associated with a particular library or binary of Kea. However, each library or binary may (and usually does) include multiple loggers. For example, the DHCPv4 server binary contains separate loggers for packet parsing, dropped packets, callouts, etc. .sp The loggers form a hierarchy. For each program in Kea, there is a \(dqroot\(dq logger, named after the program (e.g. the root logger for \fI\%kea\-dhcp4\fP, the DHCPv4 server, is named \fI\%kea\-dhcp4\fP). All other loggers are children of this logger and are named accordingly, e.g. the allocation engine in the DHCPv4 server logs messages using a logger called \fBkea\-dhcp4.alloc\-engine\fP\&. .sp This relationship is important, as each child logger derives its default configuration from its parent root logger. In the typical case, the root logger configuration is the only logging configuration specified in the configuration file and so applies to all loggers. If an entry is made for a given logger, any attributes specified override those of the root logger, whereas any not specified are inherited from it. .sp To illustrate this, suppose we are using the DHCPv4 server with the root logger \fI\%kea\-dhcp4\fP logging at the INFO level. In order to enable DEBUG verbosity for DHCPv4 packet drops, we must create a configuration entry for the logger with \fB\(dqname\(dq: \(dqkea\-dhcp4.bad\-packets”\fP, \fB\(dqseverity\(dq: \(dqDEBUG\(dq\fP, and an explicit debug level. All other configuration parameters may be omitted for this logger if it should use the default values specified in the root logger\(aqs configuration. .sp \fBdebuglevel\fP is inherited only if \fBseverity\fP is missing as well. For predictable results, if \fBseverity\fP is \fB\(dqDEBUG\(dq\fP, these two attributes should always be explicitly specified or omitted together. An entry with an explicit \fB\(dqDEBUG\(dq\fP severity does not inherit \fBdebuglevel\fP from the root logger and defaults to \fB0\fP if missing, resulting in no debug messages being logged. This is a consequence of relying on the log4cplus inheritance mechanism. .sp If there are multiple logger specifications in the configuration that might match a particular logger, the specification with the more specific logger name takes precedence. For example, if there are entries for both \fI\%kea\-dhcp4\fP and \fBkea\-dhcp4.dhcpsrv\fP, the main DHCPv4 server program — and all libraries it uses other than the \fBdhcpsrv\fP library (libdhcpsrv) — logs messages according to the configuration in the first entry (\fI\%kea\-dhcp4\fP). Messages generated by the \fBdhcpsrv\fP library are logged according to the configuration set by the second entry. .sp The currently defined loggers are listed in the following table. The \(dqSoftware Package\(dq column of this table specifies whether the particular loggers belong to the core Kea code (open source Kea binaries and libraries), or hook libraries (open source or subscriber). .SS List of loggers supported by Kea servers and hook libraries shipped with Kea/subscriber packages .TS box center; l|l|l. T{ Logger Name T} T{ Software Package T} T{ Description T} _ T{ \fBkea\-ctrl\-agent\fP T} T{ core T} T{ The root logger for the Control Agent exposing the RESTful control API. All components used by the Control Agent inherit the settings from this logger. T} _ T{ \fBkea\-ctrl\-agent.auth\fP T} T{ core T} T{ A logger which covers access control details, such as the result of basic HTTP authentication. T} _ T{ \fBkea\-ctrl\-agent.ctrl\-agent\fP T} T{ core T} T{ Used to log results of configuration checks, information about services starting or failing to start, command reception, and forwarding. T} _ T{ \fBkea\-ctrl\-agent.http\fP T} T{ core T} T{ A logger which outputs log messages related to receiving, parsing, and sending HTTP messages. T} _ T{ \fBkea\-ctrl\-agent.rbac\-hooks\fP T} T{ \fI\%libdhcp_rbac.so\fP subscriber hook library T} T{ Used to log messages related to the operation of the RBAC hook library. T} _ T{ \fBkea\-dhcp4\fP T} T{ core T} T{ The root logger for the DHCPv4 server. All components used by the DHCPv4 server inherit the settings from this logger. T} _ T{ \fBkea\-dhcp6\fP T} T{ core T} T{ The root logger for the DHCPv6 server. All components used by the DHCPv6 server inherit the settings from this logger. T} _ T{ \fBkea\-dhcp4.alloc\-engine\fP, \fBkea\-dhcp6.alloc\-engine\fP T} T{ core T} T{ Used by the lease allocation engine, which is responsible for managing leases in the lease database, i.e. creating, modifying, and removing DHCP leases as a result of processing messages from clients. T} _ T{ \fBkea\-ctrl\-agent.auth\fP, \fBkea\-dhcp4.auth\fP, \fBkea\-dhcp6.auth\fP T} T{ core T} T{ Used to log malformed HTTP packets when using basic authentication. T} _ T{ \fBkea\-dhcp4.bad\-packets\fP, \fBkea\-dhcp6.bad\-packets\fP T} T{ core T} T{ Used by the DHCP servers for logging inbound client packets that were dropped or to which the server responded with a DHCPNAK. It allows administrators to configure a separate log output that contains only packet drop and reject entries. T} _ T{ \fBkea\-dhcp4.bootp\-hooks\fP T} T{ \fI\%libdhcp_bootp.so\fP open\-source hook library T} T{ This logger is used to log messages related to the operation of the BOOTP hook library. T} _ T{ \fBkea\-ctrl\-agent.callouts\fP, \fBkea\-dhcp4.callouts\fP, \fBkea\-dhcp6.callouts\fP, \fBkea\-dhcp\-ddns.callouts\fP T} T{ core T} T{ Used to log messages pertaining to the callouts registration and execution for a particular hook point. T} _ T{ \fBkea\-dhcp4.cb\-cmds\-hooks\fP, \fBkea\-dhcp6.cb\-cmds\-hooks\fP T} T{ \fI\%libdhcp_cb_cmds.so\fP subscriber hook library T} T{ Used to log messages related to the operation of the Config Backend Commands hook library. T} _ T{ \fBkea\-dhcp4.class\-cmds\-hooks\fP, \fBkea\-dhcp6.class\-cmds\-hooks\fP T} T{ \fI\%libdhcp_class_cmds.so\fP open\-source hook library T} T{ Used to log messages related to the operation of the Class Commands hook library. T} _ T{ \fBkea\-dhcp4.commands\fP, \fBkea\-dhcp6.commands\fP T} T{ core T} T{ Used to log messages related to the handling of commands received by the DHCP server over the command channel. T} _ T{ \fBkea\-dhcp4.database\fP, \fBkea\-dhcp6.database\fP T} T{ core T} T{ Used to log messages related to general operations of the relational databases. T} _ T{ \fBkea\-dhcp4.ddns\-tuning\-hooks\fP, \fBkea\-dhcp6.ddns\-tuning\-hooks\fP T} T{ \fI\%libdhcp_ddns_tuning.so\fP open\-source hook library T} T{ Used to log messages related to the operation of the DDNS Tuning hook library. T} _ T{ \fBkea\-dhcp4.ddns\fP, \fBkea\-dhcp6.ddns\fP T} T{ core T} T{ Used by the DHCP server to log messages related to Client FQDN and Hostname option processing. It also includes log messages related to the relevant DNS updates. T} _ T{ \fBkea\-dhcp4.dhcp4\fP, \fBkea\-dhcp6.dhcp6\fP T} T{ core T} T{ Used to log basic operations. T} _ T{ \fBkea\-dhcp4.dhcpsrv\fP, \fBkea\-dhcp6.dhcpsrv\fP T} T{ core T} T{ The base loggers for the \fBlibkea\-dhcpsrv.so\fP library. T} _ T{ \fBkea\-dhcp4.eval\fP, \fBkea\-dhcp6.eval\fP T} T{ core T} T{ Used to log messages related to the client classification expression evaluation code. T} _ T{ \fBkea\-dhcp4.flex\-id\-hooks\fP, \fBkea\-dhcp6.flex\-id\-hooks\fP T} T{ \fI\%libdhcp_flex_id.so\fP open\-source hook library T} T{ Used to log messages related to the operation of the Flexible Identifier hook library. T} _ T{ \fBkea\-dhcp4.flex\-option\-hooks\fP, \fBkea\-dhcp6.flex\-option\-hooks\fP T} T{ \fI\%libdhcp_flex_option.so\fP open\-source hook library T} T{ Used to log messages related to the operation of the Flexible Option hook library. T} _ T{ \fBkea\-dhcp4.ha\-hooks\fP, \fBkea\-dhcp6.ha\-hooks\fP T} T{ \fI\%libdhcp_ha.so\fP open\-source hook library T} T{ Used to log messages related to the operation of the High Availability hook library. T} _ T{ \fBkea\-ctrl\-agent.hooks\fP, \fBkea\-dhcp4.hooks\fP, \fBkea\-dhcp6.hooks\fP, \fBkea\-dhcp\-ddns.hooks\fP T} T{ core T} T{ Used to log messages related to the management of hook libraries, e.g. registration and deregistration of the libraries, and to the initialization of the callouts execution for various hook points within the DHCP server. T} _ T{ \fBkea\-dhcp4.host\-cache\-hooks\fP, \fBkea\-dhcp6.host\-cache\-hooks\fP T} T{ \fI\%libdhcp_host_cache.so\fP open\-source hook library T} T{ Used to log messages related to the operation of the Host Cache hook library. T} _ T{ \fBkea\-dhcp4.host\-cmds\-hooks\fP, \fBkea\-dhcp6.host\-cmds\-hooks\fP T} T{ \fI\%libdhcp_host_cmds.so\fP open\-source hook library T} T{ Used to log messages related to the operation of the Host Commands hook library. In general, these pertain to the loading and unloading of the library and the execution of commands by the library. T} _ T{ \fBkea\-dhcp4.hosts\fP, \fBkea\-dhcp6.hosts\fP T} T{ core T} T{ Used within the \fBlibkea\-dhcpsrv.so\fP to log messages related to the management of DHCP host reservations, i.e. retrieving reservations and adding new reservations. T} _ T{ \fBkea\-dhcp4.lease\-cmds\-hooks\fP, \fBkea\-dhcp6.lease\-cmds\-hooks\fP T} T{ \fI\%libdhcp_lease_cmds.so\fP open\-source hook library T} T{ Used to log messages related to the operation of the Lease Commands hook library. In general, these pertain to the loading and unloading of the library and the execution of commands by the library. T} _ T{ \fBkea\-dhcp4.limits\-hooks\fP, \fBkea\-dhcp6.limits\-hooks\fP T} T{ \fI\%libdhcp_limits.so\fP open\-source hook library T} T{ Used to log messages related to the operation of the Limits hook library. T} _ T{ \fBkea\-dhcp4.lease\-query\-hooks\fP, \fBkea\-dhcp6.lease\-query\-hooks\fP T} T{ \fI\%libdhcp_lease_query.so\fP open\-source hook library T} T{ Used to log messages related to the operation of the Leasequery hook library. T} _ T{ \fBkea\-dhcp4.leases\fP, \fBkea\-dhcp6.leases\fP T} T{ core T} T{ Used by the DHCP server to log messages related to lease allocation. The messages include detailed information about the allocated or offered leases, errors during the lease allocation, etc. T} _ T{ \fBkea\-dhcp4.legal\-log\-hooks\fP, \fBkea\-dhcp6.legal\-log\-hooks\fP T} T{ \fI\%libdhcp_legal_log.so\fP open\-source hook library T} T{ Used to log messages related to the operation of the Forensic Logging hook library. T} _ T{ \fBkea\-dhcp4.mysql\-cb\-hooks\fP, \fBkea\-dhcp6.mysql\-cb\-hooks\fP T} T{ \fI\%libdhcp_mysql.so\fP open\-source hook library T} T{ Used to log messages related to the operation of the MySQL Configuration Backend hook library. T} _ T{ \fBkea\-dhcp4.mysql\-hb\-hooks\fP, \fBkea\-dhcp6.mysql\-hb\-hooks\fP T} T{ \fI\%libdhcp_mysql.so\fP open\-source hook library T} T{ Used to log messages related to the operation of the MySQL Host Backend hook library. T} _ T{ \fBkea\-dhcp4.mysql\-lb\-hooks\fP, \fBkea\-dhcp6.mysql\-lb\-hooks\fP T} T{ \fI\%libdhcp_mysql.so\fP open\-source hook library T} T{ Used to log messages related to the operation of the MySQL Lease Backend hook library. T} _ T{ \fBkea\-dhcp4.options\fP, \fBkea\-dhcp6.options\fP T} T{ core T} T{ Used by the DHCP server to log messages related to the processing of options in the DHCP messages, i.e. parsing options, encoding options into on\-wire format, and packet classification using options contained in the received packets. T} _ T{ \fBkea\-dhcp4.packets\fP, \fBkea\-dhcp6.packets\fP T} T{ core T} T{ Mostly used to log messages related to transmission of DHCP packets, i.e. packet reception and the sending of a response. Such messages include information about the source and destination IP addresses and interfaces used to transmit packets. The logger is also used to log messages related to subnet selection, as this selection is usually based on the IP addresses, relay addresses, and/or interface names, which can be retrieved from the received packet even before the DHCP message carried in the packet is parsed. T} _ T{ \fBkea\-dhcp4.perfmon\-hooks\fP, \fBkea\-dhcp6.perfmon\-hooks\fP T} T{ \fI\%libdhcp_perfmon.so\fP open\-source hook library T} T{ Used to log messages related to the operation of the Performance Monitoring hook library. T} _ T{ \fBkea\-dhcp4.ping\-check\-hooks\fP T} T{ \fI\%libdhcp_ping_check.so\fP open\-source hook library T} T{ Used to log messages related to the operation of the Ping Check hook library. T} _ T{ \fBkea\-dhcp4.pgsql\-cb\-hooks\fP, \fBkea\-dhcp6.pgsql\-cb\-hooks\fP T} T{ \fI\%libdhcp_pgsql.so\fP open\-source hook library T} T{ Used to log messages related to the operation of the PostgreSQL Configuration Backend hook library. T} _ T{ \fBkea\-dhcp4.pgsql\-hb\-hooks\fP, \fBkea\-dhcp6.pgsql\-hb\-hooks\fP T} T{ \fI\%libdhcp_pgsql.so\fP open\-source hook library T} T{ Used to log messages related to the operation of the PostgreSQL Host Backend hook library. T} _ T{ \fBkea\-dhcp4.pgsql\-lb\-hooks\fP, \fBkea\-dhcp6.pgsql\-lb\-hooks\fP T} T{ \fI\%libdhcp_pgsql.so\fP open\-source hook library T} T{ Used to log messages related to the operation of the PostgreSQL Lease Backend hook library. T} _ T{ \fBkea\-dhcp4.run\-script\-hooks\fP, \fBkea\-dhcp6.run\-script\-hooks\fP T} T{ \fI\%libdhcp_run_script.so\fP open\-source hook library T} T{ Used to log messages related to the operation of the Run Script hook library. T} _ T{ \fBkea\-dhcp4.radius\-hooks\fP, \fBkea\-dhcp6.radius\-hooks\fP T} T{ \fI\%libdhcp_radius.so\fP open\-source hook library T} T{ Used to log messages related to the operation of the RADIUS hook library. T} _ T{ \fBkea\-dhcp4.stat\-cmds\-hooks\fP, \fBkea\-dhcp6.stat\-cmds\-hooks\fP T} T{ \fI\%libdhcp_stat_cmds.so\fP open\-source hook library T} T{ Used to log messages related to the operation of the Statistics Commands hook library. In general, these pertain to loading and unloading the library and the execution of commands by the library. T} _ T{ \fBkea\-dhcp4.subnet\-cmds\-hooks\fP, \fBkea\-dhcp6.subnet\-cmds\-hooks\fP T} T{ \fI\%libdhcp_subnet_cmds.so\fP open\-source hook library T} T{ Used to log messages related to the operation of the Subnet Commands hook library. In general, these pertain to loading and unloading the library and the execution of commands by the library. T} _ T{ \fBkea\-dhcp4.tcp\fP, \fBkea\-dhcp6.tcp\fP T} T{ core T} T{ Used to log messages related to TCP traffic. T} _ T{ \fBkea\-dhcp4.user_chk\fP, \fBkea\-dhcp6.user_chk\fP T} T{ \fI\%libdhcp_user_chk.so\fP open\-source hook library T} T{ Used to log messages related to the operation of the User Check hook library. T} _ T{ \fBkea\-dhcp\-ddns\fP T} T{ core T} T{ The root logger for the \fI\%kea\-dhcp\-ddns\fP daemon. All components used by this daemon inherit the settings from this logger unless there are configurations for more specialized loggers. T} _ T{ \fBkea\-ctrl\-agent.dctl\fP, \fBkea\-dhcp\-ddns.dctl\fP T} T{ core T} T{ Used to log basic information about the process, received signals, and triggered reconfigurations. T} _ T{ \fBkea\-dhcp\-ddns.asiodns\fP T} T{ core T} T{ Used to log messages about network events in DDNS operations. T} _ T{ \fBkea\-dhcp\-ddns.dhcpddns\fP T} T{ core T} T{ Used by the \fI\%kea\-dhcp\-ddns\fP daemon to log events related to DDNS operations. T} _ T{ \fBkea\-dhcp\-ddns.dhcp\-to\-d2\fP T} T{ core T} T{ Used by the \fI\%kea\-dhcp\-ddns\fP daemon to log information about events dealing with receiving messages from the DHCP servers and adding them to the queue for processing. T} _ T{ \fBkea\-dhcp\-ddns.d2\-to\-dns\fP T} T{ core T} T{ Used by the \fI\%kea\-dhcp\-ddns\fP daemon to log information about events dealing with sending and receiving messages to and from the DNS servers. T} _ T{ \fBkea\-dhcp\-ddns.gss\-tsig\-hooks\fP T} T{ \fI\%libddns_gss_tsig.so\fP open\-source hook library T} T{ Used to log messages related to the operation of the GSS\-TSIG hook library. T} _ T{ \fBkea\-dhcp\-ddns.libdhcp\-ddns\fP T} T{ core T} T{ Used to log events related to DDNS operations. T} _ T{ \fBkea\-netconf\fP T} T{ core T} T{ The root logger for the NETCONF agent. All components used by NETCONF inherit the settings from this logger if there is no specialized logger provided. T} .TE .sp Note that user\-defined hook libraries should not use any of the loggers mentioned above, but should instead define new loggers with names that correspond to the libraries using them. Suppose that a user created a library called “libdhcp\-packet\-capture” to dump packets received and transmitted by the server to a file. An appropriate name for the logger could be \fBkea\-dhcp4.packet\-capture\-hooks\fP\&. (Note that the hook library implementer only specifies the second part of this name, i.e. “packet\-capture”. The first part is a root\-logger name and is prepended by the Kea logging system.) It is also important to note that since this new logger is a child of a root logger, it inherits the configuration from the root logger, something that can be overridden by an entry in the configuration file. .sp The easiest way to find a logger name is to configure all logging to go to a single destination and look there for specific logger names. See \fI\%Logging Message Format\fP for details. .SS The \fBseverity\fP (string) Logger .sp This specifies the category of messages logged. Each message is logged with an associated severity, which may be one of the following (in descending order of severity): .INDENT 0.0 .IP \(bu 2 FATAL \- associated with messages generated by a condition that is so serious that the server cannot continue executing. .IP \(bu 2 ERROR \- associated with messages generated by an error condition. The server continues executing, but the results may not be as expected. .IP \(bu 2 WARN \- indicates an out\-of\-the\-ordinary condition. However, the server continues executing normally. .IP \(bu 2 INFO \- an informational message marking some event. .IP \(bu 2 DEBUG \- messages produced for debugging purposes. .UNINDENT .sp When the severity of a logger is set to one of these values, it only logs messages of that severity and above (e.g. setting the logging severity to INFO logs INFO, WARN, ERROR, and FATAL messages). The severity may also be set to NONE, in which case all messages from that logger are inhibited. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The \fI\%keactrl\fP tool, described in \fI\%Managing Kea with keactrl\fP, can be configured to start the servers in verbose mode. If this is the case, the settings of the logging severity in the configuration file have no effect; the servers use a logging severity of DEBUG regardless of the logging settings specified in the configuration file. To control severity via the configuration file, please make sure that the \fBkea_verbose\fP value is set to \(dqno\(dq within the \fI\%keactrl\fP configuration. .UNINDENT .UNINDENT .SS The \fBdebuglevel\fP (integer) Logger .sp When a logger\(aqs severity is set to DEBUG, this value specifies the level of debug messages to be printed. It ranges from 0 (least verbose) to 99 (most verbose). If severity for the logger is not DEBUG, this value is ignored. .SS The \fBoutput\-options\fP (list) Logger .sp Each logger can have zero or more \fBoutput\-options\fP\&. These specify where log messages are sent and are explained in detail below. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The alias \fBoutput\-options\fP was added in Kea 2.5.1, to be used interchangeably with the previous \fBoutput_options\fP configuration key. This was done to keep all configuration keys consistent, i.e. using a hyphen (\fI\-\fP) instead of an underscore (\fI_\fP) in the key name. .sp As of Kea 2.5.2, \fBoutput\-options\fP becomes the default configuration key and \fBoutput_options\fP can be used as an alias. .sp As of Kea 2.7.4, \fBoutput_options\fP configuration key has been deprecated and will be removed in future versions. Please consider updating your configuration by switching to using \fBoutput\-options\fP instead. .UNINDENT .UNINDENT .SS The \fBoutput\fP (string) Option .sp This value determines the type of output. There are several special values allowed here: \fBstdout\fP (messages are printed on standard output), \fBstderr\fP (messages are printed on stderr), \fBsyslog\fP (messages are logged to syslog using the default name), \fBsyslog:name\fP (messages are logged to syslog using a specified name). Any other value is interpreted as a filename to which messages should be written. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 As of Kea 2.7.9, log files may only be written to the output directory determined during compilation as: \fB\(dq[kea\-install\-dir]/var/log/kea\(dq\fP\&. This path may be overridden at startup by setting the environment variable \fBKEA_LOG_FILE_DIR\fP to the desired path. If a path other than this value is used in \fBoutput\fP, Kea will emit an error and refuse to start or, if already running, log an unrecoverable error. For ease of use simply omit the path component from \fBoutput\fP and specify only the file name. .UNINDENT .UNINDENT .SS The \fBflush\fP (boolean) Option .sp This flushes the buffers after each log message. Doing this reduces performance but ensures that if the program terminates abnormally, all messages up to the point of termination are recorded. The default is \fBtrue\fP\&. .SS The \fBmaxsize\fP (integer) Option .sp This option is only relevant when the destination is a file; this is the maximum size in bytes that a log file may reach. When the maximum size is reached, the file is renamed and a new file created. Initially, a \(dq.1\(dq is appended to the name; if a \(dq.1\(dq file exists, it is renamed \(dq.2\(dq, etc. This is referred to as rotation. .sp The default value is 10240000 (10MB). The smallest value that can be specified without disabling rotation is 204800. Any value less than this, including 0, disables rotation. The greatest possible value is INT_MAX MB, which is approximately 2PB. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Due to a limitation of the underlying logging library (log4cplus), rolling over the log files (from \(dq.1\(dq to \(dq.2\(dq, etc.) may show odd results; there can be multiple small files at the timing of rollover. This can happen when multiple processes try to roll over the files simultaneously. Version 1.1.0 of log4cplus solved this problem, so if this version or later of log4cplus is used to build Kea, the issue should not occur. Even with older versions, it is normally expected to happen rarely unless the log messages are produced very frequently by multiple different processes. .UNINDENT .UNINDENT .SS The \fBmaxver\fP (integer) Option .sp This option is only relevant when the destination is a file and rotation is enabled (i.e. maxsize is large enough). This is the maximum number of rotated versions that will be kept. Once that number of files has been reached, the oldest file, \(dqlog\-name.maxver\(dq, is discarded each time the log rotates. In other words, at most there will be the active log file plus maxver rotated files. The minimum and default value is 1. .SS The \fBpattern\fP (string) Option .sp This option can be used to specify the layout pattern of messages for a logger. Kea logging is implemented using the log4cplus library and its output formatting is based, conceptually, on the printf formatting from C; this is discussed in detail in the next section, \fI\%Logging Message Format\fP\&. .sp Each output type (\fBstdout\fP, file, or \fBsyslog\fP) has a default \fBpattern\fP which describes the content of its log messages. This parameter can be used to specify a desired pattern. The pattern for each logger is governed individually, so each configured logger can have its own pattern. Omitting the \fBpattern\fP parameter or setting it to an empty string, \(dq\(dq, causes Kea to use the default pattern for that logger\(aqs output type. .sp In addition to the log text itself, the default patterns used for \fBstdout\fP and files contain information such as date and time, logger level, and process information. The default pattern for \fBsyslog\fP is limited primarily to log level, source, and the log text. This avoids duplicating information which is usually supplied by syslog. .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Users are strongly encouraged to test their pattern(s) on a local, non\-production instance of Kea, running in the foreground and logging to \fBstdout\fP\&. .UNINDENT .UNINDENT .SS Logging Message Format .sp As mentioned above, Kea log message content is controlled via a scheme similar to the C language\(aqs printf formatting. The \(dqpattern\(dq used for each message is described by a string containing one or more format components as part of a text string. In addition to the components, the string may contain any other useful text for the administrator. .sp The behavior of Kea\(aqs format strings is determined by log4cplus. The following time format options are possible enclosed in \fB%D{}\fP or \fB%d{}\fP: .SS List of supported time format string components by Kea\(aqs logger .TS box center; l|l. T{ Component T} T{ Value T} _ T{ \fB%a\fP T} T{ Abbreviated weekday name T} _ T{ \fB%A\fP T} T{ Full weekday name T} _ T{ \fB%b\fP T} T{ Abbreviated month name T} _ T{ \fB%B\fP T} T{ Full month name T} _ T{ \fB%c\fP T} T{ Standard date and time string T} _ T{ \fB%d\fP T} T{ Day of month as a decimal(1\-31) T} _ T{ \fB%H\fP T} T{ Hour(0\-23) T} _ T{ \fB%I\fP T} T{ Hour(1\-12) T} _ T{ \fB%j\fP T} T{ Day of year as a decimal(1\-366) T} _ T{ \fB%m\fP T} T{ Month as decimal(1\-12) T} _ T{ \fB%M\fP T} T{ Minute as decimal(0\-59) T} _ T{ \fB%p\fP T} T{ Locale\(aqs equivalent of AM or PM T} _ T{ \fB%q\fP T} T{ milliseconds as decimal(0\-999) T} _ T{ \fB%Q\fP T} T{ microseconds as decimal(0\-999.999) T} _ T{ \fB%S\fP T} T{ Second as decimal(0\-59) T} _ T{ \fB%U\fP T} T{ Week of year, Sunday being first day(0\-53) T} _ T{ \fB%w\fP T} T{ Weekday as a decimal(0\-6, Sunday being 0) T} _ T{ \fB%W\fP T} T{ Week of year, Monday being first day(0\-53) T} _ T{ \fB%x\fP T} T{ Standard date string T} _ T{ \fB%X\fP T} T{ Standard time string T} _ T{ \fB%y\fP T} T{ Year in decimal without century(0\-99) T} _ T{ \fB%Y\fP T} T{ Year including century as decimal T} _ T{ \fB%Z\fP T} T{ Time zone name T} _ T{ \fB%%\fP T} T{ The percent sign T} .TE .sp Refer to the documentation for the \fBstrftime()\fP function found in the \fB\fP header or the \fBstrftime(3)\fP UNIX manual page for more information. .sp It is probably easiest to understand this by examining the default pattern for stdout and files; currently they are the same. That pattern is shown below: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dq%D{%Y\-%m\-%d %H:%M:%S.%q} %\-5p [%c/%i.%t] %m\en\(dq .EE .UNINDENT .UNINDENT .sp and a typical log produced by this pattern looks something like this: .INDENT 0.0 .INDENT 3.5 .sp .EX 2019\-08\-05 14:27:45.871 DEBUG [kea\-dhcp4.dhcpsrv/8475.12345] DHCPSRV_TIMERMGR_START_TIMER starting timer: reclaim\-expired\-leases .EE .UNINDENT .UNINDENT .sp That breaks down to: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fB%D{%Y\-%m\-%d %H:%M:%S.%q}\fP \(dq%D\(dq is the local date and time when the log message is generated, while everything between the curly braces, \(dq{}\(dq, are date and time components. From the example log above this produces: \fB2019\-08\-05 14:27:45.871\fP .IP \(bu 2 \fB%\-5p\fP The severity of the message, output as a minimum of five characters, using right\-padding with spaces. In our example log: \fBDEBUG\fP .IP \(bu 2 \fB%c\fP The log source. This includes two elements: the Kea process generating the message, in this case, \fI\%kea\-dhcp4\fP; and the component within the program from which the message originated, \fBdhcpsrv\fP (e.g. the name of the library used by DHCP server implementations). .IP \(bu 2 \fB%i\fP The process ID. From the example log: \fB8475\fP\&. .IP \(bu 2 \fB%t\fP The thread ID. From the example log: \fB12345\fP\&. The format of the thread ID is OS\-dependent: e.g. on some systems it is an address, so it is displayed in hexadecimal. .IP \(bu 2 \fB%m\fP The log message itself. Kea log messages all begin with a message identifier followed by arbitrary log text. Every message in Kea has a unique identifier, which can be used as an index to the \fI\%Kea Messages Manual\fP, where more information can be obtained. In our example log above, the identifier is \fBDHCPSRV_TIMERMGR_START_TIMER\fP\&. The log text is typically a brief description detailing the condition that caused the message to be logged. In our example, the information logged, \fBstarting timer: reclaim\-expired\-leases\fP, explains that the timer for the expired lease reclamation cycle has been started. .UNINDENT .UNINDENT .UNINDENT .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Omitting \fB%m\fP omits the log message text from the output, making it rather useless. \fB%m\fP should be considered mandatory. .UNINDENT .UNINDENT .sp Finally, note that spacing between components, the square brackets around the log source and PID, and the final carriage return \fB\en\fP are all literal text specified as part of the pattern. .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 To ensure that each log entry is a separate line, patterns must end with an \fB\en\fP\&. There may be use cases where it is not desired so we do not enforce its inclusion. If it is omitted from the pattern, the log entries will run together in one long \(dqline\(dq. .UNINDENT .UNINDENT .sp The default pattern for \fBsyslog\fP output is: .INDENT 0.0 .INDENT 3.5 .sp .EX \(dq%\-5p [%c.%t] %m\en\(dq .EE .UNINDENT .UNINDENT .sp It omits the date and time as well as the process ID, as this information is typically output by \fBsyslog\fP\&. Note that Kea uses the pattern to construct the text it sends to \fBsyslog\fP (or any other destination). It has no influence on the content \fBsyslog\fP may add or formatting it may do. .sp Consult the OS documentation for \fBsyslog\fP behavior, as there are multiple implementations. .sp A complete list of logging parameters supported by Kea is shown in the table below: .SS List of supported format string components by Kea\(aqs logger .TS box center; l|l. T{ Component T} T{ Value T} _ T{ \fB%b\fP T} T{ Outputs file that called the log e.g., logger_impl.cc T} _ T{ \fB%c\fP T} T{ Outputs the logger of the event e.g., kea\-dhcp4.hosts T} _ T{ \fB%d\fP T} T{ \fB%d{}\fP formats UTC time output e.g., \fB%d{%Y\-%m\-%d %H:%M:%S.%q}\fP T} _ T{ \fB%D\fP T} T{ \fB%D{}\fP formats LOCAL time output e.g., \fB%D{%Y\-%m\-%d %H:%M:%S.%q}\fP T} _ T{ \fB%E\fP T} T{ Outputs environment variables e.g., \fB%E{PATH}\fP T} _ T{ \fB%F\fP T} T{ Outputs filename where logging request was issued e.g., logger_impl.cc T} _ T{ \fB%h\fP T} T{ Outputs hostname of the system e.g., host\-1 T} _ T{ \fB%H\fP T} T{ Outputs fully qualified domain name e.g., host\-1.example.com T} _ T{ \fB%l\fP T} T{ Equivalent to \fB%F:%L\fP e.g., logger_impl.cc:179 T} _ T{ \fB%L\fP T} T{ Outputs the line number where the log was called e.g., 179 T} _ T{ \fB%m\fP T} T{ Outputs the actual log message T} _ T{ \fB%M\fP T} T{ Outputs caller (function name) of the log message T} _ T{ \fB%n\fP T} T{ Outputs line separator supported by platform e.g., \fB\en\fP in Linux T} _ T{ \fB%p\fP T} T{ Outputs log severity e.g., INFO T} _ T{ \fB%r\fP T} T{ Outputs milliseconds since program start e.g., 1235 T} _ T{ \fB%t\fP T} T{ Outputs thread ID that generated the log message e.g., 281472855306256 T} _ T{ \fB%T\fP T} T{ Outputs thread name that generated the log message e.g., 168005 T} _ T{ \fB%i\fP T} T{ Outputs process ID that generated the log message e.g., 168030 T} _ T{ \fB%%\fP T} T{ Outputs a literal percent sign T} .TE .sp Padding and truncation are also possible with modifiers preceding the component; this is done by placing a number and other modifier characters between the component and the % sign. There are five ways of modifying the output: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fB%20p\fP Left pads with spaces (align right) if the severity is shorter than 20 characters. .IP \(bu 2 \fB%\-15r\fP Right pads with spaces (align left) if the milliseconds since program start is shorter than 15 characters. .IP \(bu 2 \fB%.30m\fP Truncates from the beginning of the message if the message is longer than 30 characters. .IP \(bu 2 \fB%10.35E{PATH}\fP Left pad with spaces (align right) if the environment variable \(dqPATH\(dq is shorter than 10 characters. If the content is longer than 35 characters, then truncate from the beginning of the string. .IP \(bu 2 \fB%\-15.40m\fP Right pad with spaces (align left) if the log message is shorter than 15 characters. If the message is longer than 40 characters, truncate from the beginning. .UNINDENT .UNINDENT .UNINDENT .sp Supported parameters depend on the liblog4cplus version used to compile Kea, which can be checked by executing \fBkea\-dhcp4 \-W | grep \-i log4cplus\fP\&. This produces a result such as: \fBLOG4CPLUS_VERSION: 2.0.5\fP\&. Consult the documentation in the \X'tty: link https://github.com/log4cplus/log4cplus/wiki'\fI\%log4cplus wiki\fP\X'tty: link' for further information about the installed version. .SS Example Logger Configurations .sp In this example, we want to set the server logging to write to the console using standard output. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqServer\(dq: { \(dqloggers\(dq: [ { \(dqname\(dq: \(dqkea\-dhcp4\(dq, \(dqoutput\-options\(dq: [ { \(dqoutput\(dq: \(dqstdout\(dq } ], \(dqseverity\(dq: \(dqWARN\(dq } ] } .EE .UNINDENT .UNINDENT .sp As a second example, we want to store DEBUG log messages in a file that is at most 2MB and keep up to eight copies of old log files. Once the logfile grows to 2MB, it should be renamed and a new file should be created. .INDENT 0.0 .INDENT 3.5 .sp .EX \(dqServer\(dq: { \(dqloggers\(dq: [ { \(dqname\(dq: \(dqkea\-dhcp6\(dq, \(dqoutput\-options\(dq: [ { \(dqoutput\(dq: \(dq/var/log/kea/kea\-debug.log\(dq, \(dqmaxver\(dq: 8, \(dqmaxsize\(dq: 204800, \(dqflush\(dq: true, \(dqpattern\(dq: \(dq%d{%j %H:%M:%S.%q} %c %m\en\(dq } ], \(dqseverity\(dq: \(dqDEBUG\(dq, \(dqdebuglevel\(dq: 99 } ] } .EE .UNINDENT .UNINDENT .sp Notice that the above configuration uses a custom pattern which produces output like this: .INDENT 0.0 .INDENT 3.5 .sp .EX 220 13:50:31.783 kea\-dhcp4.dhcp4 DHCP4_STARTED Kea DHCPv4 server version 1.6.0\-beta2\-git started .EE .UNINDENT .UNINDENT .SS Logging During Kea Startup .sp The logging configuration is specified in the configuration file. However, when Kea starts, the configuration file is not read until partway into the initialization process. Prior to that, the logging settings are set to default values, although it is possible to modify some aspects of the settings by means of environment variables. In the absence of any logging configuration in the configuration file, the settings of the (possibly modified) default configuration persist while the program is running. .sp The following environment variables can be used to control the behavior of logging during startup: .sp \fBKEA_LOCKFILE_DIR\fP .INDENT 0.0 .INDENT 3.5 Specifies a directory where the logging system should create its lock file. If not specified, it is prefix/var/run/kea, where \(dqprefix\(dq defaults to /usr/local. This variable must not end with a slash. There is one special value: \(dqnone\(dq, which instructs Kea not to create a lock file at all. This may cause issues if several processes log to the same file. .UNINDENT .UNINDENT .sp \fBKEA_LOGGER_DESTINATION\fP .INDENT 0.0 .INDENT 3.5 Specifies logging output. There are several special values: .sp \fBstdout\fP Log to standard output. .sp \fBstderr\fP Log to standard error. .sp \fBsyslog[:fac]\fP Log via syslog. The optional \(dqfac\(dq (which is separated from the word \(dqsyslog\(dq by a colon) specifies the facility to be used for the log messages. Unless specified, messages are logged using the facility \(dqlocal0\(dq. .sp Any other value is treated as a name of the output file. If not otherwise specified, Kea logs to standard output. .UNINDENT .UNINDENT .SS Logging Levels .sp All Kea servers follow the overall intention to let the user know what is going on while not overloading the logging system with too much information, as that could easily be used as a denial\-of\-service attack. .sp Unlike the FATAL, ERROR, WARN and INFO levels, DEBUG has additional parameters. The following list details the basic information that is logged on each level. Sometimes the circumstances determine whether a piece of information is logged on a higher or lower level. For example, if a packet is being dropped due to configured classification, that is an execution of the configured policy and would be logged on debuglevel 15. However, if the packet is dropped due to an exception being thrown, it is much more important, as it may indicate a software bug, serious problems with memory, or database connectivity problems. As such it may be logged on much higher levels, such as WARN or even ERROR. .INDENT 0.0 .IP \(bu 2 0 \- singular messages printed during startup or shutdown of the server. .IP \(bu 2 10 \- log information about received API commands. .IP \(bu 2 15 \- information about reasons why a packet was dropped. .IP \(bu 2 40 \- tracing information, including processing decisions, results of expression evaluations, and more. .IP \(bu 2 45 \- similar to level 40, but with more details, e.g. the subnet being selected for an incoming packet. .IP \(bu 2 50 \- evaluations of expressions, status received from hook points, lease processing, packet processing details, including unpacking, packing, sending, etc. .IP \(bu 2 55 \- includes all details available, including full packet contents with all options printed. .UNINDENT .sp The debug levels apply only to messages logged on DEBUG, and are configured using the \fBdebuglevel\fP option. See the \fI\%The debuglevel (integer) Logger\fP section for details. .SH THE KEA SHELL .SS Overview of the Kea Shell .sp The Kea Control Agent (CA, see \fI\%The Kea Control Agent\fP) provides a RESTful control interface over HTTP. That API is typically expected to be used by various IPAMs and similar management systems. Nevertheless, there may be cases when an administrator wants to send a command to the CA directly, and the Kea shell provides a way to do this. It is a simple command\-line, scripting\-friendly, text client that is able to connect to the CA, send it commands with parameters, retrieve the responses, and display them. .sp As the primary purpose of the Kea shell is as a tool in a scripting environment, it is not interactive. However, by following simple guidelines it can be run manually. .sp Kea 1.9.0 introduced basic HTTP authentication support. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Kea version 2.7.2 introduces direct support of HTTP/HTTPS control channel by Kea servers (\fI\%kea\-dhcp4\fP, \fI\%kea\-dhcp6\fP and \fI\%kea\-dhcp\-ddns\fP). The \fI\%kea\-shell\fP can be used with these servers, the only difference is the \fB\-\-service\fP argument becomes useless and is ignored by Kea servers. Note the result is encapsulated in a list for \fI\%kea\-ctrl\-agent\fP compatibility. .UNINDENT .UNINDENT .SS Shell Usage .sp \fI\%kea\-shell\fP is run as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX $ kea\-shell [\-\-host hostname] [\-\-port number] [\-\-path path] [\-\-auth\-user] [\-\-auth\-password] [\-\-auth\-password\-file] [\-\-timeout seconds] [\-\-service service\-name] [command] .EE .UNINDENT .UNINDENT .sp where: .INDENT 0.0 .IP \(bu 2 \fB\-\-host hostname\fP specifies the hostname of the CA. If not specified, \(dqlocalhost\(dq is used. .IP \(bu 2 \fB\-\-port number\fP specifies the TCP port on which the CA listens. If not specified, 8000 is used. .IP \(bu 2 \fB\-\-path path\fP specifies the path in the URL to connect to. If not specified, an empty path is used. As the CA listens at the empty path, this parameter is useful only with a reverse proxy. .IP \(bu 2 \fB\-\-auth\-user\fP specifies the user ID for basic HTTP authentication. If not specified or specified as the empty string, authentication is not used. .IP \(bu 2 \fB\-\-auth\-password\fP specifies the password for basic HTTP authentication. If not specified but the user ID is specified, an empty password is used. If used together with \fB\-\-auth\-password\-file\fP, it is disregarded. .IP \(bu 2 \fB\-\-auth\-password\-file\fP specifies a text file whose first line contains the password to be used for basic HTTP authentication. This flag takes precedence over \fB\-\-auth\-password\fP flag. Caution is advised when setting file permissions for the file containing the password. Access to the file should be as strict as possible and limited only to the Kea administrators. .IP \(bu 2 \fB\-\-timeout seconds\fP specifies the timeout (in seconds) for the connection. If not given, 10 seconds is used. .IP \(bu 2 \fB\-\-service service\-name\fP specifies the target of a command. If not given, the CA is used as the target. This may be used more than once to specify multiple targets. .IP \(bu 2 \fBcommand\fP specifies the command to be sent. If not specified, the \fI\%list\-commands\fP command is used. .UNINDENT .sp Other switches are: .INDENT 0.0 .IP \(bu 2 \fB\-h\fP \- prints a help message. .IP \(bu 2 \fB\-v\fP \- displays the Kea version. .IP \(bu 2 \fB\-V\fP \- displays the extended Kea version. .UNINDENT .sp See \fI\%TLS Support\fP for new command\-line arguments associated with TLS/HTTPS support. .sp Once started, the shell reads the parameters for the command from standard input, which are expected to be in JSON format. When all have been read, the shell establishes a connection with the CA using HTTP, sends the command, and awaits a response. Once that is received, it is displayed on standard output. .sp For a list of available commands, see \fI\%Management API\fP; additional commands may be provided by hook libraries. For a list of all supported commands from the CA, use the \fI\%list\-commands\fP command. .sp The following shows a simple example of usage: .INDENT 0.0 .INDENT 3.5 .sp .EX $ kea\-shell \-\-host 192.0.2.1 \-\-port 8001 \-\-auth\-user foo \-\-auth\-password\-file secret_file \-\-service dhcp4 list\-commands ^D .EE .UNINDENT .UNINDENT .sp After the command line is entered, the program waits for command parameters to be entered. Since \fI\%list\-commands\fP does not take any arguments, Ctrl\-D (represented in the above example by \(dq^D\(dq) indicates end\-of\-file and terminates the parameter input. The shell then contacts the CA and prints out the list of available commands returned for the service named \fBdhcp4\fP\&. .sp The Kea shell will likely be most frequently used in scripts; the next example shows a simple scripted execution. It sends the command \fI\%config\-write\fP to the CA (the \fB\-\-service\fP parameter has not been used), along with the parameters specified in param.json. The result will be stored in result.json. .INDENT 0.0 .INDENT 3.5 .sp .EX $ cat param.json \(dqfilename\(dq: \(dqmy\-config\-file.json\(dq $ cat param.json | kea\-shell \-\-host 192.0.2.1 config\-write > result.json .EE .UNINDENT .UNINDENT .sp When a reverse proxy is used to de\-multiplex requests to different servers, the default empty path in the URL is not enough, so the \fB\-\-path\fP parameter should be used. For instance, if requests to the \(dq/kea\(dq path are forwarded to the CA this can be used: .INDENT 0.0 .INDENT 3.5 .sp .EX $ kea\-shell \-\-host 192.0.2.1 \-\-port 8001 \-\-path kea ... .EE .UNINDENT .UNINDENT .sp The Kea shell requires Python to be installed on the system. It has been tested with various versions of Python 3. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Beginning with Kea 2.4.0, \fI\%kea\-shell\fP no longer supports Python 2.7. .UNINDENT .UNINDENT .sp The Kea shell is intended to serve more as a demonstration of the RESTful interface\(aqs capabilities (and, perhaps, an illustration for people interested in integrating their management environments with Kea) than as a serious management client. It is not likely to be significantly expanded in the future; it is, and will remain, a simple tool. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 When using this tool with basic HTTP authentication, please keep in mind that command\-line arguments are not hidden from local users. .UNINDENT .UNINDENT .SS TLS Support .sp \fI\%kea\-shell\fP supports HTTPS connections; the TLS/HTTPS support requires Python 3. The additional command\-line arguments are: .INDENT 0.0 .IP \(bu 2 \fB\-\-ca\fP specifies the file or directory name of the Certification Authority. If not specified, HTTPS is not used. .IP \(bu 2 \fB\-\-cert\fP specifies the file name of the user end\-entity public key certificate. If specified, the file name of the user key must also be specified. .IP \(bu 2 \fB\-\-key\fP specifies the file name of the user key file. If specified, the file name of the user certificate must also be specified. Encrypted key files are not supported. .UNINDENT .sp For example, a basic HTTPS request to get a list of commands could look like this: .INDENT 0.0 .INDENT 3.5 .sp .EX $ kea\-shell \-\-host 127.0.0.1 \-\-port 8000 \-\-ca ./kea\-ca.crt list\-commands .EE .UNINDENT .UNINDENT .SH INTEGRATION WITH EXTERNAL SYSTEMS .sp Kea provides optional support for a variety of external systems, such as RADIUS, NETCONF, YANG, and GSS\-TSIG. The following sections describe how to compile Kea with those additional capabilities and how to configure them. .SS YANG/NETCONF .SS Overview .sp The Network Configuration Protocol, or NETCONF, is a network management protocol defined in \X'tty: link https://tools.ietf.org/html/rfc4741'\fI\%RFC 4741\fP\X'tty: link'\&. It uses the YANG modeling language, defined in \X'tty: link https://tools.ietf.org/html/rfc6020'\fI\%RFC 6020\fP\X'tty: link', to provide a uniform way of handling the configuration syntax of various networking devices. Kea provides optional support for a YANG/NETCONF interface with the \fI\%kea\-netconf\fP agent. .SS Installing NETCONF .sp To get its NETCONF capabilities, Kea requires the v2 versions of libyang and Sysrepo. The specific versions that have been thoroughly tested with Kea are: .INDENT 0.0 .IP \(bu 2 libyang v2.1.4 .IP \(bu 2 sysrepo v2.2.12 .IP \(bu 2 libyang\-cpp v1.1.0 (ae7d649ea75da081725c119dd553b2ef3121a6f8) .IP \(bu 2 sysrepo\-cpp v1.1.0 (02634174ffc60568301c3d9b9b7cf710cff6a586) .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 For users who are unable to upgrade to one of the versions of libyang and Sysrepo listed above, these are the oldest versions known to work reliably with current Kea releases: .INDENT 0.0 .IP \(bu 2 libyang v2.0.256 (56d4e07ef1cdeab3eb2e6700247f83ec9148edcc) .IP \(bu 2 sysrepo v2.1.84 .IP \(bu 2 libyang\-cpp v1.1.0 (7824d9a862f2dc1d8ad4f6a90ab6cee9200f7c81) .IP \(bu 2 sysrepo\-cpp v1.1.0 (e66b2f0c53a428eeb743d355cf86fb30e8e491f1) .UNINDENT .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 \fI\%kea\-netconf\fP may be compatible with later versions of libyang and Sysrepo, but only the versions listed above have been thoroughly tested by ISC. .UNINDENT .UNINDENT .sp Installing from packages is recommended, if they are provided by the system. If not, users can build from sources following the directions below, which should work on all popular operating systems. .SS Installing \fBlibyang\fP From Sources .INDENT 0.0 .INDENT 3.5 .sp .EX $ git clone https://github.com/CESNET/libyang.git $ cd libyang $ git checkout v2.1.4 $ mkdir build $ cd build $ cmake .. $ make $ make install .EE .UNINDENT .UNINDENT .SS Installing \fBsysrepo\fP From Sources .INDENT 0.0 .INDENT 3.5 .sp .EX $ git clone https://github.com/sysrepo/sysrepo.git $ cd sysrepo $ git checkout v2.2.12 $ mkdir build $ cd build $ cmake \-DREPO_PATH=/etc/sysrepo .. $ make $ make install # without sudo if you\(aqre doing development and want to run unit tests .EE .UNINDENT .UNINDENT .SS Installing \fBlibyang\-cpp\fP From Sources .INDENT 0.0 .INDENT 3.5 .sp .EX $ git clone https://github.com/CESNET/libyang\-cpp.git $ cd libyang\-cpp $ git checkout ae7d649ea75da081725c119dd553b2ef3121a6f8 $ mkdir build $ cd build $ cmake \-DBUILD_TESTING=OFF .. $ make $ make install .EE .UNINDENT .UNINDENT .SS Installing \fBsysrepo\-cpp\fP From Sources .INDENT 0.0 .INDENT 3.5 .sp .EX $ git clone https://github.com/sysrepo/sysrepo\-cpp.git $ cd sysrepo\-cpp $ git checkout 02634174ffc60568301c3d9b9b7cf710cff6a586 $ mkdir build $ cd build $ cmake \-DBUILD_TESTING=OFF .. $ make $ make install .EE .UNINDENT .UNINDENT .SS Compiling With NETCONF .INDENT 0.0 .IP 1. 3 Obtain the Kea sources. .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX $ git clone gitlab.isc.org/isc\-projects/kea.git $ cd kea .EE .UNINDENT .UNINDENT .INDENT 0.0 .IP 2. 3 Set up the build. .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX $ meson setup build \-D netconf=enabled \-D cpp_std=c++20 .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 If any of the libraries are installed in a custom location, the PKG_CONFIG_PATH can point to the .pc files. .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX PKG_CONFIG_PATH=:/opt/libyang/lib/pkgconfig:/opt/libyang\-cpp/lib/pkgconfig:/opt/sysrepo/lib/pkgconfig:/opt/sysrepo\-cpp/lib/pkgconfig .EE .UNINDENT .UNINDENT .INDENT 0.0 .IP 3. 3 Check \fBbuild/config.report\fP to verify NETCONF support. .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX NETCONF: YANG: 2.1.4 YANG_PREFIX: /opt/libyang YANGCPP: 1.1.0 YANGCPP_PREFIX: /opt/libyang\-cpp SYSREPO: 2.2.12 SYSREPO_PREFIX: /opt/sysrepo SYSREPOCPP: 1.1.0 SYSREPOCPP_PREFIX: /opt/sysrepo\-cpp .EE .UNINDENT .UNINDENT .INDENT 0.0 .IP 4. 3 Compile as usual. .INDENT 3.0 .INDENT 3.5 $ meson compile \-C build .UNINDENT .UNINDENT .UNINDENT .SS Quick Sysrepo Overview .sp This section offers a brief overview of a subset of available functions in Sysrepo. For more complete information, see the \X'tty: link https://www.sysrepo.org'\fI\%Sysrepo homepage\fP\X'tty: link'\&. .sp In YANG, configurations and state data are described in YANG syntax in module files named \fB[@].yang\fP .sp The revision part is optional and follows the \fBYYYY\-MM\-DD\fP format. An alternate XML syntax YIN is defined but less user\-friendly. Top\-level modules are named in Kea models (a short version of schema models). .sp There are two major modules that Kea is able to support: \fBkea\-dhcp4\-server\fP and \fBkea\-dhcp6\-server\fP\&. While there is an active effort in the DHC working group at IETF to develop a DHCPv6 YANG model, a similar initiative in the past for DHCPv4 failed. Therefore, Kea uses its own dedicated models for DHCPv4 and DHCPv6 but partially supports the IETF model for DHCPv6. .sp All of the models have extra modules as dependencies, which are also provided. All of the modules can be found in \fBsrc/share/yang/modules\fP in sources and in \fBshare/kea/yang/modules\fP in the installation directory. This directory is referred to as \fI${share_directory}\fP in the commands below. .sp To install modules from sources or upgrade them from older revisions, run the following command. In the case of a revision upgrade, YANG data will be migrated automatically to the new module schema. .INDENT 0.0 .INDENT 3.5 .sp .EX $ ${share_directory}/yang/modules/utils/reinstall.sh .EE .UNINDENT .UNINDENT .sp However, if there are any issues during the upgrade process, and data can be recreated from a NETCONF client or through other means, Kea modules can be easily uninstalled before installing again via this command: .INDENT 0.0 .INDENT 3.5 .sp .EX $ ${share_directory}/yang/modules/utils/reinstall.sh \-u .EE .UNINDENT .UNINDENT .sp This script should be able to reinstall Sysrepo. However, the \fB\-s\fP flag can also be used to specify a path: .INDENT 0.0 .INDENT 3.5 .sp .EX $ ./build/src/share/yang/modules/utils/reinstall.sh \-s /path/to/sysrepo .EE .UNINDENT .UNINDENT .sp To individually install all modules: .INDENT 0.0 .INDENT 3.5 .sp .EX $ cd ./src/share/yang/modules $ sysrepoctl \-i ./ietf\-dhcpv6\-server*.yang $ sysrepoctl \-i ./kea\-dhcp4\-server*.yang $ sysrepoctl \-i ./kea\-dhcp6\-server*.yang \&... .EE .UNINDENT .UNINDENT .sp The installation should look similar to the following: .INDENT 0.0 .INDENT 3.5 .sp .EX $ ./build/src/share/yang/modules/utils/reinstall.sh [INF] Connection 2 created. [INF] Module \(dqkeatest\-module\(dq was installed. [INF] File \(dqkeatest\-module@2022\-11\-30.yang\(dq was installed. [INF] No datastore changes to apply. [INF] Connection 4 created. [ERR] Module \(dqietf\-interfaces@2018\-02\-20\(dq already installed. [INF] No datastore changes to apply. [INF] Connection 7 created. [ERR] Module \(dqietf\-dhcpv6\-client\(dq is already in sysrepo. [INF] No datastore changes to apply. [INF] Connection 9 created. [ERR] Module \(dqietf\-dhcpv6\-relay\(dq is already in sysrepo. [INF] No datastore changes to apply. [INF] Connection 11 created. [ERR] Module \(dqietf\-dhcpv6\-server\(dq is already in sysrepo. [INF] No datastore changes to apply. [INF] Connection 13 created. [ERR] Write permission \(dqietf\-yang\-types\(dq check failed. [INF] No datastore changes to apply. [INF] Connection 15 created. [ERR] Module \(dqietf\-dhcpv6\-options\(dq is already in sysrepo. [INF] No datastore changes to apply. [INF] Connection 17 created. [ERR] Module \(dqietf\-dhcpv6\-types\(dq is already in sysrepo. [INF] No datastore changes to apply. [INF] Connection 21 created. [INF] Module \(dqkea\-types\(dq was installed. [INF] File \(dqkea\-types@2019\-08\-12.yang\(dq was installed. [INF] No datastore changes to apply. [INF] Connection 23 created. [INF] Module \(dqkea\-dhcp\-types\(dq was installed. [INF] File \(dqkea\-dhcp\-types@2022\-11\-30.yang\(dq was installed. [INF] No datastore changes to apply. [INF] Connection 25 created. [INF] Module \(dqkea\-dhcp\-ddns\(dq was installed. [INF] File \(dqkea\-dhcp\-ddns@2022\-07\-27.yang\(dq was installed. [INF] No datastore changes to apply. [INF] Connection 27 created. [INF] Module \(dqkea\-ctrl\-agent\(dq was installed. [INF] File \(dqkea\-ctrl\-agent@2019\-08\-12.yang\(dq was installed. [INF] No datastore changes to apply. [INF] Connection 29 created. [INF] Module \(dqkea\-dhcp4\-server\(dq was installed. [INF] File \(dqkea\-dhcp4\-server@2022\-11\-30.yang\(dq was installed. [INF] No datastore changes to apply. [INF] Connection 31 created. [INF] Module \(dqkea\-dhcp6\-server\(dq was installed. [INF] File \(dqkea\-dhcp6\-server@2022\-11\-30.yang\(dq was installed. [INF] No datastore changes to apply. .EE .UNINDENT .UNINDENT .sp To confirm whether the modules have been imported correctly, check the list of currently installed YANG modules. It should be similar to this: .INDENT 0.0 .INDENT 3.5 .sp .EX $ sysrepoctl \-l Sysrepo repository: /etc/sysrepo Module Name | Revision | Flags | Owner | Startup Perms | Submodules | Features \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- ietf\-datastores | 2018\-02\-14 | I | user:user | 444 | | ietf\-dhcpv6\-client | 2018\-09\-04 | I | user:user | 600 | | ietf\-dhcpv6\-options | 2018\-09\-04 | I | user:user | 600 | | ietf\-dhcpv6\-relay | 2018\-09\-04 | I | user:user | 600 | | ietf\-dhcpv6\-server | 2018\-09\-04 | I | user:user | 600 | | ietf\-dhcpv6\-types | 2018\-09\-04 | I | user:user | 600 | | ietf\-inet\-types | 2013\-07\-15 | I | user:user | 444 | | ietf\-interfaces | 2018\-02\-20 | I | user:user | 600 | | ietf\-netconf | 2013\-09\-29 | I | user:user | 644 | | ietf\-netconf\-acm | 2018\-02\-14 | I | user:user | 600 | | ietf\-netconf\-notifications | 2012\-02\-06 | I | user:user | 644 | | ietf\-netconf\-with\-defaults | 2011\-06\-01 | I | user:user | 444 | | ietf\-origin | 2018\-02\-14 | I | user:user | 444 | | ietf\-yang\-library | 2019\-01\-04 | I | user:user | 644 | | ietf\-yang\-metadata | 2016\-08\-05 | i | | | | ietf\-yang\-schema\-mount | 2019\-01\-14 | I | user:user | 644 | | ietf\-yang\-types | 2013\-07\-15 | I | user:user | 444 | | kea\-ctrl\-agent | 2019\-08\-12 | I | user:user | 600 | | kea\-dhcp\-ddns | 2022\-07\-27 | I | user:user | 600 | | kea\-dhcp\-types | 2022\-11\-30 | I | user:user | 600 | | kea\-dhcp4\-server | 2022\-11\-30 | I | user:user | 600 | | kea\-dhcp6\-server | 2022\-11\-30 | I | user:user | 600 | | kea\-types | 2019\-08\-12 | I | user:user | 600 | | keatest\-module | 2022\-11\-30 | I | user:user | 600 | | sysrepo\-monitoring | 2022\-04\-08 | I | user:user | 600 | | sysrepo\-plugind | 2022\-03\-10 | I | user:user | 644 | | yang | 2022\-06\-16 | I | user:user | 444 | | Flags meaning: I \- Installed/i \- Imported; R \- Replay support .EE .UNINDENT .UNINDENT .sp To reinstall a module, if the revision YANG entry was bumped, simply installing it will update it automatically. Otherwise, it must first be uninstalled: .INDENT 0.0 .INDENT 3.5 .sp .EX $ sysrepoctl \-u kea\-dhcp4\-server .EE .UNINDENT .UNINDENT .sp If the module is used (i.e. imported) by other modules, it can be uninstalled only after the dependent modules have first been uninstalled. Installation and uninstallation must be done in dependency order and reverse\-dependency order, as appropriate. .SS Supported YANG Models .sp The currently supported models are \fBkea\-dhcp4\-server\fP and \fBkea\-dhcp6\-server\fP\&. There is partial support for \fBietf\-dhcpv6\-server\fP, but the primary focus of testing has been on Kea DHCP servers. Other models (\fI\%kea\-dhcp\-ddns\fP and \fI\%kea\-ctrl\-agent\fP) are currently not supported. .SS Using the NETCONF Agent .sp The NETCONF agent follows this algorithm: .INDENT 0.0 .IP \(bu 2 For each managed server, get the initial configuration from the server through the control socket. .IP \(bu 2 Open a connection with the Sysrepo environment and establish two sessions with the startup and running datastores. .IP \(bu 2 Check that the used (not\-essential) and required (essential) modules are installed in the Sysrepo repository at the right revision. If an essential module \- that is, a module where the configuration schema for a managed server is defined \- is not installed, raise a fatal error. .IP \(bu 2 For each managed server, get the YANG configuration from the startup datastore, translate it to JSON, and load it onto the server being configured. .IP \(bu 2 For each managed server, subscribe a module change callback using its model name. .IP \(bu 2 When a running configuration is changed, try to validate or load the updated configuration via the callback to the managed server. .UNINDENT .SS Configuration .sp The behavior described in \fI\%Using the NETCONF Agent\fP is controlled by several configuration flags, which can be set in the global scope or in a specific managed\-server scope. If the latter, the value defined in the managed\-server scope takes precedence. These flags are: .INDENT 0.0 .IP \(bu 2 \fBboot\-update\fP \- controls the initial configuration phase; when \fBtrue\fP (the default), the initial configuration retrieved from the classic Kea server JSON configuration file is loaded first, and then the startup YANG model is loaded. This setting lets administrators define a control socket in the local JSON file and then download the configuration from YANG. When set to \fBfalse\fP, this phase is skipped. .IP \(bu 2 \fBsubscribe\-changes\fP \- controls the module change subscription; when \fBtrue\fP (the default), a module change callback is subscribed, but when \fBfalse\fP the phase is skipped and running configuration updates are disabled. When set to \fBtrue\fP, the running datastore is used to subscribe for changes. .IP \(bu 2 \fBvalidate\-changes\fP \- controls how Kea monitors changes in the Sysrepo configuration. Sysrepo offers two stages where Kea can interact: validation and application. At the validation (or \fBSR_EV_CHANGE\fP event, in the Sysrepo naming convention) stage, Kea retrieves the newly committed configuration and verifies it. If the configuration is incorrect for any reason, the Kea servers reject it and the error is propagated back to the Sysrepo, which then returns an error. This step only takes place if \fBvalidate\-changes\fP is set to \fBtrue\fP\&. In the application (or \fBSR_EV_UPDATE\fP event in the Sysrepo naming convention) stage, the actual configuration is applied. At this stage Kea can receive the configuration, but it is too late to signal back any errors as the configuration has already been committed. .UNINDENT .sp The idea behind the initial configuration phase is to boot Kea servers with a minimal configuration which includes only a control socket, making them manageable. For instance, for the DHCPv4 server: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp4\(dq: { \(dqcontrol\-socket\(dq: { \(dqsocket\-name\(dq: \(dqkea\-dhcp4\-ctrl.sock\(dq, \(dqsocket\-type\(dq: \(dqunix\(dq } } } .EE .UNINDENT .UNINDENT .sp With module change subscriptions enabled, the \fI\%kea\-netconf\fP daemon monitors any configuration changes as they appear in the Sysrepo. Such changes can be done using the \fBsysrepocfg\fP tool or remotely using any NETCONF client. For details, please see the Sysrepo documentation or \fI\%A Step\-by\-Step NETCONF Agent Operation Example\fP\&. Those tools can be used to modify YANG configurations in the running datastore. Note that committed configurations are only updated in the running datastore; to keep them between server reboots they must be copied to the startup datastore. .sp When module changes are tracked (using \fBsubscribe\-changes\fP set to \fBtrue\fP) and the running configuration has changed (e.g. using \fBsysrepocfg\fP or any NETCONF client), the callback validates the modified configuration (if \fBvalidate\-changes\fP was not set to \fBfalse\fP) and runs a second time to apply the new configuration. If the validation fails, the callback is still called again but with an \fBSR_EV_ABORT\fP (vs. \fBSR_EV_DONE\fP) event with rollback changes. .sp The returned code of the callback on an \fBSR_EV_DONE\fP event is ignored, as it is too late to refuse a bad configuration. .sp There are four ways in which a modified YANG configuration might be incorrect: .INDENT 0.0 .IP 1. 3 It could be non\-compliant with the schema, e.g. an unknown entry, missing a mandatory entry, a value with a bad type, or not matching a constraint. .IP 2. 3 It could fail to be translated from YANG to JSON, e.g. an invalid user context. .IP 3. 3 It could fail Kea server sanity checks, e.g. an out\-of\-subnet\-pool range or an unsupported database type. .IP 4. 3 The syntax may be correct and pass server sanity checks but the configuration could fail to run, e.g. the configuration specifies database credentials but the database refuses the connection. .UNINDENT .sp The first case is handled by Sysrepo. The second and third cases are handled by \fI\%kea\-netconf\fP in the validation phase (if not disabled by setting \fBvalidate\-changes\fP to \fBtrue\fP). The last case causes the application phase to fail without a sensible report to Sysrepo. .sp The managed Kea servers and agents are described in the \fBmanaged\-servers\fP section. Each sub\-section begins with the service name: \fBdhcp4\fP, \fBdhcp6\fP, \fBd2\fP (the DHCP\-DDNS server does not support the control\-channel feature yet), and \fBca\fP (the control agent). .sp Each managed server entry may contain: .INDENT 0.0 .IP \(bu 2 control flags \- \fBboot\-update\fP, \fBsubscribe\-changes\fP, and/or \fBvalidate\-changes\fP\&. .IP \(bu 2 \fBmodel\fP \- specifies the YANG model/module name. For each service, the default is the corresponding Kea YANG model, e.g. for \fB\(dqdhcp4\(dq\fP it is \fB\(dqkea\-dhcp4\-server\(dq\fP\&. .IP \(bu 2 \fBcontrol\-socket\fP \- specifies the control socket for managing the service configuration. .UNINDENT .sp A control socket is specified by: .INDENT 0.0 .IP \(bu 2 \fBsocket\-type\fP \- the socket type is either \fBstdout\fP, \fBunix\fP, or \fBhttp\fP\&. \fBstdout\fP is the default; it is not really a socket, but it allows \fI\%kea\-netconf\fP to run in debugging mode where everything is printed on stdout, and it can also be used to redirect commands easily. \fBunix\fP is the standard direct server control channel, which uses UNIX sockets; \fBhttp\fP uses a control agent, which accepts HTTP connections. .IP \(bu 2 \fBsocket\-name\fP \- the local socket name for the \fBunix\fP socket type (default empty string). .IP \(bu 2 \fBsocket\-url\fP \- the HTTP URL for the \fBhttp\fP socket type (default \fBhttp://127.0.0.1:8000/\fP). .UNINDENT .sp User contexts can store arbitrary data as long as they are in valid JSON syntax and their top\-level element is a map (i.e. the data must be enclosed in curly brackets). They are accepted at the NETCONF entry, i.e. below the top\-level, managed\-service entry, and control\-socket entry scopes. .sp Hook libraries can be loaded by the NETCONF agent just as with other servers or agents; however, currently no hook points are defined. The \fBhooks\-libraries\fP list contains the list of hook libraries that should be loaded by \fI\%kea\-netconf\fP, along with their configuration information specified with \fBparameters\fP\&. .sp Please consult \fI\%Logging\fP for details on how to configure logging. The name of the NETCONF agent\(aqs main logger is \fI\%kea\-netconf\fP, as given in the example above. .SS A \fI\%kea\-netconf\fP Configuration Example .sp The following example demonstrates the basic NETCONF configuration. More examples are available in the \fBdoc/examples/netconf\fP directory in the Kea sources. .INDENT 0.0 .INDENT 3.5 .sp .EX // This is a simple example of a configuration for the NETCONF agent. // This server provides a YANG interface for all Kea servers and the agent. { \(dqNetconf\(dq: { // Control flags can be defined in the global scope or // in a managed server scope. Precedences are: // \- use the default value (true) // \- use the global value // \- use the local value. // So this overwrites the default value: \(dqboot\-update\(dq: false, // This map specifies how each server is managed. For each server there // is a name of the YANG model to be used and the control channel. // Currently three control channel types are supported: // \(dqstdout\(dq which outputs the configuration on the standard output, // \(dqunix\(dq which uses the local control channel supported by the // \(dqdhcp4\(dq and \(dqdhcp6\(dq servers (\(dqd2\(dq support is not yet available), // and \(dqhttp\(dq which uses the Control Agent \(dqca\(dq to manage itself or // to forward commands to \(dqdhcp4\(dq or \(dqdhcp6\(dq. \(dqmanaged\-servers\(dq: { // This is how kea\-netconf can communicate with the DHCPv4 server. \(dqdhcp4\(dq: { \(dqcomment\(dq: \(dqDHCPv4 server\(dq, \(dqmodel\(dq: \(dqkea\-dhcp4\-server\(dq, \(dqcontrol\-socket\(dq: { \(dqsocket\-type\(dq: \(dqunix\(dq, \(dqsocket\-name\(dq: \(dqkea4\-ctrl\-socket\(dq } }, // DHCPv6 parameters. \(dqdhcp6\(dq: { \(dqmodel\(dq: \(dqkea\-dhcp6\-server\(dq, \(dqcontrol\-socket\(dq: { \(dqsocket\-type\(dq: \(dqunix\(dq, \(dqsocket\-name\(dq: \(dqkea6\-ctrl\-socket\(dq } }, \(dqd2\(dq: { \(dqmodel\(dq: \(dqkea\-dhcp\-ddns\(dq, \(dqcontrol\-socket\(dq: { \(dqsocket\-type\(dq: \(dqunix\(dq, \(dqsocket\-name\(dq: \(dqkea\-ddns\-ctrl\-socket\(dq, \(dquser\-context\(dq: { \(dqin\-use\(dq: true } } }, // Of course the Control Agent (CA) supports HTTP. \(dqca\(dq: { \(dqmodel\(dq: \(dqkea\-ctrl\-agent\(dq, \(dqcontrol\-socket\(dq: { \(dqsocket\-type\(dq: \(dqhttp\(dq, \(dqsocket\-url\(dq: \(dqhttp://127.0.0.1:8000/\(dq } } }, // kea\-netconf is able to load hook libraries that augment its operation. // Currently there are no hook points defined in kea\-netconf // processing. \(dqhooks\-libraries\(dq: [ // The hook libraries list may contain more than one library. { // The only necessary parameter is the library filename. \(dqlibrary\(dq: \(dq/opt/local/custom_hooks_example.so\(dq, // Some libraries may support parameters. Make sure you // type this section carefully, as kea\-netconf does not // validate it (because the format is library\-specific). \(dqparameters\(dq: { \(dqparam1\(dq: \(dqfoo\(dq } } ], // Similar to other Kea components, NETCONF also uses logging. \(dqloggers\(dq: [ { \(dqname\(dq: \(dqkea\-netconf\(dq, \(dqoutput\-options\(dq: [ { \(dqoutput\(dq: \(dq/var/log/kea/kea\-netconf.log\(dq, // Several additional parameters are possible in // addition to the typical output. // Flush determines whether logger flushes output // to a file. // Maxsize determines maximum filesize before // the file is rotated. // Maxver specifies the maximum number of // rotated files to be kept. \(dqflush\(dq: true, \(dqmaxsize\(dq: 204800, \(dqmaxver\(dq: 4 } ], \(dqseverity\(dq: \(dqINFO\(dq, \(dqdebuglevel\(dq: 0 } ] } } .EE .UNINDENT .UNINDENT .SS Starting and Stopping the NETCONF Agent .sp \fI\%kea\-netconf\fP accepts the following command\-line switches: .INDENT 0.0 .IP \(bu 2 \fB\-c file\fP \- specifies the configuration file. .IP \(bu 2 \fB\-d\fP \- specifies whether the agent logging should be switched to debug/verbose mode. In verbose mode, the logging severity and debuglevel specified in the configuration file are ignored and \(dqdebug\(dq severity and the maximum debuglevel (99) are assumed. The flag is convenient for temporarily switching the server into maximum verbosity, e.g. when debugging. .IP \(bu 2 \fB\-t file\fP \- specifies the configuration file to be tested. \fI\%kea\-netconf\fP attempts to load it and conducts sanity checks; certain checks are possible only while running the actual server. The actual status is reported with exit code (0 = configuration appears valid, 1 = error encountered). Kea prints out log messages to standard output and error to standard error when testing the configuration. .IP \(bu 2 \fB\-v\fP \- displays the version of \fI\%kea\-netconf\fP and exits. .IP \(bu 2 \fB\-V\fP \- displays the extended version information for \fI\%kea\-netconf\fP and exits. The listing includes the versions of the libraries dynamically linked to Kea. .IP \(bu 2 \fB\-W\fP \- displays the Kea configuration report and exits. The report is a copy of the \fBconfig.report\fP file produced by \fBmeson setup\fP; it is embedded in the executable binary. .sp The contents of the \fBconfig.report\fP file may also be accessed by examining certain libraries in the installation tree or in the source tree. .INDENT 2.0 .INDENT 3.5 .sp .EX # from installation using libkea\-process.so $ strings ${prefix}/lib/libkea\-process.so | sed \-n \(aqs/;;;; //p\(aq # from sources using libkea\-process.so $ strings src/lib/process/.libs/libkea\-process.so | sed \-n \(aqs/;;;; //p\(aq # from sources using libkea\-process.a $ strings src/lib/process/.libs/libkea\-process.a | sed \-n \(aqs/;;;; //p\(aq # from sources using libcfgrpt.a $ strings src/lib/process/cfgrpt/.libs/libcfgrpt.a | sed \-n \(aqs/;;;; //p\(aq .EE .UNINDENT .UNINDENT .UNINDENT .SS A Step\-by\-Step NETCONF Agent Operation Example .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Copies of example configurations presented within this section can be found in the Kea source code, under \fBdoc/examples/netconf/kea\-dhcp6\-operations\fP\&. .UNINDENT .UNINDENT .SS Setup of NETCONF Agent Operation Example .sp The test box has an Ethernet interface named eth1. On some systems it is possible to rename interfaces; for instance, on Linux with an ens38 interface: .INDENT 0.0 .INDENT 3.5 .sp .EX # ip link set down dev ens38 # ip link set name eth1 dev ens38 # ip link set up dev eth1 .EE .UNINDENT .UNINDENT .sp The interface must have an address in the test prefix: .INDENT 0.0 .INDENT 3.5 .sp .EX # ip \-6 addr add 2001:db8::1/64 dev eth1 .EE .UNINDENT .UNINDENT .sp The Kea DHCPv6 server must be launched with the configuration specifying a control socket used to receive control commands. The \fI\%kea\-netconf\fP process uses this socket to communicate with the DHCPv6 server, i.e. it pushes translated configurations to that server using control commands. The following is an example control socket specification for the Kea DHCPv6 server: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp6\(dq: { \(dqcontrol\-socket\(dq: { \(dqsocket\-name\(dq: \(dqkea\-dhcp6\-ctrl.sock\(dq, \(dqsocket\-type\(dq: \(dqunix\(dq } } } .EE .UNINDENT .UNINDENT .sp In order to launch the Kea DHCPv6 server using the configuration contained within the \fBboot.json\fP file, run: .INDENT 0.0 .INDENT 3.5 .sp .EX # kea\-dhcp6 \-d \-c boot.json .EE .UNINDENT .UNINDENT .sp The current configuration of the server can be fetched via a control socket by running: .INDENT 0.0 .INDENT 3.5 .sp .EX # echo \(aq{ \(dqcommand\(dq: \(dqconfig\-get\(dq }\(aq | socat UNIX:/opt/kea/var/run/kea/kea\-dhcp6\-ctrl.sock \(aq\-,ignoreeof\(aq .EE .UNINDENT .UNINDENT .sp The following is the example \fBnetconf.json\fP configuration for \fI\%kea\-netconf\fP, to manage the Kea DHCPv6 server: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqNetconf\(dq: { \(dqloggers\(dq: [ { \(dqdebuglevel\(dq: 99, \(dqname\(dq: \(dqkea\-netconf\(dq, \(dqoutput\-options\(dq: [ { \(dqoutput\(dq: \(dqstderr\(dq } ], \(dqseverity\(dq: \(dqDEBUG\(dq } ], \(dqmanaged\-servers\(dq: { \(dqdhcp6\(dq: { \(dqcontrol\-socket\(dq: { \(dqsocket\-name\(dq: \(dqkea\-dhcp6\-ctrl.sock\(dq, \(dqsocket\-type\(dq: \(dqunix\(dq } } } } } .EE .UNINDENT .UNINDENT .sp Note that in production there should not be a need to log at the DEBUG level. .sp The Kea NETCONF agent is launched by: .INDENT 0.0 .INDENT 3.5 .sp .EX # kea\-netconf \-d \-c netconf.json .EE .UNINDENT .UNINDENT .sp Now that both \fI\%kea\-netconf\fP and \fI\%kea\-dhcp6\fP are running, it is possible to populate updates to the configuration to the DHCPv6 server. The following is the configuration extracted from \fBstartup.xml\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX 1 2001:db8::1:0 2001:db8::1:ffff 2001:db8::1:0/112 2001:db8::/64 eth1 kea\-dhcp6\-ctrl.sock unix .EE .UNINDENT .UNINDENT .sp To populate this new configuration: .INDENT 0.0 .INDENT 3.5 .sp .EX $ sysrepocfg \-d startup \-f xml \-m kea\-dhcp6\-server \-\-import=startup.xml .EE .UNINDENT .UNINDENT .sp \fI\%kea\-netconf\fP pushes the configuration found in the Sysrepo startup datastore to all Kea servers during its initialization phase, after it subscribes to module changes in the Sysrepo running datastore. This action copies the configuration from the startup datastore to the running datastore and enables the running datastore, making it available. .sp Changes to the running datastore are applied after validation to the Kea servers. Note that they are not by default copied back to the startup datastore, i.e. changes are not permanent. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 \fI\%kea\-netconf\fP fetches the entire configuration from any Sysrepo datastore in a single \fBget\-config\fP NETCONF operation. Prior to Kea 2.3.2, a \fBget\-config\fP operation was done for each leaf and leaf\-list node. .UNINDENT .UNINDENT .SS Example of Error Handling in NETCONF Operation .sp There are four classes of issues with configurations applied via NETCONF: .INDENT 0.0 .IP 1. 3 The configuration does not comply with the YANG schema. .IP 2. 3 The configuration cannot be translated from YANG to the Kea JSON. .IP 3. 3 The configuration is rejected by the Kea server. .IP 4. 3 The configuration was validated by the Kea server but cannot be applied. .UNINDENT .sp In the first case, consider the following \fBBAD\-schema.xml\fP configuration file: .INDENT 0.0 .INDENT 3.5 .sp .EX 1 2001:db8::1:0 2001:db8::1:ffff 2001:db8::1:0/112 2001:db8::/64 eth1 kea\-dhcp6\-ctrl.sock unix .EE .UNINDENT .UNINDENT .sp It is directly rejected by \fBsysrepocfg\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX $ sysrepocfg \-d running \-f xml \-m kea\-dhcp6\-server \-\-import=BAD\-schema.xml .EE .UNINDENT .UNINDENT .sp In the second case, the configuration is rejected by \fI\%kea\-netconf\fP\&. For example, consider this \fBBAD\-translator.xml\fP file: .INDENT 0.0 .INDENT 3.5 .sp .EX 1 2001:db8::1:0 2001:db8::1:ffff 2001:db8::1:0/112 2001:db8::/64 eth1 kea\-dhcp6\-ctrl.sock unix bad .EE .UNINDENT .UNINDENT .sp In the third case, the configuration is presented to the Kea DHCPv6 server and fails to validate, as in this \fBBAD\-config.xml\fP file: .INDENT 0.0 .INDENT 3.5 .sp .EX 1 2001:db8:1::0 2001:db8:1::ffff 2001:db8:1::0/112 2001:db8::/64 eth1 kea\-dhcp6\-ctrl.sock unix .EE .UNINDENT .UNINDENT .sp In the last case, the misconfiguration is detected too late and the change must be reverted in Sysrepo, e.g. using the startup datastore as a backup. .SS NETCONF Operation Example with Two Pools .sp This example adds a second pool to the initial (i.e. startup) configuration in the \fBtwopools.xml\fP file: .INDENT 0.0 .INDENT 3.5 .sp .EX 1 2001:db8::1:0 2001:db8::1:ffff 2001:db8::1:0/112 2001:db8::2:0 2001:db8::2:ffff 2001:db8::2:0/112 2001:db8::/64 eth1 kea\-dhcp6\-ctrl.sock unix .EE .UNINDENT .UNINDENT .sp This configuration is installed by: .INDENT 0.0 .INDENT 3.5 .sp .EX $ sysrepocfg \-d running \-f xml \-m kea\-dhcp6\-server \-\-import=twopools.xml .EE .UNINDENT .UNINDENT .SS NETCONF Operation Example with Two Subnets .sp This example specifies two subnets in the \fBtwosubnets.xml\fP file: .INDENT 0.0 .INDENT 3.5 .sp .EX 1 2001:db8:1:: 2001:db8:1::ffff 2001:db8:1::/112 2001:db8:1::/64 2 2001:db8:2:: 2001:db8:2::ffff 2001:db8:2::/112 2001:db8:2::/64 eth1 kea\-dhcp6\-ctrl.sock unix .EE .UNINDENT .UNINDENT .sp This configuration is installed by: .INDENT 0.0 .INDENT 3.5 .sp .EX $ sysrepocfg \-d running \-f xml \-m kea\-dhcp6\-server \-\-import=twosubnets.xml .EE .UNINDENT .UNINDENT .SS NETCONF Operation Example With Logging .sp This example adds a logger entry to the initial (i.e. startup) configuration in the \fBlogging.xml\fP file: .INDENT 0.0 .INDENT 3.5 .sp .EX eth1 1 2001:db8::1:0 2001:db8::1:ffff 2001:db8::1:0/112 2001:db8::/64 kea\-dhcp6\-ctrl.sock unix kea\-dhcp6 stderr 99 DEBUG .EE .UNINDENT .UNINDENT .sp The corresponding Kea configuration in JSON is: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp6\(dq: { \(dqcontrol\-socket\(dq: { \(dqsocket\-name\(dq: \(dqkea\-dhcp6\-ctrl.sock\(dq, \(dqsocket\-type\(dq: \(dqunix\(dq }, \(dqinterfaces\-config\(dq: { \(dqinterfaces\(dq: [ \(dqeth1\(dq ] }, \(dqsubnet6\(dq: [ { \(dqid\(dq: 1, \(dqpools\(dq: [ { \(dqpool\(dq: \(dq2001:db8::1:0/112\(dq } ], \(dqsubnet\(dq: \(dq2001:db8::/64\(dq } ], \(dqloggers\(dq: [ { \(dqname\(dq: \(dqkea\-dhcp6\(dq, \(dqoutput\-options\(dq: [ { \(dqoutput\(dq: \(dqstderr\(dq } ], \(dqseverity\(dq: \(dqDEBUG\(dq, \(dqdebuglevel\(dq: 99 } ] } } .EE .UNINDENT .UNINDENT .sp Finally, any of the previous examples can be replayed by using \fBsysrepocfg\fP in edit mode as follows: .INDENT 0.0 .INDENT 3.5 .sp .EX $ sysrepocfg \-d running \-f xml \-m kea\-dhcp6\-server \-\-edit .EE .UNINDENT .UNINDENT .sp or by using a NETCONF client like \fBnetopeer2\-cli\fP from the \X'tty: link https://github.com/CESNET/Netopeer2'\fI\%Netopeer2\fP\X'tty: link' NETCONF Toolset. .SS Migrating YANG Data From a Prior Sysrepo Version .sp 1. Shut down \fI\%kea\-netconf\fP\&. This ensures that backups for both datastores are done at the same configuration state and that no change happens between exporting them. .INDENT 0.0 .IP 2. 3 Make data backups for all YANG modules, with one XML for each datastore. .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX $ sysrepocfg \-\-datastore running \-\-export=save.xml \-\-format=xml $ sysrepocfg \-\-datastore startup \-\-export=save.xml \-\-format=xml .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Sysrepo v0 does not support import/export of all YANG modules; this capability was added in Sysrepo v1. Users that are migrating from Sysrepo v0 will need to do per\-module backups. This has the added benefit of isolating potential failures and preventing them from affecting all modules. The command is the same, except it has the module name added to it at the end. .INDENT 0.0 .INDENT 3.5 .sp .EX $ sysrepocfg \-\-datastore running \-\-export=save.xml \-\-format=xml kea\-dhcp6\-server $ sysrepocfg \-\-datastore startup \-\-export=save.xml \-\-format=xml kea\-dhcp6\-server .EE .UNINDENT .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .IP 3. 3 Upgrade Sysrepo to the newer version and then run: .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX $ sysrepocfg \-\-datastore running \-\-import=save.xml $ sysrepocfg \-\-datastore startup \-\-import=save.xml .EE .UNINDENT .UNINDENT .SS GSS\-TSIG .SS GSS\-TSIG Overview .sp Kea provides support for DNS updates, which can be protected using Transaction Signatures (or TSIG). This protection is often adequate. However, some systems, in particular Active Directory (AD) on Microsoft Windows servers, have chosen to adopt a more complex GSS\-TSIG approach that offers additional capabilities, such as using negotiated dynamic keys. .sp Kea supports GSS\-TSIG to protect DNS updates sent by the Kea DHCP\-DDNS (D2) server in a hook, called \fI\%libddns_gss_tsig.so\fP\&. .sp GSS\-TSIG is defined in \X'tty: link https://tools.ietf.org/html/rfc3645'\fI\%RFC 3645\fP\X'tty: link'\&. The GSS\-TSIG protocol itself is an implementation of generic GSS\-API v2 services, defined in \X'tty: link https://tools.ietf.org/html/rfc2743'\fI\%RFC 2743\fP\X'tty: link'\&. .sp Many protocols are involved in this mechanism: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 Kerberos 5 \- \X'tty: link https://tools.ietf.org/html/rfc4120'\fI\%RFC 4120\fP\X'tty: link', which provides the security framework; .IP \(bu 2 GSS\-API (Generic Security Services Application Program Interface) \- \X'tty: link https://tools.ietf.org/html/rfc2743'\fI\%RFC 2743\fP\X'tty: link' for the API, \X'tty: link https://tools.ietf.org/html/rfc2743'\fI\%RFC 2744\fP\X'tty: link' for the C bindings, and \X'tty: link https://tools.ietf.org/html/rfc4121'\fI\%RFC 4121\fP\X'tty: link' for the application to Kerberos 5; .IP \(bu 2 SPNEGO (Simple and Protected GSS\-API Negotiation Mechanism) \- \X'tty: link https://tools.ietf.org/html/rfc4178'\fI\%RFC 4178\fP\X'tty: link' for the negotiation; .IP \(bu 2 DNS update \X'tty: link https://tools.ietf.org/html/rfc2136'\fI\%RFC 2136\fP\X'tty: link'; .IP \(bu 2 TSIG (Secret Key Transaction Authentication for DNS) \- \X'tty: link https://tools.ietf.org/html/rfc8945'\fI\%RFC 8945\fP\X'tty: link', which protects DNS exchanges; .IP \(bu 2 Secure Domain Name System (DNS) Dynamic Update \- \X'tty: link https://tools.ietf.org/html/rfc3007'\fI\%RFC 3007\fP\X'tty: link', which is the application of TSIG to DNS update protection; .IP \(bu 2 TKEY (Secret Key Establishment for DNS) \- \X'tty: link https://tools.ietf.org/html/rfc2930'\fI\%RFC 2930\fP\X'tty: link', which establishes secret keys for TSIG by transmitting crypto payloads between DNS parties; and .IP \(bu 2 GSS\-TSIG \- \X'tty: link https://tools.ietf.org/html/rfc3645'\fI\%RFC 3645\fP\X'tty: link', which is the application of GSS\-API to TSIG. .UNINDENT .UNINDENT .UNINDENT .sp To summarize, GSS\-API for Kerberos 5 with SPNEGO and TKEY are used to negotiate a security context between the Kea D2 server and a DNS server: .INDENT 0.0 .INDENT 2.5 [image] .UNINDENT .UNINDENT .sp The security context is then used by GSS\-TSIG to protect updates: .INDENT 0.0 .INDENT 2.5 [image] .UNINDENT .UNINDENT .sp The Kea implementation of GSS\-TSIG uses a GSS\-API for Kerberos 5 with the SPNEGO library. Two implementations meet this criteria: MIT Kerberos 5 and Heimdal. .SS GSS\-TSIG Compilation .sp The following procedure was tested on Debian 12. A similar approach can be applied to other systems. .INDENT 0.0 .IP 1. 3 Install either the MIT (\fBlibkrb5\-dev\fP) or the Heimdal (\fBheimdal\-dev\fP) library, for instance: .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX sudo apt install libkrb5\-dev .EE .UNINDENT .UNINDENT .INDENT 0.0 .IP 2. 3 Obtain the Kea sources, extract the Kea sources. .IP 3. 3 Set up the build: .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX meson setup build \-D krb5=enabled .EE .UNINDENT .UNINDENT .INDENT 0.0 .IP 4. 3 Make sure \fBbuild/config.report\fP shows the \fBKerberos5 GSS\-API\fP entry. .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX Kerberos5 GSS\-API: VERSION: 1.20.1 VENDOR: MIT .EE .UNINDENT .UNINDENT .sp Either the \fBkrb5.pc\fP file or the \fBkrb5\-config\fP tool are required to be present. They are provided by both MIT Kerberos 5 and Heimdal; however, on some systems where both Kerberos 5 and Heimdal are installed, it is a symbolic link to one of them. If the tool is not in the standard location, it can be selected by setting \fBPKG_CONFIG_PATH=/path/to/krb5.pc:${PKG_CONFIG_PATH}\fP or \fBPATH=/path/to/krb5\-config:${PATH}\fP prior to \fBmeson setup\fP\&. .INDENT 0.0 .IP 6. 3 Compile with \fBmeson compile \-C build\fP\&. .IP 7. 3 .INDENT 3.0 .TP .B After compilation, \fI\%libddns_gss_tsig.so\fP is available in the \fBbuild/src/hooks/d2/gss_tsig\fP directory. It can be loaded by \fI\%kea\-dhcp\-ddns\fP\&. .UNINDENT .UNINDENT .sp \fI\%libddns_gss_tsig.so\fP supports both MIT Kerberos 5 and Heimdal implementations. Heimdal is picky about security\-sensitive file permissions and is known to emit an unclear error message. It is a good idea to keep these files plain, with one link and no access for the group or other users. .sp The \fBkrb5\-config\fP script should provide an \fB\-\-vendor\fP option which identifies the implementation. .SS GSS\-TSIG Deployment .sp Before using GSS\-TSIG, a GSS\-TSIG capable DNS server, such as BIND 9 or Microsoft Active Directory (AD), must be deployed. Other GSS\-TSIG capable implementations may work, but have not been tested. .SS Kerberos 5 Setup .sp There are two kinds of key tables (keytab files): the system one used by servers, and client tables used by clients. For Kerberos 5, Kea is a \fBclient\fP\&. .sp Install the Kerberos 5 client library and \fBkadmin\fP tool: .INDENT 0.0 .INDENT 3.5 .sp .EX sudo apt install krb5\-kdc krb5\-admin\-server .EE .UNINDENT .UNINDENT .sp The following examples use the \fBEXAMPLE.ORG\fP realm to demonstrate required configuration steps and settings. .sp The Kerberos 5 client library must be configured to accept incoming requests for the realm \fBEXAMPLE.ORG\fP by updating the \fBkrb5.conf\fP file (e.g. on Linux: /etc/krb5.conf): .INDENT 0.0 .INDENT 3.5 .sp .EX [libdefaults] default_realm = EXAMPLE.ORG kdc_timesync = 1 ccache_type = 4 forwardable = true proxiable = true [realms] EXAMPLE.ORG = { kdc = kdc.example.org admin_server = kdc.example.org } .EE .UNINDENT .UNINDENT .sp In addition to the \fBkrb5.conf\fP file, the \fBkdc.conf\fP file can be used (e.g. on Linux: /etc/krb5kdc/kdc.conf): .INDENT 0.0 .INDENT 3.5 .sp .EX [kdcdefaults] kdc_ports = 750,88 [realms] EXAMPLE.ORG = { database_name = /var/lib/krb5kdc/principal admin_keytab = FILE:/etc/krb5kdc/kadm5.keytab acl_file = /etc/krb5kdc/kadm5.acl key_stash_file = /etc/krb5kdc/stash kdc_ports = 750,88 max_life = 10h 0m 0s max_renewable_life = 7d 0h 0m 0s master_key_type = des3\-hmac\-sha1 #supported_enctypes = aes256\-cts:normal aes128\-cts:normal default_principal_flags = +preauth } .EE .UNINDENT .UNINDENT .sp The \fBkadmind\fP daemon Access Control List (ACL) must be configured to give permissions to the DNS client principal to access the Kerberos 5 database (e.g. on Linux: /etc/krb5kdc/kadm5.acl): .INDENT 0.0 .INDENT 3.5 .sp .EX DHCP/admin.example.org@EXAMPLE.ORG * .EE .UNINDENT .UNINDENT .sp The administrator password for the default realm must be set: .INDENT 0.0 .INDENT 3.5 .sp .EX krb5_newrealm .EE .UNINDENT .UNINDENT .sp After the following message is displayed, enter the password for the default realm: .INDENT 0.0 .INDENT 3.5 .sp .EX This script should be run on the master KDC/admin server to initialize a Kerberos realm. It will ask you to type in a master key password. This password will be used to generate a key that is stored in /etc/krb5kdc/stash. You should try to remember this password, but it is much more important that it be a strong password than that it be remembered. However, if you lose the password and /etc/krb5kdc/stash, you cannot decrypt your Kerberos database. Loading random data Initializing database \(aq/var/lib/krb5kdc/principal\(aq for realm \(aqEXAMPLE.ORG\(aq, master key name \(aqK/M@EXAMPLE.ORG\(aq You will be prompted for the database Master Password. It is important that you NOT FORGET this password. Enter KDC database master key: .EE .UNINDENT .UNINDENT .sp Then retype the password: .INDENT 0.0 .INDENT 3.5 .sp .EX Re\-enter KDC database master key to verify: .EE .UNINDENT .UNINDENT .sp If successfully applied, the following message is displayed: .INDENT 0.0 .INDENT 3.5 .sp .EX Now that your realm is set up you may wish to create an administrative principal using the addprinc subcommand of the kadmin.local program. Then, this principal can be added to /etc/krb5kdc/kadm5.acl so that you can use the kadmin program on other computers. Kerberos admin principals usually belong to a single user and end in /admin. For example, if jruser is a Kerberos administrator, then in addition to the normal jruser principal, a jruser/admin principal should be created. Don\(aqt forget to set up DNS information so your clients can find your KDC and admin servers. Doing so is documented in the administration guide. .EE .UNINDENT .UNINDENT .sp The next step is to create the principals for the BIND 9 DNS server (the service protected by the GSS\-TSIG TKEY) and for the DNS client (the Kea DHCP\-DDNS server). .sp The BIND 9 DNS server principal (used for authentication) is created the following way: .INDENT 0.0 .INDENT 3.5 .sp .EX kadmin.local \-q \(dqaddprinc \-randkey DNS/server.example.org\(dq .EE .UNINDENT .UNINDENT .sp If successfully created, the following message is displayed: .INDENT 0.0 .INDENT 3.5 .sp .EX No policy specified for DNS/server.example.org@EXAMPLE.ORG; defaulting to no policy Authenticating as principal root/admin@EXAMPLE.ORG with password. Principal \(dqDNS/server.example.org@EXAMPLE.ORG\(dq created. .EE .UNINDENT .UNINDENT .sp The DNS server principal must be exported so that it can be used by the BIND 9 DNS server. Only this principal is required, and it is exported to the keytab file with the name \fBdns.keytab\fP\&. .INDENT 0.0 .INDENT 3.5 .sp .EX kadmin.local \-q \(dqktadd \-k /usr/local/share/kea/dns.keytab DNS/server.example.org\(dq .EE .UNINDENT .UNINDENT .sp If successfully exported, the following message is displayed: .INDENT 0.0 .INDENT 3.5 .sp .EX Authenticating as principal root/admin@EXAMPLE.ORG with password. Entry for principal DNS/server.example.org with kvno 2, encryption type aes256\-cts\-hmac\-sha1\-96 added to keytab WRFILE:/usr/local/share/kea/dns.keytab. Entry for principal DNS/server.example.org with kvno 2, encryption type aes128\-cts\-hmac\-sha1\-96 added to keytab WRFILE:/usr/local/share/kea/dns.keytab. .EE .UNINDENT .UNINDENT .sp The DHCP client principal (used by the Kea DHCP\-DDNS server) is created the following way: .INDENT 0.0 .INDENT 3.5 .sp .EX kadmin.local \-q \(dqaddprinc \-randkey DHCP/admin.example.org\(dq .EE .UNINDENT .UNINDENT .sp If successfully created, the following message is displayed: .INDENT 0.0 .INDENT 3.5 .sp .EX No policy specified for DHCP/admin.example.org@EXAMPLE.ORG; defaulting to no policy Authenticating as principal root/admin@EXAMPLE.ORG with password. Principal \(dqDHCP/admin.example.org@EXAMPLE.ORG\(dq created. .EE .UNINDENT .UNINDENT .sp The DHCP client principal must be exported so that it can be used by the Kea DHCP\-DDNS server and the GSS\-TSIG hook library. It is exported to the client keytab file with the name \fBdhcp.keytab\fP\&. .INDENT 0.0 .INDENT 3.5 .sp .EX kadmin.local \-q \(dqktadd \-k /usr/local/share/kea/dhcp.keytab DHCP/admin.example.org\(dq .EE .UNINDENT .UNINDENT .sp Finally, the \fBkrb5\-admin\-server\fP must be restarted: .INDENT 0.0 .INDENT 3.5 .sp .EX systemctl restart krb5\-admin\-server.service .EE .UNINDENT .UNINDENT .SS BIND 9 with GSS\-TSIG Configuration .sp The BIND 9 DNS server must be configured to use GSS\-TSIG, and to use the previously exported DNS server principal from the keytab file \fBdns.keytab\fP\&. Updating the \fBnamed.conf\fP file is required: .INDENT 0.0 .INDENT 3.5 .sp .EX options { ... directory \(dq/var/cache/bind\(dq; dnssec\-validation auto; listen\-on\-v6 { any; }; tkey\-gssapi\-keytab \(dq/etc/bind/dns.keytab\(dq; }; zone \(dqexample.org\(dq { type master; file \(dq/var/lib/bind/db.example.org\(dq; update\-policy { grant \(dqDHCP/admin.example.org@EXAMPLE.ORG\(dq zonesub any; }; }; zone \(dq84.102.10.in\-addr.arpa\(dq { type master; file \(dq/etc/bind/db.10\(dq; }; .EE .UNINDENT .UNINDENT .sp The zone files should have an entry for the server principal FQDN \fBserver.example.org\fP\&. .sp The \fB/etc/bind/db.10\fP file needs to be created or updated: .INDENT 0.0 .INDENT 3.5 .sp .EX ; ; BIND reverse data file for local loopback interface ; $TTL 604800 ; 1 week @ IN SOA server.example.org. root.example.org. ( 2 ; Serial 604800 ; Refresh 86400 ; Retry 2419200 ; Expire 604800 ; Negative Cache TTL ) ; @ IN NS ns. 40 IN PTR ns.example.org. .EE .UNINDENT .UNINDENT .sp The \fB/var/lib/bind/db.example.org\fP file needs to be created or updated: .INDENT 0.0 .INDENT 3.5 .sp .EX $ORIGIN . $TTL 604800 ; 1 week example.org IN SOA server.example.org. root.example.org. ( 8 ; serial 604800 ; refresh (1 week) 86400 ; retry (1 day) 2419200 ; expire (4 weeks) 604800 ; minimum (1 week) ) NS example.org. A ${BIND9_IP_ADDR} AAAA ::1 $ORIGIN example.org. kdc A ${KDC_IP_ADDR} server A ${BIND9_IP_ADDR} .EE .UNINDENT .UNINDENT .sp After any configuration change the server must be reloaded or restarted: .INDENT 0.0 .INDENT 3.5 .sp .EX systemctl restart named.service .EE .UNINDENT .UNINDENT .sp It is possible to get the status or restart the logs: .INDENT 0.0 .INDENT 3.5 .sp .EX systemctl status named.service journalctl \-u named | tail \-n 30 .EE .UNINDENT .UNINDENT .SS Windows Active Directory Configuration .sp This sub\-section is based on an Amazon AWS provided Microsoft Windows Server 2016 with Active Directory pre\-installed, so it describes only the steps used for GSS\-TSIG deployment. (For the complete configuration process, please refer to Microsoft\(aqs documentation or other external resources. We found \X'tty: link https://www.tenforums.com/tutorials/51456-windows-server-2016-setup-local-domain-controller.html'\fI\%this\fP\X'tty: link' tutorial very useful during configuration of our internal QA testing systems.) .INDENT 0.0 .TP .B Two Active Directory (AD) user accounts are needed: .INDENT 7.0 .IP \(bu 2 the first account is used to download AD information, such as the client key table of Kea .IP \(bu 2 the second account is mapped to the Kea DHCP client principal .UNINDENT .TP .B Kea needs to know: .INDENT 7.0 .IP \(bu 2 the server IP address .IP \(bu 2 the domain/realm name: the domain is in lower case, the realm in upper case, both without a final dot .IP \(bu 2 the server name .UNINDENT .UNINDENT .sp The second account (named \fBkea\fP below) is used to create a Service Principal Name (SPN): .INDENT 0.0 .INDENT 3.5 .sp .EX setspn \-S DHCP/kea. kea .EE .UNINDENT .UNINDENT .sp After a shared secret key is generated and put in a key table file: .INDENT 0.0 .INDENT 3.5 .sp .EX ktpass \-princ DHCP/kea.@ \-mapuser kea +rndpass \-mapop set \-ptype KRB5_NT_PRINCIPAL \-out dhcp.keytab .EE .UNINDENT .UNINDENT .sp The \fBdhcp.keytab\fP takes the same usage as for UNIX Kerberos. .SS GSS\-TSIG Troubleshooting .sp While testing GSS\-TSIG integration with Active Directory we came across one very cryptic error: .INDENT 0.0 .INDENT 3.5 .sp .EX INFO [kea\-dhcp\-ddns.gss\-tsig\-hooks/4678.139690935890624] GSS_TSIG_VERIFY_FAILED GSS\-TSIG verify failed: gss_verify_mic failed with GSSAPI error: Major = \(aqA token had an invalid Message Integrity Check (MIC)\(aq (393216), Minor = \(aqPacket was replayed in wrong direction\(aq (100002). .EE .UNINDENT .UNINDENT .sp In our case, the problem was that the Kea D2 server was trying to perform an update of a reverse DNS zone while it was not configured. An easy solution is to add a reverse DNS zone similar to the one configured in Kea. To do that, open the \(dqDNS Manager\(dq and choose \(dqDNS\(dq from the list; from the dropdown list, choose \(dqReverse Lookup Zones\(dq; then click \(dqAction\(dq and \(dqNew Zone\(dq; finally, follow the New Zone Wizard to add a new zone. .sp The standard requires both anti\-replay and sequence services. Experiences with the BIND 9 nsupdate showed the sequence service led to problems so it is disabled by default in the hook. It seems the anti\-replay service can also lead to problems with Microsoft DNS servers so it is now configurable. Note that these security services are useless for DNS dynamic update which was designed to run over UDP so with out of order and duplicated messages. .SS Using GSS\-TSIG .sp There are a number of steps required to enable the GSS\-TSIG mechanism: .INDENT 0.0 .IP 1. 3 \fI\%libddns_gss_tsig.so\fP must be loaded by \fI\%kea\-dhcp\-ddns\fP\&. .IP 2. 3 The GSS\-TSIG\-capable DNS servers must be specified with their parameters. .UNINDENT .sp An excerpt from a D2 server configuration is provided below; more examples are available in the \fBdoc/examples/ddns\fP directory in the Kea sources. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcpDdns\(dq: { // The following parameters are used to receive NCRs (NameChangeRequests) // from the local Kea DHCP server. Make sure your kea\-dhcp4 and kea\-dhcp6 // matches this. \(dqip\-address\(dq: \(dq127.0.0.1\(dq, \(dqport\(dq: 53001, \(dqdns\-server\-timeout\(dq : 1000, // Forward zone: secure.example.org. It uses GSS\-TSIG. It is served // by two DNS servers, which listen for DDNS requests at 192.0.2.1 // and 192.0.2.2. \(dqforward\-ddns\(dq: { \(dqddns\-domains\(dq: [ // DdnsDomain for zone \(dqsecure.example.org.\(dq { \(dqname\(dq: \(dqsecure.example.org.\(dq, \(dqcomment\(dq: \(dqDdnsDomain example\(dq, \(dqdns\-servers\(dq: [ { // This server has an entry in gss/servers and // thus will use GSS\-TSIG. \(dqip\-address\(dq: \(dq192.0.2.1\(dq }, { // This server also has an entry there, so will // use GSS\-TSIG, too. \(dqip\-address\(dq: \(dq192.0.2.2\(dq, \(dqport\(dq: 5300 } ] } ] }, // Reverse zone: we want to update the reverse zone \(dq2.0.192.in\-addr.arpa\(dq. \(dqreverse\-ddns\(dq: { \(dqddns\-domains\(dq: [ { \(dqname\(dq: \(dq2.0.192.in\-addr.arpa.\(dq, \(dqdns\-servers\(dq: [ { // There is a GSS\-TSIG definition for this server (see // DhcpDdns/gss\-tsig/servers), so it will use // Krb/GSS\-TSIG. \(dqip\-address\(dq: \(dq192.0.2.1\(dq } ] } ] }, // The GSS\-TSIG hook is loaded and its configuration is specified here. \(dqhooks\-libraries\(dq: [ { \(dqlibrary\(dq: \(dq/opt/lib/libddns_gss_tsig.so\(dq, \(dqparameters\(dq: { // This section governs the GSS\-TSIG integration. Each server // mentioned in forward\-ddns and/or reverse\-ddns needs to have // an entry here to be able to use GSS\-TSIG defaults (optional, // if specified they apply to all the GSS\-TSIG servers, unless // overwritten on specific server level). \(dqserver\-principal\(dq: \(dqDNS/server.example.org@EXAMPLE.ORG\(dq, \(dqclient\-principal\(dq: \(dqDHCP/admin.example.org@EXAMPLE.ORG\(dq, // client\-keytab and credentials\-cache can both be used to // store client keys. As credentials cache is more flexible, // it is recommended to use it. Typically, using both at the // same time may cause problems. // \(dqclient\-keytab\(dq: \(dqFILE:/etc/dhcp.keytab\(dq, // toplevel only \(dqcredentials\-cache\(dq: \(dqFILE:/etc/ccache\(dq, // toplevel only \(dqgss\-replay\-flag\(dq: true, // GSS anti replay service \(dqgss\-sequence\-flag\(dq: false, // no GSS sequence service \(dqtkey\-lifetime\(dq: 3600, // 1 hour \(dqrekey\-interval\(dq: 2700, // 45 minutes \(dqretry\-interval\(dq: 120, // 2 minutes \(dqtkey\-protocol\(dq: \(dqTCP\(dq, \(dqfallback\(dq: false, // The list of GSS\-TSIG capable servers \(dqservers\(dq: [ { // First server (identification is required) \(dqid\(dq: \(dqserver1\(dq, \(dqdomain\-names\(dq: [ ], // if not specified or empty, will // match all domains that want to // use this IP+port pair \(dqip\-address\(dq: \(dq192.0.2.1\(dq, \(dqport\(dq: 53, \(dqserver\-principal\(dq: \(dqDNS/server1.example.org@EXAMPLE.ORG\(dq, \(dqclient\-principal\(dq: \(dqDHCP/admin1.example.org@EXAMPLE.ORG\(dq, \(dqgss\-replay\-flag\(dq: false, // no GSS anti replay service \(dqgss\-sequence\-flag\(dq: false, // no GSS sequence service \(dqtkey\-lifetime\(dq: 7200, // 2 hours \(dqrekey\-interval\(dq: 5400, // 90 minutes \(dqretry\-interval\(dq: 240, // 4 minutes \(dqtkey\-protocol\(dq: \(dqTCP\(dq, \(dqfallback\(dq: true // if no key is available fallback to the // standard behavior (vs skip this server) }, { // The second server (it has most of the parameters missing // as those are using the defaults specified above) \(dqid\(dq: \(dqserver2\(dq, \(dqip\-address\(dq: \(dq192.0.2.2\(dq, \(dqport\(dq: 5300 } ] } } ] // Additional parameters, such as logging, control socket and // others omitted for clarity. } } .EE .UNINDENT .UNINDENT .sp This configuration file contains a number of extra elements. .sp First, a list of forward and/or reverse domains with related DNS servers identified by their IP+port pairs is defined. If the port is not specified, the default of 53 is assumed. This is similar to basic mode, with no authentication done using TSIG keys, with the exception that static TSIG keys are not referenced by name. .sp Second, \fI\%libddns_gss_tsig.so\fP must be specified on the \fBhooks\-libraries\fP list. This hook takes many parameters. The most important one is \fBservers\fP, which is a list of GSS\-TSIG\-capable servers. If there are several servers and they share some characteristics, the values can be specified in the \fBparameters\fP scope as defaults. In the example above, the defaults that apply to all servers, unless otherwise specified on a per\-server scope, are defined in lines 63 through 68. The defaults can be skipped if there is only one server defined, or if all servers have different values. .SS List of available parameters .TS box center; l|l|l|l|l. T{ Name T} T{ Scope T} T{ Type T} T{ Default value T} T{ Description T} _ T{ client\-keytab T} T{ global / server T} T{ string T} T{ empty T} T{ the Kerberos \fBclient\fP key table T} _ T{ credentials\-cache T} T{ global / server T} T{ string T} T{ empty T} T{ the Kerberos credentials cache T} _ T{ server\-principal T} T{ global / server T} T{ string T} T{ empty T} T{ the Kerberos principal name of the DNS server that will receive updates T} _ T{ client\-principal T} T{ global / server T} T{ string T} T{ empty T} T{ the Kerberos principal name of the Kea D2 service T} _ T{ gss\-replay\-flag T} T{ global / server T} T{ true / false T} T{ true T} T{ require the GSS anti replay service (GSS_C_REPLAY_FLAG) T} _ T{ gss\-sequence\-flag T} T{ global / server T} T{ true / false T} T{ false T} T{ require the GSS sequence service (GSS_C_SEQUENCE_FLAG) T} _ T{ tkey\-protocol T} T{ global / server T} T{ string \(dqTCP\(dq / \(dqUDP\(dq T} T{ \(dqTCP\(dq T} T{ the protocol used to establish the security context with the DNS servers T} _ T{ tkey\-lifetime T} T{ global / server T} T{ uint32 T} T{ .nf 3600 seconds ( 1 hour ) .fi T} T{ the lifetime of GSS\-TSIG keys T} _ T{ rekey\-interval T} T{ global / server T} T{ uint32 T} T{ .nf 2700 seconds ( 45 minutes ) .fi T} T{ the time interval the keys are checked for rekeying T} _ T{ retry\-interval T} T{ global / server T} T{ uint32 T} T{ .nf 120 seconds ( 2 minutes ) .fi T} T{ the time interval to retry to create a key if any error occurred previously T} _ T{ fallback T} T{ global / server T} T{ true / false T} T{ false T} T{ the behavior to fallback to non\-GSS\-TSIG when GSS\-TSIG should be used but no GSS\-TSIG key is available. T} _ T{ exchange\-timeout T} T{ global / server T} T{ uint32 T} T{ .nf 3000 milliseconds ( 3 seconds ) .fi T} T{ the time used to wait for the GSS\-TSIG TKEY exchange to finish before it timeouts T} _ T{ user\-context T} T{ global / server T} T{ string T} T{ empty T} T{ the user\-provided data in JSON format (not used by the GSS\-TSIG hook) T} _ T{ comment T} T{ global / server T} T{ string T} T{ empty T} T{ ignored T} _ T{ id T} T{ server T} T{ string T} T{ empty T} T{ identifier to a DNS server (required) T} _ T{ domain\-names T} T{ server T} T{ list of strings T} T{ empty T} T{ the many\-to\-one relationship between D2 DNS servers and GSS\-TSIG DNS servers T} _ T{ ip\-address T} T{ server T} T{ IPv4 / IPv6 address T} T{ empty T} T{ the IP address at which the GSS\-TSIG DNS server listens for DDNS and TKEY requests (required) T} _ T{ port T} T{ server T} T{ uint16 T} T{ 53 T} T{ the DNS transport port at which the GSS\-TSIG DNS server listens for DDNS and TKEY requests T} .TE .sp The global parameters are described below: .INDENT 0.0 .IP \(bu 2 \fBclient\-keytab\fP specifies the Kerberos \fBclient\fP key table. For instance, \fBFILE:\fP can be used to point to a specific file. This parameter can be specified only once, in the parameters scope, and is the equivalent of setting the \fBKRB5_CLIENT_KTNAME\fP environment variable. An empty value is silently ignored. .IP \(bu 2 \fBcredentials\-cache\fP specifies the Kerberos credentials cache. For instance, \fBFILE:\fP can be used to point to a file or, if using a directory which supports more than one principal, \fBDIR:\fP\&. This parameter can be specified only once, in the parameters scope, and is the equivalent of setting the \fBKRB5CCNAME\fP environment variable. An empty value is silently ignored. .IP \(bu 2 \fBserver\-principal\fP is the Kerberos principal name of the DNS server that receives updates. In other words, this is the DNS server\(aqs name in the Kerberos system. This parameter is mandatory, and uses the typical Kerberos notation: \fB/@\fP\&. .IP \(bu 2 \fBclient\-principal\fP is the Kerberos principal name of the Kea D2 service. It is optional, and uses the typical Kerberos notation: \fB/@\fP\&. .IP \(bu 2 \fBgss\-replay\-flag\fP determines if the GSS anti replay service is required. It is by default but this can be disabled. .IP \(bu 2 \fBgss\-sequence\-flag\fP determines if the GSS sequence service is required. It is not by default but is required by the standard so it can be enabled. .IP \(bu 2 \fBtkey\-protocol\fP determines which protocol is used to establish the security context with the DNS servers. Currently, the only supported values are TCP (the default) and UDP. .IP \(bu 2 \fBtkey\-lifetime\fP determines the lifetime of GSS\-TSIG keys in the TKEY protocol. The value must be greater than the \fBrekey\-interval\fP value. It is expressed in seconds and defaults to 3600 (one hour). .IP \(bu 2 \fBrekey\-interval\fP governs the time interval at which the keys for each configured server are checked for rekeying, i.e. when a new key is created to replace the current usable one if its age is greater than the \fBrekey\-interval\fP value. The value must be smaller than the \fBtkey\-lifetime\fP value (it is recommended to be set between 50% and 80% of the \fBtkey\-lifetime\fP value). It is expressed in seconds and defaults to 2700 (45 minutes, or 75% of one hour). .IP \(bu 2 \fBretry\-interval\fP governs the time interval at which to retry to create a key if any error occurred previously for any configured server. The value must be smaller than the \fBrekey\-interval\fP value, and should be at most 1/3 of the difference between \fBtkey\-lifetime\fP and \fBrekey\-interval\fP\&. It is expressed in seconds and defaults to 120 (2 minutes). .IP \(bu 2 \fBfallback\fP governs the behavior when GSS\-TSIG should be used (a matching DNS server is configured) but no GSS\-TSIG key is available. If set to \fBfalse\fP (the default), this server is skipped; if set to \fBtrue\fP, the DNS server is ignored and the DNS update is sent with the configured DHCP\-DDNS protection (e.g. TSIG key), or without any protection when none was configured. .IP \(bu 2 \fBexchange\-timeout\fP governs the amount of time to wait for the GSS\-TSIG TKEY exchange to finish before the process times out. It is expressed in milliseconds and defaults to 3000 (3 seconds). .IP \(bu 2 \fBuser\-context\fP is an optional parameter (see \fI\%Comments and User Context\fP for a general description of user contexts in Kea). .IP \(bu 2 \fBcomment\fP is allowed but currently ignored. .IP \(bu 2 \fBservers\fP specifies the list of DNS servers where GSS\-TSIG is enabled. .UNINDENT .sp The server map parameters are described below: .INDENT 0.0 .IP \(bu 2 \fBid\fP assigns an identifier to a DNS server. It is used for statistics and commands. It is required, and must be both not empty and unique. .IP \(bu 2 \fBdomain\-names\fP governs the many\-to\-one relationship between D2 DNS servers and GSS\-TSIG DNS servers: for each domain name on this list, Kea looks for a D2 DNS server for this domain with the specified IP address and port. An empty list (the default) means that all domains match. .IP \(bu 2 \fBip\-address\fP specifies the IP address at which the GSS\-TSIG DNS server listens for DDNS and TKEY requests. It is a mandatory parameter. .IP \(bu 2 \fBport\fP specifies the DNS transport port on which the GSS\-TSIG DNS server listens for DDNS and TKEY requests. It defaults to 53. .IP \(bu 2 \fBserver\-principal\fP is the Kerberos principal name of the DNS server that receives updates. The \fBserver\-principal\fP parameter set at the per\-server level takes precedence over one set at the global level. It is a mandatory parameter which must be specified at either the global or the server level. .IP \(bu 2 \fBclient\-principal\fP is the Kerberos principal name of the Kea D2 service for this DNS server. The \fBclient\-principal\fP parameter set at the per\-server level takes precedence over one set at the global level. It is an optional parameter. .IP \(bu 2 \fBgss\-replay\-flag\fP determines if the GSS anti replay service is required. The \fBgss\-replay\-flag\fP parameter set at the per\-server level takes precedence over one set at the global level. It is an optional parameter which defaults to true. .IP \(bu 2 \fBgss\-sequence\-flag\fP determines if the GSS sequence service is required. The \fBgss\-sequence\-flag\fP parameter set at the per\-server level takes precedence over one set at the global level. It is an optional parameter which defaults to false. .IP \(bu 2 \fBtkey\-protocol\fP determines which protocol is used to establish the security context with the DNS server. The \fBtkey\-protocol\fP parameter set at the per\-server level takes precedence over one set at the global level. The default and supported values for the per\-server level parameter are the same as for the global\-level parameter. .IP \(bu 2 \fBtkey\-lifetime\fP determines the lifetime of GSS\-TSIG keys in the TKEY protocol for the DNS server. The \fBtkey\-lifetime\fP parameter set at the per\-server level takes precedence over one set at the global level. The default and supported values for the per\-server level parameter are the same as for the global\-level parameter. .IP \(bu 2 \fBrekey\-interval\fP governs the time interval at which the keys for this particular server are checked for rekeying, i.e. when a new key is created to replace the current usable one if its age is greater than the \fBrekey\-interval\fP value. The value must be smaller than the \fBtkey\-lifetime\fP value (it is recommended to be set between 50% and 80% of the \fBtkey\-lifetime\fP value). The \fBrekey\-interval\fP parameter set at the per\-server level takes precedence over one set at the global level. The default and supported values for the per\-server level parameter are the same as for the global\-level parameter. .IP \(bu 2 \fBretry\-interval\fP governs the time interval at which to retry to create a key if any error occurred previously for this particular server. The value must be smaller than the \fBrekey\-interval\fP value, and should be at most 1/3 of the difference between \fBtkey\-lifetime\fP and \fBrekey\-interval\fP\&. The \fBretry\-interval\fP parameter set at the per\-server level takes precedence over one set at the global level. The default and supported values for the per\-server level parameter are the same as for the global\-level parameter. .IP \(bu 2 \fBfallback\fP governs the behavior when GSS\-TSIG should be used (a matching DNS server is configured) but no GSS\-TSIG key is available. The \fBfallback\fP parameter set at the per\-server level takes precedence over one set at the global level. The default and supported values for the per\-server level parameter are the same as for the global\-level parameter.. .IP \(bu 2 \fBexchange\-timeout\fP governs the amount of time to wait for the GSS\-TSIG TKEY exchange to finish before the process times out. The \fBexchange\-timeout\fP parameter set at the per\-server level takes precedence over one set at the global level. The default and supported values for the per\-server level parameter are the same as for the global\-level parameter. .IP \(bu 2 \fBuser\-context\fP is an optional parameter (see \fI\%Comments and User Context\fP for a general description of user contexts in Kea). .IP \(bu 2 \fBcomment\fP is allowed but currently ignored. .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Generally it is not recommended to specify both the client keytab (\fBclient\-keytab\fP) and the credentials cache (\fBcredentials\-cache\fP), although this may differ between Kerberos implementations. The client keytab is just for the client key and is typically used to specify the key explicitly in more static manner, while the credentials cache can be used to store multiple credentials and can be dynamically updated by the Kerberos library. As such, the credentials\-cache is more flexible and thus the recommended alternative. .sp Also note that only the read access right is needed to use the cache. Fetching credentials and updating the cache requires the write access right. .UNINDENT .UNINDENT .SS GSS\-TSIG Automatic Key Removal .sp The server periodically deletes keys after they have been expired more than three times the length of the maximum key lifetime (the \fBtkey\-lifetime\fP parameter). The user has the option to purge keys on demand by using the \fI\%gss\-tsig\-purge\-all\fP command or the \fI\%gss\-tsig\-purge\fP command. .SS GSS\-TSIG Configuration for Deployment .sp When using Kerberos 5 and BIND 9 as described in \fI\%GSS\-TSIG Deployment\fP, the local resolver must point to the BIND 9 \fBnamed\fP server address. The local Kerberos must also be configured by putting the following text into the \fBkrb5.conf\fP file: .INDENT 0.0 .INDENT 3.5 .sp .EX [libdefaults] default_realm = EXAMPLE.ORG kdc_timesync = 1 ccache_type = 4 forwardable = true proxiable = true [realms] EXAMPLE.ORG = { kdc = kdc.example.org admin_server = kdc.example.org } .EE .UNINDENT .UNINDENT .sp With Windows AD, the DNS service is provided by AD, which also provides the Kerberos service. The required text in the \fBkrb5.conf\fP file becomes: .INDENT 0.0 .INDENT 3.5 .sp .EX [libdefaults] default_realm = kdc_timesync = 1 ccache_type = 4 forwardable = true proxiable = true [realms] ${REALM} = { kdc = admin_server = } .EE .UNINDENT .UNINDENT .sp Even when the GSS\-API library can use the secret from the client key table, it is far better for performance to get and cache credentials. .sp This can be done manually via the command: .INDENT 0.0 .INDENT 3.5 .sp .EX kinit \-k \-t /usr/local/share/kea/dhcp.keytab DHCP/admin.example.org .EE .UNINDENT .UNINDENT .sp or, when using AD: .INDENT 0.0 .INDENT 3.5 .sp .EX kinit \-k \-t /usr/local/share/kea/dhcp.keytab DHCP/kea. .EE .UNINDENT .UNINDENT .sp The credential cache can be displayed using \fBklist\fP\&. .sp In production, it is better to rely on a Kerberos Credential Manager as the System Security Services Daemon (\fBsssd\fP). .sp When using BIND 9, the server principal is in the form \(dq\X'tty: link mailto:DNS/server.example.org@EXAMPLE'\fI\%DNS/server.example.org@EXAMPLE\fP\X'tty: link'\&.ORG¨; with AD, the format is \(dqDNS/.@\(dq. .SS GSS\-TSIG Statistics .sp The GSS\-TSIG hook library introduces new statistics at global and per\-DNS\-server levels: .INDENT 0.0 .IP \(bu 2 \fBgss\-tsig\-key\-created\fP \- the number of created GSS\-TSIG keys .IP \(bu 2 \fBtkey\-sent\fP \- the number of sent TKEY exchange initial requests .IP \(bu 2 \fBtkey\-success\fP \- the number of TKEY exchanges which completed with a success .IP \(bu 2 \fBtkey\-timeout\fP \- the number of TKEY exchanges which completed on timeout .IP \(bu 2 \fBtkey\-error\fP \- the number of TKEY exchanges which completed with an error other than a timeout .UNINDENT .sp The relationship between keys and DNS servers is very different between the D2 code and static TSIG keys, and GSS\-TSIG keys and DNS servers: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 a static TSIG key can be shared between many DNS servers; .IP \(bu 2 a GSS\-TSIG key is only used by one DNS server inside a dedicated set of keys. .UNINDENT .UNINDENT .UNINDENT .SS GSS\-TSIG Commands .sp The GSS\-TSIG hook library supports some commands, which are described below. .SS The \fBgss\-tsig\-get\-all\fP Command .sp This command lists all the GSS\-TSIG servers and keys. .sp An example command invocation looks like this: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqgss\-tsig\-get\-all\(dq } .EE .UNINDENT .UNINDENT .sp Here is an example of a response returning one GSS\-TSIG server and one key: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dq1 GSS\-TSIG servers and 1 keys\(dq, \(dqarguments\(dq: { \(dqgss\-tsig\-servers\(dq: [ { \(dqid\(dq: \(dqfoo\(dq, \(dqip\-address\(dq: \(dq192.1.2.3\(dq, \(dqport\(dq: 53, \(dqserver\-principal\(dq: \(dqDNS/foo.com@FOO.COM\(dq, \(dqkey\-name\-suffix\(dq: \(dqfoo.com.\(dq, \(dqtkey\-lifetime\(dq: 3600, \(dqtkey\-protocol\(dq: \(dqTCP\(dq, \(dqkeys\(dq: [ { \(dqname\(dq: \(dq1234.sig\-foo.com.\(dq, \(dqinception\-date\(dq: \(dq2021\-09\-05 12:23:36.281176\(dq, \(dqserver\-id\(dq: \(dqfoo\(dq, \(dqexpire\-date\(dq: \(dq2021\-09\-05 13:23:36.281176\(dq, \(dqstatus\(dq: \(dqnot yet ready\(dq, \(dqtkey\-exchange\(dq: true } ] }, { \(dqid\(dq: \(dqbar\(dq, \(dqip\-address\(dq: \(dq192.1.2.4\(dq, \(dqport\(dq: 53, \(dqserver\-principal\(dq: \(dqDNS/bar.com@FOO.COM\(dq, \(dqkey\-name\-suffix\(dq: \(dqbar.com.\(dq, \(dqtkey\-lifetime\(dq: 7200, \(dqtkey\-protocol\(dq: \(dqUDP\(dq, \(dqkeys\(dq: [ ] } ] } } .EE .UNINDENT .UNINDENT .SS The \fBgss\-tsig\-get\fP Command .sp This command retrieves information about the specified GSS\-TSIG server. .sp An example command invocation looks like this: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqgss\-tsig\-get\(dq, \(dqarguments\(dq: { \(dqserver\-id\(dq: \(dqfoo\(dq } } .EE .UNINDENT .UNINDENT .sp Here is an example of a response returning information about the server \(dqfoo\(dq: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dqGSS\-TSIG server[foo] found\(dq, \(dqarguments\(dq: { \(dqid\(dq: \(dqfoo\(dq, \(dqip\-address\(dq: \(dq192.1.2.3\(dq, \(dqport\(dq: 53, \(dqserver\-principal\(dq: \(dqDNS/foo.com@FOO.COM\(dq, \(dqkey\-name\-suffix\(dq: \(dqfoo.com.\(dq, \(dqtkey\-lifetime\(dq: 3600, \(dqtkey\-protocol\(dq: \(dqTCP\(dq, \(dqkeys\(dq: [ { \(dqname\(dq: \(dq1234.sig\-foo.com.\(dq, \(dqserver\-id\(dq: \(dqfoo\(dq, \(dqinception\-date\(dq: \(dq2021\-09\-05 12:23:36.281176\(dq, \(dqexpire\-date\(dq: \(dq2021\-09\-05 13:23:36.281176\(dq, \(dqstatus\(dq: \(dqnot yet ready\(dq, \(dqtkey\-exchange\(dq: true } ] } } .EE .UNINDENT .UNINDENT .SS The \fBgss\-tsig\-list\fP Command .sp This command generates a list of GSS\-TSIG server IDs and key names. .sp An example command invocation looks like this: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqgss\-tsig\-list\(dq } .EE .UNINDENT .UNINDENT .sp Here is an example of a response returning two GSS\-TSIG servers and three keys: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dq2 GSS\-TSIG servers and 3 keys\(dq, \(dqarguments\(dq: { \(dqgss\-tsig\-servers\(dq: [ \(dqfoo\(dq, \(dqbar\(dq ], \(dqgss\-tsig\-keys\(dq: [ \(dq1234.example.com.\(dq, \(dq5678.example.com.\(dq, \(dq43888.example.org.\(dq ] } } .EE .UNINDENT .UNINDENT .SS The \fBgss\-tsig\-key\-get\fP Command .sp This command retrieves information about the specified GSS\-TSIG key. .sp An example command invocation looks like this: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqgss\-tsig\-key\-get\(dq, \(dqarguments\(dq: { \(dqkey\-name\(dq: \(dq1234.sig\-foo.com.\(dq } } .EE .UNINDENT .UNINDENT .sp Here is an example of a response returning information about GSS\-TSIG key \(dq1234.sig\-foo.com.\(dq: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dqGSS\-TSIG key \(aq1234.sig\-foo.com.\(aq found\(dq, \(dqarguments\(dq: { \(dqname\(dq: \(dq1234.sig\-foo.com.\(dq, \(dqserver\-id\(dq: \(dqfoo\(dq, \(dqinception\-date\(dq: \(dq2021\-09\-05 12:23:36.281176\(dq, \(dqexpire\-date\(dq: \(dq2021\-09\-05 13:23:36.281176\(dq, \(dqstatus\(dq: \(dqnot yet ready\(dq, \(dqtkey\-exchange\(dq: true } } .EE .UNINDENT .UNINDENT .SS The \fBgss\-tsig\-key\-expire\fP Command .sp This command expires the specified GSS\-TSIG key. .sp An example command invocation looks like this: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqgss\-tsig\-key\-expire\(dq, \(dqarguments\(dq: { \(dqkey\-name\(dq: \(dq1234.sig\-foo.com.\(dq } } .EE .UNINDENT .UNINDENT .sp Here is an example of a response indicating that GSS\-TSIG key \(dq1234.sig\-foo.com.\(dq has been expired: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dqGSS\-TSIG key \(aq1234.sig\-foo.com.\(aq expired\(dq } .EE .UNINDENT .UNINDENT .SS The \fBgss\-tsig\-key\-del\fP Command .sp This command deletes the specified GSS\-TSIG key. .sp An example command invocation looks like this: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqgss\-tsig\-key\-del\(dq, \(dqarguments\(dq: { \(dqkey\-name\(dq: \(dq1234.sig\-foo.com.\(dq } } .EE .UNINDENT .UNINDENT .sp Here is an example of a response indicating that GSS\-TSIG key \(dq1234.sig\-foo.com.\(dq has been deleted: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dqGSS\-TSIG key \(aq1234.sig\-foo.com.\(aq deleted\(dq } .EE .UNINDENT .UNINDENT .SS The \fBgss\-tsig\-purge\-all\fP Command .sp This command removes all unusable GSS\-TSIG keys. .sp An example command invocation looks like this: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqgss\-tsig\-purge\-all\(dq } .EE .UNINDENT .UNINDENT .sp Here is an example of a response indicating that two GSS\-TSIG keys have been purged: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dq2 purged GSS\-TSIG keys\(dq } .EE .UNINDENT .UNINDENT .SS The \fBgss\-tsig\-purge\fP Command .sp This command removes unusable GSS\-TSIG keys for the specified server. .sp An example command invocation looks like this: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqgss\-tsig\-purge\(dq, \(dqarguments\(dq: { \(dqserver\-id\(dq: \(dqfoo\(dq } } .EE .UNINDENT .UNINDENT .sp Here is an example of a response indicating that two GSS\-TSIG keys for server \(dqfoo\(dq have been purged: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dq2 purged keys for GSS\-TSIG server[foo]\(dq } .EE .UNINDENT .UNINDENT .SS The \fBgss\-tsig\-rekey\-all\fP Command .sp This command unconditionally creates new GSS\-TSIG keys (rekeys) for all DNS servers. .sp An example command invocation looks like this: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqgss\-tsig\-rekey\-all\(dq } .EE .UNINDENT .UNINDENT .sp Here is an example of a response indicating that a rekey was performed: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dqrekeyed\(dq } .EE .UNINDENT .UNINDENT .sp This command is useful when, for instance, the DHCP\-DDNS server is reconnected to the network. .SS The \fBgss\-tsig\-rekey\fP Command .sp This command unconditionally creates new GSS\-TSIG keys (rekeys) for a specified DNS server. .sp An example command invocation looks like this: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqgss\-tsig\-rekey\(dq, \(dqarguments\(dq: { \(dqserver\-id\(dq: \(dqfoo\(dq } } .EE .UNINDENT .UNINDENT .sp Here is an example of a response indicating that a rekey was performed: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dqGSS\-TSIG server[foo] rekeyed\(dq } .EE .UNINDENT .UNINDENT .sp This command is typically used when a DNS server has been rebooted, so that existing GSS\-TSIG keys shared with this server can no longer be used. .SS RADIUS .SS RADIUS Overview .sp This hook library allows Kea to interact with two types of RADIUS services: access and accounting. The most common DHCP and RADIUS integration is done on the DHCP relay\-agent level: DHCP clients send DHCP packets to DHCP relays; those relays contact the RADIUS server and either send the packet to the DHCP server or drop it, depending on the response. It does require DHCP relay hardware to support RADIUS communication, though, and even if the relay has the necessary support, it is often not flexible enough to send and receive additional RADIUS attributes. There is a more appealing alternative: to extend the DHCP server to talk to RADIUS directly. That is the goal of this library. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 This library can only be loaded by the \fI\%kea\-dhcp4\fP or the \fI\%kea\-dhcp6\fP process. .UNINDENT .UNINDENT .sp The major feature of this hook library is the ability to use RADIUS authorization. When a DHCP packet is received, the Kea server sends an Access\-Request to the RADIUS server and waits for a response. The server then sends back either an Access\-Accept with specific client attributes, or an Access\-Reject. There are two cases supported here: first, the Access\-Accept includes a Framed\-IP\-Address attribute (for DHCPv4) or a Framed\-IPv6\-Address attribute/Delegated\-IPv6\-Prefix (for DHCPv6), which are interpreted by Kea as instructions to assign the specified IPv4 or IPv6 address/IPv6 prefix. This effectively means RADIUS can act as an address\-reservation database. .sp The second supported case is the ability to assign clients to specific pools based on a RADIUS response. In this case, the RADIUS server sends back an Access\-Accept with a Framed\-Pool attribute. For both DHCPv4 and DHCPv6, Kea interprets this attribute as a client class. With the addition of the ability to limit access to pools to specific classes (see \fI\%Configuring Pools With Class Information\fP), RADIUS can be used to force the client to be assigned a dynamic address or prefix from a specific pool. Furthermore, the same mechanism can be used to control what kind of options the client gets if there are DHCP options specified for a particular class. .SS RADIUS Hook Library Configuration .sp The RADIUS hook is a library that must be loaded by either \fI\%kea\-dhcp4\fP or \fI\%kea\-dhcp6\fP servers. Unlike some other available hook libraries, this one takes many parameters. For example, this configuration can be used: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqDhcp4\(dq: { // Your regular DHCPv4 configuration parameters go here. \(dqhooks\-libraries\(dq: [ { // Note that the RADIUS access service requires host\-cache for // proper operation, so this library is loaded as well. \(dqlibrary\(dq: \(dq/usr/local/lib/kea/hooks/libdhcp_host_cache.so\(dq }, { \(dqlibrary\(dq: \(dq/usr/local/lib/kea/hooks/libdhcp_radius.so\(dq, \(dqparameters\(dq: { // Specify where the dictionary is located. \(dqdictionary\(dq: \(dq/etc/kea/radius/dictionary\(dq, // Specify which address to use to communicate with RADIUS servers \(dqbindaddr\(dq: \(dq*\(dq // More RADIUS parameters go here. } } ] } } .EE .UNINDENT .UNINDENT .sp RADIUS is a complicated environment. As such, it is not feasible to provide a default configuration that works for everyone. However, we do have an example that showcases some of the more common features; please see \fBdoc/examples/kea4/hooks\-radius.json\fP in the Kea sources. .sp The RADIUS hook library supports the following global configuration flags: .INDENT 0.0 .IP \(bu 2 \fBbindaddr\fP (default \fB\(dq*\(dq\fP) \- specifies the address to be used by the hook library in communication with the RADIUS servers. The \fB\(dq*\(dq\fP special value tells the kernel to choose the address at hook library load time. .IP \(bu 2 \fBcanonical\-mac\-address\fP (default \fBfalse\fP) \- specifies whether MAC addresses in attributes follow the canonical RADIUS format (lowercase pairs of hexadecimal digits separated by \fB\-\fP). .IP \(bu 2 \fBclient\-id\-pop0\fP (default \fBfalse\fP) \- is used with \fI\%libdhcp_flex_id.so\fP; it removes the leading zero (or pair of zeroes in DHCPv6) type in the client ID (DUID in DHCPv6). See \fBclient\-id\-printable\fP for any value implications when used in conjunction with it. .IP \(bu 2 \fBclient\-id\-printable\fP (default \fBfalse\fP) \- checks whether the \fBclient\-id\fP/\fBduid\fP content is printable and uses it as is instead of in hexadecimal. It implies that \fBclient\-id\-pop0\fP and \fBextract\-duid\fP as 0 and 255 are not printable. .IP \(bu 2 \fBdeadtime\fP (default \fB0\fP) \- is a mechanism that helps in sorting the servers so those that have proved responsive so far are contacted first, and the servers that have proved unresponsive are left to try later. The deadtime value specifies the number of seconds after which a server is considered unresponsive. 0 disables the mechanism. .IP \(bu 2 \fBdictionary\fP (default \fB\(dq/etc/kea/radius/dictionary\(dq\fP) \- is the attribute and value dictionary; note that it is a critical parameter. A dictionary is provided by Kea and is set by default. .IP \(bu 2 \fBextract\-duid\fP (default \fBtrue\fP) \- extracts the embedded DUID from an RFC 4361\-compliant DHCPv4 client ID. See \fBclient\-id\-printable\fP for any value implications when used in conjunction with it. .IP \(bu 2 \fBidentifier\-type4\fP (default \fB\(dqclient\-id\(dq\fP) \- specifies the identifier type to build the User\-Name attribute for DHCPv4; it should be the same as the host identifier. When \fI\%libdhcp_flex_id.so\fP is used, then \fBreplace\-client\-id\fP must be set to \fBtrue\fP and \fBclient\-id\fP must be used with \fBclient\-id\-pop0\fP enabled. .IP \(bu 2 \fBidentifier\-type6\fP (default \fB\(dqduid\(dq\fP) \- specifies the identifier type to build the User\-Name attribute for DHCPv6; it should be the same as the host identifier. When \fI\%libdhcp_flex_id.so\fP is used, then \fBreplace\-client\-id\fP must be set to \fBtrue\fP and \fBduid\fP must be used with \fBclient\-id\-pop0\fP enabled. .IP \(bu 2 \fBnas\-ports\fP (default \fB[]\fP), specifies the NAS port to use in place of a subnet ID (default behavior). It is an array of maps, each map having two elements at most: the mandatory NAS port value, and optionally, a selector consisting of either a subnet ID, a subnet prefix, or a shared\-network name. If the selector is applied to the packet, the NAS port is used instead of the subnet ID. When the subnet ID is 0 or missing, the specified NAS port acts as a default. The substitution happens for all packets that did not match a selector. .IP \(bu 2 \fBrealm\fP (default \fB\(dq\(dq\fP) \- is the default realm. .IP \(bu 2 \fBreselect\-subnet\-address\fP (default \fBfalse\fP) \- enables subnet reselection according to the value of the Framed\-IP\-Address or, respectively, the Framed\-IPv6\-Address attribute from the RADIUS access response. With this flag enabled, if the IP address is not in the range of the currently selected subnet, but is in the range of another subnet that is selectable with regards to other criteria, the latter subnet is selected and used further in the lease assignment process. .IP \(bu 2 \fBreselect\-subnet\-pool\fP (default \fBfalse\fP) \- enables subnet reselection according to the value of the Framed\-Pool attribute from the RADIUS access response. With this flag enabled, if the currently selected subnet is not guarded by the client class represented by the attribute value, but there is another selectable subnet that is guarded by it, the latter subnet is selected and used further in the lease assignment process. This reselection is attempted first, and if successful, it prevents the function of \fBreselect\-subnet\-address\fP from coming into effect. .IP \(bu 2 \fBretries\fP (default \fB3\fP) \- is the number of retries before trying the next server. .IP \(bu 2 \fBsession\-history\fP (default \fB\(dq\(dq\fP) \- is the name of the file providing persistent storage for accounting session history. .UNINDENT .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fBthread\-pool\-size\fP (default \fB0\fP) indicates the number of threads that are used for sending RADIUS requests and processing RADIUS responses for both access and accounting services before passing them to the core thread pool. A value of \fB0\fP instructs the RADIUS hook library to use the same number of threads used for core DHCP processing. This value is only relevant if the Kea core is configured as multi\-threaded; a single\-threaded Kea core results in single\-threaded RADIUS processing. .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .IP \(bu 2 \fBtimeout\fP (default \fB10\fP) \- is the number of seconds during which a response is awaited. .UNINDENT .sp Two services are supported: .INDENT 0.0 .IP \(bu 2 \fBaccess\fP \- the authorization service. .IP \(bu 2 \fBaccounting\fP \- the accounting service. .UNINDENT .sp At the service level, three sections can be configured: .INDENT 0.0 .IP \(bu 2 Servers that define RADIUS services that the library is expected to contact. Each server may have the following items specified: .INDENT 2.0 .IP \(bu 2 \fBname\fP \- specifies the IP address of the server. A domain name may be used and will be resolved at hook library load time. .IP \(bu 2 \fBport\fP \- specifies the UDP port of the server. By default, it is 1812 for access and 1813 for accounting. .IP \(bu 2 \fBsecret\fP \- authenticates messages. .UNINDENT .sp When no server is specified, the service is disabled. .IP \(bu 2 Attributes which define additional information that the Kea server sends to a RADIUS server. The parameter must be identified either by a name or type. Its value can be specified in one of three possible ways: \fBdata\fP (which defines a plain text value), \fBraw\fP (which defines the value in hex), or \fBexpr\fP (which defines an expression that is evaluated for each incoming packet independently). .INDENT 2.0 .IP \(bu 2 \fBname\fP \- is the name of the attribute. .IP \(bu 2 \fBtype\fP \- is the type of the attribute. Either the type or the name must be provided, and the attribute must be defined in the dictionary. .IP \(bu 2 \fBdata\fP \- is the first of three ways to specify the attribute content. It specifies the textual representation of the attribute content. .IP \(bu 2 \fBraw\fP \- is the second of three ways to specify the attribute content. It specifies the content in hexadecimal. .IP \(bu 2 \fBexpr\fP \- is the last of the three ways to specify the attribute content. It specifies an evaluation expression on the DHCP query packet. .UNINDENT .INDENT 2.0 .INDENT 3.5 Attributes are supported only for the access service. .UNINDENT .UNINDENT .IP \(bu 2 The \fBpeer\-updates\fP boolean flag (default \fBtrue\fP) controls whether lease updates coming from an active High\-Availability (HA) partner should result in an accounting request. This may be desirable to remove duplicates if HA partners are configured to send requests to the same RADIUS server. The flag is only supported by the accounting service. The lease synchronization process at the startup of an HA node does not trigger a RADIUS accounting request, regardless of the value of this flag. .IP \(bu 2 The \fBmax\-pending\-requests\fP positive integer (default \fB0\fP) limits the number of pending RADIUS requests. It is supported only by the access service. The value \fB0\fP means no limit; \fB64\fP is a recommended setting. .UNINDENT .sp For example, to specify a single access server available on localhost that uses \fB\(dq1234\(dq\fP as a secret, and tell Kea to send three additional attributes (\fBUser\-Password\fP, \fBConnect\-Info\fP, and \fBConfiguration\-Token\fP), the following snippet could be used: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqparameters\(dq: { // Other RADIUS parameters here \(dqaccess\(dq: { // This starts the list of access servers. \(dqservers\(dq: [ { // These are parameters for the first (and only) access server \(dqname\(dq: \(dq127.0.0.1\(dq, \(dqport\(dq: 1812, \(dqsecret\(dq: \(dq1234\(dq } // Additional access servers could be specified here. ], // This defines a list of additional attributes Kea will send to each // access server in Access\-Request. \(dqattributes\(dq: [ { // This attribute is identified by name (must be present in the // dictionary) and has static value (i.e. the same value will be // sent to every server for every packet). \(dqname\(dq: \(dqUser\-Password\(dq, \(dqdata\(dq: \(dqmysecretpassword\(dq }, { // It is also possible to specify an attribute using its type, // rather than a name. 77 is Connect\-Info. The value is specified // using hex. Again, this is a static value. It will be sent the // same for every packet and to every server. \(dqtype\(dq: 77, \(dqraw\(dq: \(dq65666a6a71\(dq }, { // This example shows how an expression can be used to send dynamic value. // The expression (see \fI\%Using Expressions in Classification\fP) may take any // value from the incoming packet or even its metadata e.g. the // interface it was received over from. \(dqname\(dq: \(dqConfiguration\-Token\(dq, \(dqexpr\(dq: \(dqhexstring(pkt4.mac,\(aq:\(aq)\(dq } ] // End of attributes }, // End of access // Accounting parameters. \(dqaccounting\(dq: { // This starts the list of accounting servers. \(dqservers\(dq: [ { // These are parameters for the first (and only) accounting server \(dqname\(dq: \(dq127.0.0.1\(dq, \(dqport\(dq: 1813, \(dqsecret\(dq: \(dq1234\(dq } // Additional accounting servers could be specified here. ] } } } .EE .UNINDENT .UNINDENT .sp Customization is sometimes required for certain attributes by devices belonging to various vendors. This is a great way to leverage the expression evaluation mechanism. For example, MAC addresses which might be used as a convenience value for the \fBUser\-Password\fP attribute are most likely to appear in colon\-hexadecimal notation (\fBde:ad:be:ef:ca:fe\fP), but they might need to be expressed in hyphen\-hexadecimal notation (\fBde\-ad\-be\-ef\-ca\-fe\fP). Here\(aqs how to specify that: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqparameters\(dq: { \(dqaccess\(dq: { \(dqattributes\(dq: [ { \(dqname\(dq: \(dqUser\-Password\(dq, \(dqexpr\(dq: \(dqhexstring(pkt4.mac, \(aq\-\(aq)\(dq } ] } } } .EE .UNINDENT .UNINDENT .sp And here\(aqs how to specify period\-separated hexadecimal notation (\fBdead.beef.cafe\fP), preferred by Cisco devices: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqparameters\(dq: { \(dqaccess\(dq: { \(dqattributes\(dq: [ { \(dqname\(dq: \(dqUser\-Password\(dq, \(dqexpr\(dq: \(dqsubstring(hexstring(pkt4.mac, \(aq\(aq), 0, 4) + \(aq.\(aq + substring(hexstring(pkt4.mac, \(aq\(aq), 4, 4) + \(aq.\(aq + substring(hexstring(pkt4.mac, \(aq\(aq), 8, 4)\(dq } ] } } } .EE .UNINDENT .UNINDENT .sp For the access service of \fI\%libdhcp_radius.so\fP to operate properly, \fI\%libdhcp_host_cache.so\fP must also be loaded. The reason for this is somewhat complex. In a typical deployment, DHCP clients send their packets via DHCP relay, which inserts certain Relay Agent Information options, such as \fBcircuit\-id\fP or \fBremote\-id\fP\&. The values of those options are then used by the Kea DHCP server to formulate the necessary attributes in the Access\-Request message sent to the RADIUS server. However, once the DHCP client gets its address, it then renews by sending packets directly to the DHCP server. The relays cannot insert their RAI options at that point, and the DHCP server cannot send the Access\-Request queries to the RADIUS server by using just the information from incoming packets. Kea needs to keep the information received during the initial Discover/Offer exchanges and use it again later when sending accounting messages. .sp This mechanism is implemented based on user context in host reservations. (See \fI\%Comments and User Context\fP and \fI\%User Contexts in Hooks\fP for details.) The host\-cache mechanism allows the information retrieved by RADIUS to be stored and used later instead of doing another authorization round\-trip to the RADIUS server. In other words, the host\-cache mechanism is mandatory for the access service. The Kea configuration is rejected if \fI\%libdhcp_host_cache.so\fP is not loaded alongside \fI\%libdhcp_radius.so\fP\&. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Currently the RADIUS hook library is incompatible with the \fBearly\-global\-reservations\-lookup\fP global parameter, i.e. setting the parameter to \fBtrue\fP raises an error when the hook library is loaded. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Currently the RADIUS hook library is incompatible with the multi\-subnet shared networks that have host reservations other than global. Loading the RADIUS hook library in a Kea DHCP server that has this configuration raises an error. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Currently the \fBreselect\-subnet\-address\fP and \fBreselect\-subnet\-pool\fP parameters are incompatible with the hub\-and\-spoke configuration of the \fI\%libdhcp_ha.so\fP\&. This hook library uses an originally selected subnet for choosing an HA relationship to process a packet. The subnet reselection may interfere with this choice. See the \fI\%Hub and Spoke Configuration\fP for details. .UNINDENT .UNINDENT .SS RADIUS Server Setup Example .sp The RADIUS hook library requires at least one RADIUS server to function. One popular open source implementation is FreeRADIUS; here\(aqs how to set it up to enable basic functionality in Kea. .INDENT 0.0 .IP 1. 3 Install FreeRADIUS through the package manager or from the tarballs available on [the freeradius.org download page](\X'tty: link https://freeradius.org/releases/'\fI\%https://freeradius.org/releases/\fP\X'tty: link'). .IP 2. 3 Establish the FreeRADIUS configuration directory. It\(aqs commonly \fB/etc/freeradius\fP, but it may be \fB/etc/raddb\fP\&. .IP 3. 3 Generate certificates. Go to \fB/etc/freeradius/certs\fP\&. Run \fB\&./bootstrap\fP or \fBmake\fP\&. Wait until finished. It should take a few seconds. .IP 4. 3 Check that the server is able to start. Running with the \fB\-X\fP flag is a good way to display potential errors. Run \fBradiusd \-X\fP or \fBfreeradius \-X\fP, whichever is available. It should display \fBReady to process requests\fP on the final line. .IP 5. 3 If the Kea DHCP server and the RADIUS server are on different machines, edit \fB/etc/freeradius/clients.conf\fP with the proper address under \fBipadddr\fP\&. This file is also where the secret is set; it needs to match the one set in the hook library\(aqs configuration. .IP 6. 3 If RADIUS is used to authorize DHCP clients, each DHCP client needs to have an entry in the authorize file, which can be commonly found at: .INDENT 3.0 .IP \(bu 2 \fB/etc/raddb/mods\-config/files/authorize\fP .IP \(bu 2 \fB/etc/freeradius/3.0/mods\-config/files/authorize\fP .IP \(bu 2 \fB/etc/freeradius/users\fP (for RADIUS 2.x series) .UNINDENT .sp The passwords for entries must match the passwords in the configuration of the RADIUS hook library under the \fBUser\-Password\fP attribute. Each entry can have zero or more attributes. .sp In the following example, there are six entries with the password set to the client ID, which needs to be dynamically set in the hook library\(aqs configuration. Here\(aqs how the entries might look: .INDENT 3.0 .INDENT 3.5 .sp .EX 01:00:0c:01:02:03:04 Cleartext\-password := \(dq00:0c:01:02:03:04\(dq 01:00:0c:01:02:03:05 Cleartext\-password := \(dq00:0c:01:02:03:05\(dq Framed\-IP\-Address = \(dq192.0.2.5\(dq 01:00:0c:01:02:03:06 Cleartext\-password := \(dq00:0c:01:02:03:06\(dq Framed\-IP\-Address = \(dq192.0.2.6\(dq, Framed\-Pool = \(dqclassical\(dq 00:03:00:01:00:0c:01:02:03:07 Cleartext\-password := \(dq00:0c:01:02:03:07\(dq 00:03:00:01:00:0c:01:02:03:08 Cleartext\-password := \(dq00:0c:01:02:03:08\(dq Framed\-IPv6\-Address = \(dq2001:db8::8\(dq 00:03:00:01:00:0c:01:02:03:09 Cleartext\-password := \(dq00:0c:01:02:03:09\(dq Framed\-IPv6\-Address = \(dq2001:db8::9\(dq, Framed\-Pool = \(dqclassroom\(dq .EE .UNINDENT .UNINDENT .IP 7. 3 Accounting does not need to be modified to work with Kea, but customizations are possible in the accounting file, which can commonly be found at: .INDENT 3.0 .IP \(bu 2 \fB/etc/radius\-config/mods\-config/files/accounting\fP .IP \(bu 2 \fB/etc/freeradius/3.0/mods\-config/files/accounting\fP .UNINDENT .UNINDENT .SS RADIUS Workflows for Lease Allocation .sp The following diagrams show a high\-level view of how RADIUS assists with the lease allocation process in \fI\%kea\-dhcp4\fP and \fI\%kea\-dhcp6\fP\&. .INDENT 0.0 .INDENT 2.5 [image] .UNINDENT .UNINDENT .sp Somewhat tangential to lease allocation, and not shown in the diagrams above, is the \fBcommand_processed\fP callout, which sends Accounting\-Request messages when a lease command is received. .SS Parked\-Packet Limit .sp Refer to \fI\%Parked\-Packet Limit\fP for a basic introduction to packet parking. .sp The RADIUS hook library uses this mechanism. To allow for asynchronous communication between Kea and the RADIUS server and concurrent processing of DHCP packets by the Kea server, the DHCP request is parked, before the access request is sent on the subnet select callout. When the access response becomes available to the Kea DHCP server, the request is unparked, and the server continues processing it. .SS Differences Between RADIUS Hook Libraries Prior To Kea 2.4.0 and As Of 2.6.0 .sp The RADIUS hook library in 2.4.0 and prior versions relied on the FreeRADIUS client library to function. Starting with 2.6.0 and onward, the RADIUS hook library is standalone, with its own RADIUS client implementation and its own RADIUS dictionary. There are differences: .TS box center; l|l|l. T{ Feature T} T{ Old T} T{ New T} _ T{ Support for Attribute Data Types T} T{ string, ipaddr, ipv4prefix, integer, integer64, date, ifid, ipv6addr, ipv6prefix, tlv, abinary, byte, ether, short, signed, octets T} T{ string (can simulate any other unsupported data type too), ipaddr, integer, date (interpreted as integer), ipv6addr, ipv6prefix T} _ T{ Names of Standard Attributes T} T{ Taken from the FreeRADIUS dictionary. T} T{ Taken from the Kea RADIUS dictionary and the IANA registry. There is an aliasing mechanism built into the library that ensures backward compatibility, e.g. \fBPassword\fP translates to the standard name of the attribute \fBUser\-Password\fP\&. T} _ T{ Resolution of RADIUS Server Domain Names T} T{ At run time. T} T{ At hook library load time. T} _ T{ Automatic Deduction of Source Address for Reaching RADIUS Servers (configured with \fBbindaddr: \(dq*\(dq\fP) T} T{ At run time. T} T{ At hook library load time. T} _ T{ RADIUS Server Limit per Service T} T{ 8 T} T{ Unlimited T} _ T{ Support for Including Dictionaries Inside Dictionaries T} T{ Yes T} T{ No T} _ T{ Support for Vendor Attributes T} T{ Yes T} T{ No T} _ T{ Attribute Names and Attribute Values T} T{ Case\-insensitive T} T{ Case\-sensitive T} _ T{ Integer Values T} T{ Do not require an attribute definition. T} T{ Must have an associated attribute definition in the dictionary. T} _ T{ Reply\-Message Presence in the Kea Logs T} T{ Only as part of the aggregated list of attributes in \fBRADIUS_AUTHENTICATION_ACCEPTED\fP, \fBRADIUS_ACCESS_CACHE_INSERT\fP, \fBRADIUS_ACCESS_CACHE_GET\fP log messages. T} T{ Also has a dedicated \fBRADIUS_REPLY_MESSAGE_ATTRIBUTE\fP message per each Reply\-Message attribute logged after a valid RADIUS reply is received. T} _ T{ Behavior of Multiple Attributes of the Same Type (except Reply\-Message) T} T{ Experimentally, only the \fBfirst\fP attribute on the wire from an Access\-Accept message is considered. T} T{ Experimentally, only the \fBlast\fP attribute on the wire from an Access\-Accept message is considered. T} .TE .SH MONITORING KEA WITH STORK .sp Most administrators want to be able to monitor any Kea services that are running. Kea offers so many pieces of information \- configuration files, API, statistics, logs, open database content, and more \- that it may sometimes be overwhelming to keep up. ISC\(aqs Stork project is intended to address this problem for both Kea and BIND 9. Stork is useful in a variety of ways: .INDENT 0.0 .IP \(bu 2 Stork can be used as a dashboard. It provides insight into what exactly is happening on the servers. In particular, it allows users to: see up\-to\-date details regarding pool utilization in subnets and shared networks; monitor the state of the HA pair (and provide extra insight in case of failover and recovery events); list, filter, and search for specific host reservations; and more. Only a single Stork server needs to be deployed, and one Stork agent on each machine to be monitored. .IP \(bu 2 The Stork agent can integrate Kea with Prometheus and Grafana. Once the Stork agent is active on the server, it serves as a Prometheus exporter. Users who have deployed Prometheus in their networks can visualize statistics as time series using Grafana. .IP \(bu 2 Stork can act as both a dashboard and an integrator for Prometheus/Grafana. Once Stork is linked to where Grafana is deployed on the network, users can inspect the current status and visit a customized link to Grafana to see how a given property behaves over time. .UNINDENT .sp Stork is available as source code, but also as native deb and RPM packages, which makes it easy to install on most popular systems. For more details, please see the \X'tty: link https://stork.readthedocs.io'\fI\%Stork ARM\fP\X'tty: link' or the \X'tty: link https://gitlab.isc.org/isc-projects/stork'\fI\%Stork project page\fP\X'tty: link'\&. The ARM has a nice collection of screenshots that is frequently updated, to give users an idea of what is currently available. Stork is in the midst of full development with monthly releases, so please check back frequently. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Stork uses Kea API calls from the \fI\%libdhcp_host_cmds.so\fP and \fI\%libdhcp_subnet_cmds.so\fP hooks to make changes to Kea\(aqs configuration. Such usage is incompatible with the \fI\%Kea Configuration Backend\fP (CB). Stork does not currently implement support for the \fI\%libdhcp_cb_cmds.so\fP needed to make changes to CB configuration. If using the Kea CB, Stork can only be safely used in a \(dqread\-only\(dq fashion. Support for the CB is planned for a future release of Stork. .UNINDENT .UNINDENT .SS Kea Statistics in Grafana .sp The ISC Stork project provides an agent that can be deployed alongside Kea. It exposes Kea statistics in a format that is accepted by Prometheus. One of the major benefits of Prometheus is that it turns repeated one\-time observations into time series, which lets users monitor how certain behaviors change over time. It is easy to use other tools to visualize data available in Prometheus; the most common approach is to use Grafana to provide visual dashboards. The Stork project provides dashboard definitions for Kea that can be imported into Grafana very easily. .sp Learn more about Prometheus and Grafana on their websites: \fIPrometheus \fP and \fIGrafana \fP\&. .SH API REFERENCE .sp Kea currently supports 201 commands in \fI\%kea\-ctrl\-agent\fP, \fI\%kea\-dhcp\-ddns\fP, \fI\%kea\-dhcp4\fP, \fI\%kea\-dhcp6\fP daemons and \fI\%cb_cmds\fP, \fI\%class_cmds\fP, \fI\%gss_tsig\fP, \fI\%high_availability\fP, \fI\%host_cache\fP, \fI\%host_cmds\fP, \fI\%lease_cmds\fP, \fI\%lease_query\fP, \fI\%perfmon\fP, \fI\%stat_cmds\fP, \fI\%subnet_cmds\fP hook libraries. .sp Commands supported by \fIkea\-ctrl\-agent\fP daemon: \fI\%build\-report\fP, \fI\%config\-get\fP, \fI\%config\-hash\-get\fP, \fI\%config\-reload\fP, \fI\%config\-set\fP, \fI\%config\-test\fP, \fI\%config\-write\fP, \fI\%list\-commands\fP, \fI\%shutdown\fP, \fI\%status\-get\fP, \fI\%version\-get\fP\&. .sp Commands supported by \fIkea\-dhcp\-ddns\fP daemon: \fI\%build\-report\fP, \fI\%config\-get\fP, \fI\%config\-hash\-get\fP, \fI\%config\-reload\fP, \fI\%config\-set\fP, \fI\%config\-test\fP, \fI\%config\-write\fP, \fI\%gss\-tsig\-get\fP, \fI\%gss\-tsig\-get\-all\fP, \fI\%gss\-tsig\-key\-del\fP, \fI\%gss\-tsig\-key\-expire\fP, \fI\%gss\-tsig\-key\-get\fP, \fI\%gss\-tsig\-list\fP, \fI\%gss\-tsig\-purge\fP, \fI\%gss\-tsig\-purge\-all\fP, \fI\%gss\-tsig\-rekey\fP, \fI\%gss\-tsig\-rekey\-all\fP, \fI\%list\-commands\fP, \fI\%shutdown\fP, \fI\%statistic\-get\fP, \fI\%statistic\-get\-all\fP, \fI\%statistic\-reset\fP, \fI\%statistic\-reset\-all\fP, \fI\%status\-get\fP, \fI\%version\-get\fP\&. .sp Commands supported by \fIkea\-dhcp4\fP daemon: \fI\%build\-report\fP, \fI\%cache\-clear\fP, \fI\%cache\-flush\fP, \fI\%cache\-get\fP, \fI\%cache\-get\-by\-id\fP, \fI\%cache\-insert\fP, \fI\%cache\-load\fP, \fI\%cache\-remove\fP, \fI\%cache\-size\fP, \fI\%cache\-write\fP, \fI\%class\-add\fP, \fI\%class\-del\fP, \fI\%class\-get\fP, \fI\%class\-list\fP, \fI\%class\-update\fP, \fI\%config\-backend\-pull\fP, \fI\%config\-get\fP, \fI\%config\-hash\-get\fP, \fI\%config\-reload\fP, \fI\%config\-set\fP, \fI\%config\-test\fP, \fI\%config\-write\fP, \fI\%dhcp\-disable\fP, \fI\%dhcp\-enable\fP, \fI\%extended\-info4\-upgrade\fP, \fI\%ha\-continue\fP, \fI\%ha\-heartbeat\fP, \fI\%ha\-maintenance\-cancel\fP, \fI\%ha\-maintenance\-notify\fP, \fI\%ha\-maintenance\-start\fP, \fI\%ha\-reset\fP, \fI\%ha\-scopes\fP, \fI\%ha\-sync\fP, \fI\%ha\-sync\-complete\-notify\fP, \fI\%lease4\-add\fP, \fI\%lease4\-del\fP, \fI\%lease4\-get\fP, \fI\%lease4\-get\-all\fP, \fI\%lease4\-get\-by\-client\-id\fP, \fI\%lease4\-get\-by\-hostname\fP, \fI\%lease4\-get\-by\-hw\-address\fP, \fI\%lease4\-get\-page\fP, \fI\%lease4\-resend\-ddns\fP, \fI\%lease4\-update\fP, \fI\%lease4\-wipe\fP, \fI\%lease4\-write\fP, \fI\%leases\-reclaim\fP, \fI\%list\-commands\fP, \fI\%network4\-add\fP, \fI\%network4\-del\fP, \fI\%network4\-get\fP, \fI\%network4\-list\fP, \fI\%network4\-subnet\-add\fP, \fI\%network4\-subnet\-del\fP, \fI\%perfmon\-control\fP, \fI\%perfmon\-get\-all\-durations\fP, \fI\%remote\-class4\-del\fP, \fI\%remote\-class4\-get\fP, \fI\%remote\-class4\-get\-all\fP, \fI\%remote\-class4\-set\fP, \fI\%remote\-global\-parameter4\-del\fP, \fI\%remote\-global\-parameter4\-get\fP, \fI\%remote\-global\-parameter4\-get\-all\fP, \fI\%remote\-global\-parameter4\-set\fP, \fI\%remote\-network4\-del\fP, \fI\%remote\-network4\-get\fP, \fI\%remote\-network4\-list\fP, \fI\%remote\-network4\-set\fP, \fI\%remote\-option\-def4\-del\fP, \fI\%remote\-option\-def4\-get\fP, \fI\%remote\-option\-def4\-get\-all\fP, \fI\%remote\-option\-def4\-set\fP, \fI\%remote\-option4\-global\-del\fP, \fI\%remote\-option4\-global\-get\fP, \fI\%remote\-option4\-global\-get\-all\fP, \fI\%remote\-option4\-global\-set\fP, \fI\%remote\-option4\-network\-del\fP, \fI\%remote\-option4\-network\-set\fP, \fI\%remote\-option4\-pool\-del\fP, \fI\%remote\-option4\-pool\-set\fP, \fI\%remote\-option4\-subnet\-del\fP, \fI\%remote\-option4\-subnet\-set\fP, \fI\%remote\-server4\-del\fP, \fI\%remote\-server4\-get\fP, \fI\%remote\-server4\-get\-all\fP, \fI\%remote\-server4\-set\fP, \fI\%remote\-subnet4\-del\-by\-id\fP, \fI\%remote\-subnet4\-del\-by\-prefix\fP, \fI\%remote\-subnet4\-get\-by\-id\fP, \fI\%remote\-subnet4\-get\-by\-prefix\fP, \fI\%remote\-subnet4\-list\fP, \fI\%remote\-subnet4\-set\fP, \fI\%reservation\-add\fP, \fI\%reservation\-del\fP, \fI\%reservation\-get\fP, \fI\%reservation\-get\-all\fP, \fI\%reservation\-get\-by\-address\fP, \fI\%reservation\-get\-by\-hostname\fP, \fI\%reservation\-get\-by\-id\fP, \fI\%reservation\-get\-page\fP, \fI\%reservation\-update\fP, \fI\%server\-tag\-get\fP, \fI\%shutdown\fP, \fI\%stat\-lease4\-get\fP, \fI\%statistic\-get\fP, \fI\%statistic\-get\-all\fP, \fI\%statistic\-remove\fP, \fI\%statistic\-remove\-all\fP, \fI\%statistic\-reset\fP, \fI\%statistic\-reset\-all\fP, \fI\%statistic\-sample\-age\-set\fP, \fI\%statistic\-sample\-age\-set\-all\fP, \fI\%statistic\-sample\-count\-set\fP, \fI\%statistic\-sample\-count\-set\-all\fP, \fI\%status\-get\fP, \fI\%subnet4\-add\fP, \fI\%subnet4\-del\fP, \fI\%subnet4\-delta\-add\fP, \fI\%subnet4\-delta\-del\fP, \fI\%subnet4\-get\fP, \fI\%subnet4\-list\fP, \fI\%subnet4\-select\-test\fP, \fI\%subnet4\-update\fP, \fI\%subnet4o6\-select\-test\fP, \fI\%version\-get\fP\&. .sp Commands supported by \fIkea\-dhcp6\fP daemon: \fI\%build\-report\fP, \fI\%cache\-clear\fP, \fI\%cache\-flush\fP, \fI\%cache\-get\fP, \fI\%cache\-get\-by\-id\fP, \fI\%cache\-insert\fP, \fI\%cache\-load\fP, \fI\%cache\-remove\fP, \fI\%cache\-size\fP, \fI\%cache\-write\fP, \fI\%class\-add\fP, \fI\%class\-del\fP, \fI\%class\-get\fP, \fI\%class\-list\fP, \fI\%class\-update\fP, \fI\%config\-backend\-pull\fP, \fI\%config\-get\fP, \fI\%config\-hash\-get\fP, \fI\%config\-reload\fP, \fI\%config\-set\fP, \fI\%config\-test\fP, \fI\%config\-write\fP, \fI\%dhcp\-disable\fP, \fI\%dhcp\-enable\fP, \fI\%extended\-info6\-upgrade\fP, \fI\%ha\-continue\fP, \fI\%ha\-heartbeat\fP, \fI\%ha\-maintenance\-cancel\fP, \fI\%ha\-maintenance\-notify\fP, \fI\%ha\-maintenance\-start\fP, \fI\%ha\-reset\fP, \fI\%ha\-scopes\fP, \fI\%ha\-sync\fP, \fI\%ha\-sync\-complete\-notify\fP, \fI\%lease6\-add\fP, \fI\%lease6\-bulk\-apply\fP, \fI\%lease6\-del\fP, \fI\%lease6\-get\fP, \fI\%lease6\-get\-all\fP, \fI\%lease6\-get\-by\-duid\fP, \fI\%lease6\-get\-by\-hostname\fP, \fI\%lease6\-get\-page\fP, \fI\%lease6\-resend\-ddns\fP, \fI\%lease6\-update\fP, \fI\%lease6\-wipe\fP, \fI\%lease6\-write\fP, \fI\%leases\-reclaim\fP, \fI\%list\-commands\fP, \fI\%network6\-add\fP, \fI\%network6\-del\fP, \fI\%network6\-get\fP, \fI\%network6\-list\fP, \fI\%network6\-subnet\-add\fP, \fI\%network6\-subnet\-del\fP, \fI\%perfmon\-control\fP, \fI\%perfmon\-get\-all\-durations\fP, \fI\%remote\-class6\-del\fP, \fI\%remote\-class6\-get\fP, \fI\%remote\-class6\-get\-all\fP, \fI\%remote\-class6\-set\fP, \fI\%remote\-global\-parameter6\-del\fP, \fI\%remote\-global\-parameter6\-get\fP, \fI\%remote\-global\-parameter6\-get\-all\fP, \fI\%remote\-global\-parameter6\-set\fP, \fI\%remote\-network6\-del\fP, \fI\%remote\-network6\-get\fP, \fI\%remote\-network6\-list\fP, \fI\%remote\-network6\-set\fP, \fI\%remote\-option\-def6\-del\fP, \fI\%remote\-option\-def6\-get\fP, \fI\%remote\-option\-def6\-get\-all\fP, \fI\%remote\-option\-def6\-set\fP, \fI\%remote\-option6\-global\-del\fP, \fI\%remote\-option6\-global\-get\fP, \fI\%remote\-option6\-global\-get\-all\fP, \fI\%remote\-option6\-global\-set\fP, \fI\%remote\-option6\-network\-del\fP, \fI\%remote\-option6\-network\-set\fP, \fI\%remote\-option6\-pd\-pool\-del\fP, \fI\%remote\-option6\-pd\-pool\-set\fP, \fI\%remote\-option6\-pool\-del\fP, \fI\%remote\-option6\-pool\-set\fP, \fI\%remote\-option6\-subnet\-del\fP, \fI\%remote\-option6\-subnet\-set\fP, \fI\%remote\-server6\-del\fP, \fI\%remote\-server6\-get\fP, \fI\%remote\-server6\-get\-all\fP, \fI\%remote\-server6\-set\fP, \fI\%remote\-subnet6\-del\-by\-id\fP, \fI\%remote\-subnet6\-del\-by\-prefix\fP, \fI\%remote\-subnet6\-get\-by\-id\fP, \fI\%remote\-subnet6\-get\-by\-prefix\fP, \fI\%remote\-subnet6\-list\fP, \fI\%remote\-subnet6\-set\fP, \fI\%reservation\-add\fP, \fI\%reservation\-del\fP, \fI\%reservation\-get\fP, \fI\%reservation\-get\-all\fP, \fI\%reservation\-get\-by\-address\fP, \fI\%reservation\-get\-by\-hostname\fP, \fI\%reservation\-get\-by\-id\fP, \fI\%reservation\-get\-page\fP, \fI\%reservation\-update\fP, \fI\%server\-tag\-get\fP, \fI\%shutdown\fP, \fI\%stat\-lease6\-get\fP, \fI\%statistic\-get\fP, \fI\%statistic\-get\-all\fP, \fI\%statistic\-remove\fP, \fI\%statistic\-remove\-all\fP, \fI\%statistic\-reset\fP, \fI\%statistic\-reset\-all\fP, \fI\%statistic\-sample\-age\-set\fP, \fI\%statistic\-sample\-age\-set\-all\fP, \fI\%statistic\-sample\-count\-set\fP, \fI\%statistic\-sample\-count\-set\-all\fP, \fI\%status\-get\fP, \fI\%subnet6\-add\fP, \fI\%subnet6\-del\fP, \fI\%subnet6\-delta\-add\fP, \fI\%subnet6\-delta\-del\fP, \fI\%subnet6\-get\fP, \fI\%subnet6\-list\fP, \fI\%subnet6\-select\-test\fP, \fI\%subnet6\-update\fP, \fI\%version\-get\fP\&. .sp Commands supported by \fIcb_cmds\fP hook library: \fI\%remote\-class4\-del\fP, \fI\%remote\-class4\-get\fP, \fI\%remote\-class4\-get\-all\fP, \fI\%remote\-class4\-set\fP, \fI\%remote\-class6\-del\fP, \fI\%remote\-class6\-get\fP, \fI\%remote\-class6\-get\-all\fP, \fI\%remote\-class6\-set\fP, \fI\%remote\-global\-parameter4\-del\fP, \fI\%remote\-global\-parameter4\-get\fP, \fI\%remote\-global\-parameter4\-get\-all\fP, \fI\%remote\-global\-parameter4\-set\fP, \fI\%remote\-global\-parameter6\-del\fP, \fI\%remote\-global\-parameter6\-get\fP, \fI\%remote\-global\-parameter6\-get\-all\fP, \fI\%remote\-global\-parameter6\-set\fP, \fI\%remote\-network4\-del\fP, \fI\%remote\-network4\-get\fP, \fI\%remote\-network4\-list\fP, \fI\%remote\-network4\-set\fP, \fI\%remote\-network6\-del\fP, \fI\%remote\-network6\-get\fP, \fI\%remote\-network6\-list\fP, \fI\%remote\-network6\-set\fP, \fI\%remote\-option\-def4\-del\fP, \fI\%remote\-option\-def4\-get\fP, \fI\%remote\-option\-def4\-get\-all\fP, \fI\%remote\-option\-def4\-set\fP, \fI\%remote\-option\-def6\-del\fP, \fI\%remote\-option\-def6\-get\fP, \fI\%remote\-option\-def6\-get\-all\fP, \fI\%remote\-option\-def6\-set\fP, \fI\%remote\-option4\-global\-del\fP, \fI\%remote\-option4\-global\-get\fP, \fI\%remote\-option4\-global\-get\-all\fP, \fI\%remote\-option4\-global\-set\fP, \fI\%remote\-option4\-network\-del\fP, \fI\%remote\-option4\-network\-set\fP, \fI\%remote\-option4\-pool\-del\fP, \fI\%remote\-option4\-pool\-set\fP, \fI\%remote\-option4\-subnet\-del\fP, \fI\%remote\-option4\-subnet\-set\fP, \fI\%remote\-option6\-global\-del\fP, \fI\%remote\-option6\-global\-get\fP, \fI\%remote\-option6\-global\-get\-all\fP, \fI\%remote\-option6\-global\-set\fP, \fI\%remote\-option6\-network\-del\fP, \fI\%remote\-option6\-network\-set\fP, \fI\%remote\-option6\-pd\-pool\-del\fP, \fI\%remote\-option6\-pd\-pool\-set\fP, \fI\%remote\-option6\-pool\-del\fP, \fI\%remote\-option6\-pool\-set\fP, \fI\%remote\-option6\-subnet\-del\fP, \fI\%remote\-option6\-subnet\-set\fP, \fI\%remote\-server4\-del\fP, \fI\%remote\-server4\-get\fP, \fI\%remote\-server4\-get\-all\fP, \fI\%remote\-server4\-set\fP, \fI\%remote\-server6\-del\fP, \fI\%remote\-server6\-get\fP, \fI\%remote\-server6\-get\-all\fP, \fI\%remote\-server6\-set\fP, \fI\%remote\-subnet4\-del\-by\-id\fP, \fI\%remote\-subnet4\-del\-by\-prefix\fP, \fI\%remote\-subnet4\-get\-by\-id\fP, \fI\%remote\-subnet4\-get\-by\-prefix\fP, \fI\%remote\-subnet4\-list\fP, \fI\%remote\-subnet4\-set\fP, \fI\%remote\-subnet6\-del\-by\-id\fP, \fI\%remote\-subnet6\-del\-by\-prefix\fP, \fI\%remote\-subnet6\-get\-by\-id\fP, \fI\%remote\-subnet6\-get\-by\-prefix\fP, \fI\%remote\-subnet6\-list\fP, \fI\%remote\-subnet6\-set\fP\&. .sp Commands supported by \fIclass_cmds\fP hook library: \fI\%class\-add\fP, \fI\%class\-del\fP, \fI\%class\-get\fP, \fI\%class\-list\fP, \fI\%class\-update\fP\&. .sp Commands supported by \fIgss_tsig\fP hook library: \fI\%gss\-tsig\-get\fP, \fI\%gss\-tsig\-get\-all\fP, \fI\%gss\-tsig\-key\-del\fP, \fI\%gss\-tsig\-key\-expire\fP, \fI\%gss\-tsig\-key\-get\fP, \fI\%gss\-tsig\-list\fP, \fI\%gss\-tsig\-purge\fP, \fI\%gss\-tsig\-purge\-all\fP, \fI\%gss\-tsig\-rekey\fP, \fI\%gss\-tsig\-rekey\-all\fP\&. .sp Commands supported by \fIhigh_availability\fP hook library: \fI\%ha\-continue\fP, \fI\%ha\-heartbeat\fP, \fI\%ha\-maintenance\-cancel\fP, \fI\%ha\-maintenance\-notify\fP, \fI\%ha\-maintenance\-start\fP, \fI\%ha\-reset\fP, \fI\%ha\-scopes\fP, \fI\%ha\-sync\fP, \fI\%ha\-sync\-complete\-notify\fP\&. .sp Commands supported by \fIhost_cache\fP hook library: \fI\%cache\-clear\fP, \fI\%cache\-flush\fP, \fI\%cache\-get\fP, \fI\%cache\-get\-by\-id\fP, \fI\%cache\-insert\fP, \fI\%cache\-load\fP, \fI\%cache\-remove\fP, \fI\%cache\-size\fP, \fI\%cache\-write\fP\&. .sp Commands supported by \fIhost_cmds\fP hook library: \fI\%reservation\-add\fP, \fI\%reservation\-del\fP, \fI\%reservation\-get\fP, \fI\%reservation\-get\-all\fP, \fI\%reservation\-get\-by\-address\fP, \fI\%reservation\-get\-by\-hostname\fP, \fI\%reservation\-get\-by\-id\fP, \fI\%reservation\-get\-page\fP, \fI\%reservation\-update\fP\&. .sp Commands supported by \fIlease_cmds\fP hook library: \fI\%lease4\-add\fP, \fI\%lease4\-del\fP, \fI\%lease4\-get\fP, \fI\%lease4\-get\-all\fP, \fI\%lease4\-get\-by\-client\-id\fP, \fI\%lease4\-get\-by\-hostname\fP, \fI\%lease4\-get\-by\-hw\-address\fP, \fI\%lease4\-get\-page\fP, \fI\%lease4\-resend\-ddns\fP, \fI\%lease4\-update\fP, \fI\%lease4\-wipe\fP, \fI\%lease4\-write\fP, \fI\%lease6\-add\fP, \fI\%lease6\-bulk\-apply\fP, \fI\%lease6\-del\fP, \fI\%lease6\-get\fP, \fI\%lease6\-get\-all\fP, \fI\%lease6\-get\-by\-duid\fP, \fI\%lease6\-get\-by\-hostname\fP, \fI\%lease6\-get\-page\fP, \fI\%lease6\-resend\-ddns\fP, \fI\%lease6\-update\fP, \fI\%lease6\-wipe\fP, \fI\%lease6\-write\fP\&. .sp Commands supported by \fIlease_query\fP hook library: \fI\%extended\-info4\-upgrade\fP, \fI\%extended\-info6\-upgrade\fP\&. .sp Commands supported by \fIperfmon\fP hook library: \fI\%perfmon\-control\fP, \fI\%perfmon\-get\-all\-durations\fP\&. .sp Commands supported by \fIstat_cmds\fP hook library: \fI\%stat\-lease4\-get\fP, \fI\%stat\-lease6\-get\fP\&. .sp Commands supported by \fIsubnet_cmds\fP hook library: \fI\%network4\-add\fP, \fI\%network4\-del\fP, \fI\%network4\-get\fP, \fI\%network4\-list\fP, \fI\%network4\-subnet\-add\fP, \fI\%network4\-subnet\-del\fP, \fI\%network6\-add\fP, \fI\%network6\-del\fP, \fI\%network6\-get\fP, \fI\%network6\-list\fP, \fI\%network6\-subnet\-add\fP, \fI\%network6\-subnet\-del\fP, \fI\%subnet4\-add\fP, \fI\%subnet4\-del\fP, \fI\%subnet4\-delta\-add\fP, \fI\%subnet4\-delta\-del\fP, \fI\%subnet4\-get\fP, \fI\%subnet4\-list\fP, \fI\%subnet4\-update\fP, \fI\%subnet6\-add\fP, \fI\%subnet6\-del\fP, \fI\%subnet6\-delta\-add\fP, \fI\%subnet6\-delta\-del\fP, \fI\%subnet6\-get\fP, \fI\%subnet6\-list\fP, \fI\%subnet6\-update\fP\&. .SS build\-report .sp This command returns the list of compilation options that this particular binary was built with. .sp Supported by: \fI\%kea\-ctrl\-agent\fP, \fI\%kea\-dhcp\-ddns\fP, \fI\%kea\-dhcp4\fP, \fI\%kea\-dhcp6\fP .sp Availability: 1.2.0 (built\-in) .sp Access: read \fI(parameter ignored in this Kea version)\fP .sp Description and examples: see \fI\%build\-report command\fP .sp Command syntax: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqbuild\-report\(dq } .EE .UNINDENT .UNINDENT .sp Response syntax: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: } .EE .UNINDENT .UNINDENT .SS cache\-clear .sp This command removes all cached host reservations. .sp Supported by: \fI\%kea\-dhcp4\fP, \fI\%kea\-dhcp6\fP .sp Availability: 1.4.0 (\fI\%host_cache\fP hook library) .sp Access: write \fI(parameter ignored in this Kea version)\fP .sp Description and examples: see \fI\%cache\-clear command\fP .sp Command syntax: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqcache\-clear\(dq } .EE .UNINDENT .UNINDENT .sp Response syntax: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: , \(dqtext\(dq: \(dq\(dq } .EE .UNINDENT .UNINDENT .sp Result is an integer representation of the status. Currently supported statuses are: .INDENT 0.0 .IP \(bu 2 0 \- success .IP \(bu 2 1 \- error .IP \(bu 2 2 \- unsupported .IP \(bu 2 3 \- empty (command was completed successfully, but no data was affected or returned) .IP \(bu 2 4 \- conflict (command could not apply requested configuration changes because they were in conflict with the server state) .UNINDENT .SS cache\-flush .sp This command removes up to the given number or all cached host reservations. .sp Supported by: \fI\%kea\-dhcp4\fP, \fI\%kea\-dhcp6\fP .sp Availability: 1.4.0 (\fI\%host_cache\fP hook library) .sp Access: write \fI(parameter ignored in this Kea version)\fP .sp Description and examples: see \fI\%cache\-flush command\fP .sp Command syntax: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqcache\-flush\(dq, \(dqarguments\(dq: 5 } .EE .UNINDENT .UNINDENT .sp Response syntax: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: , \(dqtext\(dq: \(dq\(dq } .EE .UNINDENT .UNINDENT .sp Result is an integer representation of the status. Currently supported statuses are: .INDENT 0.0 .IP \(bu 2 0 \- success .IP \(bu 2 1 \- error .IP \(bu 2 2 \- unsupported .IP \(bu 2 3 \- empty (command was completed successfully, but no data was affected or returned) .IP \(bu 2 4 \- conflict (command could not apply requested configuration changes because they were in conflict with the server state) .UNINDENT .SS cache\-get .sp This command returns the full content of the host cache. .sp Supported by: \fI\%kea\-dhcp4\fP, \fI\%kea\-dhcp6\fP .sp Availability: 1.4.0 (\fI\%host_cache\fP hook library) .sp Access: read \fI(parameter ignored in this Kea version)\fP .sp Description and examples: see \fI\%cache\-get command\fP .sp Command syntax: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqcache\-get\(dq } .EE .UNINDENT .UNINDENT .sp Response syntax: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dq123 entries returned.\(dq, \(dqarguments\(dq: } .EE .UNINDENT .UNINDENT .sp Result is an integer representation of the status. Currently supported statuses are: .INDENT 0.0 .IP \(bu 2 0 \- success .IP \(bu 2 1 \- error .IP \(bu 2 2 \- unsupported .IP \(bu 2 3 \- empty (command was completed successfully, but no data was affected or returned) .IP \(bu 2 4 \- conflict (command could not apply requested configuration changes because they were in conflict with the server state) .UNINDENT .SS cache\-get\-by\-id .sp This command returns entries matching the given identifier from the host cache. .sp Supported by: \fI\%kea\-dhcp4\fP, \fI\%kea\-dhcp6\fP .sp Availability: 1.6.0 (\fI\%host_cache\fP hook library) .sp Access: read \fI(parameter ignored in this Kea version)\fP .sp Description and examples: see \fI\%cache\-get\-by\-id command\fP .sp Command syntax: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqcache\-get\-by\-id\(dq, \(dqarguments\(dq: { \(dqhw\-address\(dq: \(dq01:02:03:04:05:06\(dq } } .EE .UNINDENT .UNINDENT .sp Response syntax: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dq2 entries returned.\(dq, \(dqarguments\(dq: } .EE .UNINDENT .UNINDENT .sp Result is an integer representation of the status. Currently supported statuses are: .INDENT 0.0 .IP \(bu 2 0 \- success .IP \(bu 2 1 \- error .IP \(bu 2 2 \- unsupported .IP \(bu 2 3 \- empty (command was completed successfully, but no data was affected or returned) .IP \(bu 2 4 \- conflict (command could not apply requested configuration changes because they were in conflict with the server state) .UNINDENT .SS cache\-insert .sp This command inserts a host into the cache. .sp Supported by: \fI\%kea\-dhcp4\fP, \fI\%kea\-dhcp6\fP .sp Availability: 1.4.0 (\fI\%host_cache\fP hook library) .sp Access: write \fI(parameter ignored in this Kea version)\fP .sp Description and examples: see \fI\%cache\-insert command\fP .sp Command syntax: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqcache\-insert\(dq, \(dqarguments\(dq: { \(dqhw\-address\(dq: \(dq01:02:03:04:05:06\(dq, \(dqsubnet\-id4\(dq: 4, \(dqsubnet\-id6\(dq: 0, \(dqip\-address\(dq: \(dq192.0.2.100\(dq, \(dqhostname\(dq: \(dqsomehost.example.org\(dq, \(dqclient\-classes4\(dq: [ ], \(dqclient\-classes6\(dq: [ ], \(dqoption\-data4\(dq: [ ], \(dqoption\-data6\(dq: [ ], \(dqnext\-server\(dq: \(dq192.0.0.2\(dq, \(dqserver\-hostname\(dq: \(dqserver\-hostname.example.org\(dq, \(dqboot\-file\-name\(dq: \(dqbootfile.efi\(dq, \(dqhost\-id\(dq: 0 } } Another example that adds IPv6 host reservation to cache is: { \(dqcommand\(dq: \(dqcache\-insert\(dq, \(dqarguments\(dq: { \(dqhw\-address\(dq: \(dq01:02:03:04:05:06\(dq, \(dqsubnet\-id4\(dq: 0, \(dqsubnet\-id6\(dq: 6, \(dqip\-addresses\(dq: [ \(dq2001:db8::cafe:babe\(dq ], \(dqprefixes\(dq: [ \(dq2001:db8:dead:beef::/64\(dq ], \(dqhostname\(dq: \(dq\(dq, \(dqclient\-classes4\(dq: [ ], \(dqclient\-classes6\(dq: [ ], \(dqoption\-data4\(dq: [ ], \(dqoption\-data6\(dq: [ ], \(dqnext\-server\(dq: \(dq0.0.0.0\(dq, \(dqserver\-hostname\(dq: \(dq\(dq, \(dqboot\-file\-name\(dq: \(dq\(dq, \(dqhost\-id\(dq: 0 } } .EE .UNINDENT .UNINDENT .sp Response syntax: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: , \(dqtext\(dq: \(dq\(dq } .EE .UNINDENT .UNINDENT .sp Result is an integer representation of the status. Currently supported statuses are: .INDENT 0.0 .IP \(bu 2 0 \- success .IP \(bu 2 1 \- error .IP \(bu 2 2 \- unsupported .IP \(bu 2 3 \- empty (command was completed successfully, but no data was affected or returned) .IP \(bu 2 4 \- conflict (command could not apply requested configuration changes because they were in conflict with the server state) .UNINDENT .SS cache\-load .sp This command allows the contents of a file on disk to be loaded into an in\-memory cache. .sp Supported by: \fI\%kea\-dhcp4\fP, \fI\%kea\-dhcp6\fP .sp Availability: 1.4.0 (\fI\%host_cache\fP hook library) .sp Access: write \fI(parameter ignored in this Kea version)\fP .sp Description and examples: see \fI\%cache\-load command\fP .sp Command syntax: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqcache\-load\(dq, \(dqarguments\(dq: \(dq/usr/local/share/kea/kea\-host\-cache.json\(dq } .EE .UNINDENT .UNINDENT .sp Response syntax: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: , \(dqtext\(dq: \(dq\(dq } .EE .UNINDENT .UNINDENT .sp Result is an integer representation of the status. Currently supported statuses are: .INDENT 0.0 .IP \(bu 2 0 \- success .IP \(bu 2 1 \- error .IP \(bu 2 2 \- unsupported .IP \(bu 2 3 \- empty (command was completed successfully, but no data was affected or returned) .IP \(bu 2 4 \- conflict (command could not apply requested configuration changes because they were in conflict with the server state) .UNINDENT .SS cache\-remove .sp This command removes entries from the host cache. It takes parameters similar to the \fBreservation\-get\fP command. .sp Supported by: \fI\%kea\-dhcp4\fP, \fI\%kea\-dhcp6\fP .sp Availability: 1.4.0 (\fI\%host_cache\fP hook library) .sp Access: write \fI(parameter ignored in this Kea version)\fP .sp Description and examples: see \fI\%cache\-remove command\fP .sp Command syntax: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqcache\-remove\(dq, \(dqarguments\(dq: { \(dqip\-address\(dq: \(dq192.0.2.1\(dq, \(dqsubnet\-id\(dq: 123 } } Another example that removes the IPv6 host identifier by DUID and specific subnet\-id is: { \(dqcommand\(dq: \(dqcache\-remove\(dq, \(dqarguments\(dq: { \(dqduid\(dq: \(dq00:01:ab:cd:f0:a1:c2:d3:e4\(dq, \(dqsubnet\-id\(dq: 123 } } .EE .UNINDENT .UNINDENT .sp Response syntax: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: , \(dqtext\(dq: \(dq\(dq } .EE .UNINDENT .UNINDENT .sp Result is an integer representation of the status. Currently supported statuses are: .INDENT 0.0 .IP \(bu 2 0 \- success .IP \(bu 2 1 \- error .IP \(bu 2 2 \- unsupported .IP \(bu 2 3 \- empty (command was completed successfully, but no data was affected or returned) .IP \(bu 2 4 \- conflict (command could not apply requested configuration changes because they were in conflict with the server state) .UNINDENT .SS cache\-size .sp This command returns the number of entries in the host cache. .sp Supported by: \fI\%kea\-dhcp4\fP, \fI\%kea\-dhcp6\fP .sp Availability: 1.6.0 (\fI\%host_cache\fP hook library) .sp Access: read \fI(parameter ignored in this Kea version)\fP .sp Description and examples: see \fI\%cache\-size command\fP .sp Command syntax: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqcache\-size\(dq } .EE .UNINDENT .UNINDENT .sp Response syntax: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dq123 entries.\(dq, \(dqarguments\(dq: { \(dqsize\(dq: 123 } } .EE .UNINDENT .UNINDENT .sp Result is an integer representation of the status. Currently supported statuses are: .INDENT 0.0 .IP \(bu 2 0 \- success .IP \(bu 2 1 \- error .IP \(bu 2 2 \- unsupported .IP \(bu 2 3 \- empty (command was completed successfully, but no data was affected or returned) .IP \(bu 2 4 \- conflict (command could not apply requested configuration changes because they were in conflict with the server state) .UNINDENT .SS cache\-write .sp This command instructs Kea to write its host cache content to disk. .sp Supported by: \fI\%kea\-dhcp4\fP, \fI\%kea\-dhcp6\fP .sp Availability: 1.4.0 (\fI\%host_cache\fP hook library) .sp Access: write \fI(parameter ignored in this Kea version)\fP .sp Description and examples: see \fI\%cache\-write command\fP .sp Command syntax: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqcache\-write\(dq, \(dqarguments\(dq: \(dq/path/to/the/file.json\(dq } .EE .UNINDENT .UNINDENT .sp The command takes one mandatory argument that specifies the filename path of a file to be written. .sp Response syntax: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: , \(dqtext\(dq: \(dq\(dq } .EE .UNINDENT .UNINDENT .sp Result is an integer representation of the status. Currently supported statuses are: .INDENT 0.0 .IP \(bu 2 0 \- success .IP \(bu 2 1 \- error .IP \(bu 2 2 \- unsupported .IP \(bu 2 3 \- empty (command was completed successfully, but no data was affected or returned) .IP \(bu 2 4 \- conflict (command could not apply requested configuration changes because they were in conflict with the server state) .UNINDENT .SS class\-add .sp This command adds a new class to the existing server configuration. .sp Supported by: \fI\%kea\-dhcp4\fP, \fI\%kea\-dhcp6\fP .sp Availability: 1.5.0 (\fI\%class_cmds\fP hook library) .sp Access: write \fI(parameter ignored in this Kea version)\fP .sp Description and examples: see \fI\%class\-add command\fP .sp Command syntax: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqcommand\(dq: \(dqclass\-add\(dq, \(dqarguments\(dq: { \(dqclient\-classes\(dq: [ { \(dqname\(dq: , \(dqtest\(dq: , \(dqoption\-data\(dq: [

} ], \(dqremote\(dq: { } } } .EE .UNINDENT .UNINDENT .sp This command includes two lists with exactly address pool specification and exactly one option specification. Specifying an empty list, a value of \fBnull\fP, or a server tag will result in an error. .sp Response syntax: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqresult\(dq: 0, \(dqtext\(dq: \(dqDHCPv4 option successfully set.\(dq, \(dqarguments\(dq: { \(dqoptions\(dq: [ { \(dqcode\(dq: