This is the reference guide for Kea version 1.6.0-beta2.
Copyright © 2010-2019 Internet Systems Consortium, Inc. ("ISC")
Abstract
Kea is an open source implementation of the Dynamic Host Configuration Protocol (DHCP) servers, developed and maintained by Internet Systems Consortium (ISC).
This is the reference guide for Kea version 1.6.0-beta2.
Links to the most up-to-date version of this document (in PDF, HTML,
and plain text formats), along with other documents for
Kea, can be found in ISC's Knowledgebase
.
Table of Contents
List of Tables
Kea is the next generation of DHCP software developed by ISC. It supports both DHCPv4 and DHCPv6 protocols along with their extensions, e.g. prefix delegation and dynamic updates to DNS.
This guide covers Kea version 1.6.0-beta2.
Kea is officially supported on CentOS, Fedora, Ubuntu, Debian, and FreeBSD systems. It is also likely to work on many other platforms. Kea-1.6.0-beta2 builds have been tested on:
There are currently no plans to port Kea to Windows platforms.
Running 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. You may need to install this required software separately. (For the build requirements, also see Section 3.3, “Building Requirements”.)
http://botan.randombit.net/
),
version 1.9 or later. Note that support for Botan versions earlier than 2.0 will be removed in Kea 1.6.0 and later. As an alternative to Botan, Kea can use the
OpenSSL cryptographic library (http://www.openssl.org/
),
version 1.0.2 or later.
http://log4cplus.sourceforge.net/
).
It requires log4cplus version 1.0.3 or later.
http://www.boost.org/
). Building with the header-only version of Boost is no longer recommended.
Kea is modular. Part of this modularity is accomplished using multiple cooperating processes which, together, provide the server functionality. The following software is included with Kea:
The tools and modules are covered in full detail in this guide. In addition, manual pages are also provided in the default installation.
Kea also provides C++ libraries and programmer interfaces for DHCP. These include detailed developer documentation and code examples.
Table of Contents
This section describes the basic steps needed to get Kea up and running. For further details, full customizations, and troubleshooting, see the respective chapters in the Kea Administrator Reference Manual (ARM).
Download the Kea source tarball from the ISC.org downloads page or the ISC FTP server.
Extract the tarball. For example:
$ tar xvzf kea-1.6.0-beta2.tar.gz
Go into the source directory and run the configure script:
$cd kea-1.6.0-beta2
$./configure [your extra parameters]
Build it:
$ make
Install it (by default it will be placed in
/usr/local/
,
so it is likely that you will need root privileges for this step):
# make install
Edit the Kea configuration files which by default are installed in
the [kea-install-dir]/etc/kea/
directory. These are:
kea-dhcp4.conf
, kea-dhcp6.conf
,
kea-dhcp-ddns.conf
and
kea-ctrl-agent.conf
, for DHCPv4 server, DHCPv6 server,
D2, and Control Agent, respectively.
In order to start the DHCPv4 server in the background, run the following command (as root):
# keactrl start -s dhcp4
Or run the following command to start the DHCPv6 server instead:
# keactrl start -s dhcp6
Note that it is also possible to start all servers simultaneously:
$ keactrl start
Verify that the Kea server(s) is/are running:
# keactrl status
A server status of "inactive" may indicate a configuration
error. Please check the log file (by default named
[kea-install-dir]/var/log/kea-dhcp4.log
,
[kea-install-dir]/var/log/kea-dhcp6.log
,
[kea-install-dir]/var/log/kea-ddns.log
or
[kea-install-dir]/var/log/kea-ctrl-agent.log
)
for the details of the error.
If the server has been started successfully, test that it is responding to DHCP queries and that the client receives a configuration from the server; for example, use the ISC DHCP client.
Stop running the server(s):
# keactrl stop
For instructions specific to your system, please read the system-specific notes, available in the Kea section of ISC's Knowledgebase.
The details of keactrl script usage can be found in Chapter 6, Managing Kea with keactrl.
The Kea servers can be started directly, without the need to use the keactrl. To start the DHCPv4 server run the following command:
# kea-dhcp4 -c /path/to/your/kea4/config/file.json
Similarly, to start the DHCPv6 server run the following command:
# kea-dhcp6 -c /path/to/your/kea6/config/file.json
Table of Contents
Some operating systems or software package vendors may provide ready-to-use, pre-built software packages for Kea. Installing a pre-built package means you do not need to install the software required only to build Kea and do not need to make the software.
The following is the directory layout of the complete Kea installation. (All directory paths are relative to the installation directory):
etc/kea/
—
configuration files.
include/
—
C++ development header files.
lib/
—
libraries.
lib/kea/hooks
—
additional hooks libraries.
sbin/
—
server software and commands used by the system administrator.
share/kea/
—
configuration specifications and examples.
share/doc/kea/
—
this guide, other supplementary documentation, and examples.
share/man/
—
manual pages (online documentation).
var/lib/kea/
—
server identification, and lease databases files.
var/log/
—
log files.
var/run/kea/
—
pid and logger lock files.
In addition to the run-time requirements (listed in Section 1.2, “Required Software at Run-time”), building Kea from source code requires various development include headers and program development tools.
Some operating systems have split their distribution packages into a run-time and a development package. You will need to install the development package versions, which include header files and libraries, to build Kea from the source code.
Building from source code requires the following software installed on the system:
Boost C++ Libraries
(http://www.boost.org/
).
The oldest Boost version used for testing is 1.57 (although it may also work with
older versions). The Boost system library must also be installed. Installing
a header-only version of Boost is no longer recommended.
OpenSSL (at least version 1.0.1) or Botan (at least version 1.9). Note that OpenSSL version 1.0.2 or 1.1.0 or later and Botan version 2 or later are strongly recommended.
log4cplus (at least version 1.0.3) development include headers.
A C++ compiler (with C++11 support) and standard development headers. Kea building was checked with GCC g++ 4.8.5 and some later versions and Clang 800.0.38 and some later versions.
The development tools automake, libtool, pkg-config.
The MySQL client and the client development libraries, when using the --with-mysql 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.
The PostgreSQL client and the client development libraries, when using the --with-pgsql configuration flag to build the Kea PostgreSQL database backend. In this case an instance of the PostgreSQL server running locally or on some other machine, reachable over the network from the machine running Kea, is required. Note that running the unit tests requires a local PostgreSQL server.
The cpp-driver from DataStax is needed when using the --with-cql configuration flag to build Kea with the Cassandra database backend. In this case, an instance of the Cassandra server running locally or on some other machine, reachable over the network from the machine running Kea, is required. Note that running the unit tests requires a local Cassandra server.
The FreeRADIUS client library is required to connect to a RADIUS server. (This is specified using the --with-freeradius configuration switch.)
Sysrepo (version 0.7.6 or later) and libyang (version 0.16-r2 or later) are needed to connect to a Sysrepo database. (This is specified using the --with-sysrepo switch when running "configure".)
googletest (version 1.8 or later), when using the --with-gtest configuration option to build the unit tests.
The documentation generation tools elinks, docbook-xsl, libxslt, and Doxygen, if using the --enable-generate-docs configuration option to create the documentation.
Visit ISC's Knowledgebase at
https://kb.isc.org/docs/installing-kea
for system-specific installation tips.
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 (https://gitlab.isc.org/isc-projects/kea
).
This section describes how to build Kea from the source code.
The Kea release tarballs may be downloaded from:
http://ftp.isc.org/isc/kea/
(using FTP or HTTP).
Downloading this "bleeding edge" code is recommended only for developers or advanced users. Using development code in a production environment is not recommended.
When building from source code retrieved via Git, additional software will be required: automake (v1.11 or later), libtoolize, and autoconf (v2.69 or later). These may need to be installed.
The latest development code is available on Gitlab (see
https://gitlab.isc.org/isc-projects/kea
). The Kea source
is public and development is done in the “master”
branch.
The code can be checked out from
https://gitlab.isc.org/isc-projects/kea.git
:
$ git clone https://gitlab.isc.org/isc-projects/kea.git
The code checked out from the git repository does not include the
generated configure script, Makefile.in files, nor their
related build files.
They can be created by running autoreconf
with the --install
switch.
This will run autoconf,
aclocal,
libtoolize,
autoheader,
automake,
and related commands.
Write access to the Kea repository is only granted to ISC staff. If you are a developer planning to contribute to Kea, please check our Contributor's Guide. The Kea Developer's Guide contains more information about the process, as well as describes the requirements for contributed code to be accepted by ISC.
Kea uses the GNU Build System to discover build environment details. To generate the makefiles using the defaults, simply run:
$ ./configure
Run ./configure with the --help
switch to view the different options. Some commonly-used options are:
/usr/local
).
The --runstatedir
in the installation
directories is particular: there are three cases:
--runstatedir
configure parameter.
runstatedir
environment variable is supported so simply remove the
-- before runstatedir
in the configure script call.
For instructions concerning the installation and configuration of database backends for Kea, see Section 3.5, “DHCP Database Installation and Configuration”.
There are also many additional options that are typically not used by regular users. However, they may be useful for package maintainers, developers or people who want to extend Kea code or send patches:
$ ./configure XSLTPROC_NET=yes --enable-generate-docs
For example, the following command configures Kea to find the Boost headers in /usr/pkg/include, specifies that PostgreSQL support should be enabled, and sets the installation location to /opt/kea:
$ ./configure \
--with-boost-include=/usr/pkg/include \
--with-pgsql=/usr/local/bin/pg_config \
--prefix=/opt/kea
If you have any problems with building Kea using the header-only Boost code, or you'd like to use the Boost system library (assumed for the sake of this example to be located in /usr/pkg/lib):
$ ./configure \
--with-boost-libs=-lboost_system \
--with-boost-lib-dir=/usr/pkg/lib
If configure fails, it may be due to missing or old dependencies.
If configure succeeds, it displays a report
with the parameters used to build the code. This report is saved into
the file config.report
and is also embedded into
the executable binaries, e.g., kea-dhcp4
.
After the configure step is complete, build the executables from the C++ code and prepare the Python scripts by running the command:
$ make
To install the Kea executables, support files, and documentation, issue the command:
$ make install
Do not use any form of parallel or job server options (such as GNU make's -j option) when performing this step; doing so may cause errors.
The install step may require superuser privileges.
If required, run ldconfig as root with
/usr/local/lib
(or with prefix
/lib if
configured with --prefix) in
/etc/ld.so.conf
(or the relevant linker
cache configuration file for your OS):
$ ldconfig
If you do not run ldconfig where it is required, you may see errors like the following:
program: error while loading shared libraries: libkea-something.so.1: cannot open shared object file: No such file or directory
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. At present, Kea supports four database backends: MySQL, PostgreSQL, Cassandra, and Memfile. To limit external dependencies, MySQL, PostgreSQL, and Cassandra 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.
When unit tests are built with Kea (the --with-gtest 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 Kea Developer's Guide.
Install MySQL according to the instructions for your system. The client development libraries must be installed.
Build and install Kea as described in Chapter 3, Installation, with the following modification. To enable the MySQL database code, at the "configure" step (see Section 3.4.3, “Configure Before the Build”), the --with-mysql switch should be specified:
./configure [other-options] --with-mysql
If MySQL was not installed in the default location, the location of the MySQL configuration program "mysql_config" should be included with the switch, i.e.
./configure [other-options] --with-mysql=path-to-mysql_config
See Section 4.3.2.1, “First-Time Creation of the MySQL Database” for details regarding MySQL database configuration.
Install PostgreSQL according to the instructions for your system. The client development libraries must be installed. Client development libraries are often packaged as "libpq".
Build and install Kea as described in Chapter 3, Installation, with the following modification. To enable the PostgreSQL database code, at the "configure" step (see Section 3.4.3, “Configure Before the Build”), the --with-pgsql switch should be specified:
./configure [other-options] --with-pgsql
If PostgreSQL was not installed in the default location, the location of the PostgreSQL configuration program "pg_config" should be included with the switch, i.e.
./configure [other-options] --with-pgsql=path-to-pg_config
See Section 4.3.3.1, “First-Time Creation of the PostgreSQL Database” for details regarding PostgreSQL database configuration.
Install Cassandra according to the instructions for your system. The
Cassandra project website contains useful pointers: http://cassandra.apache.org
.
If you have a cpp-driver package available as binary or as source, simply install or build and install the package. Then build and install Kea as described in Chapter 3, Installation. To enable the Cassandra (CQL) database code, at the "configure" step (see Section 3.4.3, “Configure Before the Build”), do:
./configure [other-options] --with-cql=path-to-pkg-config
Note if pkg-config is at its standard location (and thus in the shell path) you do not need to supply its path. If it does not work (e.g. no pkg-config, package not available in pkg-config with the cassandra name), you can still use the cql_config script in tools/ as described below.
Download and compile cpp-driver from DataStax. For details regarding
dependencies for building cpp-driver, see the project homepage
https://github.com/datastax/cpp-driver
. In June
2016, the following commands were used:
$git clone https://github.com/datastax/cpp-driver
$cd cpp-driver
$mkdir build
$cd build
$cmake ..
$make
As of January 2019, cpp-driver does not include cql_config script. Work is in progress to contribute such a script to the cpp-driver project but, until that is complete, intermediate steps need to be conducted. A cql_config script is present in the tools/ directory of the Kea sources. Before using it, please create a cql_config_defines.sh in the same directory (there is an example in cql_config_define.sh.sample available; you may copy it over to cql_config_defines.sh and edit the path specified in it) and change the environment variable CPP_DRIVER_PATH to point to the directory where the cpp-driver sources are located. Make sure that appropriate access rights are set on this file. It should be executable by the system user building Kea.
Build and install Kea as described in Chapter 3, Installation, with the following modification. To enable the Cassandra (CQL) database code, at the "configure" step (see Section 3.4.3, “Configure Before the Build”), do:
./configure [other-options] --with-cql=path-to-cql_config
An optionl building tool called Hammer was introduced with Kea 1.6.0. It 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 purpose and ISC cannot guarantee its proper operation. If you decide to use it, please do so with care.
Use of this tool is completely optional. Everything it does can be done manually.
The first time user is strongly encouraged to look at Hammer's built in help:
./hammer.py --help
It will list available parameters.
Hammer is able to set up various operating systems running eiter in LXC or in VirtualBox. To list of supported systems, use supported-systems command:
$./hammer.py supported-systems
fedora:
- 27: lxc, virtualbox
- 28: lxc, virtualbox
- 29: lxc, virtualbox
centos:
- 7: lxc, virtualbox
rhel:
- 8: virtualbox
ubuntu:
- 16.04: lxc, virtualbox
- 18.04: lxc, virtualbox
- 18.10: lxc, virtualbox
debian:
- 8: lxc, virtualbox
- 9: lxc, virtualbox
freebsd:
- 11.2: virtualbox
- 12.0: virtualbox
It is also possible to run build locally, in current system (if the OS is supported).
At first it is required to install Hammer dependencies which is Vagrant and either VirtualBox or LXC. To make life easier Hammer can install Vagrant and required Vagrant plugins using the command:
./hammer.py ensure-hammer-deps
VirtualBox and LXC need to be installed manually.
Basic functionality provided by Hammer is preparing building environment and performing actual build and running unit tests locally, in current system. This can be achieved by running the command:
./hammer.py build -p local
The scope of the process can be defined using --with (-w) and --without (-x) options. By default the build command will build Kea with documentation, install it locally and run unit tests.
To exclude installation and generating docs do:
./hammer.py build -p local -x install docs
The basic scope can be extended by: mysql, pgsql, cql, native-pkg, radius, shell, forge.
For build Kea locally installing Hammer dependencies like Vagrant is not needed.
Hammer can be told to set up a new virtual machine with specified operating system and not running the build:
./hammer.py prepare-system -p virtualbox -s freebsd -r 12.0
This way we can prepare a system for our own use. To get to such system using SSH invoke:
./hammer.py ssh -p virtualbox -s freebsd -r 12.0
It is possible to speed up subsequent Hammer builds. To achieve this Hammer employs ccache. During compilation ccache stores object to shared folder. In subsequent runs instead doing actuall compilation ccache just returns stored earlier objects. Cache with objects for reuse needs to be stored outside of VM or LXC. To indicate such folder Hammer requires providing --ccache-dir parameter. In indicated folder there are stored objects for each target operating system separatelly.
./hammer.py build -p lxc -s ubuntu -r 18.04 --ccache-dir ~/kea-ccache
For now ccache is only supported for LXC provider in Hammer. Support for VirtualBox will be added later.
For more information check:
./hammer.py --help
Table of Contents
Kea may be configured to use a database as a storage for leases, a source of servers' configurations and host reservations (i.e. static assignments of addresses, prefixes, options etc.). Subsequent Kea releases introduce changes to the database schemas to faciliate new features and correct discovered issues with the existing schemas.
A given version of Kea expects a particular structure in the backend and checks for this by examining the version of database it is using. Separate version numbers are maintained for backends, independent of the version of Kea itself. It is possible that the backend version will stay the same through several Kea revisions; similarly, it is possible that the version of the backend may go up several revisions during a Kea upgrade. Versions for each backend are independent, so an increment in the MySQL backend version does not imply an increment in that of PostgreSQL.
Backend versions are specified in
a major.minor
format. The minor
number is increased when there are backward-compatible changes
introduced; for example, the addition of a new index. It is
desirable but not mandatory to apply such a change; you
can run an older backend version if you want to. (Although, in
the example given, running without the new index may be at the
expense of a performance penalty.) On the other hand, the major
number is increased when an incompatible change is introduced:
for example, an extra column is added to a table. If you try to
run Kea on a backend that is too old (as signified by
a mismatched backend major version number), Kea will refuse to run;
administrative action will be required to upgrade the backend.
To manage the databases, Kea provides the kea-admin tool. It is able to initialize a new backend, check its version number, perform a backend upgrade, and dump lease data to a text file.
kea-admin takes two mandatory parameters: command and backend. Additional, non-mandatory options may be specified. The currently supported commands are:
backend specifies the type of backend database. The currently supported types are:
Additional parameters may be needed, depending on your setup and specific operation: username, password, and database name or the directory where specific files are located. See the appropriate manual page for details (man 8 kea-admin).
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 may be essential for the success of your deployment.
Table 4.1. List of available backends
Feature | Memfile | MySQL | PostgreSQL | CQL (Cassandra) |
---|---|---|---|---|
Status | Stable | Stable | Stable | Experimental |
Data format | CSV file | SQL RMDB | SQL RMDB | NoSQL database (Cassandra) |
Leases | yes | yes | yes | yes |
Host Reservations | no | yes | yes | yes |
Options defined on per host basis | no | yes | yes | yes |
Configuration Backend | no | yes | no | no |
The memfile backend is able to store lease information, but is not able to 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.)
No special initialization steps are necessary for the memfile backend. During the first run, both kea-dhcp4 and kea-dhcp6 will create an empty lease file if one is not present. Necessary disk-write permission is required.
There are no special steps required to upgrade memfile lease files from an earlier version of Kea to a new version of Kea. During startup the servers will check the schema version of the lease files against their own. If there is a mismatch, the servers will automatically launch the LFC process to convert the files to the server's 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 will be assigned appropriate default values. When downgrading, any data present in the files but not in the server's schema will be dropped. If you wish to convert the files manually prior to starting the servers, you may do so by running the LFC process yourself. See Chapter 13, The LFC Process for more information.
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). This section can be safely ignored if you choose to store the data in other backends.
If you are setting the MySQL database for the first time, you need to create the database area within MySQL and set up the MySQL user ID under which Kea will access the database. This needs to be done manually; kea-admin is not able to do this for you.
To create the database:
Log into MySQL as "root":
$ mysql -u root -p
Enter password:
mysql>
Create the MySQL database:
mysql> CREATE DATABASE database-name
;
(database-name
is the name
you have chosen for the database.)
Create the user under which Kea will access the database (and give it a password), then grant it access to the database tables:
mysql>CREATE USER '
mysql>user-name
'@'localhost' IDENTIFIED BY 'password
';GRANT ALL ON
database-name
.* TO 'user-name
'@'localhost';
(user-name
and
password
are the user ID
and password you are using to allow Kea's access to the
MySQL instance. All apostrophes in the command lines
above are required.)
At this point, you may elect to create the database tables. (Alternatively, you can exit MySQL and create the tables using the kea-admin tool, as explained below.) To do this:
mysql>CONNECT
mysql>database-name
;SOURCE
path-to-kea
/share/kea/scripts/mysql/dhcpdb_create.mysql
(path-to-kea
is the
location where you installed Kea.)
Exit MySQL:
mysql> quit
Bye
$
If you elected not to create the tables in Step 4, you can do so now by running the kea-admin tool:
$ kea-admin db-init mysql -u database-user
-p database-password
-n database-name
(Do not do this if you did create the tables in Step 4.) kea-admin implements rudimentary checks; it will refuse to initialize a database that contains any existing tables. If you want to start from scratch, you must remove all data manually. (This process is a manual operation on purpose, to avoid possibly irretrievable mistakes by kea-admin.)
Sometimes a new Kea version may use a newer database schema, so the existing database will need to be upgraded. This can be done using the kea-admin db-upgrade command.
To check the current version of the database, use the following command:
$ kea-admin db-version mysql -u database-user
-p database-password
-n database-name
(See Section 4.1, “Databases and Database Version Numbers” 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.
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. To perform an upgrade, issue the following command:
$ kea-admin db-upgrade mysql -u database-user
-p database-password
-n database-name
PostgreSQL is able to store leases, host reservations, and options defined on a per-host basis. This step can be safely ignored if you are using other database backends.
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:
Log into PostgreSQL as "root":
$ sudo -u postgres psql postgres
Enter password:
postgres=#
Create the database:
postgres=# CREATE DATABASE database-name
;
CREATE DATABASE
postgres=#
(database-name
is the name
you have chosen for the database.)
Create the user under which Kea will access the database (and give it a password), then grant it access to the database:
postgres=#CREATE USER
CREATE ROLE postgres=#user-name
WITH PASSWORD 'password
';GRANT ALL PRIVILEGES ON DATABASE
GRANT postgres=#database-name
TOuser-name
;
Exit PostgreSQL:
postgres=# \q
Bye
$
At this point you are ready to create the database tables. This can be done using the kea-admin tool as explained in the next section (recommended), or manually. To create the tables manually, enter the following command. Note that PostgreSQL will prompt you to enter the new user's password you specified in Step 3. When the command completes, you will be returned to the shell prompt. You should see output similar to the following:
$psql -d
Password for userdatabase-name
-Uuser-name
-fpath-to-kea
/share/kea/scripts/pgsql/dhcpdb_create.pgsqluser-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 $
(path-to-kea
is the location
where you installed Kea.)
If instead you encounter an error like:
psql: FATAL: no pg_hba.conf entry for host "[local]", user "user-name
", database "database-name
", SSL off
... you will need to alter the PostgreSQL configuration.
Kea uses password authentication when connecting to
the database and must have the appropriate entries
added to PostgreSQL's pg_hba.conf file. This file is
normally located in the primary data directory for your
PostgreSQL server. The precise path may vary depending on your operating system and version, but the
default location for PostgreSQL 9.3 on Centos 6.5 is:
/var/lib/pgsql/9.3/data/pg_hba.conf
.
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's database:
localdatabase-name
user-name
password hostdatabase-name
user-name
127.0.0.1/32 password hostdatabase-name
user-name
::1/128 password
These edits are primarily intended as a starting point, and are not a definitive reference on PostgreSQL administration or database security. Please consult your PostgreSQL user manual before making these changes, as they may expose other databases that you run. It may be necessary to restart PostgreSQL in order for the changes to take effect.
If you elected not to create the tables manually, you can do so now by running the kea-admin tool:
$ kea-admin db-init pgsql -u database-user
-p database-password
-n database-name
Do not do this if you already created the tables manually. kea-admin implements rudimentary checks; it will refuse to initialize a database that contains any existing tables. If you want to start from scratch, you must remove all data manually. (This process is a manual operation on purpose, to avoid possibly irretrievable mistakes by kea-admin.)
The PostgreSQL database schema can be upgraded using the same tool and commands as described in Section 4.3.2.2, “Upgrading a MySQL Database from an Earlier Version of Kea”, with the exception that the "pgsql" database backend type must be used in the commands.
Use the following command to check the current schema version:
$ kea-admin db-version pgsql -u database-user
-p database-password
-n database-name
Use the following command to perform an upgrade:
$ kea-admin db-upgrade pgsql -u database-user
-p database-password
-n database-name
Cassandra (sometimes for historical reasons referred to in documentation and commands as CQL) is the newest backend added to Kea; initial development was contributed by Deutsche Telekom. The Cassandra backend is able to store leases, host reservations, and options defined on a per-host basis.
Cassandra must be properly set up if you want Kea to store information in it. This section can be safely ignored if you choose to store the data in other backends.
If you are setting up the Cassandra database for the first time, you need to create the keyspace area within it. This needs to be done manually; kea-admin cannot do this for you.
To create the database:
Export CQLSH_HOST environment variable:
$ export CQLSH_HOST=localhost
Log into CQL:
$ cqlsh
cql>
Create the CQL keyspace:
cql> CREATE KEYSPACE keyspace-name WITH replication = {'class' : 'SimpleStrategy','replication_factor' : 1};
(keyspace-name
is the name you have
chosen for the keyspace)
At this point, you may elect to create the database tables. (Alternatively, you can exit Cassandra and create the tables using the kea-admin tool, as explained below.) To do this:
cqslh -k keyspace-name
-f path-to-kea
/share/kea/scripts/cql/dhcpdb_create.cql
(path-to-kea
is the location where you
installed Kea)
If you elected not to create the tables in Step 4, you can do so now by running the kea-admin tool:
$ kea-admin db-init cql -n database-name
(Do not do this if you did create the tables in Step 4.) kea-admin implements rudimentary checks; it will refuse to initialize a database that contains any existing tables. If you want to start from scratch, you must remove all data manually. (This process is a manual operation on purpose, to avoid possibly irretrievable mistakes by kea-admin.)
Sometimes a new Kea version may use a newer database schema, so the existing database will need to be upgraded. This can be done using the kea-admin db-upgrade command.
To check the current version of the database, use the following command:
$ kea-admin db-version cql -n database-name
(See Section 4.1, “Databases and Database Version Numbers” 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.
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. To perform an upgrade, issue the following command:
$ kea-admin db-upgrade cql -n database-name
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 Section 8.2.3.2, “Using Read-Only Databases for Host Reservations” and Section 9.2.3.2, “Using Read-Only Databases for Host Reservations” describe when such configuration may be required and how to configure Kea to operate in this way.
The lease expiration time is stored in the SQL database for each lease as a timestamp value. Kea developers observed that the MySQL database doesn't accept timestamps beyond 2147483647 seconds (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 year 2038). This will be fixed when the database support for longer timestamps is available.
Table of Contents
Kea uses JSON structures to represent server configurations. The following sections describe how the configuration structures are organized.
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 Chapter 17, Management API) and for communicating between DHCP servers and the DDNS update daemon.
Typical usage assumes that the servers are started from the command line,
either directly or using a script, e.g. keactrl
.
The configuration file is specified upon startup using the -c parameter.
Configuration files for the DHCPv4, DHCPv6, DDNS, Control Agent, and Netconf modules are defined in an extended JSON format. Basic JSON is defined in RFC 7159 and ECMA 404. In particular, the only boolean values allowed are true or false (all lowercase). The capitalized versions (True or False) are not accepted.
Kea components use an extended JSON with additional features allowed:
The configuration file consists of a single object (often colloquially called a map) started with a curly bracket. It comprises one or more of the "Dhcp4", "Dhcp6", "DhcpDdns", "Control-agent" and "Netconf" objects. It is possible to define additional elements but they will be ignored.
A very simple configuration for DHCPv4 could look like this:
# The whole configuration starts here. { # DHCPv4 specific configuration starts here. "Dhcp4": { "interfaces-config": { "interfaces": [ "eth0" ], "dhcp-socket-type": "raw" }, "valid-lifetime": 4000, "renew-timer": 1000, "rebind-timer": 2000, "subnet4": [{ "pools": [ { "pool": "192.0.2.1-192.0.2.200" } ], "subnet": "192.0.2.0/24" }], # Now loggers are inside the DHCPv4 object. "loggers": [{ "name": "*", "severity": "DEBUG" }] } # The whole configuration structure ends here. }
More examples are available in the installed
share/doc/kea/examples
directory.
The "Logging" element is removed in Kea 1.6.0 and its contents (the "loggers" object) moved inside the configuration objects (maps) for respective Kea modules. For example: the "Dhcp4" map contains the "loggers" object specifying logging configuration for the DHCPv4 server. Backward compatibility is maintained until at least Kea 1.7.0 release: it will be possible to specify "Logging" object at the top configuration level and "loggers" objects at the module configuration level. Ultimately, support for the top-level "Logging" object will be removed.
The specification of several supported elements (e.g. "Dhcp4", "Dhcp6") in a single configuration file can be confusing and works badly with the commands that fetch and write new configurations. Support for it will be removed in a future release of Kea, after which each component will require its own configuration file.
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 and Logging) are present, but they are omitted for clarity. Usually, locations where extra parameters may appear are denoted by an ellipsis (...).
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.
Kea Configuration Backend (abbreviated as CB) is a feature first introduced in 1.6.0 release, which provides Kea servers with the ability to manage and fetch their configuration from one or more databases. In the documentation, the term "Configuration Backend" may also refer to the particular Kea module providing support to manage and fetch the configuration information from the particular database type. For example: MySQL Configuration Backend is the logic implemented within the "mysql_cb" hooks library which provides a complete set of functions to manage and fetch the configuration information from the MySQL database.
In small deployments, e.g. those comprising a single DHCP server instance with limited and infrequently changing number of subnets, it may be impractical to use the CB as a configuration repository because it requires additional third party software to be installed and configured - in particular the MySQL server and MySQL client. Once the number of DHCP servers and/or the number of managed subnets in the network grows, the usefulness of the CB becomes obvious.
A good example is a pair of the Kea DHCP servers which can be configured to support High Availability as described in Section 15.4.9, “ha: High Availability”. The configurations of both servers are almost exactly the same. They may differ by the server identifier and designation of the server as a primary or standby (or secondary). They may also differ by the interfaces configuration. Typically, the subnets, shared networks, option definitions, global parameters are the same for both servers and can be sourced from a single database instance to both Kea servers.
Using the database as a single source of configuration for subnets and/or other configuration information supported by the CB has the advantage that any modifications to the configuration in the database is automatically applied to both servers.
Another case when the centralized configuration repository is desired is in deployments including large number of the DHCP servers, possibly using a common lease database to provide redundancy. The new servers can be added to the pool frequently to fulfil growing scalability requirements. Adding the new server does not require replicating the entire configuration to the new server when common database is used.
Using the database as a configuration repository for Kea servers also brings other benefits, such as:
Kea CB has been introduced in the 1.6.0 release, but this implementation comes with a number of limitations being the result of the overall complexity of this feature and the development time constraints. This feature will evolve over time and the new capabilities will be added in subsequent releases. In this section we present the limitations of the CB, present in the current Kea 1.6.0 release:
We strongly recommend to not duplicate the configuration information in the file and the database. For example, when specifying subnets for the DHCP server, please store them in the configuration backend or in the configuration file, not in both places. Storing some subnets in the database and other in the file may put you at risk of potential configuration conflicts. Note that the configuration from the database takes precedence over the configuration from the file, thus it is possible that parts of the configuration specified in the file may be overriden.
It is recommended that subnet_cmds hooks library is not used to manage the subnets when the configuration backend is used as a source of information about the subnets. The subnet_cmds hooks library modifies the local subnets configuration (in the server's memory), not in the database. Use the cb_cmds hooks library to manage the subnets information in the database instead.
In order to use the Kea CB feature, the Kea 1.6.0 version or later is
required. The mysql_cb open source hooks library
implementing the Configuration Backend for MySQL must be compiled and
loaded by the DHCP servers. This hooks library is compiled when the
--with-mysql
configuration switch is used during
Kea build. The MySQL C client libraries must be installed
as explained in the Section 3.5, “DHCP Database Installation and Configuration”.
Any existing MySQL schema must be upgraded to the latest schema required by the particular Kea version using kea-admin tool described in Section 4.2, “The kea-admin Tool”.
The cb_cmds premium hooks library is available to ISC paid supported customers, which provides a complete set of commands to manage the servers' configuration information within the database. This library can be attached to both DHCPv4 and DHCPv6 server instances. It is still possible to manage the configuration information without the cb_cmds hooks library with commonly available tools such as MySQL Workbench or command line MySQL client, by directly working with the database.
Refer to the Section 15.4.8, “cb_cmds: Configuration Backend Commands” for the details regarding the cb_cmds hooks library.
The DHCPv4 and DHCPv6 server specific configuration of the CB as well as the list of supported configuration parameters can be found in the Section 8.14, “Configuration Backend in DHCPv4” and Section 9.19, “Configuration Backend in DHCPv6” respectively.
The configuration database is designed to store the 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, finally, each server may have its own non-shared configuration.
The configuration elements in the database are associated with the servers by "server tags". 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 the DHCPv4 and the DHCPv6 server respectively.
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 the High Availability peers, there is no need to configure the server tags for these servers in the database. The database by default includes the logical server all, which is used as a keyword to indicate that the particular piece of configuration must be shared between all servers connecting to the database. The all server can't be deleted or modified. It is not even returned among other servers as a result of the remote-server[46]-get-all commands. Also, slightly different rules may apply to "all" keyword than to any user defined server when running the commands provided by the cb_cmds hooks library (see Section 15.4.8, “cb_cmds: Configuration Backend Commands” for details).
In the simplest case there are no server tags defined in the configuration database and all connecting servers will get the same configuration regardless of the server tag they are using. The server tag that the particular Kea instance presents to the database to fetch its configuration is specified in the Kea configuration file, using the config-control map (please refer to the Section 8.14.2, “Enabling Configuration Backend” and Section 9.19.2, “Enabling Configuration Backend” for details).
All Kea instances presenting the same server tag to the configuration database are given the same configuration. It is the administrator's choice whether multiple Kea instances use the same server tag or each Kea instance is using a different sever tag. Also, 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 case the server will be given the configuration specified for "all" servers.
In order to differentiate the configurations between the Kea servers, a collection of the server tags used by the servers must be stored in the database. For the DHCPv4 and DHCPv6 servers, it can be done using the commands described in Section 15.4.8.2.5, “remote-server4-set, remote-server6-set commands” and Section 15.4.8.2.5, “remote-server4-set, remote-server6-set commands”. Next, the server tags can 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 and other configuration elements may be associated with exactly one server tag. The former configuration elements are referred to as shareable configuration elements and the latter are referred to as non-shareable configuration elements. The Section 8.14, “Configuration Backend in DHCPv4” and Section 9.19, “Configuration Backend in DHCPv6” list the DHCP specific shareable and non-shareable configuration elements. However, in this section we want to briefly explain the difference between them.
The shareable configuration element is the one having some unique property identifying it and which instance may appear only once in the database. An example of the shareable DHCP element is a subnet instance. The subnet is a part of the network topology and we assume that the particular subnet may have only one definition within this network. The subnet has two unique identifiers: subnet id and the subnet prefix. The subnet identifier is used in Kea to uniquely identify the subnet and to connect it with other configuration elements, e.g. in host reservations. The subnet identifier uniquely identifies the subnet within the network. Some commands provided by the cb_cmds hooks library allow for accessing the subnet information by subnet identifier (or prefix) and explicitly prohibit using the server tag to access the subnet. This is because, in a general case, the subnet definition is associated with multiple servers rather than 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.
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.
Unlike the shareable element, the 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). The non-shareable element only exists within the context of the server. An example of the non-shareable element in DHCP is a global parameter, e.g. renew-timer. The renew timer is the value to be used by the particular server and only this server. Other servers may have their respective renew timers set to the same or different value. The renew timer is the parameter which has no unique identifier by which it could be accessed, modified or otherwise used. The 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 commands described in Section 15.4.8.2.7, “remote-global-parameter4-get, remote-global-parameter6-get commands” allow for fetching the value of the global parameter 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 the given name in the database.
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 some server (or the logical server "all").
The terms "shareable" and "non-shareable" only apply to the associations with user defined servers. All configuration elements associated with the logical server "all" are by definition shareable. For example: the renew-timer associated with "all" servers is used by all servers connecting to the database which don't have their specific renew timers defined. In the 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 "all" servers.
Be very careful when associating the configuration elements with different server tags. The configuration backend doesn't protect you against some possible misconfigurations that may arise from the wrong server tags' assignments. For example: if you assign a shared network 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 as it doesn't belong to it. In such case, both the shared network and the subnets should be assigned to the same set of servers.
Table of Contents
keactrl is a shell script which controls the startup, shutdown, and reconfiguration of the Kea servers (kea-dhcp4, kea-dhcp6, kea-dhcp-ddns, kea-ctrl-agent, and kea-netconf). It also provides the means for checking the current status of the servers and determining the configuration files in use.
keactrl is run as follows:
keactrl <command> [-c keactrl-config-file] [-s server[,server,...]]
<command> is the one of the commands described in Section 6.4, “Commands”.
The optional -c keactrl-config-file switch
allows specification of an alternate keactrl
configuration file. (--ctrl-config is a synonym for
-c.) In the absence of -c,
keactrl will use the default configuration
file [kea-install-dir]/etc/kea/keactrl.conf
.
The optional -s server[,server,...] switch selects the servers to which the command is issued. (--server is a synonym for -s.) If absent, the command is sent to all servers enabled in the keactrl configuration file. If multiple servers are specified, they should be separated by commas with no intervening spaces.
Depending on requirements, not all of the available servers need
to be run. The keactrl configuration file sets which servers are
enabled and which are disabled. The default configuration
file is [kea-install-dir]/etc/kea/keactrl.conf
,
but this can be overridden on a per-command basis using the
-c switch.
The contents of keactrl.conf
are:
# This is a configuration file for keactrl script which controls # the startup, shutdown, reconfiguration and gathering the status # of the Kea's 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
In the example above, strings of the form @something@ are replaced by the appropriate values when Kea is installed.
The dhcp4
, dhcp6
,
dhcp_ddns
, ctrl_agent
,
and netconf
parameters set to "yes" will configure keactrl to manage
(start, reconfigure) all servers, i.e. kea-dhcp4,
kea-dhcp6, kea-dhcp-ddns,
kea-ctrl-agent, and kea-netconf.
When any of these parameters is set
to "no," the keactrl will ignore
the corresponding server when starting or reconfiguring Kea. Some
daemons (ddns and netconf) are disabled by default.
By default, Kea servers managed by keactrl are
located in [kea-install-dir]/sbin
. This
should work for most installations. If the default
location needs to be altered for any reason, the paths
specified with the dhcp4_srv
,
dhcp6_srv
, dhcp_ddns_srv
ctrl_agent_srv
, and netconf_srv
parameters should be modified.
The kea_verbose
parameter specifies the verbosity
of the servers being started. When kea_verbose
is set to "yes" the logging level of the server is set to DEBUG.
Modification of the logging severity in a configuration file, as
described in Chapter 18, Logging, will have no effect as long
as the kea_verbose
is set to "yes." Setting
it to "no" will cause the server to use the logging levels specified
in the Kea configuration file. If no
logging configuration is specified, the default settings will be
used.
The verbosity for the server is set when it is started. Once
started, the verbosity can be only changed by stopping the server and
starting it again with the new value of the
kea_verbose
parameter.
The following commands are supported by keactrl:
Typical output from keactrl when starting the servers looks similar to the following:
$ 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
Kea's servers create PID files upon startup. These files are used by keactrl to determine whether a given server is running. If one or more servers are running when the start command is issued, the output will look similar to the following:
$ 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.
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 keactrl to decide that the servers are running, when in fact they are not. In such a case the PID files as listed in the keactrl output must be manually deleted.
The following command stops all servers:
$ 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...
Note that the stop command will attempt to stop all servers
regardless of whether they are "enabled" in the keactrl.conf
.
If any of the servers are not running, an informational message
is displayed as in the stop command output below.
$ keactrl stop
INFO/keactrl: kea-dhcp4 isn't running.
INFO/keactrl: kea-dhcp6 isn't running.
INFO/keactrl: kea-dhcp-ddns isn't running.
INFO/keactrl: kea-ctrl-agent isn't running.
INFO/keactrl: kea-netconf isn't running.
As already mentioned, the reconfiguration of each Kea server is triggered by the SIGHUP signal. The reload command sends the SIGHUP signal to the servers that are enabled in the keactrl configuration file and are currently running. When a server receives the SIGHUP signal it re-reads its configuration file and, if the new configuration is valid, uses the new configuration. A reload is executed as follows:
$ keactrl reload
INFO/keactrl: Reloading kea-dhcp4...
INFO/keactrl: Reloading kea-dhcp6...
INFO/keactrl: Reloading kea-dhcp-ddns...
INFO/keactrl: Reloading kea-ctrl-agent...
If any of the servers are not running, an informational message is displayed as in the reload command output below. Note that as of version 1.5.0, kea-netconf does not support the SIGHUP signal. If its configuration has changed, please stop and restart it for the change to take effect. This limitation will be removed in a future release.
$ keactrl stop
INFO/keactrl: kea-dhcp4 isn't running.
INFO/keactrl: kea-dhcp6 isn't running.
INFO/keactrl: kea-dhcp-ddns isn't running.
INFO/keactrl: kea-ctrl-agent isn't running.
INFO/keactrl: kea-netconf isn't running.
Currently keactrl does not report configuration failures when the server is started or reconfigured. To check if the server's configuration succeeded, the Kea log must be examined for errors. By default, this is written to the syslog file.
Sometimes it is useful to check which servers are running. The status reports this, with typical output that looks like:
$ 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
The optional -s switch allows the selection of the servers to which the keactrl command is issued. For example, the following instructs keactrl to stop the kea-dhcp4 and kea-dhcp6 servers and leave the kea-dhcp-ddns and kea-ctrl-agent running:
$ keactrl stop -s dhcp4,dhcp6
Similarly, the following will start only the kea-dhcp4 and kea-dhcp-ddns servers, but not kea-dhcp6 or kea-ctrl-agent.
$ keactrl start -s dhcp4,dhcp_ddns
Note that the behavior of the -s switch with the start and reload commands is different to its behavior with the stop command. On start and reload, keactrl will check if the servers given as parameters to the -s switch are enabled in the keactrl configuration file; if not, the server will be ignored. For stop, however, this check is not made; the command is applied to all listed servers, regardless of whether they have been enabled in the file.
The following keywords can be used with the -s command line option:
Table of Contents
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 "service" 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 Chapter 17, Management API.
The CA can use hook libraries to provide support for additional commands or custom behavior of existing commands. Such hook libraries must implement callouts for the "control_command_receive" hook point. Details about creating new hook libraries and supported hook points can be found in the Kea Developer's Guide.
The CA processes received commands according to the following algorithm:
The following example demonstrates the basic CA configuration.
{ "Control-agent": { "http-host": "10.20.30.40", "http-port": 8080, "control-sockets": { "dhcp4": { "comment": "main server", "socket-type": "unix", "socket-name": "/path/to/the/unix/socket-v4" }, "dhcp6": { "socket-type": "unix", "socket-name": "/path/to/the/unix/socket-v6", "user-context": { "version": 3 } }, "d2": { "socket-type": "unix", "socket-name": "/path/to/the/unix/socket-d2" }, }, "hooks-libraries": [ { "library": "/opt/local/control-agent-commands.so", "parameters": { "param1": "foo" } } ], "loggers": [ { "name": "kea-ctrl-agent", "severity": "INFO" } ] } }
The http-host and http-port 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 under the URL of http://10.20.30.40:8080/. If these parameters are not specified, the default URL is http://127.0.0.1:8000/
As mentioned in Section 7.1, “Overview”, the CA can forward received commands to the Kea servers for processing. For example, config-get is sent to retrieve the configuration of one of the Kea services. When the CA receives this command, including a service parameter indicating that the client desires to retrieve the configuration of the DHCPv4 server, the CA forwards this command to that server and passes the received response back to the client. More about the service parameter and the general structure of commands can be found in Chapter 17, Management API.
The CA uses UNIX domain sockets to forward control commands and receive
responses from other Kea services. The dhcp4,
dhcp6, and d2 maps
specify the files to which UNIX domain sockets are bound. In
the configuration above, the CA will connect to the DHCPv4 server
via /path/to/the/unix/socket-v4
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 this server)
must match. Consult Section 8.9, “Management API for the DHCPv4 Server”,
Section 9.14, “Management API for the DHCPv6 Server” and
Section 12.3.2, “Management API for the D2 Server” to learn how the socket
configuration is specified for the DHCPv4, DHCPv6 and D2 services.
"dhcp4-server", "dhcp6-server" and "d2-server" were renamed to "dhcp4", "dhcp6" and "d2" respectively in Kea 1.2. If you are migrating from Kea 1.2, you must modify your CA configuration to use this new naming convention.
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.
User contexts can be specified on either global scope, control socket, or loggers. One other useful feature is the ability to store comments or descriptions; the parser translates a "comment" entry into a user context with the entry, which allows a comment to be attached within the configuration itself.
Hooks libraries can be loaded by the Control Agent in the same way as they are loaded by the DHCPv4 and DHCPv6 servers. The CA currently supports one hook point - 'control_command_receive' - which makes it possible to delegate processing of some commands to the hooks library. The hooks-libraries list contains the list of hooks libraries that should be loaded by the CA, along with their configuration information specified with parameters.
Please consult Chapter 18, Logging for the details how to configure logging. The CA's root logger's name is kea-ctrl-agent, as given in the example above.
The Control Agent does not natively support secure HTTP connections like
SSL or TLS. In order to setup a secure connection, please use one
of the available third-party HTTP servers and configure it to run
as a reverse proxy to the Control Agent. Kea has been tested with
two major HTTP server implentations working as a reverse proxy:
Apache2 and nginx. Example configurations, including extensive
comments, are provided in the doc/examples/https/
directory.
The reverse proxy forwards HTTP requests received over a secure connection to the Control Agent using unsecured HTTP. Typically, the reverse proxy and the Control Agent are running on the same machine, but it is possible to configure them to run on separate machines as well. In this case, security depends on the protection of the communications between the reverse proxy and the Control Agent.
Apart from providing the encryption layer for the control channel, a reverse proxy server is also often used for authentication of the controlling clients. In this case, the client must present a valid certificate when it connects via reverse proxy. The proxy server authenticates the client by checking whether the presented certificate is signed by the certificate authority used by the server.
To illustrate this, the following is a sample configuration for the nginx server running as a reverse proxy to the Kea Control Agent. The server enables authentication of the clients using certificates.
# The server certificate and key can be generated as follows: # # openssl genrsa -des3 -out kea-proxy.key 4096 # openssl req -new -x509 -days 365 -key kea-proxy.key -out kea-proxy.crt # # The CA certificate and key can be generated as follows: # # openssl genrsa -des3 -out ca.key 4096 # openssl req -new -x509 -days 365 -key ca.key -out ca.crt # # # The client certificate needs to be generated and signed: # # openssl genrsa -des3 -out kea-client.key 4096 # openssl req -new -key kea-client.key -out kea-client.csr # openssl x509 -req -days 365 -in kea-client.csr -CA ca.crt \ # -CAkey ca.key -set_serial 01 -out kea-client.crt # # Note that the 'common name' value used when generating the client # and the server certificates must differ from the value used # for the CA certificate. # # The client certificate must be deployed on the client system. # In order to test the proxy configuration with 'curl' run # command similar to the following: # # curl -k --key kea-client.key --cert kea-client.crt -X POST \ # -H Content-Type:application/json -d '{ "command": "list-commands" }' \ # https://kea.example.org/kea # # # # nginx configuration starts here. events { } http { # HTTPS server server { # Use default HTTPS port. listen 443 ssl; # Set server name. server_name kea.example.org; # Server certificate and key. ssl_certificate /path/to/kea-proxy.crt; ssl_certificate_key /path/to/kea-proxy.key; # Certificate Authority. Client certificate must be signed by the CA. ssl_client_certificate /path/to/ca.crt; # Enable verification of the client certificate. ssl_verify_client on; # For URLs such as https://kea.example.org/kea, forward the # requests to http://127.0.0.1:8080. location /kea { proxy_pass http://127.0.0.1:8080; } } }
Note that the configuration snippet provided above is for testing purposes only. It should be modified according to the security policies and best practices of your organization.
When you use an HTTP client without TLS support as
kea-shell, you can use an HTTP/HTTPS translator such as stunnel
in client mode. A sample configuration is provided in the
doc/examples/https/shell/
directory.
The CA is started by running its binary and specifying the configuration file it should use. For example:
$ ./kea-ctrl-agent -c /usr/local/etc/kea/kea-ctrl-agent.conf
It can be started by keactrl as well (see Chapter 6, Managing Kea with keactrl).
For an example of a tool that can take advantage of the RESTful API, see Chapter 19, The Kea Shell.
Table of Contents
It is recommended that the Kea DHCPv4 server be started and stopped using keactrl (described in Chapter 6, Managing Kea with keactrl); however, it is also possible to run the server directly. It accepts the following command-line switches:
file
-
specifies the configuration file. This is the only mandatory
switch.
server-port
-
specifies the local UDP port on which the server will listen.
This is only useful during testing, as a DHCPv4 server
listening on ports other than the standard ones will not
be able to handle regular DHCPv4 queries.
client-port
-
specifies the remote UDP port to which the server will send
all responses. This is only useful during testing, as a
DHCPv4 server sending responses to ports other than the
standard ones will not be able to handle regular DHCPv4
queries.
file
-
specifies a configuration file to be tested. Kea-dhcp4
will load it, check it, and exit. 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.
config.report
file produced by
./configure
; it is embedded in the
executable binary.
On startup, the server will detect available network interfaces and will attempt to open UDP sockets on all interfaces mentioned in the configuration file. Since the DHCPv4 server opens privileged ports, it requires root access. Make sure you run this daemon as root.
During startup, the server will attempt to create a PID file of the form: [runstatedir]/kea/[conf name].kea-dhcp4.pid where:
If the file already exists and contains the PID of a live process, the server will issue a DHCP4_ALREADY_RUNNING log message and exit. 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.
The server can be stopped using the kill command. When running in a console, the server can also be shut down by pressing ctrl-c. It detects the key combination and shuts down gracefully.
This section explains how to configure the DHCPv4 server using a configuration file. Before DHCPv4 is started, its configuration file has to be created. The basic configuration is as follows:
{ # DHCPv4 configuration starts in this line "Dhcp4": { # First we set up global values "valid-lifetime": 4000, "renew-timer": 1000, "rebind-timer": 2000, # Next we setup the interfaces to be used by the server. "interfaces-config": { "interfaces": [ "eth0" ] }, # And we specify the type of lease database "lease-database": { "type": "memfile", "persist": true, "name": "/var/lib/kea/dhcp4.leases" }, # Finally, we list the subnets from which we will be leasing addresses. "subnet4": [ { "subnet": "192.0.2.0/24", "pools": [ { "pool": "192.0.2.1 - 192.0.2.200" } ] } ] # DHCPv4 configuration ends with the next line } }
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.
The lines starting with a hash (#) are comments and are ignored by the server; they do not impact its operation in any way.
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 Dhcp4.
In the current Kea release it is possible to specify configurations of multiple modules within a single configuration file, but this is not recommended and support for it will be removed in the future releases. The only object, besides the one specifying module configuration, which can (and usually was) included in the same file is Logging. However, we don't include this object in the example above for clarity and its content, the list of loggers, should now be inside the Dhcp4 object instead of the deprecated object.
The Dhcp4 configuration starts with the "Dhcp4": { 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 Dhcp4 configuration.
In the general case, the order in which those parameters appear does not matter, but there are two caveats. The first one is to remember that the configuration file must be well-formed JSON. That means 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, keep in mind that 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 your configuration file.
Moving onto the DHCPv4 configuration elements, the first few elements define some global parameters. valid-lifetime defines how long the addresses (leases) given out by the server are valid. If nothing changes, a client that got an address is allowed to use it for 4000 seconds. (Note that integer numbers are specified as is, without any quotes around them.) renew-timer and rebind-timer are values (also in seconds) that define T1 and T2 timers that govern when the client will begin the renewal and rebind procedures.
The interfaces-config map specifies the server configuration concerning the network interfaces, on which the server should listen to the DHCP messages. The interfaces 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 interfaces-config command should look like this:
"interfaces-config": { "interfaces": [ "eth0", "eth1" ] },
The next couple of 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 file. This is a very simple configuration; usually the lease database configuration is more extensive and contains additional parameters. Note that lease-database is an object and opens up a new scope, using an opening brace. Its parameters (just one in this example - type) 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 Dhcp4 definition follow, a trailing comma is present.
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' requests. It defines all subnets from which the server is expected to receive DHCP requests. The subnets are specified with the subnet4 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 has to have at least two parameters: subnet (which defines the whole subnet) and pools (which is a list of dynamically allocated pools that are governed by the DHCP server).
The example contains a single subnet. If more than one were defined, additional elements in the subnet4 parameter would be specified and separated by commas. For example, to define three subnets, the following syntax would be used:
"subnet4": [ { "pools": [ { "pool": "192.0.2.1 - 192.0.2.200" } ], "subnet": "192.0.2.0/24" }, { "pools": [ { "pool": "192.0.3.100 - 192.0.3.200" } ], "subnet": "192.0.3.0/24" }, { "pools": [ { "pool": "192.0.4.1 - 192.0.4.254" } ], "subnet": "192.0.4.0/24" } ]
Note that indentation is optional and is used for aesthetic purposes only. In some cases it may be preferable to use more compact notation.
After all the parameters have been specified, we have two contexts open: global and Dhcp4, hence we need two closing curly brackets to close them.
All leases issued by the server are stored in the lease database. Currently there are four database backends available: memfile (which is the default backend), MySQL, PostgreSQL, and Cassandra.
The server is able to store lease data in different repositories. Larger deployments may elect to store leases in a database. Section 8.2.2.2, “Lease Database Configuration” describes this option. In typical smaller deployments though, the server will store 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.
The configuration of the file backend (Memfile) is controlled through
the Dhcp4/lease-database parameters. The type parameter
is mandatory and it specifies which storage for leases the server should use.
The value of "memfile"
indicates that the file should
be used as the storage. The following list gives additional optional
parameters that can be used to configure the Memfile backend.
true
at all times during the server's normal
operation. Not writing leases to disk means that if a server is restarted
(e.g. after a power failure), it will not know what addresses have been
assigned. As a result, it may hand out addresses to new clients that are
already in use. The value of false
is mostly useful
for performance-testing purposes. The default value of the
persist parameter is true
,
which enables writing lease updates
to the lease file.
"[kea-install-dir]/var/lib/kea/kea-leases4.csv"
.
3600
. A value of 0
disables the LFC.
An example configuration of the Memfile backend is presented below:
"Dhcp4": { "lease-database": {"type": "memfile"
,"persist": true
,"name": "/tmp/kea-leases4.csv",
"lfc-interval": 1800
} }
This configuration selects the /tmp/kea-leases4.csv
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 30 minutes.
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 the client, the new lease information must be recorded in the lease file. For performance reasons, the server does not update the existing client's 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 the server startup, it assumes that the latest lease entry for the client is the valid one. The previous entries are discarded, meaning that the server can re-construct the 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's startup and reconfiguration, as it needs to process a larger number of lease entries.
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 lfc-interval should be. Note, however, that the LFC takes time and thus it is possible (although unlikely) that, if the lfc-interval 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 detects that the previous cleanup is still in progress. But it implies that the actual cleanups will be triggered more rarely than configured. Moreover, triggering a new cleanup adds overhead to the server, which will not be 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 lfc-interval value is selected in a way that would allow for the LFC to complete the cleanup before a new cleanup is triggered.
Lease file cleanup is performed by a separate process (in the background) to avoid a performance impact on the server process. To avoid the conflicts between two processes both using the same lease files, the LFC process starts with Kea opening new lease file and 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 is located later in this Kea Administrator's Reference Manual: Chapter 13, The LFC Process.
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.
Lease database configuration is controlled through the Dhcp4/lease-database parameters. The type of the database must be set to "memfile", "mysql", "postgresql", or "cql", e.g.:
"Dhcp4": { "lease-database": { "type": "mysql"
, ... }, ... }
Next, the name of the database to hold the leases must be set; this is the name used when the database was created (see Section 4.3.2.1, “First-Time Creation of the MySQL Database”, Section 4.3.3.1, “First-Time Creation of the PostgreSQL Database”, or Section 4.3.4.1, “First-Time Creation of the Cassandra Database”).
"Dhcp4": { "lease-database": { "name": "database-name
"
, ... }, ... }
For Cassandra:
"Dhcp4": { "lease-database": { "keyspace": "database-name
"
, ... }, ... }
If the database is located on a different system from the DHCPv4 server, the database host name must also be specified. (It should be noted that this configuration may have a severe impact on server performance.):
"Dhcp4": { "lease-database": { "host": "remote-host-name
"
, ... }, ... }
Normally, the database will be on the same machine as the DHCPv4 server. In this case, set the value to the empty string:
"Dhcp4": { "lease-database": { "host" : ""
, ... }, ... }
Should the database use a port different than the default, it may be specified as well:
"Dhcp4": { "lease-database": { "port" : 12345
, ... }, ... }
Should the database be located on a different system, you may need to specify a longer interval for the connection timeout:
"Dhcp4": { "lease-database": { "connect-timeout" : timeout-in-seconds
, ... }, ... }
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.
The maximum number of times the server will automatically attempt to reconnect to the lease database after connectivity has been lost may be specified:
"Dhcp4": { "lease-database": { "max-reconnect-tries" : number-of-tries
, ... }, ... }
If the server is unable to reconnect to the database after making the maximum number of attempts the server will exit. A value of zero (the default) disables automatic recovery and the server will exit immediately upon detecting a loss of connectivity (MySQL and Postgres only). For Cassandra, Kea uses a Cassandra interface that connects to all nodes in a cluster at the same time. Any connectivity issues should be handled by internal Cassandra mechanisms.
The number of milliseconds the server will wait between attempts to reconnect to the lease database after connectivity has been lost may also be specified:
"Dhcp4": { "lease-database": { "reconnect-wait-time" : number-of-milliseconds
, ... }, ... }
The default value for MySQL and Postgres is 0, which disables automatic recovery and causes the server to exit immediately upon detecting the loss of connectivity. The default value for Cassandra is 2000 ms.
Automatic reconnection to database backends is configured individually per backend. This allows you to tailor the recovery parameters to each backend you use. We do suggest that you enable it either for all backends or no backends so you have consistent behavior. Losing connectivity to a backend for which reconnect is disabled will result 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.
"Dhcp4": { "lease-database": { "contact-points" : "192.0.2.1,192.0.2.2"
, ... }, ... }
Finally, the credentials of the account under which the server will access the database should be set:
"Dhcp4": { "lease-database": {"user": "
,user-name
""password": "
, ... }, ... }password
"
If there is no password to the account, set the password to the empty string "". (This is also the default.)
The Cassandra backend is configured slightly differently. Cassandra has a concept of contact points that could be used to contact the cluster, instead of a single IP or hostname. It takes a list of comma-separated IP addresses, which may be specified as:
"Dhcp4": {
"lease-database": {
"type": "cql",
"contact-points": "ip-address1, ip-address2 [,...]
"
,
...
},
...
}
Cassandra also supports a number of optional parameters:
For example, a complex Cassandra configuration with most parameters specified could look as follows:
"Dhcp4": { "lease-database": { "type": "cql", "keyspace": "keatest", "contact-points": "192.0.2.1, 192.0.2.2, 192.0.2.3", "port": 9042, "reconnect-wait-time": 2000, "connect-timeout": 5000, "request-timeout": 12000, "tcp-keepalive": 1, "tcp-nodelay": true }, ... }
Similar parameters can be specified for the hosts database.
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, a Kea server opens independent connections for each purpose, be it lease or hosts information. This arrangement 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, PostgreSQL, and Cassandra.
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 (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.
In fact, 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 is 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.
Hosts database configuration is controlled through the Dhcp4/hosts-database parameters. If enabled, the type of database must be set to "mysql" or "postgresql".
"Dhcp4": { "hosts-database": { "type": "mysql"
, ... }, ... }
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 Section 4.3, “Supported Backends” for instructions on how to set up the desired database type).
"Dhcp4": { "hosts-database": { "name": "database-name
"
, ... }, ... }
If the database is located on a different system than the DHCPv4 server, the database host name must also be specified. (Again it should be noted that this configuration may have a severe impact on server performance.)
"Dhcp4": { "hosts-database": { "host": remote-host-name
, ... }, ... }
Normally, the database will be on the same machine as the DHCPv4 server. In this case, set the value to the empty string:
"Dhcp4": { "hosts-database": { "host" : ""
, ... }, ... }
Should the database use a port different than the default, it may be specified as well:
"Dhcp4": { "hosts-database": { "port" : 12345
, ... }, ... }
The maximum number of times the server will automatically attempt to reconnect to the host database after connectivity has been lost may be specified:
"Dhcp4": { "hosts-database": { "max-reconnect-tries" : number-of-tries
, ... }, ... }
If the server is unable to reconnect to the database after making the maximum number of attempts the server will exit. A value of zero (the default) disables automatic recovery and the server will exit immediately upon detecting a loss of connectivity (MySQL and Postgres only).
The number of milliseconds the server will wait between attempts to reconnect to the host database after connectivity has been lost may also be specified:
"Dhcp4": { "hosts-database": { "reconnect-wait-time" : number-of-milliseconds
, ... }, ... }
The default value for MySQL and Postgres is 0, which disables automatic recovery and causes the server to exit immediately upon detecting the loss of connectivity. The default value for Cassandra is 2000 ms.
Automatic reconnection to database backends is configured individually per backend. This allows you to tailor the recovery parameters to each backend you use. We do suggest that you enable it either for all backends or no backends so you have consistent behavior. Losing connectivity to a backend for which reconnect is disabled will result 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.
Finally, the credentials of the account under which the server will access the database should be set:
"Dhcp4": { "hosts-database": {"user": "
,user-name
""password": "
, ... }, ... }password
"
If there is no password to the account, set the password to the empty string "". (This is also the default.)
The multiple storage extension uses a similar syntax; a configuration is placed into a "hosts-databases" list instead of into a "hosts-database" entry as in:
"Dhcp4": { "hosts-databases": [ { "type": "mysql"
, ... }, ... ], ... }
For additional Cassandra-specific parameters, see Section 8.2.2.3, “Cassandra-Specific Parameters”.
In some deployments the database 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.
Kea host database backends operate with an implicit configuration to both read from and write to the database. If the database 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 "read-only" mode. This is controlled by the readonly boolean parameter as follows:
"Dhcp4": { "hosts-database": { "readonly": true
, ... }, ... }
Setting this parameter to false
configures the
database backend to operate in "read-write" mode, which is also the default
configuration if the parameter is not specified.
The readonly parameter is currently only supported for MySQL and PostgreSQL databases.
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:
"Dhcp4": {
"interfaces-config": {
"interfaces": [ "*"
]
}
...
},
The asterisk plays the role of a wildcard and means "listen on all interfaces." However, it is usually a good idea to explicitly specify interface names:
"Dhcp4": {
"interfaces-config": {
"interfaces": [ "eth1", "eth3"
]
},
...
}
It is possible to use a wildcard interface name (asterisk) concurrently with explicit interface names:
"Dhcp4": {
"interfaces-config": {
"interfaces": [ "eth1", "eth3", "*"
]
},
...
}
It is anticipated that this form of usage will only be used when it is desired to temporarily override a list of interface names and listen on all interfaces.
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:
"Dhcp4": {
"interfaces-config": {
"interfaces": [ "eth1/10.0.0.1", "eth3/192.0.2.3"
]
},
...
}
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:
"Dhcp4": {
"interfaces-config": {
"interfaces": [ "eth1/10.0.0.1", "eth1/10.0.0.2"
]
},
...
}
Alternatively, if the server should listen on all addresses for the particular interface, an interface name without any address should be specified.
Kea supports responding to directly connected clients which don't 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). It is also troublesome to handle traffic on multiple IPv4 addresses assigned to the same interface, as raw sockets are bound to the interface; plus, advanced packet filtering techniques (e.g. using the BPF) have to be used to receive unicast traffic on the desired addresses assigned to the interface, rather than capturing whole traffic reaching the interface to which the raw socket is bound. Therefore, in deployments where the server doesn't have to provision the directly connected clients and only receives the unicast packets from the relay agents, the DHCP server should be configured to use IP/UDP datagram sockets instead of raw sockets. The following configuration demonstrates how this can be achieved:
"Dhcp4": {
"interfaces-config": {
"interfaces": [ "eth1", "eth3"
],
"dhcp-socket-type": "udp"
},
...
}
The dhcp-socket-type specifies that the IP/UDP sockets will
be opened on all interfaces on which the server listens, i.e. "eth1" and
"eth3" in our case. If dhcp-socket-type is set to
raw
, it configures the server to use raw sockets
instead. If the dhcp-socket-type value is not specified, the
default value raw
is used.
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. 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 interface, the "interface-name/address" notation should be used.
Specifying the value raw
as the socket type
doesn't guarantee that the raw sockets will be used! The use of raw sockets
to handle the traffic from the directly connected clients is currently
supported on Linux and BSD systems only. If the raw sockets are not
supported on your particular OS, the server will issue a warning and
fall back to using IP/UDP sockets.
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 will be sent as regular traffic and the outbound
interface will be determined by the routing tables. This kind of asymmetric
traffic is uncommon, but valid. Kea now supports a parameter called
outbound-interface that controls this behavior. It supports
two values. The first one, same-as-inbound
, tells Kea
to send back the response on the same interface where the query packet was received. This
is the default behavior. The second one, use-routing
,
tells Kea to send regular UDP packets and let the kernel's routing table
determine the most appropriate interface. This only works when
dhcp-socket-type is set to udp
.
An example configuration looks as follows:
"Dhcp4": {
"interfaces-config": {
"interfaces": [ "eth1", "eth3" ],
"dhcp-socket-type": "udp",
"outbound-interface": "use-routing"
},
...
}
Interfaces are re-detected at each reconfiguration. This behavior
can be disabled by setting the re-detect value to
false
, for instance:
"Dhcp4": { "interfaces-config": { "interfaces": ["eth1", "eth3"
], "re-detect":false
}, ... }
Note that interfaces are not re-detected during config-test.
Usually loopback interfaces (e.g. the "lo" or "lo0" interface) may not be configured, but if a loopback interface is explicitely configured and IP/UDP sockets are specified, the loopback interface is accepted.
For example, it can be used to run Kea in a FreeBSD jail having only a loopback interface, to service a relayed DHCP request:
"Dhcp4": {
"interfaces-config": {
"interfaces": [ "lo0"
],
"dhcp-socket-type": "udp"
},
...
}
The use of UDP sockets has certain benefits in deployments where the server receives only relayed traffic; these benefits are mentioned in Section 8.2.4, “Interface Configuration”. From the administrator's perspective it is often desirable to configure the system's firewall to filter out the 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's operation.
In this section we are focusing on the case when the server receives the DHCPINFORM message from the client via a relay. According to RFC 2131, the server should unicast the DHCPACK response to the address carried in the "ciaddr" 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 will first use ARP to obtain the client's link-layer address to be inserted into the frame's 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.
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.
Note that the issue described in this section is not observed when the 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 'chaddr' field of the DHCPINFORM message into the link layer.
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.
The subnet identifier is a unique number associated with a particular subnet. In principle, it is used to associate clients' leases with their respective subnets. When a subnet identifier is not specified for a subnet being configured, it will be automatically assigned by the configuration mechanism. The identifiers are assigned from 1 and are monotonically increased for each subsequent subnet: 1, 2, 3 ....
If there are multiple subnets configured with auto-generated identifiers and one of them is removed, the subnet identifiers may be renumbered. For example: if there are four subnets and the third is removed, the last subnet will be assigned the identifier that the third subnet had before removal. As a result, the leases stored in the lease database for subnet 3 are now associated with subnet 4, something that may have unexpected consequences. The only remedy for this issue at present is to manually specify a unique identifier for each subnet.
The following configuration will assign the specified subnet identifier to the newly configured subnet:
"Dhcp4": {
"subnet4": [
{
"subnet": "192.0.2.0/24",
"id": 1024
,
...
}
]
}
This identifier will not change for this subnet unless the "id" parameter is removed or set to 0. The value of 0 forces auto-generation of the subnet identifier.
The subnet prefix is the second way to identify a subnet. It does not need to have the address part to match the prefix length, for instance this configuration is accepted:
"Dhcp4": {
"subnet4": [
{
"subnet": "192.0.2.1/24"
,
...
}
]
}
Even there is another subnet with the "192.0.2.0/24" prefix: only the textual form of subnets are compared to avoid duplicates.
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 range 192.0.2.10 to 192.0.2.20 are going to be managed by the Dhcp4 server. Such a configuration can be achieved in the following way:
"Dhcp4": {
"subnet4": [
{
"subnet": "192.0.2.0/24",
"pools": [
{ "pool": "192.0.2.10 - 192.0.2.20" }
],
...
}
]
}
Note that subnet is defined as a simple string, but the pools 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.
Each pool is a structure that contains the parameters that describe a single pool. Currently there is only one parameter, pool, which gives the range of addresses in the pool.
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 be also be managed by the server. It could be written as 192.0.2.64 to 192.0.2.127. Alternatively, it can be expressed more simply as 192.0.2.64/26. Both formats are supported by Dhcp4 and can be mixed in the pool list. For example, one could define the following pools:
"Dhcp4": {
"subnet4": [
{
"subnet": "192.0.2.0/24",
"pools": [
{ "pool": "192.0.2.10-192.0.2.20" },
{ "pool": "192.0.2.64/26" }
]
,
...
}
],
...
}
White space in pool definitions is ignored, so spaces before and after the hyphen are optional. They can be used to improve readability.
The number of pools is not limited, but for performance reasons it is recommended to use as few as possible.
The server may be configured to serve more than one subnet:
"Dhcp4": { "subnet4": [ { "subnet": "192.0.2.0/24", "pools": [ { "pool": "192.0.2.1 - 192.0.2.200" } ], ... }, { "subnet": "192.0.3.0/24", "pools": [ { "pool": "192.0.3.100 - 192.0.3.200" } ], ... }, { "subnet": "192.0.4.0/24", "pools": [ { "pool": "192.0.4.1 - 192.0.4.254" } ], ... } ] }
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 will also be 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, please use the "min-max" notation.
To send specific, fixed values use the following two parameters:
The server will only send T2 if it is less than valid lease time. T1 will only be sent if a: T2 is being sent and T1 is less than T2 or b: T2 is not being sent and T1 is less than the valid lease time.
Calculating the values is controlled by the following three parameters.
One of the major features of the DHCPv4 server is 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. "Domain Server", and options which require special behavior, e.g. "Client FQDN", which is returned to the client if the client has included this option in its message to the server.
Table 8.1, “List of Standard DHCPv4 Options” 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 some 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.
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.
"Dhcp4": {
"option-data": [
{
"name": "domain-name-servers",
"code": 6,
"space": "dhcp4",
"csv-format": true,
"data": "192.0.2.1, 192.0.2.2"
},
...
]
}
Note that only one of name or code is required; you don't need to specify both. Space has a default value of "dhcp4", so you can skip this as well if you define a regular (not encapsulated) DHCPv4 option. Finally, csv-format defaults to true, so it too can be skipped, unless you want to specify the option value as a hexadecimal string. Therefore, the above example can be simplified to:
"Dhcp4": {
"option-data": [
{
"name": "domain-name-servers",
"data": "192.0.2.1, 192.0.2.2"
},
...
]
}
Defined options are added to the response when the client requests them at a few exceptions, which are always added. To enforce the addition of a particular option set the always-send flag to true as in:
"Dhcp4": {
"option-data": [
{
"name": "domain-name-servers",
"data": "192.0.2.1, 192.0.2.2",
"always-send": true
},
...
]
}
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):
"Dhcp4": { "option-data": [ {"name": "domain-name-servers", "data": "192.0.2.1, 192.0.2.2", "always-send": true
}, ... ], "subnet4": [ { "subnet": "192.0.3.0/24", "option-data": [ {"name": "domain-name-servers", "data": "192.0.3.1, 192.0.3.2"
}, ... ], ... }, ... ], ... }
The Domain Name Servers option is always added to responses (the always-send is "sticky") but the value is the subnet one when the client is localized in the subnet.
The name parameter specifies the option name. For a list of currently supported names, see Table 8.1, “List of Standard DHCPv4 Options” below. The code 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 "dhcp4" as these are standard DHCPv4 options. For other option spaces, including custom option spaces, see Section 8.2.14, “Nested DHCPv4 Options (Custom Option Spaces)”. 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. Data is specified as normal text, with values separated by commas if more than one value is allowed.
Options can also be configured as hexadecimal values. If csv-format is set to false, option data must be specified as a hexadecimal string. The following commands configure the domain-name-servers option for all subnets with the following addresses: 192.0.3.1 and 192.0.3.2. Note that csv-format is set to false.
"Dhcp4": {
"option-data": [
{
"name": "domain-name-servers",
"code": 6,
"space": "dhcp4",
"csv-format": false,
"data": "C0 00 03 01 C0 00 03 02"
},
...
],
...
}
Kea supports the following formats when specifying hexadecimal data:
Care should be taken to use proper encoding when using hexadecimal format. Kea's ability to validate data correctness in hexadecimal is limited.
Most of the parameters in the "option-data" structure are optional and can be omitted in some circumstances as discussed in Section 8.2.15, “Unspecified Parameters for DHCPv4 Option Configuration”.
It is possible to specify or override options on a per-subnet basis. If clients connected to most of your subnets are expected to get the same values of a given option, you should use global options; you can then override specific values for a small number of subnets. On the other hand, if you use different values in each subnet, it does not make sense to specify global option values; rather, you should set only subnet-specific ones.
The following commands override the global DNS servers option for a particular subnet, setting a single DNS server with address 192.0.2.3:
"Dhcp4": {
"subnet4": [
{
"option-data": [
{
"name": "domain-name-servers",
"code": 6,
"space": "dhcp4",
"csv-format": true,
"data": "192.0.2.3"
},
...
]
,
...
},
...
],
...
}
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. The server's administrator must not try to prioritize assignment of pool-specific options by trying to order pool declarations in the server configuration.
The following configuration snippet demonstrates how to specify the DNS servers option, which will be assigned to a client only if the client obtains an address from the given pool:
"Dhcp4": {
"subnet4": [
{
"pools": [
{
"pool": "192.0.2.1 - 192.0.2.200",
"option-data": [
{
"name": "domain-name-servers",
"data": "192.0.2.3"
},
...
]
,
...
},
...
],
...
},
...
],
...
}
Options can also be specified in class or host reservation scope. The current Kea options precedence order is (from most important): host reservation, pool, subnet, shared network, class, global.
The currently supported standard DHCPv4 options are listed in Table 8.1, “List of Standard DHCPv4 Options”. "Name" and "Code" are the values that should be used as a name/code in the option-data structures. "Type" designates the format of the data; the meanings of the various types is given in Table 8.2, “List of Standard DHCP Option Types”.
When a data field is a string and that string contains the comma (,; U+002C) character, the comma must be escaped with two backslashes (\; U+005C). This double escape is required because both the routine splitting CSV data into fields and JSON use the same escape character; a single escape (\,) would make the JSON invalid. For example, the string "foo,bar" would be represented as:
"Dhcp4": {
"subnet4": [
{
"pools": [
{
"option-data": [
{
"name": "boot-file-name",
"data": "foo\\,bar"
}
]
},
...
],
...
},
...
],
...
}
Some options are designated as arrays, which means that more than one value is allowed in such an option. For example, the option time-servers allows the specification of more than one IPv4 address, enabling clients to obtain the addresses of multiple NTP servers.
Section 8.2.11, “Custom DHCPv4 Options” 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. There is an exception to this rule for standard options for which Kea currently does not provide a definition. In order to use such options, a server administrator must create a definition as described in Section 8.2.11, “Custom DHCPv4 Options” in the 'dhcp4' option space. This definition should match the option format described in the relevant RFC, but the configuration mechanism will allow any option format as it currently has no means to validate it.
Table 8.1. List of Standard DHCPv4 Options
Name | Code | Type | Array? | Returned if not requested? |
---|---|---|---|---|
time-offset | 2 | int32 | false | false |
routers | 3 | ipv4-address | true | true |
time-servers | 4 | ipv4-address | true | false |
name-servers | 5 | ipv4-address | true | false |
domain-name-servers | 6 | ipv4-address | true | true |
log-servers | 7 | ipv4-address | true | false |
cookie-servers | 8 | ipv4-address | true | false |
lpr-servers | 9 | ipv4-address | true | false |
impress-servers | 10 | ipv4-address | true | false |
resource-location-servers | 11 | ipv4-address | true | false |
boot-size | 13 | uint16 | false | false |
merit-dump | 14 | string | false | false |
domain-name | 15 | fqdn | false | true |
swap-server | 16 | ipv4-address | false | false |
root-path | 17 | string | false | false |
extensions-path | 18 | string | false | false |
ip-forwarding | 19 | boolean | false | false |
non-local-source-routing | 20 | boolean | false | false |
policy-filter | 21 | ipv4-address | true | false |
max-dgram-reassembly | 22 | uint16 | false | false |
default-ip-ttl | 23 | uint8 | false | false |
path-mtu-aging-timeout | 24 | uint32 | false | false |
path-mtu-plateau-table | 25 | uint16 | true | false |
interface-mtu | 26 | uint16 | false | false |
all-subnets-local | 27 | boolean | false | false |
broadcast-address | 28 | ipv4-address | false | false |
perform-mask-discovery | 29 | boolean | false | false |
mask-supplier | 30 | boolean | false | false |
router-discovery | 31 | boolean | false | false |
router-solicitation-address | 32 | ipv4-address | false | false |
static-routes | 33 | ipv4-address | true | false |
trailer-encapsulation | 34 | boolean | false | false |
arp-cache-timeout | 35 | uint32 | false | false |
ieee802-3-encapsulation | 36 | boolean | false | false |
default-tcp-ttl | 37 | uint8 | false | false |
tcp-keepalive-interval | 38 | uint32 | false | false |
tcp-keepalive-garbage | 39 | boolean | false | false |
nis-domain | 40 | string | false | false |
nis-servers | 41 | ipv4-address | true | false |
ntp-servers | 42 | ipv4-address | true | false |
vendor-encapsulated-options | 43 | empty | false | false |
netbios-name-servers | 44 | ipv4-address | true | false |
netbios-dd-server | 45 | ipv4-address | true | false |
netbios-node-type | 46 | uint8 | false | false |
netbios-scope | 47 | string | false | false |
font-servers | 48 | ipv4-address | true | false |
x-display-manager | 49 | ipv4-address | true | false |
dhcp-option-overload | 52 | uint8 | false | false |
dhcp-server-identifier | 54 | ipv4-address | false | true |
dhcp-message | 56 | string | false | false |
dhcp-max-message-size | 57 | uint16 | false | false |
vendor-class-identifier | 60 | string | false | false |
nwip-domain-name | 62 | string | false | false |
nwip-suboptions | 63 | binary | false | false |
nisplus-domain-name | 64 | string | false | false |
nisplus-servers | 65 | ipv4-address | true | false |
tftp-server-name | 66 | string | false | false |
boot-file-name | 67 | string | false | false |
mobile-ip-home-agent | 68 | ipv4-address | true | false |
smtp-server | 69 | ipv4-address | true | false |
pop-server | 70 | ipv4-address | true | false |
nntp-server | 71 | ipv4-address | true | false |
www-server | 72 | ipv4-address | true | false |
finger-server | 73 | ipv4-address | true | false |
irc-server | 74 | ipv4-address | true | false |
streettalk-server | 75 | ipv4-address | true | false |
streettalk-directory-assistance-server | 76 | ipv4-address | true | false |
user-class | 77 | binary | false | false |
slp-directory-agent | 78 | record (boolean, ipv4-address) | true | false |
slp-service-scope | 79 | record (boolean, string) | false | false |
nds-server | 85 | ipv4-address | true | false |
nds-tree-name | 86 | string | false | false |
nds-context | 87 | string | false | false |
bcms-controller-names | 88 | fqdn | true | false |
bcms-controller-address | 89 | ipv4-address | true | false |
client-system | 93 | uint16 | true | false |
client-ndi | 94 | record (uint8, uint8, uint8) | false | false |
uuid-guid | 97 | record (uint8, binary) | false | false |
uap-servers | 98 | string | false | false |
geoconf-civic | 99 | binary | false | false |
pcode | 100 | string | false | false |
tcode | 101 | string | false | false |
netinfo-server-address | 112 | ipv4-address | true | false |
netinfo-server-tag | 113 | string | false | false |
default-url | 114 | string | false | false |
auto-config | 116 | uint8 | false | false |
name-service-search | 117 | uint16 | true | false |
subnet-selection | 118 | ipv4-address | false | false |
domain-search | 119 | fqdn | true | false |
vivco-suboptions | 124 | binary | false | false |
vivso-suboptions | 125 | binary | false | false |
pana-agent | 136 | ipv4-address | true | false |
v4-lost | 137 | fqdn | false | false |
capwap-ac-v4 | 138 | ipv4-address | true | false |
sip-ua-cs-domains | 141 | fqdn | true | false |
rdnss-selection | 146 | record (uint8, ipv4-address, ipv4-address, fqdn) | true | false |
v4-portparams | 159 | record (uint8, psid) | false | false |
v4-captive-portal | 160 | string | false | false |
option-6rd | 212 | record (uint8, uint8, ipv6-address, ipv4-address) | true | false |
v4-access-domain | 213 | fqdn | false | false |
Table 8.2. List of Standard DHCP Option Types
Name | Meaning |
---|---|
binary | An arbitrary string of bytes, specified as a set of hexadecimal digits. |
boolean | A boolean value with allowed values true or false. |
empty | No value; data is carried in suboptions. |
fqdn | Fully qualified domain name (e.g. www.example.com). |
ipv4-address | IPv4 address in the usual dotted-decimal notation (e.g. 192.0.2.1). |
ipv6-address | IPv6 address in the usual colon notation (e.g. 2001:db8::1). |
ipv6-prefix | 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. |
psid | 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 "0011000000000000b" using binary notation). Allowed values for a PSID length are 0 to 16. See RFC 7597 for details about the PSID wire representation. |
record | Structured data that may be comprised of any types (except "record" and "empty"). The array flag applies to the last field only. |
string | Any text. Please note that Kea will silently discard any terminating/trailing nulls from the end of 'string' options when unpacking received packets. This is keeping with RFC 2132, Section 2 |
tuple | A length encoded as an 8- (16- for DHCPv6) bit unsigned integer followed by a string of this length. |
uint8 | 8-bit unsigned integer with allowed values 0 to 255. |
uint16 | 16-bit unsigned integer with allowed values 0 to 65535. |
uint32 | 32-bit unsigned integer with allowed values 0 to 4294967295. |
int8 | 8-bit signed integer with allowed values -128 to 127. |
int16 | 16-bit signed integer with allowed values -32768 to 32767. |
int32 | 32-bit signed integer with allowed values -2147483648 to 2147483647. |
Kea supports custom (non-standard) DHCPv4 options. Assume that we want to define a new DHCPv4 option called "foo" which will have a code 222 and will convey a single, unsigned, 32-bit integer value. We can define such an option by using the following entry in the configuration file:
"Dhcp4": {
"option-def": [
{
"name": "foo",
"code": 222,
"type": "uint32",
"array": false,
"record-types": "",
"space": "dhcp4",
"encapsulate": ""
}, ...
],
...
}
The false value of the array parameter determines that the option does NOT comprise an array of "uint32" values but is, instead, a single value. Two other parameters have been left blank: record-types and encapsulate. The former specifies the comma-separated list of option data fields, if the option comprises a record of data fields. The record-types value should be non-empty if type is set to "record"; 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, it should be left blank. Note that the option-def configuration statement only defines the format of an option and does not set its value(s).
The name, code, and type parameters are required; all others are optional. The array default value is false. The record-types and encapsulate default values are blank (i.e. ""). The default space is "dhcp4".
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.
"Dhcp4": {
"option-data": [
{
"name": "foo",
"code": 222,
"space": "dhcp4",
"csv-format": true,
"data": "12345"
}, ...
],
...
}
New options can take more complex forms than simple use of primitives (uint8, string, ipv4-address, etc); it is possible to define an option comprising a number of existing primitives.
For example, assume 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:
"Dhcp4": {
"option-def": [
{
"name": "bar",
"code": 223,
"space": "dhcp4",
"type": "record",
"array": false,
"record-types": "ipv4-address, uint16, boolean, string",
"encapsulate": ""
}, ...
],
...
}
The type is set to "record" to indicate that the option contains multiple values of different types. These types are given as a comma-separated list in the record-types field and should be ones from those listed in Table 8.2, “List of Standard DHCP Option Types”.
The values of the option are set as follows:
"Dhcp4": {
"option-data": [
{
"name": "bar",
"space": "dhcp4",
"code": 223,
"csv-format": true,
"data": "192.0.2.100, 123, true, Hello World"
}
],
...
}
csv-format is set to true to indicate that the data field comprises a command-separated list of values. The values in data must correspond to the types set in the record-types field of the option definition.
When array is set to true and type is set to "record", the last field is an array, i.e. it can contain more than one value, as in:
"Dhcp4": {
"option-def": [
{
"name": "bar",
"code": 223,
"space": "dhcp4",
"type": "record",
"array": true,
"record-types": "ipv4-address, uint16",
"encapsulate": ""
}, ...
],
...
}
The new option content is one IPv4 address followed by one or more 16- bit unsigned integers.
In general, boolean values are specified as true or false, without quotes. Some specific boolean parameters may accept also "true", "false", 0, 1, "0", and "1".
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).
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:
"Dhcp4": {
"client-classes": [
{
"name": "pxeclient",
"test": "option[vendor-class-identifier].text == 'PXEClient'",
"option-def": [
{
"name": "configfile",
"code": 209,
"type": "string"
}
],
...
}, ...
],
...
}
As the Vendor-Specific Information option (code 43) has vendor- specific format, i.e. can carry either raw binary value or sub-options, this mechanism is available for this option too.
In the following example taken from a real configuration, two vendor classes use the option 43 for different and incompatible purposes:
"Dhcp4": { "option-def": [ {"name": "cookie", "code": 1, "type": "string", "space": "APC" }, { "name": "mtftp-ip", "code": 1, "type": "ipv4-address", "space": "PXE" },
... ], "client-classes": [ {"name": "APC", "test": "(option[vendor-class-identifier].text == 'APC'", "option-def": [ { "name": "vendor-encapsulated-options", "type": "empty", "encapsulate": "APC" } ], "option-data": [ { "name": "cookie", "space": "APC", "data": "1APC" }, { "name": "vendor-encapsulated-options" },
... ], ... }, {"name": "PXE", "test": "(option[vendor-class-identifier].text == 'PXE'", "option-def": [ { "name": "vendor-encapsulated-options", "type": "empty", "encapsulate": "PXE" } ], "option-data": [ { "name": "mtftp-ip", "space": "PXE", "data": "0.0.0.0" }, { "name": "vendor-encapsulated-options" },
... ], ... }, ... ], ... }
The definition used to decode a VSI option is:
The local definition of a client class the incoming packet belongs to;
If none, the global definition;
If none, the last-resort definition described in the next section Section 8.2.13, “DHCPv4 Vendor-Specific Options” (backwards-compatible with previous Kea versions).
This last-resort definition for the Vendor-Specific Information option (code 43) is not compatible with a raw binary value. So when there are some known cases where a raw binary value will be used, a client class must be defined with a classification expression matching these cases and an option definition for the VSI option with a binary type and no encapsulation.
Option definitions in client classes are allowed only for this limited option set (codes 43 and from 224 to 254), and only for DHCPv4.
Currently there are two option spaces defined for the DHCPv4 daemon: "dhcp4" (for the top-level DHCPv4 options) and "vendor-encapsulated-options-space", which is empty by default but in which options can be defined. Such options will be carried in the Vendor-Specific Information option (code 43). The following examples show how to define an option "foo" in that space that has a code 1, and comprises an IPv4 address, an unsigned 16-bit integer, and a string. The "foo" option is conveyed in a Vendor-Specific Information option.
The first step is to define the format of the option:
"Dhcp4": {
"option-def": [
{
"name": "foo",
"code": 1,
"space": "vendor-encapsulated-options-space",
"type": "record",
"array": false,
"record-types": "ipv4-address, uint16, string",
"encapsulate": ""
}
],
...
}
(Note that the option space is set to "vendor-encapsulated-options-space".) Once the option format is defined, the next step is to define actual values for that option:
"Dhcp4": {
"option-data": [
{
"name": "foo",
"space": "vendor-encapsulated-options-space",
"code": 1,
"csv-format": true,
"data": "192.0.2.3, 123, Hello World"
}
],
...
}
We also include the Vendor-Specific Information option, the option that conveys our sub-option "foo". This is required; otherwise the option will not be included in messages sent to the client.
"Dhcp4": {
"option-data": [
{
"name": "vendor-encapsulated-options"
}
],
...
}
Alternatively, the option can be specified using its code.
"Dhcp4": {
"option-data": [
{
"code": 43
}
],
...
}
Another popular option that is often somewhat imprecisely called vendor option is option 125. It's proper name is vendor-independent vendor-specific information option or vivso. The idea behind those options is that each vendor has its own unique set of options with their own custom formats. The vendor is identified by a 32 unsigned integer called enterprise-id or vendor-id. For example, vivso with vendor-id 4491 repesents DOCSIS options and you are likely to see many of them when dealing with cable modems.
In Kea each vendor is represented by its own vendor space. Since there are hundreds of vendors and sometimes they use different option definitions for different hardware, it's impossible for Kea to support them all out of the box. Fortunately, it's easy to define support for new vendor options. Let's take an example of Genexis home gateway. This device requires sending vivso 125 option with a suboption 2 that contains a string with TFTP server URL. To support such a device, three steps are needed. First, we need to define option definitions that will explain how the option is supposed to be formed. Second, we will need to define option values. Third, we will need to tell Kea when to send those specific options. This last step will be done with client classification.
An example snippet of a configuration could look similar to the following:
{ // First, we need to define that suboption 2 in vivso option for // vendor-id 25167 has specific format (it's a plain string in this example). // After this definition, we can specify values for option tftp. "option-def": [ { // We define a short name, so the option could be referenced by name. // The option has code 2 and resides with vendor space 25167. // Its data is a plain string. "name": "tftp", "code": 2, "space": "vendor-25167", "type": "string" } ], "client-classes": [ { // We now need to tell Kea how to recognize when to use vendor space 25167. // Usually we can use simple expression such as checking if the device // sent a vivso option with specific vendor-id, e.g. "vendor[4491].exists" // Unfortunately, Genexis is a bit unusual in this aspect, because it // doesn't send vivso. In this case we need to look into vendor class // (option code 60) and see if there's specific string that identifies // the device. "name": "cpe_genexis", "test": "substring(option[60].hex,0,7) == 'HMC1000'", // Once the device is recognized, we want to send two options: // the VIVSO option with vendor-id set to 25167 and a suboption 2. "option-data": [ { "name": "vivso-suboptions", "data": "25167", "encapsulate": "vendor-25167" }, // The suboption 2 value is defined as any other option. However, // we want to send this suboption 2, even when the client didn't // explicitly requested 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. { "name": "tftp", "space": "vendor-25167", "data": "tftp://192.0.2.1/genexis/HMC1000.v1.3.0-R.img", "always-send": true } ] } ] }
One aspect requires a bit broader comment. By default Kea sends back only those options that are requested by a client, unless there are protocol rules that tell DHCP server to always send an option. This approach works nicely for most cases and avoids problems with clients refusing responses with options they don't understand. Unfortunately, this is more blurry when we consider vendor options. Some vendors (such as docsis, identified by vendor options 4491) have a mechanism to request specific vendor options and Kea is able to honor that. Unfortunately, for many other vendors, such as Genexis (25167) discussed here, Kea does not have such a mechanism, so it can't sent any suboptions on its own. To solve this issue, we came up with a concept of persistent options. Kea can be told to always send options, even if client didn't request them. This can be achieved by adding "always-send": true to your option definition. Note that in this particular case an option is defined in a vendor space 25167. With the "always-send" enabled, the option will be sent every time there is a need to deal with vendor space 25167.
Another possibility is to redefine the option; see Section 8.2.12, “DHCPv4 Private Options”.
It is sometimes useful to define a completely new option space. This is the case when a user creates a new option in the standard option space ("dhcp4") and wants this option to convey sub-options. Since they are in a separate space, sub-option codes will have a separate numbering scheme and may overlap with the codes of standard options.
Note that the creation of a new option space is not required when defining sub-options for a standard option, because it is created by default if the standard option is meant to convey any sub-options (see Section 8.2.13, “DHCPv4 Vendor-Specific Options”).
Assume that we want to have a DHCPv4 option called "container" with code 222 that conveys two sub-options with codes 1 and 2. First we need to define the new sub-options:
"Dhcp4": {
"option-def": [
{
"name": "subopt1",
"code": 1,
"space": "isc",
"type": "ipv4-address",
"record-types": "",
"array": false,
"encapsulate": ""
},
{
"name": "subopt2",
"code": 2,
"space": "isc",
"type": "string",
"record-types": "",
"array": false,
"encapsulate": ""
}
],
...
}
Note that we have defined the options to belong to a new option space (in this case, "isc").
The next step is to define a regular DHCPv4 option with our desired code and specify that it should include options from the new option space:
"Dhcp4": {
"option-def": [
...,
{
"name": "container",
"code": 222,
"space": "dhcp4",
"type": "empty",
"array": false,
"record-types": "",
"encapsulate": "isc"
}
],
...
}
The name of the option space in which the sub-options are defined is set in the encapsulate field. The type field is set to empty, to indicate that this option does not carry any data other than sub-options.
Finally, we can set values for the new options:
"Dhcp4": { "option-data": [ {"name": "subopt1", "code": 1, "space": "isc", "data": "192.0.2.3"
}, }"name": "subopt2", "code": 2, "space": "isc", "data": "Hello world"
}, {"name": "container", "code": 222, "space": "dhcp4"
} ], ... }
Note that 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 "container" option from the previous example were required to carry a uint16 value as well as the sub-options, the type value would have to be set to "uint16" 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 data parameter — which should be a valid integer enclosed in quotes, e.g. "123" — would then be assigned to the uint16 field in the "container" option.
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:
The DHCPv4 server supports the 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, e.g. addresses of DNS servers. In order to obtain the stateless configuration parameters, the client sends the DHCPINFORM message to the server with the "ciaddr" set to the address that the client is currently using. The server unicasts the DHCPACK message to the client that includes the stateless configuration ("yiaddr" not set).
The server will respond to the DHCPINFORM when the client is associated with a subnet defined in the server's configuration. An example subnet configuration will look like this:
"Dhcp4": { "subnet4": [ { "subnet": "192.0.2.0/24" "option-data": [ { "name": "domain-name-servers", "code": 6, "data": "192.0.2.200,192.0.2.201", "csv-format": true, "space": "dhcp4" } ] } ] }
This subnet specifies the single option which will be included in the DHCPACK message to the client in response to DHCPINFORM. Note that the subnet definition does not require the address pool configuration if it will be used solely for the stateless configuration.
This server will associate the subnet with the client if one of the following conditions is met:
The DHCPv4 server includes support for client classification. For a deeper discussion of the classification process see Chapter 14, Client Classification.
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 the 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.
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 a lease from subnet B. That segregation is essential to prevent overly curious users from playing with their cable modems. For details on how to set up class restrictions on subnets, see Section 14.6, “Configuring Subnets With Class Information”.
When subnets belong to a shared network, the classification applies to subnet selection but not to pools, e.g. 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. So the limit on access based on class information is also available at the pool level; see Section 14.7, “Configuring Pools With Class Information”, within a subnet. This is useful when segregating clients belonging to the same subnet into different address ranges.
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 "KNOWN" or "UNKNOWN" classes. One can assign addresses 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 KNOWN/UNKNOWN classes to select a shared network or a subnet.
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, "DROP", it is dropped and a debug message logged. The next step is to evaluate class expressions depending on the built-in "KNOWN"/"UNKNOWN" 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 "true" 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 Chapter 14, Client Classification.
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 specifies an expression that is evaluated for each packet. If the result is "true", the packet is a member of the class.
Care should be taken with client classification, as it is easy for clients that do not meet class criteria to be denied all service.
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: next-server (conveys an IPv4 address, which is set in the siaddr field), server-hostname (conveys a server hostname, can be up to 64 bytes long, and is sent in the sname field) and boot-file-name (conveys the configuration file, can be up to 128 bytes long, and is sent using the file field).
Obviously, there are many ways to assign clients to specific classes, but for the PXE clients the client architecture type option (code 93) seems to be particularly suited to make the distinction. The following example checks if the client identifies itself as a PXE device with architecture EFI x86-64, and sets several fields if it does. See Section 2.1 of RFC 4578) or the documentation of your client for specific values.
"Dhcp4": {
"client-classes": [
{
"name": "ipxe_efi_x64",
"test": "option[93].hex == 0x0009",
"next-server": "192.0.2.254",
"server-hostname": "hal9000",
"boot-file-name": "/dev/null"
},
...
],
...
}
If there are multiple classes defined and an incoming packet is matched to multiple classes, the class which is evaluated first is used.
The classes are ordered as specified in the configuration.
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 "VENDOR_CLASS_", and it is interpreted as a class. For example, modern cable modems will send this option with value "docsis3.0" and as a result the packet will belong to class "VENDOR_CLASS_docsis3.0".
Certain special actions for clients in VENDOR_CLASS_docsis3.0 can be achieved by defining VENDOR_CLASS_docsis3.0 and setting its next-server and boot-file-name values appropriately.
This example shows a configuration using an automatically generated "VENDOR_CLASS_" class. The administrator of the network has decided that addresses from 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 docsis3.0 client class are allowed to use that pool.
"Dhcp4": {
"subnet4": [
{
"subnet": "192.0.2.0/24",
"pools": [ { "pool": "192.0.2.10 - 192.0.2.20" } ],
"client-class": "VENDOR_CLASS_docsis3.0"
}
],
...
}
The following example shows how to configure a class using an expression and a subnet using that class. This configuration defines the class named "Client_foo". It is comprised of all clients whose client ids (option 61) start with the string "foo". 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.
"Dhcp4": { "client-classes": [ {"name": "Client_foo", "test": "substring(option[61].hex,0,3) == 'foo'", "option-data": [ { "name": "domain-name-servers", "code": 6, "space": "dhcp4", "csv-format": true, "data": "192.0.2.1, 192.0.2.2" } ]
}, ... ], "subnet4": [ { "subnet": "192.0.2.0/24", "pools": [ { "pool": "192.0.2.10 - 192.0.2.20" } ],"client-class": "Client_foo"
}, ... ], ... }
In some cases it is useful to limit the scope of a class to a shared-network, subnet, or pool. There are two parameters for this, which instruct the server to evaluate test expressions when required.
The first one is the per-class only-if-required flag which is false by default. When it is set to true, the test expression of the class is not evaluated at the reception of the incoming packet but later, and only if the class evaluation is required.
The second is require-client-classes, which takes a list of class names and is valid in shared-network, subnet, and pool scope. Classes in these lists are marked as required and evaluated after selection of this specific shared-network/subnet/pool and before output option processing.
In this example, a class is assigned to the incoming packet when the specified subnet is used:
"Dhcp4": { "client-classes": [ {"name": "Client_foo", "test": "member('ALL')", "only-if-required": true
}, ... ], "subnet4": [ { "subnet": "192.0.2.0/24", "pools": [ { "pool": "192.0.2.10 - 192.0.2.20" } ],"require-client-classes": [ "Client_foo" ],
... }, ... ], ... }
Required evaluation can be used to express complex dependencies, for example, subnet membership. It can also be used to reverse the precedence; if you set an option-data in a subnet, it takes precedence over an option-data in a class. When you move the option-data to a required class and require it in the subnet, a class evaluated earlier may take precedence.
Required evaluation is also available at shared-network and pool levels. The order in which required classes are considered is: shared-network, subnet, and pool, i.e. in the opposite order in which option-data is processed.
As mentioned earlier, kea-dhcp4 can be configured to generate requests to the DHCP-DDNS server (referred to here as "D2") to update DNS entries. These requests are known as Name Change Requests or NCRs. Each NCR contains the following information:
Whether it is a request to add (update) or remove DNS entries
Whether the change requests forward DNS updates (A records), reverse DNS updates (PTR records), or both
The Fully Qualified Domain Name (FQDN), lease address, and DHCID (information identifying the client associated with the FQDN)
The parameters for controlling the generation of NCRs for submission to D2 are contained in the dhcp-ddns section of the kea-dhcp4 server configuration. The mandatory parameters for the DHCP DDNS configuration are enable-updates, which is unconditionally required, and qualifying-suffix, which has no default value and is required when enable-updates is set to true. The two (disabled and enabled) minimal DHCP DDNS configurations are:
"Dhcp4": {
"dhcp-ddns": {
"enable-updates": false
},
...
}
and for example:
"Dhcp4": {
"dhcp-ddns": {
"enable-updates": true,
"qualifying-suffix": "example."
},
...
}
The default values for the "dhcp-ddns" section are as follows:
For NCRs to reach the D2 server, kea-dhcp4 must be able to communicate with it. kea-dhcp4 uses the following configuration parameters to control this communication:
By default, kea-dhcp-ddns is assumed to be running on the same machine as kea-dhcp4, 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:
"Dhcp4": {
"dhcp-ddns": {
"server-ip": "192.168.1.10",
"server-port": 900
,
...
},
...
}
kea-dhcp4 follows the behavior prescribed for DHCP servers in RFC 4702. It is important to keep in mind that kea-dhcp4 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 (Chapter 12, The DHCP-DDNS Server). This section describes when kea-dhcp4 will generate NCRs and the configuration parameters that can be used to influence this decision. It assumes that the enable-updates parameter is true.
In general, kea-dhcp4 will generate DDNS update requests when:
A new lease is granted in response to a DHCPREQUEST
An existing lease is renewed but the FQDN associated with it has changed
An existing lease is released in response to a DHCPRELEASE
In the second case, lease renewal, two DDNS requests will be issued: one request to remove entries for the previous FQDN, and a second request to add entries for the new FQDN. In the last case, a lease release, a single DDNS request to remove its entries will be made.
The decisions involved when granting a new lease (the first case) are more complex. When a new lease is granted, kea-dhcp4 will generate 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 will use the FQDN option. By default, kea-dhcp4 will respect the FQDN N and S flags specified by the client as shown in the following table:
Table 8.3. Default FQDN Flag Behavior
Client Flags:N-S | Client Intent | Server Response | Server Flags:N-S-O |
---|---|---|---|
0-0 | Client wants to do forward updates, server should do reverse updates | Server generates reverse-only request | 1-0-0 |
0-1 | Server should do both forward and reverse updates | Server generates request to update both directions | 0-1-0 |
1-0 | Client wants no updates done | Server does not generate a request | 1-0-0 |
The first row in the table above represents "client delegation". Here the DHCP client states that it intends to do the forward DNS updates and the server should do the reverse updates. By default, kea-dhcp4 will honor the client's wishes and generate a DDNS request to the D2 server to update only reverse DNS data. The parameter override-client-update can be used to instruct the server to override client delegation requests. When this parameter is true, kea-dhcp4 will disregard requests for client delegation and generate a DDNS request to update both forward and reverse DNS data. In this case, the N-S-O flags in the server's response to the client will be 0-1-1 respectively.
(Note that the flag combination N=1, S=1 is prohibited according to RFC 4702. If such a combination is received from the client, the packet will be dropped by kea-dhcp4.)
To override client delegation, set the following values in the configuration file:
"Dhcp4": {
"dhcp-ddns": {
"override-client-update": true
,
...
},
...
}
The third row in the table above describes the case in which the client requests that no DNS updates be done. The parameter, override-no-update, can be used to instruct the server to disregard the client's wishes. When this parameter is true, kea-dhcp4 will generate DDNS update requests to kea-dhcp-ddns even if the client requests that no updates be done. The N-S-O flags in the server's response to the client will be 0-1-1.
To override client delegation, issue the following commands:
"Dhcp4": {
"dhcp-ddns": {
"override-no-update": true
,
...
},
...
}
kea-dhcp4 will always generate DDNS update requests if the client request only contains the Host Name option. In addition, it will include 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 will be the name submitted to D2 in the DDNS update request.
Each NameChangeRequest must of course include the fully qualified domain name whose DNS entries are to be affected. kea-dhcp4 can be configured to supply a portion or all of that name, based upon what it receives from the client in the DHCPREQUEST.
The default rules for constructing the FQDN that will be used for DNS entries are:
If the DHCPREQUEST contains the client FQDN option, take the candidate name from there; otherwise, take it from the Host Name option.
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.
If the candidate name provided is empty, generate an FQDN using a configurable prefix and suffix.
If the client provided neither option, then no DNS action will be taken.
These rules can be amended by setting the replace-client-name parameter, which provides the following modes of behavior:
never - Use the name the client sent. If the client sent no name, do not generate one. This is the default mode.
always - Replace the name the client sent. If the client sent no name, generate one for the client.
when-present - Replace the name the client sent. If the client sent no name, do not generate one.
when-not-present - Use the name the client sent. If the client sent no name, generate one for the client.
Note that formerly, this parameter was a boolean and permitted only values of true and false. Boolean values have been deprecated and are no longer accepted. If you are currently using booleans, you must replace them with the desired mode name. A value of true maps to "when-present", while false maps to "never".
For example, to instruct kea-dhcp4 to always generate the FQDN for a client, set the parameter replace-client-name to always as follows:
"Dhcp4": {
"dhcp-ddns": {
"replace-client-name": "always"
,
...
},
...
}
The prefix used in the generation of an FQDN is specified by the generated-prefix parameter. The default value is "myhost". To alter its value, simply set it to the desired string:
"Dhcp4": {
"dhcp-ddns": {
"generated-prefix": "another.host"
,
...
},
...
}
The suffix used when generating an FQDN, or when qualifying a partial name, is specified by the qualifying-suffix parameter. This parameter has no default value, thus it is mandatory when DDNS updates are enabled. To set its value simply set it to the desired string:
"Dhcp4": {
"dhcp-ddns": {
"qualifying-suffix": "foo.example.org"
,
...
},
...
}
When generating a name, kea-dhcp4 will construct the name in the format:
[generated-prefix]-[address-text].[qualifying-suffix].
where address-text 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 "example.com", and the default value is used for generated-prefix, the generated FQDN would be:
myhost-172-16-1-10.example.com.
"Dhcp4": { "dhcp-ddns": { "hostname-char-set": "[^A-Za-z0-9.-]", "hostname-char-replacement": "x", ... }, ... }Thus, a client-supplied value of "myhost-$[123.org" would become "myhost-xx123.org". 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).
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. If you find you have clients that are using odd corner cases of character combinations that cannot be readily handled with this mechanism, you should consider writing a hook that can carry out sufficiently complex logic to address your needs.
If your clients include domain names in the Host Name option and you want these preserved, you will need to make sure that the dot, '.', is considered a valid character by the hostname-char-set expression, such as this: "[^A-Za-z0-9.-]". This will 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.
If your clients are sending values that differ only by characters considered as invalid by your hostname-char-set, 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.
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 hostname-char-replacement could yield an empty domain label within a name, if that label consists only of invalid characters.
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 siaddr field in the DHCPv4 packet for that purpose. That specific field can be configured using the next-server 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 subnet can be set to 0.0.0.0, which means that next-server should not be sent. It may also be set to an empty string, which means the same as if it were not defined at all, i.e. use the global value.
The server-hostname (which conveys a server hostname, can be up to 64 bytes long, and will be sent in the sname field) and boot-file-name (which conveys the configuration file, can be up to 128 bytes long, and will be sent using the file field) directives are handled the same way as next-server.
"Dhcp4": {"next-server": "192.0.2.123", "boot-file-name": "/dev/null"
, ..., "subnet4": [ {"next-server": "192.0.2.234", "server-hostname": "some-name.example.org", "boot-file-name": "bootfile.efi"
, ... } ] }
The original DHCPv4 specification (RFC 2131) states that the DHCPv4 server must not send back client-id options when responding to clients. However, in some cases that confused clients that did not have a MAC address or client-id; see RFC 6842 for details. That behavior changed with the publication of RFC 6842, which updated RFC 2131. That update states that the server must send the client-id if the client sent it. That is Kea's default behavior. However, in some cases older devices that do not support RFC 6842 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:
"Dhcp4": {
"echo-client-id": false
,
...
}
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:
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: "chaddr" and "client identifier". 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 RFC 2132.
RFC 2131 indicates that the server may use both of these identifiers to identify the client but the "client identifier", if present, takes precedence over "chaddr". One of the reasons for this is that "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, RFC 4361 gives the recommendation to use a DUID (see RFC 8415, the DHCPv6 specification) carried as "client identifier" when dual-stack networks are in use to provide consistent identification information for the client, regardless of the protocol type it is using. Kea adheres to these specifications, and the "client identifier" by default takes precedence over the value carried in the "chaddr" field when the server searches, creates, updates, or removes the client's lease.
When the server receives a DHCPDISCOVER or DHCPREQUEST message from the client, it will try to find out if the client already has a lease in the database and will hand out that lease rather than allocate a new one. Each lease in the lease database is associated with the "client identifier" and/or "chaddr". The server will first use the "client identifier" (if present) to search the lease. If the lease is found, the server will treat this lease as belonging to the client even if the current "chaddr" and the "chaddr" 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 will perform another lookup using the "chaddr". If this lookup returns no result, the client is considered as not having a lease and the new lease will be created.
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's interface remains stable, and using the "chaddr" field to identify the client guarantees that the particular system is considered to be the same client, even though its "client identifier" changes.
To address this problem, Kea includes a configuration option which enables client identification using "chaddr" only by instructing the server to disregard the server to "ignore" the "client identifier" during lease lookups and allocations for a particular subnet. Consider the following simplified server configuration:
"Dhcp4": { ..."match-client-id": true,
... "subnet4": [ { "subnet": "192.0.10.0/24", "pools": [ { "pool": "192.0.2.23-192.0.2.87" } ],"match-client-id": false
}, { "subnet": "10.0.0.0/8", "pools": [ { "pool": "10.0.0.23-10.0.2.99" } ], } ] }
The match-client-id is a boolean value which
controls this behavior. The default value of true
indicates that the server will use the "client identifier" for lease
lookups and "chaddr" if the first lookup returns no results. The
false means that the server will only
use the "chaddr" to search for client's lease. Whether the DHCID for
DNS updates is generated from the "client identifier" or "chaddr" is
controlled through the same parameter.
The match-client-id 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
match-client-id will be false
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 match-client-id for the subnet
10.0.0.0/8 will be set to true
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
true
is the default value.
It is important to explain what happens when the client obtains
its lease for one setting of the match-client-id
and then renews when the setting has been changed. First, consider
the case when the client obtains the lease when the
match-client-id is set to true
.
The server will store the lease information, including "client identifier"
(if supplied) and "chaddr", in the lease database. When the setting is
changed and the client renews the lease, the server will determine that
it should use the "chaddr" to search for the existing lease. If the
client hasn't changed its MAC address, the server should successfully
find the existing lease. The "client identifier" associated with the
returned lease is ignored and the client is allowed to use this lease.
When the lease is renewed only the "chaddr" is recorded for this
lease, according to the new server setting.
In the second case the client has the lease with only a "chaddr"
value recorded. When the match-client-id setting is changed to
true
,
the server will first try to use the "client identifier" to find the
existing client's lease. This will return no results because the
"client identifier" was not recorded for this lease. The server will
then use the "chaddr" 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 match-client-id.
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 the new lease will be
allocated.
The original DHCPv4 specification
(RFC 2131)
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 dhcpd 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's DHCPREQUEST with a DHCPNAK message if it
already has a lease for the client, but with a different IP address.
Administrators can override this behavior through the
boolean authoritative (false
by default) setting.
In authoritative mode, authoritative set to
true
, Kea always rejects INIT-REBOOT requests from
unknown clients with DHCPNAK messages.
The authoritative 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
authoritative setting.
The support of DHCPv4-over-DHCPv6 transport is described in RFC 7341 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 Section 9.2.24, “DHCPv4-over-DHCPv6: DHCPv6 Side”).
DHCPv4-over-DHCPv6 support is experimental and the details of the inter-process communication may change; both the DHCPv4 and DHCPv6 sides should be running the same version of Kea. For instance, the support of port relay (RFC 8357) introduced an incompatible change.
The dhcp4o6-port 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 port + 1 and connected to ::1 on port).
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 have been added; the presence of any of these allows the subnet to be used with DHCPv4-over-DHCPv6. These entries are:
The following configuration was used during some tests:
{ # DHCPv4 conf "Dhcp4": { "interfaces-config": { "interfaces": [ "eno33554984" ] }, "lease-database": { "type": "memfile", "name": "leases4" }, "valid-lifetime": 4000, "subnet4": [ { "subnet": "10.10.10.0/24","4o6-interface": "eno33554984",
"4o6-subnet": "2001:db8:1:1::/64",
"pools": [ { "pool": "10.10.10.100 - 10.10.10.199" } ] } ],"dhcp4o6-port": 6767,
"loggers": [ { "name": "kea-dhcp4", "output_options": [ { "output": "/tmp/kea-dhcp4.log" } ], "severity": "DEBUG", "debuglevel": 0 } ] } }
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 that temporarily removed a subnet from a configuration wouldn't want all the leases associated with it to disappear from the lease database. Kea has a mechanism to better control sanity checks such as this.
Kea supports a configuration scope called sanity-checks. It currently allows only a single parameter called lease-checks. It governs the verification that is done when a new lease is loaded from a lease file. With the sanity-checks mechanism, it is possible to tell Kea to try to correct inconsistent data.
Every subnet has a subnet-id value; this is how Kea internally identifies subnets. Each lease has a subnet-id parameter as well, which identifies which subnet it belongs to. However, if the configuration has changed, it is possible that a lease could exist with a subnet-id, but without any subnet that matches it. Also, it may be possible that the subnet's configuration has changed and the subnet-id now belongs to a subnet that does not match the lease. Kea's corrective algorithm first checks to see if there is a subnet with the subnet-id specified by the lease. If there is, it verifies whether the lease belongs to that subnet. If not, depending on the lease-checks setting, the lease is discarded, a warning is displayed, or a new subnet is selected for the lease that matches it topologically.
There are five levels which are supported:
This feature is currently implemented for the memfile backend.
An example configuration that sets this parameter looks as follows:
"Dhcp4": {
"sanity-checks": {
"lease-checks": "fix-del"
},
...
}
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 will receive the same address from the server every time, and other clients will generally not receive that address. Note that 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 "conflict." These conflicts get resolved automatically over time as described in subsequent sections. Once the conflict is resolved, the client will keep receiving the reserved configuration when it renews.
Another example when host reservations are applicable is 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.
Host reservations are defined as parameters for each subnet. Each host must be identified by an identifier, for example the hardware/MAC address. There is an optional reservations array in the subnet4 structure. Each element in that array is a structure that holds information about reservations for a single host. In particular, the structure must have 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 DHCPv4 message such as siaddr, sname, or file.
The following example shows how to reserve addresses for specific hosts in a subnet:
"subnet4": [
{
"pools": [ { "pool": "192.0.2.1 - 192.0.2.200" } ],
"subnet": "192.0.2.0/24",
"interface": "eth0",
"reservations": [
{
"hw-address": "1a:1b:1c:1d:1e:1f",
"ip-address": "192.0.2.202"
},
{
"duid": "0a:0b:0c:0d:0e:0f",
"ip-address": "192.0.2.100",
"hostname": "alice-laptop"
},
{
"circuit-id": "'charter950'",
"ip-address": "192.0.2.203"
},
{
"client-id": "01:11:22:33:44:55:66",
"ip-address": "192.0.2.204"
}
]
}
]
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 alice-laptop for the client using a DUID 0a:0b:0c:0d:0e:0f. (Note that if you plan to do DNS updates, it is strongly recommended for the hostnames to 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 circuit-id option with the value 'charter950'. 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.
The above example is used for illustrational purposes only and in actual deployments it is recommended to use as few types as possible (preferably just one). See Section 8.3.8, “Fine-Tuning DHCPv4 Host Reservation” for a detailed discussion of this point.
Making a reservation for a mobile host that may visit multiple subnets requires a separate host definition in each subnet it 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.
Adding host reservation 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 also supports 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.
In a typical 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 "in-pool reservations." In contrast, those that do not belong to dynamic pools are called "out-of-pool reservations." There is no formal difference in the reservation syntax and both reservation types are handled uniformly.
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 will still match inbound client packets to a subnet as before, but when the subnet's reservation mode is set to "global", Kea will look 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.
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.
The server now has a conflict to resolve. If Host B boots up and requests an address, the server is not able to 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.
When Host A renews its address, the server will discover that the address being renewed is now reserved for another host - Host B. Therefore 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's a small chance that the DHCPNAK may be lost 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. 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.
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).
The recovery mechanism allows the server to fully recover from a case where reservations conflict with existing leases. This procedure takes time and will roughly take as long as the value set for renew-timer. The best way to avoid such 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.
The conflict-resolution mechanism does not work for global reservations. As of Kea 1.5.0, it is generally recommended that you not use global reservations for addresses. If you choose to use them anyway, you must manually ensure that the reserved addresses are not in the dynamic pools.
When the reservation for a client includes the hostname, the server will return this hostname to the client in the Client FQDN or Hostname options. The server responds with the Client FQDN option only if the client has included Client FQDN option in its message to the server. The server will respond with the Hostname option if the client included Hostname option in its message to the server or when the client requested the Hostname option using the Parameter Request List option. The server will return 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.
The server qualifies the reserved hostname with the value of the qualifying-suffix parameter. For example, the following subnet configuration:
{ "subnet4": [ { "subnet": "10.0.0.0/24", "pools": [ { "pool": "10.0.0.10-10.0.0.100" } ], "reservations": [ { "hw-address": "aa:bb:cc:dd:ee:ff", "hostname": "alice-laptop" } ] }], "dhcp-ddns": { "enable-updates": true, "qualifying-suffix": "example.isc.org." } }
will result in assigning the "alice-laptop.example.isc.org." hostname to the client using the MAC address "aa:bb:cc:dd:ee:ff". If the qualifying-suffix is not specified, the default (empty) value will be used, and in this case the value specified as a hostname will be treated as a fully qualified name. Thus, by leaving the qualifying-suffix empty it is possible to qualify hostnames for different clients with different domain names:
{ "subnet4": [ { "subnet": "10.0.0.0/24", "pools": [ { "pool": "10.0.0.10-10.0.0.100" } ], "reservations": [ { "hw-address": "aa:bb:cc:dd:ee:ff", "hostname": "alice-laptop.isc.org." }, { "hw-address": "12:34:56:78:99:AA", "hostname": "mark-desktop.example.org." } ] }], "dhcp-ddns": { "enable-updates": true, } }
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 Section 8.2.10, “Standard DHCPv4 Options”), custom options (see Section 8.2.11, “Custom DHCPv4 Options”), or vendor-specific options (see Section 8.2.13, “DHCPv4 Vendor-Specific Options”). The following example demonstrates how standard options can be defined.
{
"subnet4": [ {
"reservations": [
{
"hw-address": "aa:bb:cc:dd:ee:ff",
"ip-address": "192.0.2.1",
"option-data": [
{
"name": "cookie-servers",
"data": "10.1.1.202,10.1.1.203"
},
{
"name": "log-servers",
"data": "10.1.1.200,10.1.1.201"
} ]
} ]
} ]
}
Vendor-specific options can be reserved in a similar manner:
{
"subnet4": [ {
"reservations": [
{
"hw-address": "aa:bb:cc:dd:ee:ff",
"ip-address": "10.0.0.7",
"option-data": [
{
"name": "vivso-suboptions",
"data": "4491"
},
{
"name": "tftp-servers",
"space": "vendor-4491",
"data": "10.1.1.202,10.1.1.203"
} ]
} ]
} ]
}
Options defined at host level have the highest priority. In other words, if there are options defined with the same type on global, subnet, class, and host level, the host-specific values will be used.
BOOTP/DHCPv4 messages include "siaddr", "sname", and "file" 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 "siaddr", "sname", and "file" fields instead.
With Kea, it is possible to make static reservations for these DHCPv4 message fields:
{
"subnet4": [ {
"reservations": [
{
"hw-address": "aa:bb:cc:dd:ee:ff",
"next-server": "10.1.1.2",
"server-hostname": "server-hostname.example.org",
"boot-file-name": "/tmp/bootfile.efi"
} ]
} ]
}
Note that those parameters can be specified in combination with other parameters for a reservation, e.g. a reserved IPv4 address. These parameters are optional, i.e. a subset of them can be specified, or all of them can be omitted.
Section 14.3, “Using Expressions in Classification” 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 reservations mechanisms also allow for the static assignment of classes to clients. The definitions of these classes are placed in the Kea configuration. The following configuration snippet shows how to specify that a client belongs to classes reserved-class1 and reserved-class2. Those classes are associated with specific options being sent to the clients which belong to them.
{
"client-classes": [
{
"name": "reserved-class1",
"option-data": [
{
"name": "routers",
"data": "10.0.0.200"
}
]
},
{
"name": "reserved-class2",
"option-data": [
{
"name": "domain-name-servers",
"data": "10.0.0.201"
}
]
}
],
"subnet4": [ {
"subnet": "10.0.0.0/24",
"pools": [ { "pool": "10.0.0.10-10.0.0.100" } ],
"reservations": [
{
"hw-address": "aa:bb:cc:dd:ee:ff",
"client-classes": [ "reserved-class1", "reserved-class2" ]
}
]
} ]
}
Static class assignments, as shown above, can be used in conjunction with classification, using expressions. The "KNOWN" or "UNKNOWN" builtin class is added to the packet and any class depending on it (directly or indirectly) and not only-if-required is evaluated.
If you want to force the evaluation of a class expression after the host reservation lookup, for instance because of a dependency on "reserved-class1" from the previous example, you should add a "member('KNOWN')" statement in the expression.
It is possible to store host reservations in MySQL, PostgreSQL, or Cassandra. See
Section 9.2.3, “Hosts Storage” for information on how to configure Kea to use
reservations stored in MySQL, PostgreSQL, or Cassandra. Kea provides a dedicated hook for
managing reservations in a database; section Section 15.4.4, “host_cmds: Host Commands” provides
detailed information. The Kea wiki https://gitlab.isc.org/isc-projects/kea/wikis/designs/commands#23-host-reservations-hr-management
provides some examples of how to conduct common host reservation operations.
In Kea, the maximum length of an option specified per-host is arbitrarily set to 4096 bytes.
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. Second, 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, so the existing (dynamically allocated) address should be revoked and the reserved one be used instead.
Some of those checks may be unnecessary in certain deployments and not performing them may improve performance. The Kea server provides the reservation-mode configuration parameter 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. Allowed values are:
The parameter can be specified at global, subnet, and shared-network levels.
An example configuration that disables reservation looks as follows:
"Dhcp4": {
"subnet4": [
{
"subnet": "192.0.2.0/24",
"reservation-mode": "disabled"
,
...
}
]
}
An example configuration using global reservations is shown below:
"Dhcp4": {
"reservation-mode": "global",
"reservations": [
{
"hw-address": "01:bb:cc:dd:ee:ff",
"hostname": "host-one"
},
{
"hw-address": "02:bb:cc:dd:ee:ff",
"hostname": "host-two"
}
],
"subnet4": [
{
"subnet": "192.0.2.0/24",
...
}
]
}
For more details regarding global reservations, see Section 8.3.9, “Global Reservations in DHCPv4”.
Another aspect of the host reservations is the different types of identifiers. Kea currently supports four types of identifiers: hw-address, duid, client-id, and circuit-id. 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.
To address this problem, a parameter called host-reservation-identifiers is available. It takes a list of identifier types as a parameter. Kea will check only those identifier types enumerated in host-reservation-identifiers. From a performance perspective, the number of identifier types should be kept to a minimum, ideally one. If your 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 host reservation identifiers looks as follows:
"host-reservation-identifiers": [ "circuit-id", "hw-address", "duid", "client-id" ],
"subnet4": [
{
"subnet": "192.0.2.0/24",
...
}
]
If not specified, the default value is:
"host-reservation-identifiers": [ "hw-address", "duid", "circuit-id", "client-id" ]
In some deployments, such as mobile, clients can roam within the network and certain parameters must be specified regardless of the client's current location. To facilitate such a need, a global reservation mechanism has been implemented. 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.
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. However, global reservations that assign addresses bypass the whole topology determination provided by DHCP logic implemented in Kea. It is very easy to misuse this feature and get a configuration that is inconsistent. To give a specific example, imagine a global reservation for address 192.0.2.100 and two subnets 192.0.2.0/24 and 192.0.5.0/24. If global reservations are used in both subnets and a device matching global host reservations visits part of the network that is serviced by 192.0.5.0/24, it will get an IP address 192.0.2.100, a subnet 192.0.5.0 and a default router 192.0.5.1. Obviously, such a configuration is unusable, as the client won't be able to reach its default gateway.
To use global host reservations, a configuration similar to the following can be used:
"Dhcp4:" { // This specifies global reservations. They will apply to all subnets that // have global reservations enabled."reservations": [ { "hw-address": "aa:bb:cc:dd:ee:ff", "hostname": "hw-host-dynamic" }, { "hw-address": "01:02:03:04:05:06", "hostname": "hw-host-fixed", // Use of IP address is global reservation is risky. If used outside of // matching subnet, such as 192.0.1.0/24, it will result in a broken // configuration being handled to the client. "ip-address": "192.0.1.77" }, { "duid": "01:02:03:04:05", "hostname": "duid-host" }, { "circuit-id": "'charter950'", "hostname": "circuit-id-host" }, { "client-id": "01:11:22:33:44:55:66", "hostname": "client-id-host" } ]
, "valid-lifetime": 600, "subnet4": [ { "subnet": "10.0.0.0/24","reservation-mode": "global",
"pools": [ { "pool": "10.0.0.10-10.0.0.100" } ] } ] }
When using database backends, the global host reservations are distinguished from regular reservations by using subnet-id value of zero.
DHCP servers use subnet information in two ways. First, it is used to determine the point of attachment, or simply put, where the client is connected to the network. Second, the subnet information is used to group information pertaining to a specific location in the network. This approach works well in general cases, but there are scenarios where the boundaries are blurred. Sometimes it is useful to have more than one logical IP subnet deployed on the same physical link. The need to understand that two or more subnets are used on the same link requires additional logic in the DHCP server. This capability is called "shared networks" in Kea and ISC DHCP projects. It is sometimes also called "shared subnets." In Microsoft's nomenclature it is called "multinet."
There are many use cases where the feature is useful; this paragraph explains just a handful of the most common ones. The first and by far the most common use case is an existing 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.
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 address-space exhaustion.
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 pools exhaustion), it will use another subnet from the same shared network and try to allocate an address from this subnet, etc. Therefore, in the typical case, the server will allocate 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 the other subnets before the address pools in the first subnet get exhausted, e.g. when the client provides a hint that belongs to another subnet or the client has reservations in a subnet other than the default.
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.
In order to define a shared network an additional configuration scope is introduced:
{
"Dhcp4": {
"shared-networks": [
{
// Name of the shared network. It may be an arbitrary string
// and it must be unique among all shared networks.
"name": "my-secret-lair-level-1",
// The subnet selector can be specifed at the shared network level.
// Subnets from this shared network will be selected for directly
// connected clients sending requests to server's "eth0" interface.
"interface": "eth0",
// This starts a list of subnets in this shared network.
// There are two subnets in this example.
"subnet4": [
{
"subnet": "10.0.0.0/8",
"pools": [ { "pool": "10.0.0.1 - 10.0.0.99" } ],
},
{
"subnet": "192.0.2.0/24",
"pools": [ { "pool": "192.0.2.100 - 192.0.2.199" } ]
}
],
} ]
, // end of shared-networks
// It is likely that in your network you will have a mix of regular,
// "plain" subnets and shared networks. It is perfectly valid to mix
// them in the same configuration file.
//
// This is regular subnet. It's not part of any shared-network.
"subnet4": [
{
"subnet": "192.0.3.0/24",
"pools": [ { "pool": "192.0.3.1 - 192.0.3.200" } ],
"interface": "eth1"
}
]
} // end of Dhcp4
}
As you see in the example, it is possible to mix shared and regular ("plain") 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.
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's performance. To avoid unnecessary performance degradation, the shared subnets should only be defined when required by the deployment.
Shared networks provide an ability to specify many parameters in the shared network scope that will apply to all subnets within it. If necessary, you can specify a parameter in the shared network scope and then override its value in the subnet scope. For example:
"shared-networks": [ { "name": "lab-network3", "interface": "eth0", // This applies to all subnets in this shared network, unless // values are overridden on subnet scope."valid-lifetime": 600
, // This option is made available to all subnets in this shared // network."option-data": [ { "name": "log-servers", "data": "1.2.3.4" } ]
, "subnet4": [ { "subnet": "10.0.0.0/8", "pools": [ { "pool": "10.0.0.1 - 10.0.0.99" } ], // This particular subnet uses different values."valid-lifetime": 1200, "option-data": [ { "name": "log-servers", "data": "10.0.0.254" }, { "name": "routers", "data": "10.0.0.254" } ]
}, { "subnet": "192.0.2.0/24", "pools": [ { "pool": "192.0.2.100 - 192.0.2.199" } ], // This subnet does not specify its own valid-lifetime value, // so it is inherited from shared network scope."option-data": [ { "name": "routers", "data": "192.0.2.1" } ]
} ] } ]
In this example, there is a log-servers 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 (valid lifetime is 20 minutes, different IP address for log-servers), but also adds its own option (router address). Assuming a client asking for router and log servers options is assigned a lease from this subnet, it will get a lease for 20 minutes and a log-servers 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 log-servers value of 1.2.3.4, and routers set to 192.0.2.1.
It is possible to specify an interface name in the shared network scope to tell the server that this specific shared network is reachable directly (not via relays) using a local network interface. It is sufficient to specify it once at the shared network level. 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. It is possible to specify the interface parameter on each subnet, although its value must be the same for each subnet. Thus it is usually more convenient to specify it once at the shared network level.
"shared-networks": [ { "name": "office-floor-2", // This tells Kea that the whole shared networks is reachable over // local interface. This applies to all subnets in this network."interface": "eth0"
, "subnet4": [ { "subnet": "10.0.0.0/8", "pools": [ { "pool": "10.0.0.1 - 10.0.0.99" } ],"interface": "eth0"
}, { "subnet": "192.0.2.0/24", "pools": [ { "pool": "192.0.2.100 - 192.0.2.199" } ] // Specifying a different interface name is configuration // error: // "interface": "eth1" } ] } ]
Somewhat similar to interface names, relay IP addresses can also be specified for the whole shared network. However, depending on your relay configuration, it may use different IP addresses depending on which subnet is being used. Thus there is no requirement to use the same IP relay address for each subnet. Here's an example:
"shared-networks": [ { "name": "kakapo","relay": { "ip-addresses": [ "192.3.5.6" ] }
, "subnet4": [ { "subnet": "192.0.2.0/26","relay": { "ip-addresses": [ "192.1.1.1" ] }
, "pools": [ { "pool": "192.0.2.63 - 192.0.2.63" } ] }, { "subnet": "10.0.0.0/24","relay": { "ip-addresses": [ "192.2.2.2" ] }
, "pools": [ { "pool": "10.0.0.16 - 10.0.0.16" } ] } ] } ]
In this particular case the relay IP address specified at the network level doesn't make much sense, as it is overridden in both subnets, but it was left there as an example of how one could be defined at the network level. Note that the relay agent IP address typically belongs to the subnet it relays packets from, but this is not a strict requirement. Kea accepts any value here as long as it is a valid IPv4 address.
Sometimes it is desirable to segregate clients into specific subnets based on certain properties. This mechanism is called client classification and is described in Chapter 14, Client Classification. 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 desired subnet is selected for a given client type.
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 including a client class is preferred over subnets without client classes. Consider the following example:
{
"client-classes": [
{
"name": "b-devices",
"test": "option[93].hex == 0x0002"
}
],
"shared-networks": [
{
"name": "galah",
"interface": "eth0",
"subnet4": [
{
"subnet": "192.0.2.0/26",
"pools": [ { "pool": "192.0.2.1 - 192.0.2.63" } ],
},
{
"subnet": "10.0.0.0/24",
"pools": [ { "pool": "10.0.0.2 - 10.0.0.250" } ],
"client-class": "b-devices"
}
]
}
]
}
If the client belongs to the "b-devices" class (because it includes option 93 with a value of 0x0002), that doesn't 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 a way to express subnet preference. For example, if the client doesn't belong to the "b-devices" class it may only use the subnet 192.0.2.0/26 and will never use the subnet 10.0.0.0/24.
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.
{ "client-classes": [ { "name": "a-devices", "test": "option[93].hex == 0x0001" }, { "name": "b-devices", "test": "option[93].hex == 0x0002" } ], "shared-networks": [ { "name": "galah", "interface": "eth0", "subnet4": [ { "subnet": "192.0.2.0/26", "pools": [ { "pool": "192.0.2.1 - 192.0.2.63" } ],"client-class": "a-devices"
}, { "subnet": "10.0.0.0/24", "pools": [ { "pool": "10.0.0.2 - 10.0.0.250" } ],"client-class": "b-devices"
} ] } ] }
In this example each class has its own restriction. Only clients that belong to class "a-devices" will be able to use subnet 192.0.2.0/26 and only clients belonging to "b-devices" will be 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).
Note that 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 "interface" or "relay" parameter. All subnets belonging to this shared network will inherit those parameters.
Subnets that are part of a shared network allow host reservations, similar to regular subnets:
{ "shared-networks": [ { "name": "frog", "interface": "eth0", "subnet4": [ { "subnet": "192.0.2.0/26", "id": 100, "pools": [ { "pool": "192.0.2.1 - 192.0.2.63" } ],"reservations": [ { "hw-address": "aa:bb:cc:dd:ee:ff", "ip-address": "192.0.2.28" } ]
}, { "subnet": "10.0.0.0/24", "id": 101, "pools": [ { "pool": "10.0.0.1 - 10.0.0.254" } ],"reservations": [ { "hw-address": "11:22:33:44:55:66", "ip-address": "10.0.0.29" } ]
} ] } ] }
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's 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 will be picked for the client. Although it's technically not an error, it is considered a bad practice to define reservations for the same host in multiple subnets belonging to the same shared network.
While not strictly mandatory, it is strongly recommended to use explicit "id" values for subnets if you plan to use database storage for host reservations. If an ID is not specified, the values for it are autogenerated, i.e. it assigns increasing integer values starting from 1. Thus, the autogenerated IDs are not stable across configuration changes.
The DHCPv4 protocol uses a "server identifier" 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 will use multiple server identifiers if it is receiving queries on multiple interfaces.
It is possible to override the default server identifier values by specifying the "dhcp-server-identifier" option. This option is only supported at the global, shared network, and subnet levels. It must not be specified on the client class and host reservation levels.
The following example demonstrates how to override the server identifier for a subnet:
"subnet4": [ { "subnet": "192.0.2.0/24", "option-data": [ { "name": "dhcp-server-identifier", "data": "10.2.5.76" } ], ... } ]
The DHCPv4 server differentiates between directly connected clients, clients trying to renew leases, and clients sending their messages through relays. For directly connected clients, the server will check the configuration for the interface on which the message has been received and, if the server configuration doesn't match any configured subnet, the message is discarded.
Assuming that the server's interface is configured with the IPv4 address 192.0.2.3, the server will only process messages received through this interface from a directly connected client if there is a subnet configured to which this IPv4 address belongs, e.g. 192.0.2.0/24. The server will use this subnet to assign an IPv4 address for the client.
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 ciaddr 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).
If the message is relayed it is accepted through any interface. The giaddr set by the relay agent is used to select the subnet for the client.
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 Section 8.6.1, “Using a Specific Relay Agent for a Subnet” for details.
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.
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 will assign addresses. Normally, the server is able to use the IPv4 address inserted by the relay (in the giaddr field of the DHCPv4 packet) to select the appropriate subnet.
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 where this is the case are long-lasting network renumbering (where both old and new address space is 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.
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.
"Dhcp4": {
"subnet4": [
{
"subnet": "192.0.2.0/24",
"pools": [ { "pool": "192.0.2.10 - 192.0.2.20" } ],
"relay": {
"ip-addresses": [ "10.0.0.1" ]
}
,
...
}
],
...
}
If "relay" is specified, the "ip-addresses" parameter within it is mandatory.
The current version of Kea uses the "ip-addresses" parameter, which supports specifying a list of addresses.
In certain cases, it is useful to mix relay address information, introduced in Section 8.6.1, “Using a Specific Relay Agent for a Subnet”, with client classification, explained in Chapter 14, Client Classification. One specific example is in a cable network, where typically modems get addresses from a different subnet than all the devices connected behind them.
Let us assume that there is one CMTS (Cable Modem Termination System) 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 another subnet (192.0.2.0/24). The CMTS that acts as a relay uses address 10.1.1.1. The following configuration can serve that configuration:
"Dhcp4": { "subnet4": [ { "subnet": "10.1.1.0/24", "pools": [ { "pool": "10.1.1.2 - 10.1.1.20" } ],"client-class" "docsis3.0", "relay": { "ip-addresses": [ "10.1.1.1 ]" }
}, { "subnet": "192.0.2.0/24", "pools": [ { "pool": "192.0.2.10 - 192.0.2.20" } ],"relay": { "ip-addresses": [ "10.1.1.1" ] }
} ], ... }
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's approval or knowledge.
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 will do a sanity check (to see whether the client declining an address really was supposed to use it), and then will conduct a clean-up operation. Any DNS entries related to that address will be removed, the fact will be logged, and hooks will be triggered. After that is complete, the address will be marked as declined (which indicates that it is used by an unknown entity and thus not available for assignment) and a probation time will be set on it. Unless otherwise configured, the probation period lasts 24 hours; after that period, 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 sysadmin intervention.
To configure the decline probation period to a value other than the default, the following syntax can be used:
"Dhcp4": {
"decline-probation-period": 3600
,
"subnet4": [ ... ],
...
}
The parameter is expressed in seconds, so the example above will instruct the server to recycle declined leases after one hour.
There are several statistics and hook points associated with the Decline handling procedure. The lease4_decline hook is triggered after the incoming DHCPDECLINE message has been sanitized and the server is about to decline the lease. The declined-addresses statistic is increased after the hook returns (both global and subnet-specific variants). (See Section 8.8, “Statistics in the DHCPv4 Server” and Chapter 15, Hooks Libraries for more details on DHCPv4 statistics and Kea hook points.)
Once the probation time elapses, the declined lease is recovered using the standard expired-lease reclamation procedure, with several additional steps. In particular, both declined-addresses statistics (global and subnet-specific) are decreased. At the same time, reclaimed-declined-addresses statistics (again in two variants, global and subnet-specific) are increased.
A note about statistics: The server does not decrease the assigned-addresses statistics when a DHCPDECLINE is received and processed successfully. While technically a declined address is no longer assigned, the primary usage of the assigned-addresses statistic is to monitor pool utilization. Most people would forget to include declined-addresses in the calculation, and simply use assigned-addresses/total-addresses. This would cause a bias towards under-representing pool utilization. As this has a potential for major issues, we decided not to decrease assigned-addresses immediately after receiving DHCPDECLINE, but to do it later when Kea recovers the address back to the available pool.
This section describes DHCPv4-specific statistics. For a general overview and usage of statistics, see Chapter 16, Statistics.
The DHCPv4 server supports the following statistics:
Table 8.4. DHCPv4 Statistics
Statistic | Data Type | Description |
---|---|---|
pkt4-received | integer | Number of DHCPv4 packets received. This includes all packets: valid, bogus, corrupted, rejected, etc. This statistic is expected to grow rapidly. |
pkt4-discover-received | integer | 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 your Kea server. |
pkt4-offer-received | integer | 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. |
pkt4-request-received | integer | Number of DHCPREQUEST packets received. This statistic is expected to grow. Its increase means that clients that just booted received the server's response (DHCPOFFER) and accepted it, and are now requesting an address (DHCPREQUEST). |
pkt4-ack-received | integer | 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. |
pkt4-nak-received | integer | 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. |
pkt4-release-received | integer | 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. |
pkt4-decline-received | integer | 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 in your network. |
pkt4-inform-received | integer | 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. |
pkt4-unknown-received | integer | Number of packets received of an unknown type. A non-zero value of this statistic indicates that the server received a packet that it wasn't able to recognize, either with an unsupported type or possibly malformed (without message type option). |
pkt4-sent | integer | Number of DHCPv4 packets sent. This statistic is expected to grow every time the server transmits a packet. In general, it should roughly match pkt4-received, 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. |
pkt4-offer-sent | integer | 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 pkt4-discover-received. |
pkt4-ack-sent | integer | 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 pkt4-ack-sent and pkt4-nak-sent should be close to pkt4-request-received. |
pkt4-nak-sent | integer | 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 pkt4-ack-sent and pkt4-nak-sent should be close to pkt4-request-received. |
pkt4-parse-failed | integer | 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 your network, faulty clients, or a bug in the server. |
pkt4-receive-drop | integer | Number of incoming packets that were dropped. The exact reason for dropping packets is logged, but the most common reasons may be: an unacceptable packet type, direct responses are forbidden, or the server-id sent by the client does not match the server's server-id. |
subnet[id].total-addresses | integer | Total number of addresses available for DHCPv4 management; in other words, this is the sum of all addresses in all configured pools. This statistic changes only during configuration changes. Note it does not take into account any addresses that may be reserved due to host reservation. The id is the subnet-id of a given subnet. This statistic is exposed for each subnet separately, and is reset during a reconfiguration event. |
subnet[id].assigned-addresses | integer | 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 is decreased every time a lease is released (a DHCPRELEASE message is received) or expires. The id is the subnet-id of the subnet. This statistic is exposed for each subnet separately, and is reset during a reconfiguration event. |
reclaimed-leases | integer | Number of expired leases that have been reclaimed since server startup. It is incremented each time an expired lease is reclaimed and is reset when the server is reconfigured. |
subnet[id].reclaimed-leases | integer | Number of expired leases associated with a given subnet (id is the subnet-id) that have been reclaimed since server startup. It is incremented each time an expired lease is reclaimed and is reset when the server is reconfigured. |
declined-addresses | integer | Number of IPv4 addresses that are currently declined; a count of the number of leases currently unavailable. Once a lease is recovered, this statistic will be 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. |
subnet[id].declined-addresses | integer | 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 will be 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 id is the subnet-id of a given subnet. This statistic is exposed for each subnet separately. |
reclaimed-declined-addresses | integer | Number of IPv4 addresses that were declined, but have now been recovered. Unlike declined-addresses, 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. |
subnet[id].reclaimed-declined-addresses | integer | Number of IPv4 addresses that were declined, but have now been recovered. Unlike declined-addresses, 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 id is the subnet-id of a given subnet. This statistic is exposed for each subnet separately. |
The management API allows the issuing of specific management commands, such as statistics retrieval, reconfiguration, or shutdown. For more details, see Chapter 17, Management API. Currently, the only supported communication channel type is UNIX stream socket. By default there are no sockets open; to instruct Kea to open a socket, the following entry in the configuration file can be used:
"Dhcp4": {
"control-socket": {
"socket-type": "unix",
"socket-name": "/path/to/the/unix/socket"
},
"subnet4": [
...
],
...
}
The length of the path specified by the socket-name parameter is restricted by the maximum length for the UNIX socket name on your operating system, i.e. the size of the sun_path field in the sockaddr_un 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.
Communication over the control channel is conducted using JSON structures.
See the Control Channel section in the Kea Developer's Guide
for more
details.
The DHCPv4 server supports the following operational commands:
as described in Section 17.3, “Commands Supported by Both the DHCPv4 and DHCPv6 Servers”. In addition, it supports the following statistics-related commands:
as described in Section 16.3, “Commands for Manipulating Statistics”.
Kea allows loading hook libraries that sometimes could 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.
User contexts can store arbitrary data 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.
User contexts can be specified at global scope, shared network, subnet, pool, client class, option data, or definition level, and via host reservation. One other useful usage is the ability to store comments or descriptions.
Let's consider an imaginary case of devices that have color 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 as maybe 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 forementioned case of LED devices could be configured in the following way:
"Dhcp4": { "subnet4": [ { "subnet": "192.0.2.0/24", "pools": [ { "pool": "192.0.2.10 - 192.0.2.20", // This is pool specific user context"user-context": { "color": "red" }
} ], // This is a subnet specific user context. You can put whatever type // of information you want as long as it is a valid JSON."user-context": { "comment": "network on the second floor", "last-modified": "2017-09-04 13:32", "description": "you can put here anything you like", "phones": [ "x1234", "x2345" ], "devices-registered": 42, "billing": false }
}, ... ], ... }
Kea does not use that 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 "comment" entry into a user context with the entry, which allows a comment to be attached inside the configuration itself.
For more background information, see Section 15.5, “User contexts”.
The following standards are currently supported:
These are the current limitations of the DHCPv4 server software. Most of them are reflections of the current stage of development and should be treated as “not implemented yet”, rather than actual limitations. However, some of them are implications of the design choices made. Those are clearly marked as such.
A collection of simple-to-use examples for the DHCPv4 component of Kea is available with the source files, located in the doc/examples/kea4 directory.
In the Section 5.2, “Kea Configuration Backend” we have described the Configuration Backend feature, its applicability and limitations. This section focuses on the usage of the CB with the DHCPv4 server. It lists the supported parameters, describes limitations and gives examples of the DHCPv4 server configuration to take advantage of the CB. Please also refer to the sibling section Section 9.19, “Configuration Backend in DHCPv6” for the DHCPv6 specific usage of the CB.
The ultimate goal for the CB is to serve as a central configuration repository for one or multiple Kea servers connected to the database. In the future it will be possible to store the most of the server's configuration in the database and reduce the configuration file to bare minimum, i.e. the only mandatory parameter will be the config-control which includes the necessary information to connect to the database. In the Kea 1.6.0 release, however, only the subset of the DHCPv4 server parameters can be stored in the database. All other parameters must be specified in the JSON configuration file, if required.
The following table lists DHCPv4 specific parameters supported by the Configuration Backend with an indication on which level of the hierarchy it is currently supported. The "n/a" is used in cases when the particular parameter is not applicable on the particular level of the hierarchy or in cases when the parameter is not supported by the server on this level of hierarchy. The "no" is used when the parameter is supported by the server on the particular level of hierarchy but is not configurable via the Configuration Backend.
All supported parameters can be configured via cb_cmds hooks library described in the Section 15.4.8, “cb_cmds: Configuration Backend Commands”. The general rule is that the scalar global parameters are set using the remote-global-parameter4-set. The shared network specific parameters are set using the remote-network4-set. Finally, the subnet and pool level parameters are set using the remote-subnet4-set. Whenever there is an exception from this general rule, it is highlighted in the table. The non-scalar global parameters have dedicated commands, e.g. modifying the global DHCPv4 options (option-data) is performed using the remote-option4-global-set.
The Section 5.2.4, “Configuration Sharing and Server Tags” 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 they can be associated with only one server tag. This rule does not apply to the configuration elements associated with "all" servers. Any configuration element associated with "all" servers (using "all" keyword as a server tag) is used by all servers connecting to the configuration database.
Table 8.5. List of DHCPv4 Parameters Supported by the Configuration Backend
Parameter | Global | Shared Network | Subnet | Pool |
---|---|---|---|---|
4o6-interface | n/a | n/a | yes | n/a |
4o6-interface-id | n/a | n/a | yes | n/a |
4o6-subnet | n/a | n/a | yes | n/a |
boot-file-name | yes | yes | yes | n/a |
calculate-tee-times | yes | yes | yes | n/a |
client-class | n/a | yes | yes | no |
decline-probation-period | yes | n/a | n/a | n/a |
dhcp4o6-port | yes | n/a | n/a | n/a |
echo-client-id | yes | n/a | n/a | n/a |
interface | n/a | yes | yes | n/a |
match-client-id | yes | yes | yes | n/a |
next-server | yes | yes | yes | n/a |
option-data | yes (via remote-option4-global-set) | yes | yes | yes |
option-def | yes (via remote-option-def4-set) | n/a | n/a | n/a |
rebind-timer | yes | yes | yes | n/a |
renew-timer | yes | yes | yes | n/a |
server-hostname | yes | yes | yes | n/a |
valid-lifetime | yes | yes | yes | n/a |
relay | n/a | yes | yes | n/a |
require-client-classes | no | yes | yes | no |
reservation-mode | yes | yes | yes | n/a |
t1-percent | yes | yes | yes | n/a |
t2-percent | yes | yes | yes | n/a |
Consider the following configuration snippet:
{ "Dhcp4": { "config-control": { "config-databases": [ { "type": "mysql", "name": "kea", "user": "kea", "password": "kea", "host": "192.0.2.1", "port": 3302 } ], "config-fetch-wait-time": 20 }, "hooks-libraries": [ { "library": "/usr/local/lib/kea/hooks/libdhcp_mysql_cb.so" }, { "library": "/usr/local/lib/kea/hooks/libdhcp_cb_cmds.so" } ], ... } }
The config-control contains two parameters. The config-databases is a list which contains one element comprising database type, 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 config-databases list. The server will connect to this database during the startup or reconfiguration, and will fetch the configuration available for this server from the database. This configuration is merged into the configuration read from the configuration file.
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 to avoid duplicating parameters in the file and the database but this recommendation is not enforced by the Kea servers. In particular, if the subnets' configuration is sourced from the database, we recommend that all subnets are specified in the database and no subnets are specified in the configuration file. It is possible to specify the subnets in both places, but that must be done with care. 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.
Once the Kea server is configured, it starts periodically polling for the configuration changes in the database. The frequency of polling is controlled by the config-fetch-wait-time parameter. It is expressed in seconds and it is the period between the time when the server completed last polling (and possibly the local configuration update) and the time when it begins 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. added 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 config-fetch-wait-time value, the shorter the time for the server to react to the incremental configuration updates in the database. On the other hand, polling the database too frequently may impact the DHCP server's performance because the server needs to make at least one query to the database to discover the pending configuration updates.The default value of the config-fetch-wait-time is 30 seconds.
Finally, in the configuration example above, two hooks libraries are loaded.
The former, libdhcp_mysql_cb.so
, is the implementation of
the Configuration Backend for MySQL. It must be always present when the
server uses MySQL as the configuration repository. Failing to load this
library will result in an error during the server configuration if the
"mysql" database is selected with the config-control
parameter.
The latter hooks library, libdhcp_cb_cmds.so
, is
optional. It should be loaded when the Kea server instance is to be used
for managing the configuration in the database. See the
Section 15.4.8, “cb_cmds: Configuration Backend Commands” for the details. Note that this hooks
library is only available to the ISC customers with a support contract.
Table of Contents
It is recommended that the Kea DHCPv6 server be started and stopped using keactrl (described in Chapter 6, Managing Kea with keactrl); however, it is also possible to run the server directly. It accepts the following command-line switches:
file
-
specifies the configuration file. This is the only mandatory
switch.
server-port
-
specifies the local UDP port on which the server will listen.
This is only useful during testing, as a DHCPv6 server
listening on ports other than the standard ones will not
be able to handle regular DHCPv6 queries.
client-port
-
specifies the remote UDP port to which the server will send
all responses. This is only useful during testing, as a
DHCPv6 server sending responses to ports other than the
standard ones will not be able to handle regular DHCPv6
queries.
file
- specifies a
configuration file to be tested. Kea-dhcp6 will load it, check it, and
exit. 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.
config.report
file produced by
./configure
; it is embedded in the
executable binary.
On startup, the server will detect available network interfaces and will attempt to open UDP sockets on all interfaces mentioned in the configuration file. Since the DHCPv6 server opens privileged ports, it requires root access. Make sure you run this daemon as root.
During startup, the server will attempt to create a PID file of the form: [runstatedir]/kea/[conf name].kea-dhcp6.pid where:
If the file already exists and contains the PID of a live process, the server will issue a DHCP6_ALREADY_RUNNING log message and exit. 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.
The server can be stopped using the kill command. When running in a console, the server can also be shut down by pressing ctrl-c. It detects the key combination and shuts down gracefully.
This section explains how to configure the DHCPv6 server using a configuration file. Before DHCPv6 is started, its configuration file has to be created. The basic configuration is as follows:
{ # DHCPv6 configuration starts on the next line "Dhcp6": { # First we set up global values "valid-lifetime": 4000, "renew-timer": 1000, "rebind-timer": 2000, "preferred-lifetime": 3000, # Next we setup the interfaces to be used by the server. "interfaces-config": { "interfaces": [ "eth0" ] }, # And we specify the type of lease database "lease-database": { "type": "memfile", "persist": true, "name": "/var/lib/kea/dhcp6.leases" }, # Finally, we list the subnets from which we will be leasing addresses. "subnet6": [ { "subnet": "2001:db8:1::/64", "pools": [ { "pool": "2001:db8:1::1-2001:db8:1::ffff" } ] } ] # DHCPv6 configuration ends with the next line } }
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.
The lines starting with a hash (#) are comments and are ignored by the server; they do not impact its operation in any way.
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 Dhcp6.
In the current Kea release it is possible to specify configurations of multiple modules within a single configuration file, but this is not recommended and support for it will be removed in the future releases. The only object, besides the one specifying module configuration, which can (and usually was) included in the same file is Logging. However, we don't include this object in the example above for clarity and its content, the list of loggers, should now be inside the Dhcp4 object instead of this deprecated object.
The Dhcp6 configuration starts with the "Dhcp6": { 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 Dhcp6 configuration.
In the general case, the order in which those parameters appear does not matter, but there are two caveats. The first one is to remember that the configuration file must be well-formed JSON. That means 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, keep in mind that 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 your configuration file.
Moving onto the DHCPv6 configuration elements, the first few elements define some global parameters. valid-lifetime defines how long the addresses (leases) given out by the server are valid. If nothing changes, a client that got an address is allowed to use it 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 can't use this address for creating new connections. renew-timer and rebind-timer are values that define T1 and T2 timers that govern when the client will begin the renewal and rebind procedures.
The interfaces-config map specifies the server configuration concerning the network interfaces, on which the server should listen to the DHCP messages. The interfaces 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 interfaces-config should look like this:
"interfaces-config": { "interfaces": [ "eth0", "eth1" ] },
The next couple of 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 file. This is a very simple configuration; usually the lease database configuration is more extensive and contains additional parameters. Note that lease-database is an object and opens up a new scope, using an opening brace. Its parameters (just one in this example - type) 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 Dhcp6 definition follow, a trailing comma is present.
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' requests. It defines all subnets from which the server is expected to receive DHCP requests. The subnets are specified with the subnet6 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 has to have at least two parameters: subnet (which defines the whole subnet) and pools (which is a list of dynamically allocated pools that are governed by the DHCP server).
The example contains a single subnet. If more than one were defined, additional elements in the subnet6 parameter would be specified and separated by commas. For example, to define two subnets, the following syntax would be used:
"subnet6": [ { "pools": [ { "pool": "2001:db8:1::/112" } ], "subnet": "2001:db8:1::/64" }, { "pools": [ { "pool": "2001:db8:2::1-2001:db8:2::ffff" } ], "subnet": "2001:db8:2::/64" } ]
Note that indentation is optional and is used for aesthetic purposes only. In some cases in may be preferable to use more compact notation.
After all parameters are specified, we have two contexts open: global and Dhcp6, hence we need two closing curly brackets to close them.
All leases issued by the server are stored in the lease database. Currently there are four database backends available: memfile (which is the default backend), MySQL, PostgreSQL, and Cassandra.
The server is able to store lease data in different repositories. Larger deployments may elect to store leases in a database. Section 9.2.2.2, “Lease Database Configuration” describes this option. In typical smaller deployments though, the server will store 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.
The configuration of the file backend (Memfile) is controlled through
the Dhcp6/lease-database parameters. The type parameter
is mandatory and it specifies which storage for leases the server should use.
The value of "memfile"
indicates that the file should
be used as the storage. The following list gives additional optional
parameters that can be used to configure the Memfile backend.
true
at all times, during the server's normal
operation. Not writing leases to disk means that if a server is restarted
(e.g. after a power failure), it will not know what addresses have been
assigned. As a result, it may hand out addresses to new clients that are
already in use. The value of false
is mostly useful
for performance-testing purposes. The default value of the
persist parameter is true
,
which enables writing lease updates
to the lease file.
"[kea-install-dir]/var/lib/kea/kea-leases6.csv"
.
3600
. A value of 0
disables the LFC.
An example configuration of the Memfile backend is presented below:
"Dhcp6": { "lease-database": {"type": "memfile"
,"persist": true
,"name": "/tmp/kea-leases6.csv"
,"lfc-interval": 1800
} }
This configuration selects the /tmp/kea-leases6.csv
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 30 minutes.
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 the client, the new lease information must be recorded in the lease file. For performance reasons, the server does not update the existing client's 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 the server startup, it assumes that the latest lease entry for the client is the valid one. The previous entries are discarded, meaning that the server can re-construct the 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's startup and reconfiguration, as it needs to process a larger number of lease entries.
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 lfc-interval should be. Note, however, that the LFC takes time and thus it is possible (although unlikely) that, if the lfc-interval 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 detects that the previous cleanup is still in progress. But it implies that the actual cleanups will be triggered more rarely than configured. Moreover, triggering a new cleanup adds overhead to the server, which will not be 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 lfc-interval value is selected in a way that would allow for the LFC to complete the cleanup before a new cleanup is triggered.
Lease file cleanup is performed by a separate process (in the background) to avoid a performance impact on the server process. To avoid the conflicts between two processes both using the same lease files, the LFC process starts with Kea opening new lease file and 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 is located later in this Kea Administrator's Reference Manual: Chapter 13, The LFC Process.
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.
Lease database configuration is controlled through the Dhcp6/lease-database parameters. The type of the database must be set to "memfile", "mysql", "postgresql", or "cql", e.g.:
"Dhcp6": { "lease-database": { "type": "mysql"
, ... }, ... }
Next, the name of the database to hold the leases must be set; this is the name used when the database was created (see Section 4.3.2.1, “First-Time Creation of the MySQL Database”, Section 4.3.3.1, “First-Time Creation of the PostgreSQL Database”, or Section 4.3.4.1, “First-Time Creation of the Cassandra Database”).
"Dhcp6": { "lease-database": { "name": "database-name
"
, ... }, ... }
For Cassandra:
"Dhcp6": { "lease-database": { "keyspace": "database-name
"
, ... }, ... }
If the database is located on a different system from the DHCPv6 server, the database host name must also be specified. (It should be noted that this configuration may have a severe impact on server performance.):
"Dhcp6": { "lease-database": { "host": "remote-host-name
"
, ... }, ... }
For Cassandra, multiple contact points can be provided:
"Dhcp6": { "lease-database": { "contact-points": "remote-host-name[, ...]
"
, ... }, ... }
Normally, the database will be on the same machine as the DHCPv6 server. In this case, set the value to the empty string:
"Dhcp6": { "lease-database": { "host" : ""
, ... }, ... }
For Cassandra:
"Dhcp6": { "lease-database": { "contact-points": ""
, ... }, ... }
Should the database use a port different than the default, it may be specified as well:
"Dhcp6": { "lease-database": { "port" : 12345
, ... }, ... }
Should the database be located on a different system, you may need to specify a longer interval for the connection timeout:
"Dhcp6": { "lease-database": { "connect-timeout" : timeout-in-seconds
, ... }, ... }
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.
The maxiumum number of times the server will automatically attempt to reconnect to the lease database after connectivity has been lost may be specified:
"Dhcp6": { "lease-database": { "max-reconnect-tries" : number-of-tries
, ... }, ... }
If the server is unable to reconnect to the database after making the maximum number of attempts the server will exit. A value of zero (the default) disables automatic recovery and the server will exit immediately upon detecting a loss of connectivity (MySQL and Postgres only).
The number of milliseconds the server will wait in between attempts to reconnect to the lease database after connectivity has been lost may also be specified:
"Dhcp6": { "lease-database": { "reconnect-wait-time" : number-of-milliseconds
, ... }, ... }
The default value for MySQL and Postgres is 0, which disables automatic recovery and causes the server to exit immediately upon detecting the loss of connectivity. The default value for Cassandra is 2000 ms.
Automatic reconnection to database backends is configured individually per backend. This allows you to tailor the recovery parameters to each backend you use. We do suggest that you enable it either for all backends or no backends so you have consistent behavior. Losing connectivity to a backend for which reconnect is disabled will result 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.
"Dhcp6": { "lease-database": { "contact-points" : "192.0.2.1,192.0.2.2"
, ... }, ... }
Finally, the credentials of the account under which the server will access the database should be set:
"Dhcp6": { "lease-database": {"user": "
,user-name
""password": "
, ... }, ... }password
"
If there is no password to the account, set the password to the empty string "". (This is also the default.)
The parameters are the same for DHCPv4 and DHCPv6. See Section 8.2.2.3, “Cassandra-Specific Parameters” for details.
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, a Kea server opens independent connections for each purpose, be it lease or hosts information. This arrangement 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, PostgreSQL and Cassandra.
For example, the following configuration can be used to configure connection to MySQL:
"Dhcp6": {
"hosts-database": {
"type": "mysql",
"name": "kea",
"user": "kea",
"password": "secret123",
"host": "localhost",
"port": 3306
}
}
Note that depending on your database configuration, many of the parameters may be optional.
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 (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.
In fact, 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.
Hosts database configuration is controlled through the Dhcp6/hosts-database parameters. If enabled, the type of database must be set to "mysql" or "postgresql".
"Dhcp6": { "hosts-database": { "type": "mysql"
, ... }, ... }
Next, the name of the database to hold the reservations must be set; this is the name used when the database was created (see Section 4.3, “Supported Backends” for instructions on how to set up the desired database type).
"Dhcp6": { "hosts-database": { "name": "database-name
"
, ... }, ... }
If the database is located on a different system than the DHCPv6 server, the database host name must also be specified. (Again it should be noted that this configuration may have a severe impact on server performance.)
"Dhcp6": { "hosts-database": { "host": remote-host-name
, ... }, ... }
Normally, the database will be on the same machine as the DHCPv6 server. In this case, set the value to the empty string:
"Dhcp6": { "hosts-database": { "host" : ""
, ... }, ... }
"Dhcp6": { "hosts-database": { "port" : 12345
, ... }, ... }
The maximum number of times the server will automatically attempt to reconnect to the host database after connectivity has been lost may be specified:
"Dhcp6": { "host-database": { "max-reconnect-tries" : number-of-tries
, ... }, ... }
If the server is unable to reconnect to the database after making the maximum number of attempts the server will exit. A value of zero (the default) disables automatic recovery and the server will exit immediately upon detecting a loss of connectivity (MySQL and Postgres only). For Cassandra, Kea uses a Cassandra interface that connects to all nodes in a cluster at the same time. Any connectivity issues should be handled by internal Cassandra mechanisms.
The number of milliseconds the server will wait between attempts to reconnect to the host database after connectivity has been lost may also be specified:
"Dhcp6": { "hosts-database": { "reconnect-wait-time" : number-of-milliseconds
, ... }, ... }
The default value for MySQL and Postgres is 0, which disables automatic recovery and causes the server to exit immediately upon detecting the loss of connectivity. The default value for Cassandra is 2000 ms.
Automatic reconnection to database backends is configured individually per backend. This allows you to tailor the recovery parameters to each backend you use. We do suggest that you enable it either for all backends or no backends so you have consistent behavior. Losing connectivity to a backend for which reconnect is disabled will result 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.
Finally, the credentials of the account under which the server will access the database should be set:
"Dhcp6": { "hosts-database": {"user": "
,user-name
""password": "
, ... }, ... }password
"
If there is no password to the account, set the password to the empty string "". (This is also the default.)
The multiple store extension uses a similar syntax; a configuration is placed into a "hosts-databases" list instead of into a "hosts-database" entry as in:
"Dhcp6": { "hosts-databases": [ { "type": "mysql"
, ... }, ... ], ... }
For additional Cassandra-specific parameters, see Section 8.2.2.3, “Cassandra-Specific Parameters”.
In some deployments the database 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.
Kea host database backends operate with an implicit configuration to both read from and write to the database. If the database 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 "read-only" mode. This is controlled by the readonly boolean parameter as follows:
"Dhcp6": { "hosts-database": { "readonly": true
, ... }, ... }
Setting this parameter to false
configures the
database backend to operate in "read-write" mode, which is also the default
configuration if the parameter is not specified.
The readonly parameter is currently only supported for MySQL and PostgreSQL databases.
The DHCPv6 server has to be configured to listen on specific network interfaces. The simplest network interface configuration instructs the server to listen on all available interfaces:
"Dhcp6": {
"interfaces-config": {
"interfaces": [ "*"
]
}
...
}
The asterisk plays the role of a wildcard and means "listen on all interfaces." However, it is usually a good idea to explicitly specify interface names:
"Dhcp6": {
"interfaces-config": {
"interfaces": [ "eth1", "eth3"
]
},
...
}
It is possible to use a wildcard interface name (asterisk) concurrently with explicit interface names:
"Dhcp6": {
"interfaces-config": {
"interfaces": [ "eth1", "eth3", "*"
]
},
...
}
It is anticipated that this form of usage will only be used when it is desired to temporarily override a list of interface names and listen on all interfaces.
As with the DHCPv4 server, binding to specific addresses and disabling re-detection of interfaces are supported. But dhcp-socket-type is not because DHCPv6 uses UDP/IPv6 sockets only. The following example shows how to disable the interface detection:
"Dhcp6": { "interfaces-config": { "interfaces": ["eth1", "eth3"
], "re-detect":false
}, ... }
The loopback interfaces (i.e. the "lo" or "lo0" interface) are not configured by default, unless explicitely 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:
"Dhcp6": {
"interfaces-config": {
"interfaces": [ "enp0s2/2001:db8::1234:abcd"
]
},
...
}
The subnet identifier is a unique number associated with a particular subnet. In principle, it is used to associate clients' leases with their respective subnets. When a subnet identifier is not specified for a subnet being configured, it will be automatically assigned by the configuration mechanism. The identifiers are assigned from 1 and are monotonically increased for each subsequent subnet: 1, 2, 3 ....
If there are multiple subnets configured with auto-generated identifiers and one of them is removed, the subnet identifiers may be renumbered. For example: if there are four subnets and the third is removed, the last subnet will be assigned the identifier that the third subnet had before removal. As a result, the leases stored in the lease database for subnet 3 are now associated with subnet 4, something that may have unexpected consequences. The only remedy for this issue at present is to manually specify a unique identifier for each subnet.
The following configuration will assign the specified subnet identifier to the newly configured subnet:
"Dhcp6": {
"subnet6": [
{
"subnet": "2001:db8:1::/64",
"id": 1024
,
...
}
]
}
This identifier will not change for this subnet unless the "id" parameter is removed or set to 0. The value of 0 forces auto-generation of the subnet identifier.
The subnet prefix is the second way to identify a subnet. It does not need to have the address part to match the prefix length, for instance this configuration is accepted:
"Dhcp6": {
"subnet6": [
{
"subnet": "2001:db8:1::1/64"
,
...
}
]
}
Even there is another subnet with the "2001:db8:1::/64" prefix: only the textual form of subnets are compared to avoid duplicates.
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 Section 9.2.4, “Interface Configuration”). 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, the interface name can be optionally followed by a slash, followed by the global unicast address on which the server should listen. The server listens 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 eth1 interface.
"Dhcp6": {
"interfaces-config": {
"interfaces": [ "eth1/2001:db8::1"
]
},
...
"option-data": [
{
"name": "unicast",
"data": "2001:db8::1"
} ],
...
}
This configuration will cause the server to listen on eth1 on the link-local address, the multicast group (ff02::1:2), and 2001:db8::1.
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 will cause the client to send messages to the specified unicast address.
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.
Care should be taken to specify proper unicast addresses. The server will attempt to bind to the addresses specified without any additional checks. This approach was selected on purpose to allow the software to communicate over uncommon addresses if so desired.
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 range 2001:db8:1::1 to 2001:db8:1::ffff are going to be managed by the Dhcp6 server. Such a configuration can be achieved in the following way:
"Dhcp6": {
"subnet6": [
{
"subnet": "2001:db8:1::/64",
"pools": [
{
"pool": "2001:db8:1::1-2001:db8:1::ffff"
}
],
...
}
]
}
Note that subnet is defined as a simple string, but the pools 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.
Each pool is a structure that contains the parameters that describe a single pool. Currently there is only one parameter, pool, which gives the range of addresses in the pool.
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 'f's is cumbersome. It can be expressed more simply as 2001:db8:1:0:5::/80. Both formats are supported by Dhcp6 and can be mixed in the pool list. For example, one could define the following pools:
"Dhcp6": {
"subnet6": [
{
"subnet": "2001:db8:1::/64",
"pools": [
{ "pool": "2001:db8:1::1-2001:db8:1::ffff" },
{ "pool": "2001:db8:1:05::/80" }
]
,
...
}
]
}
White space in pool definitions is ignored, so spaces before and after the hyphen are optional. They can be used to improve readability.
The number of pools is not limited, but for performance reasons it is recommended to use as few as possible.
The server may be configured to serve more than one subnet. To add a second subnet, use a command similar to the following:
"Dhcp6": {
"subnet6": [
{
"subnet": "2001:db8:1::/64",
"pools": [
{ "pool": "2001:db8:1::1-2001:db8:1::ffff" }
]
},
{
"subnet": "2001:db8:2::/64",
"pools": [
{ "pool": "2001:db8:2::/64" }
]
},
...
]
}
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.
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 will also be 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 "min-max" notation.
Subnets may also be configured to delegate prefixes, as defined in RFC 8415, 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 (prefix) and a prefix length (prefix-len), as well as a delegated prefix length (delegated-len). The delegated length must not be shorter than (that is, 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.
Below is a sample subnet configuration which enables prefix delegation for the subnet:
"Dhcp6": {
"subnet6": [
{
"subnet": "2001:d8b:1::/64",
"pd-pools": [
{
"prefix": "3000:1::",
"prefix-len": 64,
"delegated-len": 96
}
]
}
],
...
}
For each delegated prefix, the delegating router may choose to exclude a single prefix out of the delegated prefix as specified in RFC 6603. The requesting router must not assign the excluded prefix to any of its downstream interfaces, and it 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 "2001:db8:1:8000:cafe:80::/72" will be sent to a requesting router which includes the Prefix Exclude option in the ORO, and which is delegated a prefix from this pool.
"Dhcp6": { "subnet6": [ { "subnet": "2001:db8:1::/48", "pd-pools": [ { "prefix": "2001:db8:1:8000::", "prefix-len": 48, "delegated-len": 64, "excluded-prefix": "2001:db8:1:8000:cafe:80::", "excluded-prefix-len": 72 } ] } ] }
One of the major features of a 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 one of the most frequently used options, which supplies the address of DNS servers. Options specified in this way are considered global and apply to all configured subnets.
"Dhcp6": {
"option-data": [
{
"name": "dns-servers",
"code": 23,
"space": "dhcp6",
"csv-format": true,
"data": "2001:db8::cafe, 2001:db8::babe"
},
...
]
}
The option-data 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 name line specifies the option name. (For a complete list of currently supported names, see Table 9.1, “List of Standard DHCPv6 Options”.) The next line specifies the option code, which must match one of the values from that list. The line beginning with space specifies the option space, which must always be set to "dhcp6" as these are standard DHCPv6 options. For other name spaces, including custom option spaces, see Section 9.2.15, “Nested DHCPv6 Options (Custom Option Spaces)”. The following line specifies the format in which the data will be entered; use of CSV (comma-separated values) is recommended. Finally, the data line gives the actual value to be sent to clients. Data is specified as normal text, with values separated by commas if more than one value is allowed.
Options can also be configured as hexadecimal values. If "csv-format" is set to false, the option data must be specified as a hexadecimal string. The following commands configure the DNS-SERVERS option for all subnets with the following addresses: 2001:db8:1::cafe and 2001:db8:1::babe.
"Dhcp6": {
"option-data": [
{
"name": "dns-servers",
"code": 23,
"space": "dhcp6",
"csv-format": false,
"data": "20 01 0D B8 00 01 00 00 00 00 00 00 00 00 CA FE
20 01 0D B8 00 01 00 00 00 00 00 00 00 00 BA BE"
},
...
]
}
The value for the setting of the "data" 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.
Kea supports the following formats when specifying hexadecimal data:
Care should be taken to use proper encoding when using hexadecimal format. Kea's ability to validate data correctness in hexadecimal is limited.
Most of the parameters in the "option-data" structure are optional and can be omitted in some circumstances as discussed in Section 9.2.16, “Unspecified Parameters for DHCPv6 Option Configuration”. Only one of name or code is required; you don't need to specify both. Space has a default value of "dhcp6", so you can skip this as well if you define a regular (not encapsulated) DHCPv6 option. Finally, csv-format defaults to true, so it too can be skipped, unless you want to specify the option value as hexstring. Therefore the above example can be simplified to:
"Dhcp6": {
"option-data": [
{
"name": "dns-servers",
"data": "2001:db8::cafe, 2001:db8::babe"
},
...
]
}
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 "always-send" flag to true as in:
"Dhcp6": {
"option-data": [
{
"name": "dns-servers",
"data": "2001:db8::cafe, 2001:db8::babe",
"always-send": true
},
...
]
}
The effect is the same as if the client added the option code in the Option Request Option (or its equivalent for vendor options) so in:
"Dhcp6": { "option-data": [ {"name": "dns-servers", "data": "2001:db8::cafe, 2001:db8::babe", "always-send": true
}, ... ], "subnet6": [ { "subnet": "2001:db8:1::/64", "option-data": [ {"name": "dns-servers", "data": "2001:db8:1::cafe, 2001:db8:1::babe"
}, ... ], ... }, ... ], ... }
The DNS servers option is always added to responses (the always-send is "sticky") but the value is the subnet one when the client is localized in the subnet.
It is possible to override options on a per-subnet basis. If clients connected to most of your subnets are expected to get the same values of a given option, you should use global options; you can then override specific values for a small number of subnets. On the other hand, if you use different values in each subnet, it does not make sense to specify global option values; rather, you should set only subnet-specific ones.
The following commands override the global DNS servers option for a particular subnet, setting a single DNS server with address 2001:db8:1::3.
"Dhcp6": {
"subnet6": [
{
"option-data": [
{
"name": "dns-servers",
"code": 23,
"space": "dhcp6",
"csv-format": true,
"data": "2001:db8:1::3"
},
...
]
,
...
},
...
],
...
}
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 will assign 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 will be handed out to the client. The server's administrator must not try to prioritize assignment of pool-specific options by trying to order pools declarations in the server configuration.
The following configuration snippet demonstrates how to specify the DNS servers option, which will be assigned to a client only if the client obtains an address from the given pool:
"Dhcp6": {
"subnet6": [
{
"pools": [
{
"pool": "2001:db8:1::100-2001:db8:1::300",
"option-data": [
{
"name": "dns-servers",
"data": "2001:db8:1::10"
}
]
}
]
},
...
],
...
}
Options can also be specified in a class of host reservation scope. The current Kea options precedence order is (from most important): host reservation, pool, subnet, shared network, class, global.
The currently supported standard DHCPv6 options are listed in Table 9.1, “List of Standard DHCPv6 Options”. "Name" and "Code" are the values that should be used as a name/code in the option-data structures. "Type" designates the format of the data; the meanings of the various types is given in Table 8.2, “List of Standard DHCP Option Types”.
When a data field is a string, and that string contains the comma (,; U+002C) character, the comma must be escaped with double backslashes (\; U+005C). This double escape is required, because both the routine splitting CSV data into fields and JSON use the same escape character; a single escape (\,) would make the JSON invalid. For example, the string "EST5EDT4,M3.2.0/02:00,M11.1.0/02:00" would be represented as:
"Dhcp6": {
"subnet6": [
{
"pools": [
{
"option-data": [
{
"name": "new-posix-timezone",
"data": "EST5EDT4\\,M3.2.0/02:00\\,M11.1.0/02:00"
}
]
},
...
],
...
},
...
],
...
}
Some options are designated as arrays, which means that more than one value is allowed in such an option. For example, the option dns-servers allows the specification of more than one IPv6 address, enabling clients to obtain the addresses of multiple DNS servers.
Section 9.2.13, “Custom DHCPv6 Options” 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. There is an exception to this rule for standard options for which Kea currently does not provide a definition. In order to use such options, a server administrator must create a definition as described in Section 9.2.13, “Custom DHCPv6 Options” in the 'dhcp6' option space. This definition should match the option format described in the relevant RFC, but the configuration mechanism would allow any option format as it currently has no means to validate it.
Table 9.1. List of Standard DHCPv6 Options
Name | Code | Type | Array? |
---|---|---|---|
preference | 7 | uint8 | false |
unicast | 12 | ipv6-address | false |
vendor-opts | 17 | uint32 | false |
sip-server-dns | 21 | fqdn | true |
sip-server-addr | 22 | ipv6-address | true |
dns-servers | 23 | ipv6-address | true |
domain-search | 24 | fqdn | true |
nis-servers | 27 | ipv6-address | true |
nisp-servers | 28 | ipv6-address | true |
nis-domain-name | 29 | fqdn | true |
nisp-domain-name | 30 | fqdn | true |
sntp-servers | 31 | ipv6-address | true |
information-refresh-time | 32 | uint32 | false |
bcmcs-server-dns | 33 | fqdn | true |
bcmcs-server-addr | 34 | ipv6-address | true |
geoconf-civic | 36 | record (uint8, uint16, binary) | false |
remote-id | 37 | record (uint32, binary) | false |
subscriber-id | 38 | binary | false |
client-fqdn | 39 | record (uint8, fqdn) | false |
pana-agent | 40 | ipv6-address | true |
new-posix-timezone | 41 | string | false |
new-tzdb-timezone | 42 | string | false |
ero | 43 | uint16 | true |
lq-query (1) | 44 | record (uint8, ipv6-address) | false |
client-data (1) | 45 | empty | false |
clt-time (1) | 46 | uint32 | false |
lq-relay-data (1) | 47 | record (ipv6-address, binary) | false |
lq-client-link (1) | 48 | ipv6-address | true |
v6-lost | 51 | fqdn | false |
capwap-ac-v6 | 52 | ipv6-address | true |
relay-id | 53 | binary | false |
v6-access-domain | 57 | fqdn | false |
sip-ua-cs-list | 58 | fqdn | true |
bootfile-url | 59 | string | false |
bootfile-param | 60 | tuple | true |
client-arch-type | 61 | uint16 | true |
nii | 62 | record (uint8, uint8, uint8) | false |
aftr-name | 64 | fqdn | false |
erp-local-domain-name | 65 | fqdn | false |
rsoo | 66 | empty | false |
pd-exclude | 67 | binary | false |
rdnss-selection | 74 | record (ipv6-address, uint8, fqdn) | true |
client-linklayer-addr | 79 | binary | false |
link-address | 80 | ipv6-address | false |
solmax-rt | 82 | uint32 | false |
inf-max-rt | 83 | uint32 | false |
dhcp4o6-server-addr | 88 | ipv6-address | true |
s46-rule | 89 | record (uint8, uint8, uint8, ipv4-address, ipv6-prefix) | false |
s46-br | 90 | ipv6-address | false |
s46-dmr | 91 | ipv6-prefix | false |
s46-v4v6bind | 92 | record (ipv4-address, ipv6-prefix) | false |
s46-portparams | 93 | record(uint8, psid) | false |
s46-cont-mape | 94 | empty | false |
s46-cont-mapt | 95 | empty | false |
s46-cont-lw | 96 | empty | false |
v6-captive-portal | 103 | string | false |
ipv6-address-andsf | 143 | ipv6-address | true |
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.
Softwire46 options are involved in IPv4 over IPv6 provisioning by means of tunneling or translation as specified in RFC 7598. The following sections provide configuration examples of these options.
S46 container options group rules and optional port parameters for a specified domain. There are three container options specified in the "dhcp6" (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 encapsulated options specified below; they do not include any data fields.
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:
"Dhcp6": { ... "option-data": [ { "name": "s46-cont-mape" } ], ... }
This configuration will cause the server to include the MAP-E Container option to the client. Use "s46-cont-mapt" or "s46-cont-lw" for the MAP-T Container and S46 Lightweight 4over6 Container options, respectively.
All remaining Softwire options described below are included in one of the container options. Thus, they have to be included in appropriate option spaces by selecting a "space" name, which specifies in which option they are supposed to be included.
The S46 Rule option is used for conveying the Basic Mapping Rule (BMR) and Forwarding Mapping Rule (FMR).
{ "space": "s46-cont-mape-options", "name": "s46-rule", "data": "128, 0, 24, 192.0.2.0, 2001:db8:1::/64" }
Another possible "space" value is "s46-cont-mapt-options".
The S46 Rule option conveys a number of parameters:
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.
{ "space": "s46-cont-mape-options", "name": "s46-br", "data": "2001:db8:cafe::1", }
Another possible "space" value is "s46-cont-lw-options".
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.
{ "space": "s46-cont-mapt-options", "name": "s46-dmr", "data": "2001:db8:cafe::/64", }
This option must not be included in other containers.
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.
{ "space": "s46-cont-lw", "name": "s46-v4v6bind", "data": "192.0.2.3, 2001:db8:1:cafe::/64" }
This option must not be included in other containers.
The S46 Port Parameters option specifies optional port-set information that MAY be provided to CEs.
{ "space": "s46-rule-options", "name": "s46-portparams", "data": "2, 3/4", }
Another possible "space" value is "s46-v4v6bind", to include this option in the S46 IPv4/IPv6 Address Binding option.
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 PSID-len=4 and PSID=12288 conveyed in the S46 Port Parameters option.
It is possible to define options in addition to the standard ones. Assume that we want to define a new DHCPv6 option called "foo" which will have code 100 and which will convey a single, unsigned, 32-bit integer value. We can define such an option by using the following commands:
"Dhcp6": {
"option-def": [
{
"name": "foo",
"code": 100,
"type": "uint32",
"array": false,
"record-types": "",
"space": "dhcp6",
"encapsulate": ""
}, ...
],
...
}
The "false" value of the array parameter determines that the option does NOT comprise an array of "uint32" values but is, instead, a single value. Two other parameters have been left blank: record-types and encapsulate. The former specifies the comma-separated list of option data fields, if the option comprises a record of data fields. The record-types value should be non-empty if type is set to "record"; 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, it should be left blank. Note that the above example only defines the format of the new option and does not set its value(s).
Only the name, code, and type parameters are required; all others are optional. The array default value is false. The record-types and encapsulate default values are blank (i.e. ""). The default space is "dhcp6".
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.
"Dhcp6": {
"option-data": [
{
"name": "foo",
"code": 100,
"space": "dhcp6",
"csv-format": true,
"data": "12345"
}, ...
],
...
}
New options can take more complex forms than simple use of primitives (uint8, string, ipv6-address, etc); it is possible to define an option comprising a number of existing primitives.
For example, assume 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:
"Dhcp6": {
"option-def": [
{
"name": "bar",
"code": 101,
"space": "dhcp6",
"type": "record",
"array": false,
"record-types": "ipv6-address, uint16, boolean, string",
"encapsulate": ""
}, ...
],
...
}
The "type" is set to "record" to indicate that the option contains multiple values of different types. These types are given as a comma-separated list in the record-types field and should be ones from those listed in Table 8.2, “List of Standard DHCP Option Types”.
The values of the options are set in a option-data statement as follows:
"Dhcp6": {
"option-data": [
{
"name": "bar",
"space": "dhcp6",
"code": 101,
"csv-format": true,
"data": "2001:db8:1::10, 123, false, Hello World"
}
],
...
}
csv-format is set to true to indicate that the data field comprises a command-separated list of values. The values in data must correspond to the types set in the record-types field of the option definition.
When array is set to true and type is set to "record", the last field is an array, i.e. it can contain more than one value, as in:
"Dhcp6": {
"option-def": [
{
"name": "bar",
"code": 101,
"space": "dhcp6",
"type": "record",
"array": true,
"record-types": "ipv6-address, uint16",
"encapsulate": ""
}, ...
],
...
}
The new option content is one IPv6 address followed by one or more 16- bit unsigned integers.
In general, boolean values are specified as true or false, without quotes. Some specific boolean parameters may accept also "true", "false", 0, 1, "0", and "1".
Currently there are two option spaces defined for the DHCPv6 daemon: "dhcp6" (for top-level DHCPv6 options) and "vendor-opts-space", which is empty by default, but in which options can be defined. Those options are carried in the Vendor-Specific Information option (code 17). The following examples show how to define an option "foo" with code 1 that consists of an IPv6 address, an unsigned 16-bit integer, and a string. The "foo" option is conveyed in a Vendor-Specific Information option, which comprises a single uint32 value that is set to "12345". The sub-option "foo" follows the data field holding this value.
"Dhcp6": {
"option-def": [
{
"name": "foo",
"code": 1,
"space": "vendor-opts-space",
"type": "record",
"array": false,
"record-types": "ipv6-address, uint16, string",
"encapsulate": ""
}
],
...
}
(Note that the option space is set to vendor-opts-space.) Once the option format is defined, the next step is to define actual values for that option:
"Dhcp6": {
"option-data": [
{
"name": "foo",
"space": "vendor-opts-space",
"data": "2001:db8:1::10, 123, Hello World"
},
...
],
...
}
We should also define a value (enterprise-number) for the Vendor-Specific Information option, that conveys our option "foo".
"Dhcp6": {
"option-data": [
...,
{
"name": "vendor-opts",
"data": "12345"
}
],
...
}
Alternatively, the option can be specified using its code.
"Dhcp6": {
"option-data": [
...,
{
"code": 17,
"data": "12345"
}
],
...
}
It is sometimes useful to define completely new option spaces. This is the case when a user wants their new option to convey sub-options that use a separate numbering scheme, for example sub-options with codes 1 and 2. Those option codes conflict with standard DHCPv6 options, so a separate option space must be defined.
Note that the creation of a new option space is not required when defining sub-options for a standard option, because it is created by default if the standard option is meant to convey any sub-options (see Section 9.2.14, “DHCPv6 Vendor-Specific Options”).
Assume that we want to have a DHCPv6 option called "container" with code 102 that conveys two sub-options with codes 1 and 2. First we need to define the new sub-options:
"Dhcp6": { "option-def": [ {"name": "subopt1", "code": 1, "space": "isc", "type": "ipv6-address", "record-types": "", "array": false, "encapsulate": ""
}, {"name": "subopt2", "code": 2, "space": "isc", "type": "string", "record-types": "", "array": false "encapsulate": ""
} ], ... }
Note that we have defined the options to belong to a new option space (in this case, "isc").
The next step is to define a regular DHCPv6 option and specify that it should include options from the new option space:
"Dhcp6": {
"option-def": [
...,
{
"name": "container",
"code": 102,
"space": "dhcp6",
"type": "empty",
"array": false,
"record-types": "",
"encapsulate": "isc"
}
],
...
}
The name of the option space in which the sub-options are defined is set in the encapsulate field. The type field is set to empty, which limits this option to only carrying data in sub-options.
Finally, we can set values for the new options:
"Dhcp6": { "option-data": [ {"name": "subopt1", "code": 1, "space": "isc", "data": "2001:db8::abcd"
}, }"name": "subopt2", "code": 2, "space": "isc", "data": "Hello world"
}, {"name": "container", "code": 102, "space": "dhcp6"
} ], ... }
Note that 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 "container" option from the previous example were required to carry a uint16 value as well as the sub-options, the type value would have to be set to "uint16" 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 data parameter — which should be a valid integer enclosed in quotes, e.g. "123" — would then be assigned to the uint16 field in the "container" option.
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:
According to RFC 8415, section 21.4, the recommended T1 and T2 values are 50% and 80% of the preferred lease time, repsectively. Kea can be configured to send values that are specified explicitly or that are calculated as percentages of the preferred lease time. The server's behavior is governed by combination of configuration parameters, two of which have already been mentioned.
Beginning with Kea 1.6.0 lease preferred and valid lifetime are extended from single values to triplets with minimum, default and maximum values using:
When the client does not specify lifetimes the default is used. When it specifies a lifetime using IAADDR or IAPREFIX sub option with not zero values these values are used when they are between configured minimum (lower values are round up) and maximum (larger values are round down) bounds.
To send specific, fixed values use the following two parameters:
You may specify any value for T2 greater than or equal to zero. When specifying T1 it must be less than T2. This flexibility is allowed to support a use case where admins want to suppress client renewals and rebinds by deferring them beyond the life span of the lease. This should cause the lease to expire, rather than get renewed by clients. If T1 is specified as larger than T2, it will be set to zero in the outbound IA.
In 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 out there that will start renewing immediately. If you plan to use T1=T2=0 values, please test first and make sure your clients behave rationally.
In some rare cases there may be a need to disable client's ability to renew addresses. This is undesired from protocol perspective and should be avoided if possible. However, if you want to do this, you can configure your T1 and T2 values to be equal or greater to your valid lifetime. Be advised that this will cause your clients to ocasionally 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 you want to break long lasting connections on purpose).
Calculating the values is controlled by the following three parameters.
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.
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, and it can use that information to detect whether a subnet is local. That assumption is not true in IPv6; the DHCPv6 server must be able to operate while only using link-local addresses. Therefore, 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, the server that is intended to serve a local subnet over eth0 may be configured as follows:
"Dhcp6": {
"subnet6": [
{
"subnet": "2001:db8:beef::/48",
"pools": [
{
"pool": "2001:db8:beef::/48"
}
],
"interface": "eth0"
}
],
...
}
The Rapid Commit option, described in RFC 8415, is supported by the Kea DHCPv6 server. However, support is disabled by default. It can be enabled on a per-subnet basis using the rapid-commit parameter as shown below:
"Dhcp6": {
"subnet6": [
{
"subnet": "2001:db8:beef::/48",
"rapid-commit": true
,
"pools": [
{
"pool": "2001:db8:beef::1-2001:db8:beef::10"
}
],
}
],
...
}
This setting only affects the subnet for which the rapid-commit is set to true. For clients connected to other subnets, the server will ignore the Rapid Commit option sent by the client and will follow the 4-way exchange procedure, i.e. respond with an Advertise for a Solicit containing a Rapid Commit option.
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:
The first uses the linkaddr field in the RELAY_FORW 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's request.
The second mechanism is based on interface-id options. While forwarding a client's message, relays may insert an interface-id 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 hardcoded and may range from the very simple (e.g. "vlan100") to the very cryptic; one example seen on real hardware was "ISAM144|299|ipv6|nt:vp:1:110"). 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.
When configuring the DHCPv6 server, it should be noted that two similarly named parameters can be configured for a subnet:
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.
The following example configuration shows how to specify an interface-id with a value of "vlan123":
"Dhcp6": {
"subnet6": [
{
"subnet": "2001:db8:beef::/48",
"pools": [
{
"pool": "2001:db8:beef::/48"
}
],
"interface-id": "vlan123"
}
],
...
}
RFC 6422 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 will then do certain checks and copy those options to the response sent to the client.
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 "Relay Supplied Options option.") IANA maintains a list of RSOO-enabled options here. 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:
"Dhcp6": {
"relay-supplied-options": [ "110", "120", "130" ],
...
}
As of February 2019, only option 65 is RSOO-enabled by IANA. This option will always be treated as such, so there is no need to explicitly mark it. Also, when enabling standard options, it is possible to use their names, rather than option code, e.g. use dns-servers instead of 23. See Table 9.1, “List of Standard DHCPv6 Options” for the names. In certain cases it could also work for custom options, but due to the nature of the parser code this may be unreliable and should be avoided.
The DHCPv6 server includes support for client classification. For a deeper discussion of the classification process see Chapter 14, Client Classification.
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 the DHCP message processing. In the current release of Kea, there are three mechanisms that take advantage of client classification in DHCPv6: subnet selection, address pool selection, and DHCP options assignment.
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 a lease from subnet B. That segregation is essential to prevent overly curious users from playing with their cable modems. For details on how to set up class restrictions on subnets, see Section 14.6, “Configuring Subnets With Class Information”.
When subnets belong to a shared network, the classification applies to subnet selection but not to pools, e.g., 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. So the limit on access based on class information is also available at the address/prefix pool level; see Section 14.7, “Configuring Pools With Class Information”, within a subnet. This is useful when segregating clients belonging to the same subnet into different address ranges.
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 "KNOWN" or "UNKNOWN" classes. One can assign addresses 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 KNOWN/UNKNOWN classes to select a shared network or a subnet.
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. Next, a subnet is chosen, possibly based on the class information. When the incoming packet is in the special class, "DROP", it is dropped and a debug message logged. After that, class expressions are evaluated depending on the built-in "KNOWN"/"UNKNOWN" 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 "true" the packet is added as a member of the class. Finally, options are assigned, again possibly based on the class information. More complete and detailed information is available in Chapter 14, Client Classification.
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 specifies an expression that is evaluated for each packet. If the result is "true", the packet is a member of the class.
Care should be taken with client classification, as it is easy for clients that do not meet class criteria to be denied all service.
The following example shows how to configure a class using an expression and a subnet using that class. This configuration defines the class named "Client_enterprise". 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). They 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.
"Dhcp6": { "client-classes": [ {"name": "Client_enterprise", "test": "substring(option[1].hex,0,6) == 0x0002AABBCCDD", "option-data": [ { "name": "dns-servers", "code": 23, "space": "dhcp6", "csv-format": true, "data": "2001:db8:0::1, 2001:db8:2::1" } ]
}, ... ], "subnet6": [ { "subnet": "2001:db8:1::/64", "pools": [ { "pool": "2001:db8:1::-2001:db8:1::ffff" } ],"client-class": "Client_enterprise"
} ], ... }
This example shows a configuration using an automatically generated "VENDOR_CLASS_" 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 DHCP6 server and that only clients belonging to the eRouter1.0 client class are allowed to use that pool.
"Dhcp6": {
"subnet6": [
{
"subnet": "2001:db8:1::/64",
"pools": [
{
"pool": "2001:db8:1::-2001:db8:1::ffff"
}
],
"client-class": "VENDOR_CLASS_eRouter1.0"
}
],
...
}
In some cases it is useful to limit the scope of a class to a shared-network, subnet, or pool. There are two parameters which are used to limit the scope of the class by instructing the server to perform evaluation of test expressions when required.
The first one is the per-class only-if-required flag which is false by default. When it is set to true, the test expression of the class is not evaluated at the reception of the incoming packet but later, and only if the class evaluation is required.
The second is require-client-classes, which takes a list of class names and is valid in shared-network, subnet, and pool scope. Classes in these lists are marked as required and evaluated after selection of this specific shared-network/subnet/pool and before output option processing.
In this example, a class is assigned to the incoming packet when the specified subnet is used:
"Dhcp6": { "client-classes": [ {"name": "Client_foo", "test": "member('ALL')", "only-if-required": true
}, ... ], "subnet6": [ { "subnet": "2001:db8:1::/64" "pools": [ { "pool": "2001:db8:1::-2001:db8:1::ffff" } ],"require-client-classes": [ "Client_foo" ],
... }, ... ], ... }
Required evaluation can be used to express complex dependencies, for example, subnet membership. It can also be used to reverse the precedence; if you set an option-data in a subnet it takes precedence over an option-data in a class. When you move the option-data to a required class and require it in the subnet, a class evaluated earlier may take precedence.
Required evaluation is also available at shared-network and pool/pd-pool levels. The order in which required classes are considered is: shared-network, subnet, and (pd-)pool, i.e. the opposite order that option-data is processed.
As mentioned earlier, kea-dhcp6 can be configured to generate requests to the DHCP-DDNS server (referred to here as "D2") to update DNS entries. These requests are known as Name Change Requests or NCRs. Each NCR contains the following information:
Whether it is a request to add (update) or remove DNS entries
Whether the change requests forward DNS updates (AAAA records), reverse DNS updates (PTR records), or both
The Fully Qualified Domain Name (FQDN), lease address, and DHCID (information identifying the client associated with the FQDN)
The parameters controlling the generation of NCRs for submission to D2 are contained in the dhcp-ddns section of the kea-dhcp6 server configuration. The mandatory parameters for the DHCP DDNS configuration are enable-updates, which is unconditionally required, and qualifying-suffix, which has no default value and is required when enable-updates is set to true. The two (disabled and enabled) minimal DHCP DDNS configurations are:
"Dhcp6": {
"dhcp-ddns": {
"enable-updates": false
},
...
}
and for example:
"Dhcp6": {
"dhcp-ddns": {
"enable-updates": true,
"qualifying-suffix": "example."
},
...
}
The default values for the "dhcp-ddns" section are as follows:
For NCRs to reach the D2 server, kea-dhcp6 must be able to communicate with it. kea-dhcp6 uses the following configuration parameters to control this communication:
By default, kea-dhcp-ddns is assumed to be running on the same machine as kea-dhcp6, 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 altered accordingly. For example, if D2 has been configured to listen on 2001:db8::5 port 900, the following configuration is required:
"Dhcp6": {
"dhcp-ddns": {
"server-ip": "2001:db8::5",
"server-port": 900
,
...
},
...
}
kea-dhcp6 follows the behavior prescribed for DHCP servers in RFC 4704. It is important to keep in mind that kea-dhcp6 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 (Chapter 12, The DHCP-DDNS Server). This section describes when kea-dhcp6 will generate NCRs and the configuration parameters that can be used to influence this decision. It assumes that the enable-updates parameter is true.
Currently the interface between kea-dhcp6 and D2 only supports requests which update DNS entries for a single IP address. If a lease grants more than one address, kea-dhcp6 will create the DDNS update request for only the first of these addresses.
In general, kea-dhcp6 will generate DDNS update requests when:
A new lease is granted in response to a DHCPREQUEST
An existing lease is renewed but the FQDN associated with it has changed
An existing lease is released in response to a DHCPRELEASE
In the second case, lease renewal, two DDNS requests will be issued: one request to remove entries for the previous FQDN, and a second request to add entries for the new FQDN. In the last case, a lease release, a single DDNS request to remove its entries will be made.
The decisions involved when granting a new lease the first case) are more complex. When a new lease is granted, kea-dhcp6 will generate a DDNS update request only if the DHCPREQUEST contains the FQDN option (code 39). By default, kea-dhcp6 will respect the FQDN N and S flags specified by the client as shown in the following table:
Table 9.2. Default FQDN Flag Behavior
Client Flags:N-S | Client Intent | Server Response | Server Flags:N-S-O |
---|---|---|---|
0-0 | Client wants to do forward updates, server should do reverse updates | Server generates reverse-only request | 1-0-0 |
0-1 | Server should do both forward and reverse updates | Server generates request to update both directions | 0-1-0 |
1-0 | Client wants no updates done | Server does not generate a request | 1-0-0 |
The first row in the table above represents "client delegation". Here the DHCP client states that it intends to do the forward DNS updates and the server should do the reverse updates. By default, kea-dhcp6 will honor the client's wishes and generate a DDNS request to D2 to update only reverse DNS data. The parameter override-client-update can be used to instruct the server to override client delegation requests. When this parameter is true, kea-dhcp6 will disregard requests for client delegation and generate a DDNS request to update both forward and reverse DNS data. In this case, the N-S-O flags in the server's response to the client will be 0-1-1 respectively.
(Note that the flag combination N=1, S=1 is prohibited according to RFC 4702. If such a combination is received from the client, the packet will be dropped by kea-dhcp6.)
To override client delegation, set the following values in the configuration file:
"Dhcp6": {
"dhcp-ddns": {
"override-client-update": true
,
...
},
...
}
The third row in the table above describes the case in which the client requests that no DNS updates be done. The parameter, override-no-update, can be used to instruct the server to disregard the client's wishes. When this parameter is true, kea-dhcp6 will generate DDNS update requests to kea-dhcp-ddns even if the client requests no updates be done. The N-S-O flags in the server's response to the client will be 0-1-1.
To override client delegation, issue the following commands:
"Dhcp6": {
"dhcp-ddns": {
"override-no-update": true
,
...
},
...
}
Each Name Change Request must of course include the fully qualified domain name whose DNS entries are to be affected. kea-dhcp6 can be configured to supply a portion or all of that name, based upon what it receives from the client in the DHCPREQUEST.
The default rules for constructing the FQDN that will be used for DNS entries are:
If the DHCPREQUEST contains the client FQDN option, take the candidate name from there.
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.
If the candidate name provided is empty, generate an FQDN using a configurable prefix and suffix.
If the client provided neither option, then no DNS action will be taken.
These rules can be amended by setting the replace-client-name parameter, which provides the following modes of behavior:
never - Use the name the client sent. If the client sent no name, do not generate one. This is the default mode.
always - Replace the name the client sent. If the client sent no name, generate one for the client.
when-present - Replace the name the client sent. If the client sent no name, do not generate one.
when-not-present - Use the name the client sent. If the client sent no name, generate one for the client.
For example, to instruct kea-dhcp6 to always generate the FQDN for a client, set the parameter replace-client-name to always as follows:
"Dhcp6": {
"dhcp-ddns": {
"replace-client-name": "always"
,
...
},
...
}
The prefix used in the generation of an FQDN is specified by the generated-prefix parameter. The default value is "myhost". To alter its value, simply set it to the desired string:
"Dhcp6": {
"dhcp-ddns": {
"generated-prefix": "another.host"
,
...
},
...
}
The suffix used when generating an FQDN, or when qualifying a partial name, is specified by the qualifying-suffix parameter. This parameter has no default value, thus it is mandatory when DDNS updates are enabled. To set its value simply set it to the desired string:
"Dhcp6": {
"dhcp-ddns": {
"qualifying-suffix": "foo.example.org"
,
...
},
...
}
When qualifying a partial name, kea-dhcp6 will construct the name in the format:
[candidate-name].[qualifying-suffix].
where candidate-name is the partial name supplied in the DHCPREQUEST. For example, if the FQDN domain name value is "some-computer" and the qualifying-suffix "example.com", the generated FQDN is:
some-computer.example.com.
When generating the entire name, kea-dhcp6 will construct the name in the format:
[generated-prefix]-[address-text].[qualifying-suffix].
where address-text is simply the lease IP address converted to a hyphenated string. For example, if the lease address is 3001:1::70E, the qualifying suffix "example.com", and the default value is used for generated-prefix, the generated FQDN would be:
myhost-3001-1--70E.example.com.
"Dhcp4": { "dhcp-ddns": { "hostname-char-set": "[^A-Za-z0-9.-]", "hostname-char-replacement": "x", ... }, ... }Thus, a client supplied value of "myhost-$[123.org" would become "myhost-xx123.org". 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).
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. If you find you have clients that are using odd corner cases of character combinations that cannot be readily handled with this mechanism, you should consider writing a hook that can carry out sufficiently complex logic to address your needs.
Do not include dots in your hostname-char-set expression. 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.
If your clients are sending values that differ only by characters considered as invalid by your hostname-char-set, 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.
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 hostname-char-replacement could yield an empty domain label within a name, if that label consists only of invalid characters.
The support of DHCPv4-over-DHCPv6 transport is described in RFC 7341 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 Section 8.2.23, “DHCPv4-over-DHCPv6: DHCPv4 Side”).
There is only one specific parameter for the DHCPv6 side: dhcp4o6-port, 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 port and connected to ::1 on port + 1).
Two other configuration entries are generally required: unicast traffic support (see Section 9.2.7, “Unicast Traffic Support”) and DHCP 4o6 server address option (name "dhcp4o6-server-addr", code 88).
The following configuration was used during some tests:
{
# DHCPv6 conf
"Dhcp6": {
"interfaces-config": {
"interfaces": [ "eno33554984/2001:db8:1:1::1" ]
},
"lease-database": {
"type": "memfile",
"name": "leases6"
},
"preferred-lifetime": 3000,
"valid-lifetime": 4000,
"renew-timer": 1000,
"rebind-timer": 2000,
"subnet6": [ {
"subnet": "2001:db8:1:1::/64",
"interface": "eno33554984",
"pools": [ { "pool": "2001:db8:1:1::1:0/112" } ]
} ],
"dhcp4o6-port": 6767,
"option-data": [ {
"name": "dhcp4o6-server-addr",
"code": 88,
"space": "dhcp6",
"csv-format": true,
"data": "2001:db8:1:1::1"
} ],
"loggers": [ {
"name": "kea-dhcp6",
"output_options": [ {
"output": "/tmp/kea-dhcp6.log"
} ],
"severity": "DEBUG",
"debuglevel": 0
} ]
}
}
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 that temporarily removed a subnet from a configuration wouldn't want all the leases associated with it disappear from the lease database. Kea has a mechanism to control sanity checks for situations such as this.
Kea supports a configuration scope called sanity-checks. It currently allows only a single parameter called lease-checks, which 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.
Every subnet has a subnet-id value; this is how Kea internally identifies subnets. Each lease has a subnet-id parameter as well, which identifies which subnet it belongs to. However, if the configuration has changed, it is possible that a lease could exist with a subnet-id, but without any subnet that matches it. Also, it may be possible that the subnet's configuration has changed and the subnet-id now belongs to a subnet that does not match the lease. Kea's corrective algorithm first checks to see if there is a subnet with the subnet-id specified by the lease. If there is, it verifies whether the lease belongs to that subnet. If not, depending on the lease-checks setting, the lease is discarded, a warning is displayed, or a new subnet is selected for the lease that matches it topologically.
Since delegated prefixes do not have to belong to a subnet in which they're offered, there is no way to implement such a mechanism for IPv6 prefixes. As such, the mechanism works for IPv6 addresses only.
There are five levels which are supported:
This feature is currently implemented for the memfile backend.
An example configuration that sets this parameter looks as follows:
"Dhcp6": {
"sanity-checks": {
"lease-checks": "fix-del"
},
...
}
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 will get the same address or/and prefix every time, and other clients will never get that address. Another example when host reservations are applicable is 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.
Note that there may be cases when a new reservation has been made for a client for the address or prefix currently in use by another client. We call this situation a "conflict." The conflicts get resolved automatically over time as described in subsequent sections. Once the conflict is resolved, the client will keep receiving the reserved configuration when it renews.
Host reservations are defined as parameters for each subnet. Each host must be identified by either DUID or its hardware/MAC address. See Section 9.11, “MAC/Hardware Addresses in DHCPv6” for details. There is an optional reservations array in the subnet6 structure. Each element in that array is a structure that holds information about a single host. In particular, the structure has an identifier that uniquely identifies a host. In the DHCPv6 context, such an identifier is usually a DUID, but 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.
The following example shows how to reserve addresses and prefixes for specific hosts:
"subnet6": [
{
"subnet": "2001:db8:1::/48",
"pools": [ { "pool": "2001:db8:1::/80" } ],
"pd-pools": [
{
"prefix": "2001:db8:1:8000::",
"prefix-len": 48,
"delegated-len": 64
}
],
"reservations": [
{
"duid": "01:02:03:04:05:0A:0B:0C:0D:0E",
"ip-addresses": [ "2001:db8:1::100" ]
},
{
"hw-address": "00:01:02:03:04:05",
"ip-addresses": [ "2001:db8:1::101", "2001:db8:1::102" ]
},
{
"duid": "01:02:03:04:05:06:07:08:09:0A",
"ip-addresses": [ "2001:db8:1::103" ],
"prefixes": [ "2001:db8:2:abcd::/64" ],
"hostname": "foo.example.com"
}
]
}
]
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.
Note that DHCPv6 allows a single client to lease multiple addresses and multiple prefixes at the same time. Therefore ip-addresses and prefixes 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.
Making a reservation for a mobile host that may visit multiple subnets requires a separate host definition in each subnet it 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.
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 also supports 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.
In a typical 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 belongs to configured pools are called "in-pool reservations." In contrast, those that do not belong to dynamic pools are called "out-of-pool reservations." There is no formal difference in the reservation syntax and both reservation types are handled uniformly.
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 will still match inbound client packets to a subnet as before, but when the subnet's reservation mode is set to "global", Kea will look for host reservations only among the global reservations defined. Typcially, such reservations would be used to reserve hostnames for clients which may move from one subnet to another.
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.
The server now has a conflict to resolve. If Host B boots up and requests an address, the server is not able to 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 someone else (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.
When Host A renews its address, the server will discover that the address being renewed is now reserved for someone else (Host B). Therefore, 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 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 renews 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 zeroed lifetimes, and the new one that matches the reservation with proper lifetimes set.
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.
This recovery mechanism allows the server to fully recover from a case where reservations conflict with existing leases. This procedure takes time and will roughly take as long as the value set for renew-timer. The best way to avoid such 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 this address.
The conflict-resolution mechanism does not work for global reservations. As of Kea 1.5.0, it is generally recommended not to use global reservations for addresses or prefixes. If you choose to use them anyway, you must manually ensure that the reserved values are not in the dynamic pools.
When the reservation for a client includes the hostname, the server will assign this hostname to the client and send it back in the Client FQDN, if the client sent the FQDN option 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.
The server qualifies the reserved hostname with the value of the qualifying-suffix parameter. For example, the following subnet configuration:
"subnet6": [ { "subnet": "2001:db8:1::/48", "pools": [ { "pool": "2001:db8:1::/80" } ], "reservations": [ { "duid": "01:02:03:04:05:0A:0B:0C:0D:0E", "ip-addresses": [ "2001:db8:1::100" ] "hostname": "alice-laptop" } ] } ], "dhcp-ddns": { "enable-updates": true, "qualifying-suffix": "example.isc.org." }
will result in assigning the "alice-laptop.example.isc.org." hostname to the client using the DUID "01:02:03:04:05:0A:0B:0C:0D:0E". If the qualifying-suffix is not specified, the default (empty) value will be used, and in this case the value specified as a hostname will be treated as a fully qualified name. Thus, by leaving the qualifying-suffix empty it is possible to qualify hostnames for different clients with different domain names:
"subnet6": [ { "subnet": "2001:db8:1::/48", "pools": [ { "pool": "2001:db8:1::/80" } ], "reservations": [ { "duid": "01:02:03:04:05:0A:0B:0C:0D:0E", "ip-addresses": [ "2001:db8:1::100" ] "hostname": "mark-desktop.example.org." } ] } ], "dhcp-ddns": { "enable-updates": true, }
The above example results in the assignment of the "mark-desktop.example.org." hostname to the client using the DUID "01:02:03:04:05:0A:0B:0C:0D:0E".
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 Section 9.2.11, “Standard DHCPv6 Options”), custom options (see Section 9.2.13, “Custom DHCPv6 Options”), or vendor-specific options (see Section 9.2.14, “DHCPv6 Vendor-Specific Options”). The following example demonstrates how standard options can be defined.
"reservations": [
{
"duid": "01:02:03:05:06:07:08",
"ip-addresses": [ "2001:db8:1::2" ],
"option-data": [
{
"option-data": [ {
"name": "dns-servers",
"data": "3000:1::234"
},
{
"name": "nis-servers",
"data": "3000:1::234"
}
} ]
} ]
Vendor-specific options can be reserved in a similar manner:
"reservations": [
{
"duid": "aa:bb:cc:dd:ee:ff",
"ip-addresses": [ "2001:db8::1" ],
"option-data": [
{
"name": "vendor-opts",
"data": 4491
},
{
"name": "tftp-servers",
"space": "vendor-4491",
"data": "3000:1::234"
} ]
} ]
Options defined at host level have the highest priority. In other words, if there are options defined with the same type on global, subnet, class, and host level, the host-specific values will be used.
Section 14.3, “Using Expressions in Classification” 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 reservations mechanisms also allow for the static assignment of classes to clients. The definitions of these classes are placed in the Kea configuration. The following configuration snippet shows how to specify that the client belongs to classes reserved-class1 and reserved-class2. Those classes are associated with specific options being sent to the clients which belong to them.
{
"client-classes": [
{
"name": "reserved-class1",
"option-data": [
{
"name": "dns-servers",
"data": "2001:db8:1::50"
}
]
},
{
"name": "reserved-class2",
"option-data": [
{
"name": "nis-servers",
"data": "2001:db8:1::100"
}
]
}
],
"subnet6": [
{ "pools": [ { "pool": "2001:db8:1::/64" } ],
"subnet": "2001:db8:1::/48",
"reservations": [
{
"duid": "01:02:03:04:05:06:07:08",
"client-classes": [ "reserved-class1", "reserved-class2" ]
} ]
} ]
}
Static class assignments, as shown above, can be used in conjunction with classification, using expressions. The "KNOWN" or "UNKNOWN" builtin class is added to the packet and any class depending on it (directly or indirectly) and not only-if-required is evaluated.
If you want to force the evaluation of a class expression after the host reservation lookup, for instance because of a dependency on "reserved-class1" from the previous example, you should add a "member('KNOWN')" statement in the expression.
It is possible to store host reservations in MySQL, PostgreSQL, or Cassandra. See
Section 9.2.3, “Hosts Storage” for information on how to configure Kea to use
reservations stored in MySQL, PostgreSQL, or Cassandra. Kea provides a dedicated hook for
managing reservations in a database; section Section 15.4.4, “host_cmds: Host Commands” provides
detailed information. The Kea wiki https://gitlab.isc.org/isc-projects/kea/wikis/designs/commands#23-host-reservations-hr-management
provides some examples of how to conduct common host reservations operations.
In Kea, the maximum length of an option specified per-host is arbitrarily set to 4096 bytes.
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. Second, 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, so the existing (dynamically allocated) address should be revoked and the reserved one be used instead.
Some of those checks may be unnecessary in certain deployments and not performing them may improve performance. The Kea server provides the reservation-mode configuration parameter 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. Allowed values are:
The parameter can be specified at global, subnet, and shared-network levels.
An example configuration that disables reservation looks as follows:
"Dhcp6": {
"subnet6": [
{
"subnet": "2001:db8:1::/64",
"reservation-mode": "disabled"
,
...
}
]
}
An example configuration using global reservations is shown below:
"Dhcp6": {
"reservation-mode": "global",
"reservations": [
{
"duid": "00:03:00:01:11:22:33:44:55:66",
"hostname": "host-one"
},
{
"duid": "00:03:00:01:99:88:77:66:55:44",
"hostname": "host-two"
}
],
"subnet6": [
{
"subnet": "2001:db8:1::/64",
...
}
]
}
For more details regarding global reservations, see Section 9.3.8, “Global Reservations in DHCPv6”.
Another aspect of the 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 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.
To address this problem, a parameter called host-reservation-identifiers has been introduced. It takes a list of identifier types as a parameter. Kea will check only those identifier types enumerated in host-reservation-identifiers. From a performance perspective, the number of identifier types should be kept to a minimum, ideally one. If your 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 host reservation identifiers looks as follows:
"host-reservation-identifiers": [ "duid", "hw-address" ],
"subnet6": [
{
"subnet": "2001:db8:1::/64",
...
}
]
If not specified, the default value is:
"host-reservation-identifiers": [ "hw-address", "duid" ]
In some deployments, such as mobile, clients can roam within the network and certain parameters must be specified regardless of the client's current location. To facilitate such a need, a global reservation mechanism has been implemented. 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.
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. However, global reservations that assign either of these bypass the whole topology determination provided by DHCP logic implemented in Kea. It is very easy to misuse this feature and get a configuration that is inconsistent. To give a specific example, imagine a global reservation for an address 2001:db8:1111::1 and two subnets 2001:db8:1111::/48 and 2001:db8:ffff::/48. If global reservations are used in both subnets and a device matching global host reservations visits part of the network that is covered by 2001:db8:ffff::/48, it will get an IP address 2001:db8:ffff::1, which will be outside of the prefix announced by its local router using Router Advertisements. Such a configuration would be unusable or, at the very least, riddled with issues, such as downlink traffic not reaching the device.
To use global host reservations, a configuration similar to the following can be used:
"Dhcp6:" { // This specifies global reservations. They will apply to all subnets that // have global reservations enabled."reservations": [ { "hw-address": "aa:bb:cc:dd:ee:ff", "hostname": "hw-host-dynamic" }, { "hw-address": "01:02:03:04:05:06", "hostname": "hw-host-fixed", // Use of IP address is global reservation is risky. If used outside of // matching subnet, such as 3001::/64, it will result in a broken // configuration being handled to the client. "ip-address": "2001:db8:ff::77" }, { "duid": "01:02:03:04:05", "hostname": "duid-host" } ]
, "valid-lifetime": 600, "subnet4": [ { "subnet": "2001:db8:1::/64","reservation-mode": "global",
"pools": [ { "pool": "2001:db8:1::-2001:db8:1::100" } ] } ] }
When using database backends, the global host reservations are distinguished from regular reservations by using subnet-id value of zero.
DHCP servers use subnet information in two ways. First, it is used to determine the point of attachment, or simply put, where the client is connected to the network. Second, the subnet information is used to group information pertaining to a specific location in the network. This approach works well in general cases, but there are scenarios where the boundaries are blurred. Sometimes it is useful to have more than one logical IP subnet being deployed on the same physical link. The need to understand that two or more subnets are used on the same link requires additional logic in the DHCP server. This capability is called "shared networks" in Kea and ISC DHCP configurations. It is sometimes also called "shared subnets." In Microsoft's nomenclature it is called "multinet."
There are many use cases where the feature is useful. The most common example in the IPv4 case is when the server is running out of available addresses in a subnet. This is less common in IPv6, but shared networks are still useful in IPv6. One of the use cases is an exhaustion of IPv6- delegated prefixes within a subnet. Another IPv6-specific example is an 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 old and new addressing to be available. Thus the need for more than one subnet on the same physical link.
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 address-space exhaustion.
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 pools exhaustion), it will use another subnet from the same shared network and try to allocate a lease from this subnet, etc. Therefore, in the typical case, the server will allocate 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 the other subnets before the pools in the first subnet get exhausted, e.g. when the client provides a hint that belongs to another subnet or the client has reservations in a subnet other than the default.
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.
In order to define a shared network an additional configuration scope is introduced:
{
"Dhcp6": {
"shared-networks": [
{
// Name of the shared network. It may be an arbitrary string
// and it must be unique among all shared networks.
"name": "ipv6-lab-1",
// The subnet selector can be specifed on the shared network level.
// Subnets from this shared network will be selected for clients
// communicating via relay agent having the specified IP address.
"relay": {
"ip-addresses": [ "2001:db8:2:34::1" ]
},
// This starts a list of subnets in this shared network.
// There are two subnets in this example.
"subnet6": [
{
"subnet": "2001:db8::/48",
"pools": [ { "pool": "2001:db8::1 - 2001:db8::ffff" } ]
},
{
"subnet": "3ffe:ffe::/64",
"pools": [ { "pool": "3ffe:ffe::/64" } ]
}
]
} ]
, // end of shared-networks
// It is likely that in your network you'll have a mix of regular,
// "plain" subnets and shared networks. It is perfectly valid to mix
// them in the same config file.
//
// This is regular subnet. It's not part of any shared-network.
"subnet6": [
{
"subnet": "2001:db9::/48",
"pools": [ { "pool": "2001:db9::/64" } ],
"relay": {
"ip-addresses": [ "2001:db8:1:2::1" ]
}
}
]
} // end of Dhcp6
}
As you see in the example, it is possible to mix shared and regular ("plain") subnets. Each shared network must have a unique name. This is similar to the ID for subnets, but gives administrators more flexibility. This is used for logging, but also internally for identifying shared networks.
In principle it makes sense to define only shared networks that consist of two or more subnets. However, for testing purposes it is allowed to define a shared network with just one subnet or even an empty one. This is not a recommended practice in production networks, as the shared network logic requires additional processing and thus lowers the server's performance. To avoid unnecessary performance degradation, the shared subnets should only be defined when required by the deployment.
Shared networks provide an ability to specify many parameters in the shared network scope that will apply to all subnets within it. If necessary, you can specify a parameter in the shared network scope and then override its value in the subnet scope. For example:
"shared-networks": [ { "name": "lab-network3", "relay": { "ip-addresses": [ "2001:db8:2:34::1" ] }, // This applies to all subnets in this shared network, unless // values are overridden on subnet scope."valid-lifetime": 600
, // This option is made available to all subnets in this shared // network."option-data": [ { "name": "dns-servers", "data": "2001:db8::8888" } ]
, "subnet6": [ { "subnet": "2001:db8:1::/48", "pools": [ { "pool": "2001:db8:1::1 - 2001:db8:1::ffff" } ], // This particular subnet uses different values."valid-lifetime": 1200, "option-data": [ { "name": "dns-servers", "data": "2001:db8::1:2" }, { "name": "unicast", "data": "2001:abcd::1" } ]
}, { "subnet": "2001:db8:2::/48", "pools": [ { "pool": "2001:db8:2::1 - 2001:db8:2::ffff" } ], // This subnet does not specify its own valid-lifetime value, // so it is inherited from shared network scope."option-data": [ { "name": "dns-servers", "data": "2001:db8:cafe::1" } ]
} ], } ]
In this example, there is a dns-servers option defined that is available to clients in both subnets in this shared network. Also, a valid lifetime is set to 10 minutes (600s). However, the first subnet overrides some of the values (valid lifetime is 20 minutes, different IP address for dns-servers), but also adds its own option (unicast address). Assuming a client asking for a server unicast and dns servers options is assigned a lease from this subnet, it will get a lease for 20 minutes and dns-servers, 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 dns-servers value of 2001:db8:cafe::1, and no server unicast.
Some parameters must be the same in all subnets in the same shared network. This restriction applies to the interface and rapid-commit settings. The most convenient way is to define them on the shared network scope, but you may specify them for each subnet. However, care should be taken for each subnet to have the same value.
It is possible to specify an interface name in the shared network scope to tell the server that this specific shared network is reachable directly (not via relays) using a local network interface. It is sufficient to specify it once at the shared network level. 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. It is possible to specify the interface parameter on each subnet, although its value must be the same for each subnet. Thus it is usually more convenient to specify it once at the shared network level.
"shared-networks": [ { "name": "office-floor-2", // This tells Kea that the whole shared networks is reachable over // local interface. This applies to all subnets in this network."interface": "eth0"
, "subnet6": [ { "subnet": "2001:db8::/64", "pools": [ { "pool": "2001:db8::1 - 2001:db8::ffff" } ],"interface": "eth0"
}, { "subnet": "3ffe:abcd::/64", "pools": [ { "pool": "3ffe:abcd::1 - 3ffe:abcd::ffff" } ] // Specifying a different interface name is configuration // error: // "interface": "eth1" } ], } ]
Somewhat similar to interface names, relay IP addresses can also be specified for the whole shared network. However, depending on your relay configuration, it may use different IP addresses depending on which subnet is being used. Thus there is no requirement to use the same IP relay address for each subnet. Here's an example:
"shared-networks": [ { "name": "kakapo","relay": { "ip-addresses": [ "2001:db8::abcd" ] }
, "subnet6": [ { "subnet": "2001:db8::/64","relay": { "ip-addresses": [ "2001:db8::1234" ] }
, "pools": [ { "pool": "2001:db8::1 - 2001:db8::ffff" } ] }, { "subnet": "3ffe:abcd::/64", "pools": [ { "pool": "3ffe:abcd::1 - 3ffe:abcd::ffff" } ],"relay": { "ip-addresses": [ "3ffe:abcd::cafe" ] }
} ] } ]
In this particular case the relay IP address specified at the network level doesn't have much sense, as it is overridden in both subnets, but it was left there as an example of how one could be defined at the network level. Note that the relay agent IP address typically belongs to the subnet it relays packets from, but this is not a strict requirement. Kea accepts any value here as long as it is a valid IPv6 address.
Sometimes it is desirable to segregate clients into specific subnets based on certain properties. This mechanism is called client classification and is described in Chapter 14, Client Classification. 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 desired subnet is selected for a given client type.
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 including a client class is preferred over subnets without client classes. Consider the following example:
{
"client-classes": [
{
"name": "b-devices",
"test": "option[1234].hex == 0x0002"
}
],
"shared-networks": [
{
"name": "galah",
"relay": {
"ip-address": [ "2001:db8:2:34::1" ]
},
"subnet6": [
{
"subnet": "2001:db8:1::/64",
"pools": [ { "pool": "2001:db8:1::20 - 2001:db8:1::ff" } ],
},
{
"subnet": "2001:db8:3::/64",
"pools": [ { "pool": "2001:db8:3::20 - 2001:db8:3::ff" } ],
"client-class": "b-devices"
}
]
}
]
}
If the client belongs to the "b-devices" class (because it includes option 1234 with a value of 0x0002), that doesn't 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 a way to express subnet preference. For example, if the client doesn't belong to the "b-devices" class it may only use the subnet 2001:db8:1::/64 and will never use the subnet 2001:db8:3::/64.
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.
{ "client-classes": [ { "name": "a-devices", "test": "option[1234].hex == 0x0001" }, { "name": "b-devices", "test": "option[1234].hex == 0x0002" } ], "shared-networks": [ { "name": "galah", "relay": { "ip-addresses": [ "2001:db8:2:34::1" ] }, "subnet6": [ { "subnet": "2001:db8:1::/64", "pools": [ { "pool": "2001:db8:1::20 - 2001:db8:1::ff" } ],"client-class": "a-devices"
}, { "subnet": "2001:db8:3::/64", "pools": [ { "pool": "2001:db8:3::20 - 2001:db8:3::ff" } ],"client-class": "b-devices"
} ] } ] }
In this example each class has its own restriction. Only clients that belong to class "a-devices" will be able to use subnet 2001:db8:1::/64 and only clients belonging to "b-devices" will be 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).
Note that 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 "interface" or "relay" parameter. All subnets belonging to this shared network will inherit those parameters.
Subnets that are part of a shared network allow host reservations, similar to regular subnets:
{ "shared-networks": [ { "name": "frog", "relay": { "ip-addresses": [ "2001:db8:2:34::1" ] }, "subnet6": [ { "subnet": "2001:db8:1::/64", "id": 100, "pools": [ { "2001:db8:1::1 - 2001:db8:1::64" } ],"reservations": [ { "duid": "00:03:00:01:11:22:33:44:55:66", "ip-addresses": [ "2001:db8:1::28" ] } ]
}, { "subnet": "2001:db8:3::/64", "id": 101, "pools": [ { "pool": "2001:db8:3::1 - 2001:db8:3::64" } ],"reservations": [ { "duid": "00:03:00:01:aa:bb:cc:dd:ee:ff", "ip-addresses": [ "2001:db8:2::28" ] } ]
} ] } ] }
It is worth noting that Kea conducts additional checks when processing a packet if shared networks are defined. Instead of simply checking whether there's a reservation for a given client in its initially selected subnet, it 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 will be picked for the client. Although it's technically not an error, it is considered a bad practice to define reservations for the same host in multiple subnets belonging to the same shared network.
While not strictly mandatory, it is strongly recommended to use explicit "id" values for subnets if you plan to use database storage for host reservations. If ID is not specified, the values for it are autogenerated, i.e. it assigns increasing integer values starting from 1. Thus, the autogenerated IDs are not stable across configuration changes.
The DHCPv6 protocol uses a "server identifier" (also known as a DUID) to allow clients to discriminate between several servers present on the same link. RFC 8415 currently defines four DUID types: DUID-LLT, DUID-EN, DUID-LL, and DUID-UUID.
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.
Kea follows the recommendation from RFC 8415 to use DUID-LLT as the default server identifier. However, we have received reports that some deployments require different DUID types, and there is a need to administratively select both DUID type and/or its contents.
The server identifier can be configured using parameters within the server-id map element in the global scope of the Kea configuration file. The following example demonstrates how to select DUID-EN as a server identifier:
"Dhcp6": { "server-id": { "type": "EN" }, ... }
Currently supported values for type parameter are: "LLT", "EN", and "LL", for DUID-LLT, DUID-EN, and DUID-LL respectively.
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 the clients.
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 the 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 is avoided if the server has already assigned leases and these leases are still valid.
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.
"Dhcp6": { "server-id": { "type": "LLT", "htype": 8, "identifier": "A65DC7410F05", "time": 2518920166 }, ... }
where:
The hexadecimal representation of the DUID generated as a result of the configuration specified above will be:
00:01:00:08:96:23:AB:E6:A6:5D:C7:41:0F:05 |type |htype| time | identifier |
A special value of 0 for "htype" and "time" 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 doesn't yet use any DUID, it will generate these values. Similarly, if the "identifier" is assigned an empty string, the value of the identifier will be generated. Omitting any of these parameters is equivalent to setting them to those special values.
For example, the following configuration:
"Dhcp6": { "server-id": { "type": "LLT", "htype": 0, "identifier": "", "time": 2518920166 }, ... }
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.
The following example demonstrates an explicit configuration of a DUID-EN:
"Dhcp6": { "server-id": { "type": "EN", "enterprise-id": 2495, "identifier": "87ABEF7A5BB545" }, ... }
where:
The hexadecimal representation of the DUID-EN created according to the configuration above is:
00:02:00:00:09:BF:87:AB:EF:7A:5B:B5:45 |type | ent-id | identifier |
As in the case of the DUID-LLT, special values can be used for the configuration of the DUID-EN. If the enterprise-id is 0, 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 identifier, the identifier from the existing DUID-EN will be used. If the server is not using any DUID-EN, a new 6-byte-long identifier will be generated.
DUID-LL is configured in the same way as DUID-LLT except that the time 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:
"Dhcp6": { "server-id": { "type": "LL", "htype": 8, "identifier": "A65DC7410F05" }, ... }
which will result in the following server identifier:
00:03:00:08:A6:5D:C7:41:0F:05 |type |htype| identifier |
The server stores the generated server identifier in the following location: [kea-install-dir]/var/lib/kea/kea-dhcp6-serverid.
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 persist boolean parameter:
"Dhcp6": { "server-id": { "type": "EN", "enterprise-id": 2495, "identifier": "87ABEF7A5BB545", "persist": false }, ... }
The default value of the "persist" parameter is true, which configures the server to store the server identifier on a disk.
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 will be used after server restart, because the entire server identifier is explicitly specified in the configuration.
The Kea DHCPv6 server puts the server identifier file and the
default memory lease file into its data directory. By default
this directory is
but this location can be changed using the
data-directory global parameter as in:
prefix
/var/lib/kea
"Dhcp6": {
"data-directory": "/var/tmp/kea-server6"
,
...
}
Typically DHCPv6 is used to assign both addresses and options. These assignments (leases) have a state that changes over time, hence their name, stateful. DHCPv6 also supports a stateless mode, where clients request configuration options only. This mode is considered lightweight from the server perspective, as it does not require any state tracking, and carries the stateless name.
The Kea server supports stateless mode. Clients can send Information-Request messages and the server sends back answers with the requested options (providing the options are available in the server configuration). The server attempts to use per-subnet options first. If that fails - for whatever reason - it then tries to provide options defined in the global scope.
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 just the options they requested.
This usage of global options allows for an interesting case. 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 required options in the global scope and skip subnet definitions altogether. Here's a simple example of such a configuration:
"Dhcp6": {
"interfaces-config": {
"interfaces": [ "ethX" ]
},
"option-data": [ {
"name": "dns-servers",
"data": "2001:db8::1, 2001:db8::2"
} ]
,
"lease-database": {
"type": "memfile"
}
}
This very simple configuration will provide DNS server information to all clients in the network, regardless of their location. Note the specification of the memfile lease database; this is needed as Kea requires a lease database to be specified even if it is not used.
RFC 7550 introduced some changes to the previous DHCPv6 specifications, RFC 3315 and RFC 3633, to resolve a few issues with the coexistence of multiple stateful options in the messages sent between the clients and servers. Those changes were later included in the most recent DHCPv6 protocol specification, RFC 8415, which obsoleted RFC 7550. Kea supports RFC 8415 along with these protocol changes, which are briefly described below.
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 it 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 "bound" state. When the client subsequently sends Renew/Rebind messages to the server, according to the T1 and T2 times, to extend the lifetimes of the allocated addresses, 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 will allocate and send 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.
The following are the other behaviors first introduced in RFC 7550 (now part of RFC 8415) and supported by the Kea DHCPv6 server:
The 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 the interface that belongs to the subnet from which the server will assign addresses. Normally, the server is able to use the IPv6 address inserted by the relay (in the link-addr field in RELAY-FORW message) to select the appropriate subnet.
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 where this is the case are long-lasting network renumbering (where both old and new address space is 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 (like the value of the interface-id option or the IPv6 address inserted in the link-addr field in the RELAY-FORW message) to properly select an appropriate subnet.
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 with an address in 2001:db8:1::/64 subnet. It also selects that subnet for a relay with address 3000::1.
"Dhcp6": {
"subnet6": [
{
"subnet": "2001:db8:1::/64",
"pools": [
{
"pool": "2001:db8:1::1-2001:db8:1::ffff"
}
],
"relay": {
"ip-addresses": [ "3000::1" ]
}
}
]
}
If "relay" is specified, the "ip-addresses" parameter within it is mandatory.
The current version of Kea uses the "ip-addresses" parameter, which supports specifying a list of addresses.
In certain cases, it is useful to mix relay address information, introduced in Section 9.9, “Using a Specific Relay Agent for a Subnet”, with client classification, explained in Chapter 14, Client Classification. One specific example is in a cable network, where typically modems get addresses from a different subnet than all devices connected behind them.
Let us assume that there is one CMTS (Cable Modem Termination System) 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 another subnet (2001:db8:1::/64). The CMTS that acts as a relay uses address 3000::1. The following configuration can serve that configuration:
"Dhcp6": { "subnet6": [ { "subnet": "3000::/64", "pools": [ { "pool": "3000::2 - 3000::ffff" } ],"client-class": "VENDOR_CLASS_docsis3.0", "relay": { "ip-addresses": [ "3000::1" ] }
}, { "subnet": "2001:db8:1::/64", "pools": [ { "pool": "2001:db8:1::1-2001:db8:1::ffff" } ],"relay": { "ip-addresses": [ "3000::1" ] }
} ] }
MAC/hardware addresses are available in DHCPv4 messages from the 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 fail in others. Whether the mechanism works in a particular deployment is somewhat dependent on the network topology and the technologies used.
Kea allows specification of which of the supported methods should be used and in what order. This configuration may be considered a fine tuning of the DHCP deployment. In a typical deployment the default value of "any" is sufficient and there is no need to select specific methods. Changing the value of this parameter is the 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 the clients.
The configuration is controlled by the mac-sources parameter as follows:
"Dhcp6": {
"mac-sources": [ "method1", "method2", "method3", ... ]
,
"subnet6": [ ... ],
...
}
When not specified, a special value of "any" 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. If specified, it must have at least one value.
Supported methods are:
Empty mac-sources is not allowed. If you do not want to specify it, either simply omit the mac-sources definition or specify it with the "any" value which is the default.
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's approval or knowledge.
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 will do a sanity check (to see whether the client declining an address really was supposed to use it), and then will conduct a clean-up operation and confirm it by sending back a REPLY message. Any DNS entries related to that address will be removed, the fact will be logged, and hooks will be triggered. After that is complete, the address will be marked as declined (which indicates that it is used by an unknown entity and thus not available for assignment) and a probation time will be set on it. Unless otherwise configured, the probation period lasts 24 hours; after that period, 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.
To configure the decline probation period to a value other than the default, the following syntax can be used:
"Dhcp6": {
"decline-probation-period": 3600
,
"subnet6": [ ... ],
...
}
The parameter is expressed in seconds, so the example above will instruct the server to recycle declined leases after one hour.
There are several statistics and hook points associated with the Decline handling procedure. The lease6_decline hook is triggered after the incoming DHCPDECLINE message has been sanitized and the server is about to decline the lease. The declined-addresses statistic is increased after the hook returns (both global and subnet-specific variants). (See Section 9.13, “Statistics in the DHCPv6 Server” and Chapter 15, Hooks Libraries for more details on DHCPv6 statistics and Kea hook points.)
Once the probation time elapses, the declined lease is recovered using the standard expired-lease reclamation procedure, with several additional steps. In particular, both declined-addresses statistics (global and subnet-specific) are decreased. At the same time, reclaimed-declined-addresses statistics (again in two variants, global and subnet-specific) are increased.
A note about statistics: The server does not decrease the assigned-addresses statistics when a DHCPDECLINE message is received and processed successfully. While technically a declined address is no longer assigned, the primary usage of the assigned-addresses statistic is to monitor pool utilization. Most people would forget to include declined-addresses in the calculation, and simply use assigned-addresses/total-addresses. This would cause a bias towards under-representing pool utilization. As this has a potential for major issues, we decided not to decrease assigned-addresses immediately after receiving DHCPDECLINE, but to do it later when Kea recovers the address back to the available pool.
This section describes DHCPv6-specific statistics. For a general overview and usage of statistics, see Chapter 16, Statistics.
The DHCPv6 server supports the following statistics:
Table 9.3. DHCPv6 Statistics
Statistic | Data Type | Description |
---|---|---|
pkt6-received | integer | Number of DHCPv6 packets received. This includes all packets: valid, bogus, corrupted, rejected, etc. This statistic is expected to grow rapidly. |
pkt6-receive-drop | integer | Number of incoming packets that were dropped. The exact reason for dropping packets is logged, but the most common reasons may be: 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's server-id, or the packet is malformed. |
pkt6-parse-failed | integer | 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 your network, faulty clients, faulty relay agents, or a bug in the server. |
pkt6-solicit-received | integer | 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 your Kea server. |
pkt6-advertise-received | integer | 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. |
pkt6-request-received | integer | Number of DHCPREQUEST packets received. This statistic is expected to grow. Its increase means that clients that just booted received the server's response (DHCPADVERTISE) and accepted it, and are now requesting an address (DHCPREQUEST). |
pkt6-reply-received | integer | 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. |
pkt6-renew-received | integer | 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. |
pkt6-rebind-received | integer | Number of REBIND packets received. A non-zero value indicates that clients didn't 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' REPLY messages never reached the clients. |
pkt6-release-received | integer | 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 choice or due to the client moving out of range. |
pkt6-decline-received | integer | 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 your network. If this statistic is growing, it may indicate a misconfigured server or devices that have statically assigned conflicting addresses. |
pkt6-infrequest-received | integer | 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. |
pkt6-dhcpv4-query-received | integer | 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. |
pkt6-dhcpv4-response-received | integer | 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. |
pkt6-unknown-received | integer | Number of packets received of an unknown type. A non-zero value of this statistic indicates that the server received a packet that it wasn't able to recognize; either it had an unsupported type or was possibly malformed. |
pkt6-sent | integer | Number of DHCPv6 packets sent. This statistic is expected to grow every time the server transmits a packet. In general, it should roughly match pkt6-received, as most incoming packets cause the server to respond. There are exceptions (e.g. server receiving a REQUEST with server-id matching other server), so do not worry if it is less than pkt6-received. |
pkt6-advertise-sent | integer | 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 pkt6-solicit-received. |
pkt6-reply-sent | integer | 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. |
pkt6-dhcpv4-response-sent | integer | 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. |
subnet[id].total-nas | integer | Total number of NA addresses available for DHCPv6 management for a given subnet; in other words, this is the sum of all addresses in all configured pools. This statistic changes only during configuration changes. Note that it does not take into account any addresses that may be reserved due to host reservation. The id is the subnet-id of a given subnet. This statistic is exposed for each subnet separately, and is reset during a reconfiguration event. |
subnet[id].assigned-nas | integer | 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 id is the subnet-id of a given subnet. This statistic is exposed for each subnet separately, and is reset during a reconfiguration event. |
subnet[id].total-pds | integer | Total number of PD prefixes available for DHCPv6 management for a given subnet; in other words, this is the sum of all prefixes in all configured pools. This statistic changes only during configuration changes. Note it does not take into account any prefixes that may be reserved due to host reservation. The id is the subnet-id of a given subnet. This statistic is exposed for each subnet separately, and is reset during a reconfiguration event. |
subnet[id].assigned-pds | integer | 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 id is the subnet-id of a given subnet. This statistic is exposed for each subnet separately, and is reset during a reconfiguration event. |
reclaimed-leases | integer | 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) and is reset when the server is reconfigured. |
subnet[id].reclaimed-leases | integer | Number of expired leases associated with a given subnet ("id" is the subnet-id) that have been reclaimed since server startup. It is incremented each time an expired lease is reclaimed (counting both NA and PD reclamations) and is reset when the server is reconfigured. |
declined-addresses | integer | Number of IPv6 addresses that are currently declined; a count of the number of leases currently unavailable. Once a lease is recovered, this statistic will be 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. |
subnet[id].declined-addresses | integer | 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 will be 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 id is the subnet-id of a given subnet. This statistic is exposed for each subnet separately. |
reclaimed-declined-addresses | integer | Number of IPv6 addresses that were declined, but have now been recovered. Unlike declined-addresses, 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. |
subnet[id].reclaimed-declined-addresses | integer | Number of IPv6 addresses that were declined, but have now been recovered. Unlike declined-addresses, 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 id is the subnet-id of a given subnet. This statistic is exposed for each subnet separately. |
The management API allows the issuing of specific management commands, such as statistics retrieval, reconfiguration, or shutdown. For more details, see Chapter 17, Management API. Currently, the only supported communication channel type is UNIX stream socket. By default there are no sockets open; to instruct Kea to open a socket, the following entry in the configuration file can be used:
"Dhcp6": {
"control-socket": {
"socket-type": "unix",
"socket-name": "/path/to/the/unix/socket"
},
"subnet6": [
...
],
...
}
The length of the path specified by the socket-name parameter is restricted by the maximum length for the UNIX socket name on your operating system, i.e. the size of the sun_path field in the sockaddr_un 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.
Communication over the control channel is conducted using JSON structures.
See the Control Channel section in the Kea Developer's Guide
for more
details.
The DHCPv6 server supports the following operational commands:
as described in Section 17.3, “Commands Supported by Both the DHCPv4 and DHCPv6 Servers”. In addition, it supports the following statistics-related commands:
as described in Section 16.3, “Commands for Manipulating Statistics”.
Kea allows loading hook libraries that sometimes could 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.
User contexts can store arbitrary data 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.
User contexts can be specified at global scope, shared network, subnet, pool, client class, option data, or definition level, and via host reservation. One other useful usage is the ability to store comments or descriptions.
Let's consider a lightweight 4over6 deployment as an example. It is 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 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 use 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 that would be loaded only when dynamic calculation of the lightweight 4over6 option is actually needed. An example configuration looks as follows:
"Dhcp6": { "subnet6": [ { "pd-pools": [ { "prefix": "2001:db8::", "prefix-len": 56, "delegated-len": 64, // This is a pool specific context."user-context": { "threshold-percent": 85, "v4-network": "192.168.0.0/16", "v4-overflow": "10.0.0.0/16", "lw4over6-sharing-ratio": 64, "lw4over6-v4-pool": "192.0.2.0/24", "lw4over6-sysports-exclude": true, "lw4over6-bind-prefix-len": 56 }
} ], "subnet": "2001:db8::/32", // This is a subnet specific context. You can put any type of // information here as long as it is a valid JSON."user-context": { "comment": "Those v4-v6 migration technologies are tricky.", "experimental": true, "billing-department": 42, "contact-points": [ "Alice", "Bob" ] }
} ], ... }
Kea does not interpret or use the content of the user context; it simply stores it, making it available to the hook libraries. It is up to each hook library to extract the information and use it. The parser translates a "comment" entry into a user context with the entry, which allows a comment to be attached inside the configuration itself.
For more background information, see Section 15.5, “User contexts”.
The following standards are currently supported:
These are the current limitations of the DHCPv6 server software. Most of them are reflections of the current stage of development and should be treated as “not implemented yet”, rather than actual limitations.
A collection of simple-to-use examples for the DHCPv6 component of Kea is available with the source files, located in the doc/examples/kea6 directory.
In the Section 5.2, “Kea Configuration Backend” we have described the Configuration Backend feature, its applicability and 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 the DHCPv6 server configuration to take advantage of the CB. Please also refer to the sibling section Section 8.14, “Configuration Backend in DHCPv4” for the DHCPv4 specific usage of the CB.
The ultimate goal for the CB is to serve as a central configuration repository for one or multiple Kea servers connected to the database. In the future it will be possible to store the most of the server's configuration in the database and reduce the configuration file to bare minimum, i.e. the only mandatory parameter will be the config-control which includes the necessary information to connect to the database. In the Kea 1.6.0 release, however, only the subset of the DHCPv4 server parameters can be stored in the database. All other parameters must be specified in the JSON configuration file, if required.
The following table lists DHCPv6 specific parameters supported by the Configuration Backend with an indication on which level of the hierarchy it is currently supported. The "n/a" is used in cases when the particular parameter is not applicable on the particular level of the hierarchy or in cases when the parameter is not supported by the server on this level of hierarchy. The "no" is used when the parameter is supported by the server on the particular level of hierarchy but is not configurable via the Configuration Backend.
All supported parameters can be configured via cb_cmds hooks library described in the Section 15.4.8, “cb_cmds: Configuration Backend Commands”. The general rule is that the scalar global parameters are set using the remote-global-parameter6-set. The shared network specific parameters are set using the remote-network6-set. Finally, the subnet and pool level parameters are set using the remote-subnet6-set. Whenever there is an exception from this general rule, it is highlighted in the table. The non-scalar global parameters have dedicated commands, e.g. modifying the global DHCPv6 options (option-data) is performed using the remote-option6-global-set.
Table 9.4. List of DHCPv6 Parameters Supported by the Configuration Backend
Parameter | Global | Shared Network | Subnet | Pool | Prefix Delegation Pool |
---|---|---|---|---|---|
calculate-tee-times | yes | yes | yes | n/a | n/a |
client-class | n/a | yes | yes | no | no |
decline-probation-period | yes | n/a | n/a | n/a | n/a |
delegated-len | n/a | n/a | n/a | n/a | yes |
dhcp4o6-port | yes | n/a | n/a | n/a | n/a |
excluded-prefix | n/a | n/a | n/a | n/a | no |
excluded-prefix-len | n/a | n/a | n/a | n/a | no |
interface | n/a | yes | yes | n/a | n/a |
interface-id | n/a | yes | yes | n/a | n/a |
option-data | yes (via remote-option6-global-set) | yes | yes | yes | yes |
option-def | yes (via remote-option-def6-set) | n/a | n/a | n/a | n/a |
preferred-lifetime | yes | yes | yes | n/a | n/a |
prefix | n/a | n/a | n/a | n/a | yes |
prefix-len | n/a | n/a | n/a | n/a | yes |
rapid-commit | yes | yes | yes | n/a | n/a |
rebind-timer | yes | yes | yes | n/a | n/a |
relay | n/a | yes | yes | n/a | n/a |
renew-timer | yes | yes | yes | n/a | n/a |
require-client-classes | n/a | yes | yes | no | no |
reservation-mode | yes | yes | yes | n/a | n/a |
t1-percent | yes | yes | yes | n/a | n/a |
t2-percent | yes | yes | yes | n/a | n/a |
valid-lifetime | yes | yes | yes | n/a | n/a |
The following configuration snippet demonstrates how to enable the MySQL Configuration Backend for the DHCPv6 server:
{ "Dhcp6": { "config-control": { "config-databases": [ { "type": "mysql", "name": "kea", "user": "kea", "password": "kea", "host": "2001:db8:1::1", "port": 3302 } ], "config-fetch-wait-time": 20 }, "hooks-libraries": [ { "library": "/usr/local/lib/kea/hooks/libdhcp_mysql_cb.so" }, { "library": "/usr/local/lib/kea/hooks/libdhcp_cb_cmds.so" } ], ... } }
The configuration structure is almost identical as for the DHCPv4 server (see Section 8.14.2, “Enabling Configuration Backend” for the detailed description).
Table of Contents
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 "leases." Leases are typically assigned to clients for a finite amount of time, known as the "valid lifetime." DHCP clients who wish to continue using their assigned leases will 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.
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; a common scenario is when the machine running the client shuts down for an extended period of time.
The process through which the DHCP server makes expired leases available for reassignment is referred to as "lease reclamation" and expired leases returned to availability through this process are referred to as "reclaimed." 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.
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's responsiveness. Finally, it explains "lease affinity," which provides the means to assign the same lease to a returning client after its lease has expired.
Although all configuration examples in this section are provided for the DHCPv4 server, the same parameters may be used for DHCPv6 server configuration.
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:
Please refer to Chapter 12, The DHCP-DDNS Server to see how to configure DNS updates in Kea, and to Chapter 15, Hooks Libraries for information about using hooks libraries.
The following list presents all configuration parameters pertaining to processing expired leases with their default values:
The parameters are explained in more detail in the rest of this chapter.
The default value for any parameter is used when this parameter is not explicitly specified in the configuration. Also, the expired-leases-processing map may be omitted entirely in the configuration, in which case the default values are used for all parameters listed above.
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 will not process incoming DHCP messages to avoid issues with concurrent access to database information. As a result, the server will be unresponsive while lease reclamation is performed and DHCP queries will accumulate; responses will be sent once the lease-reclamation cycle is complete.
In deployments where response time is critical, administrators may wish to minimize the interruptions in service caused by lease reclamation. Toward 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:
"Dhcp4": { ... "expired-leases-processing": { "reclaim-timer-wait-time": 5, "max-reclaim-leases": 0, "max-reclaim-time": 0, }, ... }
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:
| c1 | | c2 | |c3| | c4 | |<---->|<---------->|<-->|<---------->|<>|<---------->|<-->| ----------------------------------------------------------------> | | 5s | | 5s | | 5s | | time
This diagram shows four lease-reclamation cycles (c1 through c4) of variable duration. Note that the duration of the reclamation cycle depends on the number of expired leases detected and processed in the particular cycle. This duration is usually significantly shorter than the interval between the cycles.
According to the reclaim-timer-wait-time, 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 5s-long periods during which the server remains responsive to DHCP queries and does not perform lease reclamation. The max-reclaim-leases and max-reclaim-time 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.
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:
"Dhcp4": { ... "expired-leases-processing": { "reclaim-timer-wait-time": 3, "max-reclaim-leases": 100, "max-reclaim-time": 50, "unwarned-reclaim-cycles": 10, }, ... }
The max-reclaim-leases parameter limits the number of leases reclaimed in a single cycle to 100. The max-reclaim-time 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.
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:
| c1 | | c2 | | c3 | | c4 | |<-->|<-------------->|<-->|<-------------->|<-->|<-------------->|<-->|<-- ------------------------------------------------------------------------------> |50ms| 3s |50ms| 3s |50ms| 3s |50ms| time
This diagram demonstrates the case when each reclamation cycle takes more than 50ms, and thus is interrupted according to the value of the max-reclaim-time. This results in equal durations of all reclamation cycles over time. Note that in this example the limitation of the maximum 100 leases is not reached. This may be the case when database transactions are slow 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, and any hooks libraries, etc. Administrators may need to experiment to tune the system to suit the dynamics of their deployment.
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 longer 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 unwarned-reclaim-cycles configuration parameter.
Setting the reclaim-timer-wait-time to 0 disables periodic reclamation of the expired leases.
Suppose that a laptop goes into sleep mode after a period of user inactivity. While the laptop is in sleep mode, its DHCP client will 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 will first check for those leases and re-assign them if they have not been assigned to another client. The ability of the server to re-assign the same lease to a returning client is referred to as "lease affinity."
When lease affinity is enabled (i.e. when hold-reclaimed-time is configured to a value greater than zero), the server will still reclaim leases according to the parameters described in Section 10.3, “Configuring Lease Reclamation”, but the reclaimed leases will be held in the database (rather than removed) for a specified amount of time. When the client returns, the server will first verify whether there are any reclaimed leases associated with this client and will re-assign 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 for the client to be assigned the same lease. If the lease pool is small (this mostly applies to DHCPv4 for which address space is small), there is an increased likelihood that the expired lease will be assigned to another client.
Consider the following configuration:
"Dhcp4": { ... "expired-leases-processing": { "reclaim-timer-wait-time": 3, "hold-reclaimed-time": 1800, "flush-reclaimed-timer-wait-time": 5 }, ... }
The hold-reclaim-time specifies how many seconds after an expiration a reclaimed lease should be held in the database for re-assignment to the same client. In the example given above, reclaimed leases will be held for 30 minutes (1800s) after their expiration. During this time, the server will likely be able to re-assign the same lease to the returning client, unless another client requests this lease and the server assigns it.
The server must periodically remove reclaimed leases for which the time indicated by hold-reclaim-time has elapsed. The flush-reclaimed-timer-wait-time parameter controls how often the server removes such leases. In the example provided above, the server will initiate removal of such leases 5 seconds after the previous removal attempt was completed. Setting this value to 0 disables lease affinity, in which case leases will be removed from the lease database when they are reclaimed. If lease affinity is enabled, it is recommended that hold-reclaim-time be set to a value significantly higher than the reclaim-timer-wait-time, as timely removal of expired-reclaimed leases is less critical than the removal process, which may impact server responsiveness.
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 will try to honor such a request if possible. If you want to ensure a client keeps its address, even after periods of inactivity, consider using host reservations or leases with very long lifetimes.
The leases-reclaim command can be used to trigger lease reclamation at any time. Please consult the Section 17.3.6, “leases-reclaim” section for details about using this command.
Table of Contents
Congestion occurs when servers are subjected to client queries faster than they 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.
In a well-planned deployment, the number and capacity of servers is matched to the maximum client loads expected. As long as capacity is matched to load, congestion does not occur. If the load is routinely too heavy, then the deployment needs to be re-evaluated. 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.
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.
Prior to Kea 1.5, kea-dhcp4 and kea-dhcp4 read inbound packets directly from the interface sockets in the main application thread, which meant that packets waiting to be processed were held in socket buffers themselves. Once these buffers filled, any new packets were discarded. Under swamped conditions, the servers ended up processing client packets that were no longer relevant, or worse were redundant. In other words, the packets waiting in the FIFO socket buffers became increasingly stale.
Kea 1.5 introduced the Congestion Handling feature. 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's 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.
The default packet queue implemenation for both kea-dhcp4 and kea-dhcp6 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 would be to match the capacity to the number of leases per second your installation of Kea can handle. Please note that this figure varies widely depending on the specifics of your deployment.
As there is no one algorithm that will 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 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 isc::dhcp::PacketQueue and isc::dhcp::PacketQueueMgr, described in the Kea Developer's Guide).
Packet queue behavior is configured in both kea-dhcp4 and kea-dhcp6 servers through an optional, top-level, configuration element, 'dhcp-queue-control'. Omitting this element disables packet queueing:
"dhcp-queue-control": { "enable-queue": true|false, "queue-type": "queue type", "capacity" : n }
where:
The following example enables the default packet queue for kea-dhcp4, with a queue capacity of 250 packets:
"Dhcp4": { ... "dhcp-queue-control": { "enable-queue": true, "queue-type": "kea-ring4", "capacity" : 250 }, ... }
The following example enables the default packet queue for kea-dhcp6, with a queue capacity of 300 packets:
"Dhcp6": { ... "dhcp-queue-control": { "enable-queue": true, "queue-type": "kea-ring6", "capacity" : 300 }, ... }
Table of Contents
The DHCP-DDNS Server (kea-dhcp-ddns, known informally as D2) conducts the client side of the Dynamic DNS protocol (DDNS, defined in RFC 2136) on behalf of the DHCPv4 and DHCPv6 servers (kea-dhcp4 and kea-dhcp6 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.
In order 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 DDNS Domain Lists. 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.
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 "myhost.sample.example.com.", and there are two forward domains in the catalog, "sample.example.com." and "example.com.", 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, "bogus.net", so the request would be rejected. Finally, if there are no Forward DDNS Domains defined, D2 simply disregards the forward update portion of requests.
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 "172.16.1.40" and there are two reverse domains in the catalog, "1.16.172.in-addr.arpa." and "16.172.in-addr.arpa", the former is the best match. As with forward matching, it may not find a suitable match. Given the same two domains, there would be no match for the lease address, "192.168.1.50", and the request would be rejected. Finally, if there are no Reverse DDNS Domains defined, D2 will simply disregard the reverse update portion of requests.
D2 implements the conflict resolution strategy prescribed by RFC 4703. 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.
In other words, the DHCID RR maps an FQDN to the client to whom it belongs, and thereafter changes to that mapping should only be done by or at the behest of that client.
Currently, conflict detection is always performed.
RFC 4703, section 5.2, describes issues that may arise with dual-stack clients. These are clients that wish to have have both IPv4 and IPv6 mappings for the same FQDN. For this to work properly, the clients are required to embed their IPv6 DUID within their IPv4 client identifier option as described in RFC 4703. In this way, DNS updates for both IPv4 and IPv6 can be managed under the same DHCID RR. Support for this does not yet exist in Kea.
kea-dhcp-ddns 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 keactrl (see Chapter 6, Managing Kea with keactrl). In normal operation, controlling kea-dhcp-ddns with keactrl is recommended; however, it is also possible to run the DHCP-DDNS server directly. It accepts the following command-line switches:
file
-
specifies the configuration file. This is the only mandatory
switch.
config.report
file produced by
./configure
; it is embedded in the
executable binary.
file
specifies the configuration file to be tested. Kea-dhcp-ddns
will attempt to load it and will conduct sanity checks.
Note that certain checks are possible only while running
the actual server. The actual status is reported with an exit
code (0 = configuration looks ok, 1 = error encountered).
Kea prints out log messages to standard output and errors
to standard error when testing the configuration.
The config.report
may also be accessed more
directly, via the following command. The binary path
may be found
in the install directory or in the .libs
subdirectory in the source tree. For example:
kea/src/bin/d2/.libs/kea-dhcp-ddns
.
strings path
/kea-dhcp-ddns | sed -n 's/;;;; //p'
Upon startup the module will load its configuration and begin listening for NCRs based on that configuration.
During startup the server will attempt to create a PID file of the form: [runstatedir]/[conf name].kea-dhcp-ddns.pid where:
If the file already exists and contains the PID of a live process, the server will issue a DHCP_DDNS_ALREADY_RUNNING log message and exit. 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.
Before starting kea-dhcp-ddns module for the first time, a configuration file must be created. The following default configuration is a template that can be customized to your requirements.
"DhcpDdns": {
"ip-address": "127.0.0.1",
"port": 53001,
"dns-server-timeout": 100,
"ncr-protocol": "UDP",
"ncr-format": "JSON",
"tsig-keys": [ ],
"forward-ddns": {
"ddns-domains": [ ]
},
"reverse-ddns": {
"ddns-domains": [ ]
}
}
The configuration can be divided into the following sections, each of which is described below:
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's global parameters so it will listen at 192.168.1.10 port 900:
"DhcpDdns": {
"ip-address": "192.168.1.10",
"port": 900,
...
}
}
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, but note that local users may still communicate with the DHCP-DDNS server.
If the ip-address and port are changed, the corresponding values in the DHCP servers' "dhcp-ddns" configuration section must be changed.
The management API allows the issuing of specific management commands, such as configuration retrieval or shutdown. For more details, see Chapter 17, Management API. Currently the only supported communication channel type is UNIX stream socket. By default there are no sockets open. To instruct Kea to open a socket, the following entry in the configuration file can be used:
"DhcpDdns": {
"control-socket": {
"socket-type": "unix",
"socket-name": "/path/to/the/unix/socket"
},
...
}
The length of the path specified by the socket-name parameter is restricted by the maximum length for the unix socket name on your operating system, i.e. the size of the sun_path field in the sockaddr_un 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.
Communication over control channel is conducted using JSON structures. See the Control Channel section in the Kea Developer's Guide for more details.
The D2 server supports the following operational commands:
A DDNS protocol exchange can be conducted with or without TSIG (defined in RFC 2845). This configuration section allows the administrator to define the set of TSIG keys that may be used in such exchanges.
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's 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 will use that key to sign DNS update messages sent to and verify responses received from the domain's DNS server(s). For each TSIG key required by the DNS servers that D2 will be working with, there must be a corresponding TSIG key in the TSIG Key list.
As one might gather from the name, the tsig-key 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:
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's named.conf file looks like this:
: key "key.four.example.com." { algorithm hmac-sha224; secret "bZEG7Ow8OgAUPfLWV3aAUQ=="; }; :
By default, the TSIG Key list is empty:
"DhcpDdns": {
"tsig-keys": [ ]
,
...
}
We must extend the list with a new key:
"DhcpDdns": {
"tsig-keys": [
{
"name": "key.four.example.com.",
"algorithm": "HMAC-SHA224",
"secret": "bZEG7Ow8OgAUPfLWV3aAUQ=="
}
],
...
}
These steps would be repeated for each TSIG key needed. Note that the same TSIG key can be used with more than one domain.
The Forward DDNS section is used to configure D2's forward update behavior. Currently it contains a single parameter, the catalog of Forward DDNS Domains, which is a list of structures.
"DhcpDdns": {
"forward-ddns": {
"ddns-domains": [ ]
}
,
...
}
By default, this list is empty, which will cause the server to ignore the forward update portions of requests.
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. It may very well be that some or all of the zones are maintained by the same servers, but you will still need one DDNS Domain per zone. Remember that matching a request to the appropriate server(s) is done by zone and a DDNS Domain only defines a single zone.
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:
To create a new Forward DDNS Domain, add a new domain element and set its parameters:
"DhcpDdns": {
"forward-ddns": {
"ddns-domains": [
{
"name": "other.example.com.",
"key-name": "",
"dns-servers": [
]
}
]
}
}
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, we must add at least one DNS server to it.
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.
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:
To create a new forward DNS Server, one must add a new server element to the domain and fill in its parameters. If, for example, the service is running at "172.88.99.10", then set the forward DNS Server as follows:
"DhcpDdns": {
"forward-ddns": {
"ddns-domains": [
{
"name": "other.example.com.",
"key-name": "",
"dns-servers": [
{
"hostname": "",
"ip-address": "172.88.99.10",
"port": 53
}
]
}
]
}
}
Since "hostname" is not yet supported, the parameter "ip-address" must be set to the address of the DNS server.
The Reverse DDNS section is used to configure D2's 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.
"DhcpDdns": {
"reverse-ddns": {
"ddns-domains": [ ]
}
...
}
By default, this list is empty, which will cause the server to ignore the reverse update portions of requests.
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. It may very well be that some or all of the zones are maintained by the same servers, but you will still need one DDNS Domain entry 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.
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:
To create a new Reverse DDNS Domain, one must add a new domain element and set its parameters. For example, to support subnet 2001:db8:1::, the following configuration could be used:
"DhcpDdns": {
"reverse-ddns": {
"ddns-domains": [
{
"name": "1.0.0.0.8.B.D.0.1.0.0.2.ip6.arpa.",
"key-name": "",
"dns-servers": [
]
}
]
}
}
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, you must add at least one DNS server to it.
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.
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:
To create a new reverse DNS Server, one must first add a new server element to the domain and fill in its parameters. If, for example, the service is running at "172.88.99.10", then set it as follows:
"DhcpDdns": {
"reverse-ddns": {
"ddns-domains": [
{
"name": "1.0.0.0.8.B.D.0.1.0.0.2.ip6.arpa.",
"key-name": "",
"dns-servers": [
{
"hostname": "",
"ip-address": "172.88.99.10",
"port": 53
}
]
}
]
}
}
Since "hostname" is not yet supported, the parameter "ip-address" must be set to the address of the DNS server.
User contexts were designed for hook libraries, which are not yet supported for DHCP-DDNS server configuration.
User contexts can store arbitrary data 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).
User contexts can be specified on global scope, ddns domain, dns server, tsig key, and loggers. One other useful usage is the ability to store comments or descriptions; the parser translates a "comment" entry into a user context with the entry, which allows a comment to be attached inside the configuration itself.
This section provides a sample DHCP-DDNS server configuration, based on a small example network. Let's suppose our example network has three domains, each with their own subnet.
Table 12.1. Our Example Network
Domain | Subnet | Forward DNS Servers | Reverse DNS Servers |
---|---|---|---|
four.example.com | 192.0.2.0/24 | 172.16.1.5, 172.16.2.5 | 172.16.1.5, 172.16.2.5 |
six.example.com | 2001:db8:1::/64 | 3001:1::50 | 3001:1::51 |
example.com | 192.0.0.0/16 | 172.16.2.5 | 172.16.2.5 |
We need to construct three Forward DDNS Domains:
Table 12.2. Forward DDNS Domains Needed
# | DDNS Domain Name | DNS Servers |
---|---|---|
1. | four.example.com. | 172.16.1.5, 172.16.2.5 |
2. | six.example.com. | 3001:1::50 |
3. | example.com. | 172.16.2.5 |
As discussed earlier, FQDN-to-domain matching is based on the longest
match. The FQDN, "myhost.four.example.com.", will match the first
domain ("four.example.com") while "admin.example.com." will match the
third domain ("example.com"). The
FQDN, "other.example.net.", will fail to match any domain and is
rejected.
The following example configuration specifies the Forward DDNS Domains.
"DhcpDdns": {
"comment": "example configuration: forward part",
"forward-ddns": {
"ddns-domains": [
{
"name": "four.example.com.",
"key-name": "",
"dns-servers": [
{ "ip-address": "172.16.1.5" },
{ "ip-address": "172.16.2.5" }
]
},
{
"name": "six.example.com.",
"key-name": "",
"dns-servers": [
{ "ip-address": "2001:db8::1" }
]
},
{
"name": "example.com.",
"key-name": "",
"dns-servers": [
{ "ip-address": "172.16.2.5" }
],
"user-context": { "backup": false }
},
]
}
}
Similarly, we need to construct the three Reverse DDNS Domains:
Table 12.3. Reverse DDNS Domains Needed
# | DDNS Domain Name | DNS Servers |
---|---|---|
1. | 2.0.192.in-addr.arpa. | 172.16.1.5, 172.16.2.5 |
2. | 1.0.0.0.8.d.b.0.1.0.0.2.ip6.arpa. | 3001:1::50 |
3. | 0.182.in-addr.arpa. | 172.16.2.5 |
An address of "192.0.2.150" will match the first domain,
"2001:db8:1::10" will match the second domain, and "192.0.50.77"
the third domain.
These Reverse DDNS Domains are specified as follows:
"DhcpDdns": {
"comment": "example configuration: reverse part",
"reverse-ddns": {
"ddns-domains": [
{
"name": "2.0.192.in-addr.arpa.",
"key-name": "",
"dns-servers": [
{ "ip-address": "172.16.1.5" },
{ "ip-address": "172.16.2.5" }
]
}
{
"name": "1.0.0.0.8.B.D.0.1.0.0.2.ip6.arpa.",
"key-name": "",
"dns-servers": [
{ "ip-address": "2001:db8::1" }
]
}
{
"name": "0.192.in-addr.arpa.",
"key-name": "",
"dns-servers": [
{ "ip-address": "172.16.2.5" }
]
}
]
}
}
Table of Contents
kea-lfc 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.
While kea-lfc can be started externally, there is usually no need to do this. kea-lfc is run on a periodic basis by the Kea DHCP servers.
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.
kea-lfc is run as follows:
kea-lfc [-4 | -6] -c config-file -p pid-file -x previous-file -i copy-file -o output-file -f finish-file
The argument -4 or -6 selects the protocol version of the lease files.
The -c argument specifies the configuration file. This is required, but is not currently used by the process.
The -p argument specifies the PID file. When the kea-lfc 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.
The other filenames specify where the kea-lfc process should look for input, write its output, and perform its bookkeeping:
There are several additional arguments, mostly for debugging purposes. -d sets the logging level to debug. -v and -V print out version stamps, with -V providing a longer form. -h prints out the usage string.
Table of Contents
In certain cases it is useful to differentiate between different types of clients and treat them accordingly. Common reasons include:
The clients represent different pieces of topology, e.g. a cable modem is not the same as the clients behind that modem.
The clients have different behavior, e.g. a smart phone behaves differently from a laptop.
The clients require different values for some options, e.g. a docsis3.0 cable modem requires different settings from a docsis2.0 cable modem.
To make management easier, different clients can be grouped into a client class to receive common options.
An incoming packet can be associated with a client class in several ways:
Implicitly, using a vendor class option or another builtin condition.
Using an expression which evaluates to true.
Using static host reservations, a shared network, a subnet, etc.
Using a hook.
It is envisaged that client classification will be used for changing the behavior of almost any part of the DHCP message processing. There are currently five mechanisms that take advantage of client classification: subnet selection, pool selection, definition of DHCPv4 private (codes 224-254) and code 43 options, assignment of different options, and, for DHCPv4 cable modems, the setting of specific options for use with the TFTP server address and the boot file field.
The classification process is conducted in several steps:
The ALL class is associated with the incoming packet.
Vendor class options are processed.
Classes with matching expressions and not marked for later ("on request" or depending on the KNOWN/UNKNOWN builtin classes) evaluation are processed in the order they are defined in the configuration; the boolean expression is evaluated and, if it returns true ("match"), the incoming packet is associated with the class.
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.
When the incoming packet belongs the special class, "DROP", it is dropped and an informational message is logged with the packet information.
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 doesn't have a class associated with it, or has a class which matches one of the packet's classes.
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 KNOWN class and all classes of the host reservation. If a reservation is not found, the packet is assigned to the UNKNOWN class.
Classes with matching expressions - directly or indirectly using the KNOWN/UNKNOWN builtin classes and not marked for later ("on request") evaluation - are processed in the order they are defined in the configuration; the boolean expression is evaluated and, if it returns true ("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 KNOWN/UNKNOWN classes to select a shared network or a subnet, nor to make the DROP class dependent of KNOWN/UNKNOWN classes.
If needed, addresses and prefixes from pools are assigned, possibly based on the class information when some pools are reserved for class members.
Classes marked as "required" are evaluated in the order in which they are listed: first the shared network, then the subnet, and finally the pools that assigned resources belong to.
Options are assigned, again possibly based on the class information in the order that classes were associated with the incoming packet. For DHCPv4 private and code 43 options, this includes class local option definitions.
Client classes in Kea follow the order in which they are specified in the configuration (vs. alphabetical order). Required classes follow the order in which they are required.
When determining which options to include in the response, the server examines the union of options from all of the assigned classes. If two or more classes include the same option, the value from the first class examined is used; classes are examined in the order they were associated, so ALL is always the first class and matching required classes are last.
As an example, imagine that an incoming packet matches two classes. Class "foo" defines values for an NTP server (option 42 in DHCPv4) and an SMTP server (option 69 in DHCPv4), while class "bar" 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 unspecified.
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.
Some classes are builtin, so they do not need to be defined. The main example uses Vendor Class information: 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 "VENDOR_CLASS_" and the result is interpreted as a class. For example, modern cable modems send this option with value "docsis3.0", so the packet belongs to class "VENDOR_CLASS_docsis3.0".
The "HA_" prefix is used by the High Availability hooks library to designate certain servers to process DHCP packets as a result of load balancing. The class name is constructed by prepending the "HA_" prefix to the name of the server which should process the DHCP packet. This server will use an appropriate pool or subnet to allocate IP addresses (and/or prefixes), based on the assigned client classes. The details can be found in Section 15.4.9, “ha: High Availability”.
Other examples are: the ALL class, which all incoming packets belong to, and the KNOWN class, assigned when host reservations exist for a particular client. By convention, builtin classes' names begin with all capital letters.
Currently recognized builtin class names are ALL, KNOWN and UNKNOWN, and prefixes VENDOR_CLASS_, HA_, AFTER_, and EXTERNAL_. Although the AFTER_ prefix is a provision for an as-yet-unwritten hook, the EXTERNAL_ prefix can be freely used; builtin classes are implicitly defined so they never raise warnings if they do not appear in the configuration.
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 "true" or "false". The packet belongs to the class (and the class name is added to the list of classes) if the result is "true". Expressions are written in standard format and can be nested.
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.
Other issues, for example 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.
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 builtin classes) which are evaluated in a previous or the same evaluation phase. This does not apply to the KNOWN or UNKNOWN classes.
Table 14.1. List of Classification Values
Name | Example expression | Example value | Description |
---|---|---|---|
String literal | 'example' | 'example' | A string |
Hexadecimal string literal | 0x5a7d | 'Z}' | A hexadecimal string |
IP address literal | 10.0.0.1 | 0x0a000001 | An IP address |
Integer literal | 123 | '123' | A 32-bit unsigned integer value |
Binary content of the option | option[123].hex | '(content of the option)' | The value of the option with given code from the packet as hex |
Option existence | option[123].exists | 'true' | If the option with given code is present in the packet "true" else "false" |
Client class membership | member('foobar') | 'true' | If the packet belongs to the given client class "true" else "false" |
Known client | known | member('KNOWN') | If there is a host reservation for the client "true" else "false" |
Unknown client | unknown | not member('KNOWN') | If there is a host reservation for the client "false" else "true" |
DHCPv4 relay agent sub-option | relay4[123].hex | '(content of the RAI sub-option)' | The value of sub-option with given code from the DHCPv4 Relay Agent Information option (option 82) |
DHCPv6 Relay Options | relay6[nest].option[code].hex | (value of the option) | The value of the option with code "code" from the relay encapsulation "nest" |
DHCPv6 Relay Peer Address | relay6[nest].peeraddr | 2001:DB8::1 | The value of the peer address field from the relay encapsulation "nest" |
DHCPv6 Relay Link Address | relay6[nest].linkaddr | 2001:DB8::1 | The value of the link address field from the relay encapsulation "nest" |
Interface name of packet | pkt.iface | eth0 | The name of the incoming interface of a DHCP packet. |
Source address of packet | pkt.src | 10.1.2.3 | The IP source address of a DHCP packet. |
Destination address of packet | pkt.dst | 10.1.2.3 | The IP destination address of a DHCP packet. |
Length of packet | pkt.len | 513 | The length of a DHCP packet (UDP header field), expressed as a 32-bit unsigned integer. |
Hardware address in DHCPv4 packet | pkt4.mac | 0x010203040506 | The value of the chaddr field of the DHCPv4 packet, hlen (0 to 16) bytes |
Hardware length in DHCPv4 packet | pkt4.hlen | 6 | The value of the hlen field of the DHCPv4 packet padded to 4 bytes |
Hardware type in DHCPv4 packet | pkt4.htype | 6 | The value of the htype field of the DHCPv4 packet padded to 4 bytes |
ciaddr field in DHCPv4 packet | pkt4.ciaddr | 192.0.2.1 | The value of the ciaddr field of the DHCPv4 packet (IPv4 address, 4 bytes) |
giaddr field in DHCPv4 packet | pkt4.giaddr | 192.0.2.1 | The value of the giaddr field of the DHCPv4 packet (IPv4 address, 4 bytes) |
yiaddr field in DHCPv4 packet | pkt4.yiaddr | 192.0.2.1 | The value of the yiaddr field of the DHCPv4 packet (IPv4 address, 4 bytes) |
siaddr field in DHCPv4 packet | pkt4.siaddr | 192.0.2.1 | The value of the siaddr field of the DHCPv4 packet (IPv4 address, 4 bytes) |
Message type in DHCPv4 packet | pkt4.msgtype | 1 | The value of the message type field in the DHCPv4 packet (expressed as a 32-bit unsigned integer). |
Transaction ID (xid) in DHCPv4 packet | pkt4.transid | 12345 | The value of the transaction id in the DHCPv4 packet (expressed as a 32-bit unsigned integer). |
Message type in DHCPv6 packet | pkt6.msgtype | 1 | The value of the message type field in the DHCPv6 packet (expressed as a 32-bit unsigned integer). |
Transaction ID in DHCPv6 packet | pkt6.transid | 12345 | The value of the transaction id in the DHCPv6 packet (expressed as a 32-bit unsigned integer). |
Vendor option existence (any vendor) | vendor[*].exists | true | Returns whether a vendor option from any vendor is present ('true') or absent ('false'). |
Vendor option existence (specific vendor) | vendor[4491].exists | true | Returns whether a vendor option from specified vendor (determined by its enterprise-id) is present ('true') or absent ('false'). |
Enterprise-id from vendor option | vendor.enterprise | 4491 | If the vendor option is present, it returns the value of the enterprise-id field padded to 4 bytes. Returns "" otherwise. |
Vendor sub-option existence | vendor[4491].option[1].exists | true | Returns 'true' if there is vendor option with specified enterprise-id and given sub-option is present. Returns 'false' otherwise. |
Vendor sub-option content | vendor[4491].option[1].hex | docsis3.0 | Returns content of the specified sub-option of a vendor option with specified enterprise id. Returns '' if no such option or sub-option is present. |
Vendor class option existence (any vendor) | vendor-class[*].exists | true | Returns whether a vendor class option from any vendor is present ('true') or absent ('false'). |
Vendor class option existence (specific vendor) | vendor-class[4491].exists | true | Returns whether a vendor class option from specified vendor (determined by its enterprise-id) is present ('true') or absent ('false'). |
Enterprise-id from vendor class option | vendor-class.enterprise | 4491 | If the vendor option is present, it returns the value of the enterprise-id field padded to 4 bytes. Returns "" otherwise. |
First data chunk from vendor class option | vendor-class[4491].data | docsis3.0 | Returns content of the first data chunk from the vendor class option with specified enterprise-id. Returns "" if missing. |
Specific data chunk from vendor class option | vendor-class[4491].data[3] | docsis3.0 | Returns content of the specified data chunk of a vendor class option with specified enterprise id. Returns '' if no such option or data chunk is present. |
Notes:
Hexadecimal strings are converted into a string as expected. The starting "0X" or "0x" is removed, and if the string is an odd number of characters a "0" is prepended to it.
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.
Integers in an expression are converted to 32-bit unsigned integers and are represented as four-byte strings; for example, 123 is represented as 0x0000007b. 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 0x00000001 instead of 0x1 or 0x01. Also, make sure the value is specified in network order, e.g. 1 is represented as 0x00000001.
"option[code].hex" extracts the value of the option with the code "code" from the incoming packet. If the packet doesn't 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.
"option[code].exists" checks whether an option with the code "code" is present in the incoming packet. It can be used with empty options.
"member('foobar')" checks whether the packet belongs to the client class "foobar". To avoid dependency loops, the configuration file parser verifies whether client classes were already defined or are builtin, i.e., beginning by "VENDOR_CLASS_", "AFTER__" (for the to come "after" hook) and "EXTERNAL_" or equal to "ALL", "KNOWN", "UNKNOWN"etc.
"known" and "unknown" are short hands for "member('KNOWN')" and "not member('KNOWN')". Note the evaluation of any expression using directly or indirectly the "KNOWN" class is deferred after the host reservation lookup (i.e. when the "KNOWN" or "UNKNOWN" partition is determined).
"relay4[code].hex" attempts to extract the value of the sub-option "code" from the option inserted as the DHCPv4 Relay Agent Information (82) option. If the packet doesn't contain a RAI option, or the RAI option doesn't 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.
"relay4" shares the same representation types as "option", for instance "relay4[code].exists" is supported.
"relay6[nest]" allows access to the encapsulations used by any DHCPv6 relays that forwarded the packet. The "nest" 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 to specify relays counted from the DHCPv6 client, -1 indicating the relay closest to the client. In general negative "nest" level is the same as the number of relays + "nest" level. If the requested encapsulation doesn't exist an empty string "" is returned. This expression is allowed in DHCPv6 only.
"relay6[nest].option[code]" shares the same representation types as "option", for instance "relay6[nest].option[code].exists" is supported.
Expressions starting with "pkt4" can be used only in DHCPv4. They allows access to DHCPv4 message fields.
"pkt6" refers to information from the client request. To access any information from an intermediate relay use "relay6". "pkt6.msgtype" and "pkt6.transid" output a 4 byte binary string for the message type or transaction id. For example the message type SOLICIT will be "0x00000001" or simply 1 as in "pkt6.msgtype == 1".
Vendor option means Vendor-Identifying Vendor-specific Information option in DHCPv4 (code 125, see Section 4 of RFC 3925) and Vendor-specific Information Option in DHCPv6 (code 17, defined in Section 21.17 of RFC 8415). Vendor class option means Vendor-Identifying Vendor Class Option in DHCPv4 (code 124, see Section 3 of RFC 3925) in DHCPv4 and Class Option in DHCPv6 (code 16, see Section 21.16 of RFC 8415). 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.
In the vendor and vendor-class constructs Asterisk (*) or 0 can be used to specify a wildcard enterprise-id value, i.e. it will match any enterprise-id value.
Vendor Class Identifier (option 60 in DHCPv4) can be accessed using option[60] expression.
RFC 3925 and RFC 8415 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 vendor.enterprise and vendor-class.enterprise expressions, the value from the first instance is returned. Please submit a feature request on Kea website if you need support for multiple instances.
Table 14.2. List of Classification Expressions
Name | Example | Description |
---|---|---|
Equal | 'foo' == 'bar' | Compare the two values and return "true" or "false" |
Not | not ('foo' == 'bar') | Logical negation |
And | ('foo' == 'bar') and ('bar' == 'foo') | Logical and |
Or | ('foo' == 'bar') or ('bar' == 'foo') | Logical or |
Substring | substring('foobar',0,3) | Return the requested substring |
Concat | concat('foo','bar') | Return the concatenation of the strings |
Ifelse | ifelse('foo' == 'bar','us','them') | Return the branch value according to the condition |
Hexstring | hexstring('foo', '-') | Converts the value to a hexadecimal string, e.g. 0a:1b:2c:3e |
substring('foobar', 0, 6) == 'foobar' substring('foobar', 3, 3) == 'bar' substring('foobar', 3, all) == 'bar' substring('foobar', 1, 4) == 'ooba' substring('foobar', -5, 4) == 'ooba' substring('foobar', -1, -3) == 'oba' substring('foobar', 4, -2) == 'ob' substring('foobar', 10, 2) == ''
concat('foo', 'bar') == 'foobar'
ifelse(option[230].exists, option[230].hex, 'none')
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. If you need complex or time consuming expressions you should write a hook to perform the necessary work.
A class contains five items: a name, a test expression, option data, option definition and only-if-required flag. The name must exist and must be unique amongst all classes. The test expression, option data and definition, and only-if-required flag are optional.
The test expression is a string containing the logical expression used to determine membership in the class. The entire expression is in double quotes.
The option data is a list which defines any options that should be assigned to members of this class.
The option definition is for DHCPv4 option 43 (Section 8.2.13, “DHCPv4 Vendor-Specific Options” and DHCPv4 private options (Section 8.2.12, “DHCPv4 Private Options”).
Usually the test expression is 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 not yet done. The only-if-required flag, false by default, allows to perform the evaluation of the test expression only when it was required, i.e. in a require-client-classes list of the selected subnet, shared-network or pool.
The require-client-classes list which is valid for shared-network, subnet and pool scope specifies the classes which are evaluated in the second pass before output option processing. The list is built in the reversed precedence order of option data, i.e. an option data in a subnet takes precedence on one in a shared-network but required class in a subnet is added after one in a shared-network. The mechanism is related to the only-if-required flag but it is not mandatory that the flag was set to true.
In the following example the class named "Client_foo" is defined. It is comprised of all clients whose client ids (option 61) start with the string "foo". Members of this class will be given 192.0.2.1 and 192.0.2.2 as their domain name servers.
"Dhcp4": {
"client-classes": [
{
"name": "Client_foo",
"test": "substring(option[61].hex,0,3) == 'foo'",
"option-data": [
{
"name": "domain-name-servers",
"code": 6,
"space": "dhcp4",
"csv-format": true,
"data": "192.0.2.1, 192.0.2.2"
}
]
},
...
],
...
}
This example shows a client class being defined for use by the DHCPv6 server. In it the class named "Client_enterprise" is defined. It is comprised of all clients who's 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 2001:db8:0::1 and 2001:db8:2::1 as their domain name servers.
"Dhcp6": {
"client-classes": [
{
"name": "Client_enterprise",
"test": "substring(option[1].hex,0,6) == 0x0002AABBCCDD",
"option-data": [
{
"name": "dns-servers",
"code": 23,
"space": "dhcp6",
"csv-format": true,
"data": "2001:db8:0::1, 2001:db8:2::1"
}
]
},
...
],
...
}
Classes can be statically assigned to the clients using techniques described in Section 8.3.6, “Reserving Client Classes in DHCPv4” and Section 9.3.5, “Reserving Client Classes in DHCPv6”.
In certain cases it beneficial to restrict access to certain subnets only to clients that belong to a given class, using the "client-class" keyword when defining the subnet.
Let's 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 range 192.0.2.10 to 192.0.2.20 are going to be managed by the DHCP4 server. Only clients belonging to client class Client_foo are allowed to use this subnet. Such a configuration can be achieved in the following way:
"Dhcp4": {
"client-classes": [
{
"name": "Client_foo",
"test": "substring(option[61].hex,0,3) == 'foo'",
"option-data": [
{
"name": "domain-name-servers",
"code": 6,
"space": "dhcp4",
"csv-format": true,
"data": "192.0.2.1, 192.0.2.2"
}
]
},
...
],
"subnet4": [
{
"subnet": "192.0.2.0/24",
"pools": [ { "pool": "192.0.2.10 - 192.0.2.20" } ],
"client-class": "Client_foo"
},
...
],
,
...
}
The following example shows restricting access to a DHCPv6 subnet. This configuration will restrict use of the addresses 2001:db8:1::1 to 2001:db8:1::FFFF to members of the "Client_enterprise" class.
"Dhcp6": {
"client-classes": [
{
"name": "Client_enterprise",
"test": "substring(option[1].hex,0,6) == 0x0002AABBCCDD",
"option-data": [
{
"name": "dns-servers",
"code": 23,
"space": "dhcp6",
"csv-format": true,
"data": "2001:db8:0::1, 2001:db8:2::1"
}
]
},
...
],
"subnet6": [
{
"subnet": "2001:db8:1::/64",
"pools": [ { "pool": "2001:db8:1::-2001:db8:1::ffff" } ],
"client-class": "Client_enterprise"
}
],
...
}
Similar to subnets in certain cases access to certain address or prefix pools must be restricted to only clients that belong to a given class, using the "client-class" when defining the pool.
Let's 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 range 192.0.2.10 to 192.0.2.20 are going to be managed by the DHCP4 server. Only clients belonging to client class Client_foo are allowed to use this pool. Such a configuration can be achieved in the following way:
"Dhcp4": {
"client-classes": [
{
"name": "Client_foo",
"test": "substring(option[61].hex,0,3) == 'foo'",
"option-data": [
{
"name": "domain-name-servers",
"code": 6,
"space": "dhcp4",
"csv-format": true,
"data": "192.0.2.1, 192.0.2.2"
}
]
},
...
],
"subnet4": [
{
"subnet": "192.0.2.0/24",
"pools": [
{
"pool": "192.0.2.10 - 192.0.2.20",
"client-class": "Client_foo"
}
]
},
...
],
,
}
The following example shows restricting access to an address pool. This configuration will restrict use of the addresses 2001:db8:1::1 to 2001:db8:1::FFFF to members of the "Client_enterprise" class.
"Dhcp6": {
"client-classes": [
{
"name": "Client_enterprise_",
"test": "substring(option[1].hex,0,6) == 0x0002AABBCCDD",
"option-data": [
{
"name": "dns-servers",
"code": 23,
"space": "dhcp6",
"csv-format": true,
"data": "2001:db8:0::1, 2001:db8:2::1"
}
]
},
...
],
"subnet6": [
{
"subnet": "2001:db8:1::/64",
"pools": [
{
"pool": "2001:db8:1::-2001:db8:1::ffff",
"client-class": "Client_foo"
}
]
},
...
],
...
}
Currently classes can be used for two functions. They can supply options to the members of the class and they can be used to choose a subnet from which an address will be assigned to the class member.
When supplying options, options defined as part of the class definition are considered "class globals". They will override any global options that may be defined and in turn will be overridden by any options defined for an individual subnet.
You may use a hook to classify your packets. This may be useful if the expression would either be complex or time consuming and be easier or better to write as code. Once the hook has added the proper class name to the packet the rest of the classification system will work as normal in choosing a subnet and selecting options. For a description of hooks see Chapter 15, Hooks Libraries, for a description on configuring classes see Section 14.4, “Configuring Classes” and Section 14.6, “Configuring Subnets With Class Information”.
While you are constructing your classification expressions you may find it useful to enable logging see Chapter 18, Logging for a more complete description of the logging facility.
To enable the debug statements in the classification system you will need to set the severity to "DEBUG" and the debug level to at least 55. The specific loggers are "kea-dhcp4.eval" and "kea-dhcp6.eval".
In order to understand the logging statements, one must understand a
bit about how expressions are evaluated; for a more complete description
refer to the design document at https://gitlab.isc.org/isc-projects/kea/wikis/design%20documents
.
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.
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 will be traversed in order. As each token is executed it will be 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:
"test": "substring(option[61].hex,0,3) == 'foo'",
This will result in the following tokens:
option, number (0), number (3), substring, text ('foo'), equals
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.
When debug logging is enabled, each time a token is evaluated it will emit 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.
The values will be 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 will be displayed in the order they were popped. For most expressions this won't matter but for the concat expression the values are displayed in reverse order from how they are written in the expression.
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.
"test": "substring(option[61].hex,0,3) == 'foo'",
The logging might then resemble this:
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 '0' 2016-05-19 13:35:04.165 DEBUG [kea.eval/44478] EVAL_DEBUG_STRING Pushing text string '3' 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 'foo' 2016-05-19 13:35:04.168 DEBUG [kea.eval/44478] EVAL_DEBUG_EQUAL Popping 0x666F6F and 0x666F6F pushing result 'true'
The debug logging may be quite verbose if you have a number of expressions to evaluate. It is intended as an aid in helping you create and debug your expressions. You should plan to disable debug logging when you have your expressions working correctly. You also may wish to include only one set of expressions at a time in the configuration file while debugging them in order to limit the log statements. For example when adding a new set of expressions you might find it more convenient to create a configuration file that only includes the new expressions until you have them working correctly and then add the new set to the main configuration file.
Table of Contents
Although Kea offers a lot of flexibility, there may be cases where its behavior needs customization. To accommodate this possibility, Kea includes the idea of "Hooks". This feature lets Kea load one or more dynamically-linked libraries (known as "hooks libraries") and, at various points in its processing ("hook points"), call functions in them. Those functions perform whatever custom processing is required.
The hooks concept also allows keeping the core Kea code reasonably small by moving features that some, but not all users find useful to external libraries. People who don't need specific functionality simply don't load the libraries.
Hooks libraries are loaded by individual Kea processes, not to Kea as a whole. This means (for example) that it is possible to associate one set of libraries with the DHCP4 server and a different set to the DHCP6 server.
Another point to note is that it is possible for a process to load multiple libraries. When processing reaches a hook point, Kea calls the hooks 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 to see if this is the case.
The next section describes how to configure hooks libraries. If you are interested in writing your own hooks library, information can be found in the Kea Developer's Guide.
Note that some libraries are available under different licenses.
Note that some libraries may require additional dependencies and/or compilation switches to be enabled, e.g. Radius library introduced in Kea 1.4 requires FreeRadius-client library to be present. If --with-free-radius option is not specified, the Radius library will not be built.
The installation procedure has changed in 1.4.0. Kea 1.3.0 and
earlier needed special switches passed to configure script to detect the
hook libraries. Please see this KB article: https://kb.isc.org/article/AA-01587
.
Some hook packages are included in the base Kea sources. There is no need to do anything special to compile or install them, they are covered by the usual building and installation procedure. ISC also provides several additional hooks in form of various packages. All of those packages follow the same installation procedure that is similar to base Kea, but has several additional steps. For your convenience, the whole procedure is described here. Please refer to Chapter 3, Installation for general overview.
1. Download the package. You will receive detailed instructions how to get it separately. This will be a file with a name similar to kea-premium-1.6.0-beta2.tar.gz. Your name may differ depending on which package you got.
2. If you have the sources for the corresponding version of the open-source Kea package still on your system (from when you installed Kea), skip this step. Otherwise extract the Kea source from the original tarball you downloaded. For example, if you downloaded Kea 1.6.0-beta2., you should have a tarball called kea-1.6.0-beta2.tar.gz on your system. Unpack this tarball:
$ tar zxvf kea-1.6.0-beta2.tar.gz
This will unpack the tarball into the kea-1.6.0-beta2 subdirectory of your current working directory.
3. Unpack the Kea premium tarball into the directory into which Kea was unpacked. For example, assuming that you followed step 2 and that Kea 1.6.0-beta2 has been unpacked into a kea-1.6.0-beta2 subdirectory and that the Kea premium tarball is in your current directory, the following steps will unpack the premium tarball into the correct location:
$cd kea-1.6.0-beta2
$tar xvf ../kea-premium-1.6.0-beta2.tar.gz
Note that unpacking the Kea premium package will put the files into a directory named premium. Regardless of the name of your package, the directory will always be called premium, just its content may vary.
4. Run autoreconf tools. This step is necessary to update Kea's build script to include additional directory. If this tool is not already available on your system, you need to install automake and autoconf tools. To generate configure script, please use:
$ autoreconf -i
5. Rerun configure, using the same configure options as you used when originally building Kea. You can check if configure has detected the premium package by inspecting the summary printed when it exits. The first section of the output should look something like:
Package: Name: kea Version: 1.6.0-beta2 Extended version:1.6.0-beta2 (tarball) OS Family: Linux Using GNU sed: yes Premium package: yes Included Hooks: forensic_log flex_id host_cmds
The last line indicates which specific hooks were detected. Note that some hooks may require its own dedicated switches, e.g. radius hook requires extra switches for FreeRADIUS. Please consult later sections of this chapter for details.
6. Rebuild Kea
$ make
If your machine has multiple CPU cores, interesting option to consider here is -j X, where X is the number of available cores.
7. Install Kea sources together with hooks:
$ sudo make install
Note that as part of the installation procedure, the install script will eventually venture into premium/ directory and will install additional hook libraries and associated files.
The installation location of the hooks libraries depends whether you specified --prefix parameter to the configure script. If you did not, the default location will be /usr/local/lib/kea/hooks. You can verify the libraries are installed properly with this command:
$ ls -l /usr/local/lib/kea/hooks/*.so
/usr/local/lib/kea/hooks/libdhcp_class_cmds.so
/usr/local/lib/kea/hooks/libdhcp_flex_id.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_legal_log.so
/usr/local/lib/kea/hooks/libdhcp_subnet_cmds.so
The exact list you see will depend on the packages you have. If you specified directory via --prefix, the hooks libraries will be located in {prefix directory}/lib/kea/hooks.
The hooks libraries for a given process are configured using the hooks-libraries keyword in the configuration for that process. (Note that the word "hooks" is plural). The value of the keyword is an array of map structures, each structure corresponding to a hooks library. For example, to set up two hooks libraries for the DHCPv4 server, the configuration would be:
"Dhcp4": {
:
"hooks-libraries": [
{
"library": "/opt/charging.so"
},
{
"library": "/opt/local/notification.so",
"parameters": {
"mail": "spam@example.com",
"floor": 13,
"debug": false,
"users": [ "alice", "bob", "charlie" ],
"languages": {
"french": "bonjour",
"klingon": "yl'el"
}
}
}
]
:
}
This is a change to the syntax used in Kea 0.9.2 and earlier, where hooks-libraries was a list of strings, each string being the name of a library. The change was made in Kea 1.0 to facilitate the specification of library-specific parameters, a capability available in Kea 1.1.0 onwards. Libraries should allow a parameter entry where to put comments as it is done for many configuration scopes with comment and user context.
The library reloading behavior has changed in Kea 1.1.0. Libraries are reloaded, even if their list hasn't changed. Kea does that, because the parameters specified for the library (or the files those parameters point to) may have changed.
Libraries may have additional parameters. Those are not mandatory in the sense that there may be libraries that don't require them. However, for specific library there is often specific requirement for specify certain set of parameters. Please consult the documentation for your library for details. In the example above, the first library has no parameters. The second library has five parameters, specifying mail (string parameter), floor (integer parameter), debug (boolean parameter) and even lists (list of strings) and maps (containing strings). Nested parameters could be used if the library supports it. This topic is explained in detail in the Hooks Developer's Guide in the "Configuring Hooks Libraries" section.
Notes:
The full path to each library should be given.
As noted above, order may be important - consult the documentation for each library.
An empty list has the same effect as omitting the hooks-libraries configuration element all together.
There is one case where this is not true: if Kea is running with a configuration that contains a hooks-libraries item, and that item is removed and the configuration reloaded, the removal will be ignored and the libraries remain loaded. As a workaround, instead of removing the hooks-libraries item, change it to an empty list. This will be fixed in a future version of Kea.
At the present time, only the kea-dhcp4 and kea-dhcp6 processes support hooks libraries.
As described above, the hooks 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 hooks libraries; these discussed in the following sections.
Some of these libraries will be available with the base code while others will be shared with organizations supporting development of Kea , possibly as a 'benefit' or 'thank you' for helping to sustain the larger Kea project. If you would like to get access to those libraries, please consider taking out a support contract: this includes professional support, advance security notifications, input into our roadmap planning, and many other benefits, while helping making Kea sustainable in the long term.
The following table provides a list of 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 kea-ctrl-agent process to load libraries that should, in fact, be loaded by the kea-dhcp4 or kea-dhcp6 processes. If a library from ISC doesn't work as expected, please make sure that it has been loaded by the correct process per the table below.
While the Kea Control Agent includes the "hooks" functionality, (i.e. hooks libraries can be loaded by this process), none of ISC's current hooks libraries should be loaded by the Control Agent.
Table 15.1. List of available hooks libraries
Name | Availability | Since | Load by process | Description | ||
---|---|---|---|---|---|---|
user_chk | Kea sources | Kea 0.8 |
| 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 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 src/hooks/dhcp/user_chk directory. | ||
Forensic Logging | Support customers | Kea 1.1.0 |
| This library provides hooks that record a detailed log of lease assignments and renewals into 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 your jurisdiction requires that you save a different set of information, you may use it as a template or example and create your own custom logging hooks. | ||
Flexible Identifier | Support customers | Kea 1.2.0 |
| 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 using hardware address or DUID in DHCPv6. However, there are sometimes scenarios where the reservation is more complex, e.g. uses other options that mentioned above, uses part of specific options or perhaps even a combination of several options and fields to uniquely identify a client. Those scenarios are addressed by the Flexible Identifiers hook application. It allows defining an expression, similar to the one used in client classification, e.g. substring(relay6[0].option[37],0,6). Each incoming packet is evaluated against that expression and its value is then searched in the reservations database. | ||
Host Commands | Support customers | Kea 1.2.0 |
| 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 will be rejected. Those commands are exposed via command channel (JSON over unix sockets) and Control Agent (JSON over RESTful interface). Additional commands and capabilities related to host reservations will be added in the future. | ||
Subnet Commands | Support customers | Kea 1.3.0 |
| 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 hooks library allows for incremental changes to the subnet configuration such as: adding a subnet, 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. | ||
Lease Commands | Kea sources | Kea 1.3.0 |
| The lease commands hook library offers a number of new commands used to manage leases. Kea provides a way to store lease information in various backends: memfile, MySQL, PostgreSQL and Cassandra. This library provides a unified interface that can manipulate leases in an unified, safe way. In particular, it allows: manipulate leases in memfile while Kea is running, sanity check changes, check lease existence and remove all leases belonging to specific subnet. It can also catch more obscure errors, like adding a lease with subnet-id 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. It provides a way to manage user contexts associated with leases. | ||
High Availability | Kea sources | Kea 1.4.0 |
| Minimizing a risk of DHCP service unavailability is achieved by setting up a pair of the DHCP servers in a network. Two modes of operation are supported. The first one is called load balancing and is sometimes referred to as active-active. Each server can handle selected group of clients in this network or all clients, if it detects that its partner has became unavailable. It is also possible to designate one server to serve all DHCP clients, and leave another server as "standby". This mode is called hot standby and is sometimes referenced to as active-passive. This server will activate its DHCP function 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 server, making it much easier to have a replacement that is almost up to date. The "libdhcp_ha" library provides such functionality for Kea DHCP servers. | ||
Statistics Commands | Kea sources | Kea 1.4.0 |
| The Statistics Commands library provides additional commmands 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. A feature was introduced in Kea 1.4.0 that allows tracking lease allocations within the lease database, thus making the statistics accessible to all connected DHCP servers. The Statistics Commands hooks library utilizes this feature and returns lease statistics for all subnets respectively. | ||
Radius | Support customers | Kea 1.4.0 |
| The RADIUS Hook library allows Kea to interact with the 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's messages altogether. The accounting mechanism allows RADIUS server to keep track of device activity over time. | ||
Host Cache | Support customers | Kea 1.4.0 |
| Some of the database backends, such as RADIUS, are considered slow and may take a long time to respond. Since Kea in general is synchronous, the backend performance directly affects the DHCP performance. To minimize the impact and improve performance, the Host Cache 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. | ||
Class Commands | Support customers | Kea 1.5.0 |
| This Class Cmds hooks library allows for adding, updating deleting and fetching configured DHCP client classes without the need to restart the DHCP server. | ||
MySQL Configuration Backend | Kea sources | Kea 1.6.0 |
| The MySQL CB hooks library is an implementation of the Kea Configuration Backend for MySQL. It uses MySQL database as a repository for the Kea configuration information. The Kea servers use this library to fetch their configurations. | ||
Configuration Backend Commands | Support customers | Kea 1.6.0 |
| The Configuration Backend Commands (CB Commands) hooks library implements a collection of commands to manage the configuration information of the Kea servers in the database. This library may only be used in conjuction with one of the supported configuration backend implementations. |
ISC hopes to see more hooks libraries become available as time progresses, both developed internally and externally. Since this list may evolve dynamically, we decided to keep it on a wiki page, available at this link: https://gitlab.isc.org/isc-projects/kea/wikis/Hooks-available. If you are a developer or are aware of any hooks libraries not listed there, please send a note to the kea-users or kea-dev mailing lists and someone will update it.
The libraries developed by ISC are described in detail in the following sections.
The user_chk library is the first hooks library published by ISC. It attempts to serve several purposes:
To assign "new" or "unregistered" users to a restricted subnet, while "known" or "registered" users are assigned to unrestricted subnets.
To allow DHCP response options or vendor option values to be customized based upon user identity.
To provide a real time record of the user registration activity which can be sampled by an external consumer.
To serve as a demonstration of various capabilities possible using the hooks interface.
Once loaded, the library allows segregating incoming requests into known and unknown clients. For known clients, the packets are processed mostly as usual, except it is possible to override certain options being sent. That can be done on a per host basis. Clients that are not on the known hosts list will be treated as unknown and will be assigned to the last subnet defined in the configuration file.
As an example of use, this behavior may be used to put unknown users into a separate subnet that leads to a walled garden, 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.
This library was developed several years before the host reservation mechanism has become available. Currently host reservation is much more powerful and flexible, but nevertheless the user_chk capability to consult and external source of information about clients and alter Kea's behavior is useful and remains of educational value.
The library reads the /tmp/user_chk_registry.txt file while being loaded and each time an incoming packet is processed. The file is expected to have each line contain a self-contained JSON snippet which must have the following two entries:
type, whose value is "HW_ADDR" for IPv4 users or "DUID" for IPv6 users
id, whose value is either the hardware address or the DUID from the request formatted as a string of hex digits, with or without ":" delimiters.
and may have the zero or more of the following entries:
bootfile whose value is the pathname of the desired file
tftp_server whose value is the hostname or IP address of the desired server
A sample user registry file is shown below:
{ "type" : "HW_ADDR", "id" : "0c:0e:0a:01:ff:04", "bootfile" : "/tmp/v4bootfile" } { "type" : "HW_ADDR", "id" : "0c:0e:0a:01:ff:06", "tftp_server" : "tftp.v4.example.com" } { "type" : "DUID", "id" : "00:01:00:01:19:ef:e6:3b:00:0c:01:02:03:04", "bootfile" : "/tmp/v6bootfile" } { "type" : "DUID", "id" : "00:01:00:01:19:ef:e6:3b:00:0c:01:02:03:06", "tftp_server" : "tftp.v6.example.com" }
As with any other hooks libraries provided by ISC, internals of the user_chk code are well documented. You can take a look at the Kea Developer's Guide section dedicated to the user_chk library that discusses how the code works internally. That, together with our general entries in Hooks Framework section should give you some pointers how to extend this library and perhaps even write your own from scratch.
This section describes the forensic log hooks library. This library provides hooks that record a detailed log of lease assignments and renewals into a set of log files. Currently this library is only available to ISC customers with a support contract.
This library may only be loaded by kea-dhcp4 or kea-dhcp6 process.
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 your jurisdiction requires that you save a different set of information you may use it as a template or example and create your own custom logging hooks.
This logging is done as a set of hooks to allow it to be customized to any particular need. Modifying a hooks library is easier and safer than updating the core code. In addition by using the hooks features those users who don't need to log this information can leave it out and avoid any performance penalties.
The names for the log files have the following form:
path/base-name.CCYYMMDD.txt
The "path" and "base-name" are supplied in the configuration as described below see Section 15.4.2.4, “Configuring the Forensic Log Hooks”. The next part of the name is the date the log file was started, with four digits for year, two digits for month and two digits for day. The file is rotated on a daily basis.
When running Kea servers for both DHCPv4 and DHCPv6 the log names must be distinct. See the examples in Section 15.4.2.4, “Configuring the Forensic Log Hooks”.
For DHCPv4 the library creates entries based on DHCPREQUEST messages and corresponding DHCPv4 leases intercepted by lease4_select (for new leases) and lease4_renew (for renewed leases) hooks.
An entry is a single string with no embedded end-of-line markers, a prepended timestamp and has the following sections:
timestamp address duration device-id {client-info} {relay-info} {user-context}
Where:
timestamp - the current date and time the log entry was written in "%Y-%m-%d %H:%M:%S %Z" strftime format ("%Z" is the time zone name).
address - the leased IPv4 address given out and whether it was assigned or renewed.
duration - the lease lifetime expressed in days (if present), hours, minutes and seconds. A lease lifetime of 0xFFFFFFFF will be denoted with the text "infinite duration".
device-id - the client's hardware address shown as numerical type and hex digit string.
client-info - the DHCP client id option (61) if present, shown as a hex string.
relay-info - for relayed packets the giaddr and the RAI circuit-id, remote-id and subscriber-id options (option 82 sub options: 1, 2 and 6) if present. The circuit id and remote id are presented as hex strings
user-context - the optional user context associated to the lease.
For instance (line breaks added for readability, they would not be present in the log file).
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 and remote-id: 87:f6:79:77:ef
In addition to logging lease activity driven by DHCPv4 client traffic, it also logs entries for the following lease management control channel commands: lease4-add, lease4-update, and lease4-del. Each entry is a single string with no embedded end-of-line markers and they will typically have the following forms:
lease4-add:
*timestamp* Administrator added a lease of address: *address* to a device with hardware address: *device-id*
Dependent on the arguments of the add command, it may also include the client-id and duration.
Example:
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
lease4-update:
*timestamp* Administrator updated information on the lease of address: *address* to a device with hardware address: *device-id*
Dependent on the arguments of the update command, it may also include the client-id and lease duration.
Example:
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
lease4-del: Deletes have two forms, one by address and one by identifier and identifier type:
*timestamp* Administrator deleted the lease for address: *address*
or
*timestamp* Administrator deleted a lease for a device identified by: *identifier-type* of *identifier*
Currently only a type of @b hw-address (hardware address) is supported.
Examples:
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
For DHCPv6 the library creates entries based on lease management actions intercepted by the lease6_select (for new leases), lease6_renew (for renewed leases) and lease6_rebind (for rebound leases).
An entry is a single string with no embedded end-of-line markers, a prepended timestamp and has the following sections:
timestamp address duration device-id {relay-info}* {user-context}
Where:
timestamp - the current date and time the log entry was written in "%Y-%m-%d %H:%M:%S %Z" strftime format ("%Z" is the time zone name).
address - the leased IPv6 address or prefix given out and whether it was assigned or renewed.
duration - the lease lifetime expressed in days (if present), hours, minutes and seconds. A lease lifetime of 0xFFFFFFFF will be denoted with the text "infinite duration".
device-id - the client's DUID and hardware address (if present).
relay-info - for relayed packets the content of relay agent messages, remote-id (code 37), subscriber-id (code 38) and interface-id (code 18) options if present. Note that interface-id option, if present, identifies the whole interface the relay agent received the message on. This typically translates to a single link in your network, but it depends on your specific network topology. Nevertheless, this is useful information to better scope down the location of the device, so it is being recorded, if present.
user-context - the optional user context associated to the lease.
For instance (line breaks added for readability, they would not be present in the log file).
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
In addition to logging lease activity driven by DHCPv6 client traffic, it also logs entries for the following lease management control channel commands: lease6-add, lease6-update, and lease6-del. Each entry is a single string with no embedded end-of-line markers and they will typically have the following forms:
lease6-add:
*timestamp* Administrator added a lease of address: *address* to a device with DUID: *DUID*
Dependent on the arguments of the add command, it may also include the hardware address and duration.
Example:
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
lease6-update:
*timestamp* Administrator updated information on the lease of address: *address* to a device with DUID: *DUID*
Dependent on the arguments of the update command, it may also include the hardware address and lease duration.
Example:
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
lease6-del: Deletes have two forms, one by address and one by identifier and identifier type:
*timestamp* Administrator deleted the lease for address: *address*
or
*timestamp* Administrator deleted a lease for a device identified by: *identifier-type* of *identifier*
Currently only a type of DUID is supported.
Examples:
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
To use this functionality the hook library must be included in the
configuration of the desired DHCP server modules. The legal_log
library is installed alongside the Kea libraries in
[kea-install-dir]/var/lib/kea
where
kea-install-dir
is determined by the
"--prefix" option of the configure script. It defaults to
/usr/local
. Assuming the
default value then, configuring kea-dhcp4 to load the legal_log
library could be done with the following Kea4 configuration:
"Dhcp4": {
"hooks-libraries": [
{
"library": "/usr/local/lib/kea/hooks/libdhcp_legal_log.so",
"parameters": {
"path": "/var/lib/kea/log",
"base-name": "kea-forensic4"
}
},
...
]
}
To configure it for kea-dhcp6, the commands are simply as shown below:
"Dhcp6": {
"hooks-libraries": [
{
"library": "/usr/local/lib/kea/hooks/libdhcp_legal_log.so",
"parameters": {
"path": "/var/lib/kea/log",
"base-name": "kea-forensic6"
}
},
...
]
}
Two Hook Library parameters are supported:
path - the directory in which the forensic file(s) will be written. The
default value is
[prefix]/var/lib/kea
. The directory must exist.
base-name - an arbitrary value which is used in conjunction with
the current system date to form the current forensic file name. It defaults
to kea-legal
.
If it is desired to restrict forensic logging to certain subnets, the "legal-logging" boolean parameter can be specified within a user context of these subnets. For example:
"Dhcpv4" {
"subnet4": [
{
"subnet": "192.0.2.0/24",
"pools": [
{
"pool": "192.0.2.1 - 192.0.2.200"
}
],
"user-context": {
"legal-logging": false
}
}
]
}
disables legal logging for the subnet "192.0.2.0/24". If this parameter is not specified, it defaults to 'true', which enables legal logging for the subnet.
The following example demonstrates how to selectively disable legal logging for an IPv6 subnet.
"Dhcpv6": {
"subnet6": [
{
"subnet": "2001:db8:1::/64",
"pools": [
{
"pool": "2001:db8:1::1-2001:db8:1::ffff"
}
],
"user-context": {
"legal-logging": false
}
}
]
}
See Section 8.10, “User Contexts in IPv4” and Section 9.15, “User Contexts in IPv6” to learn more about user contexts in Kea configuration.
Log entries can be inserted into a database when Kea is configured with database backend support: a table named 'logs' is used with a timestamp (timeuuid for Cassandra CQL) generated by the database software and a text log with the same format than for files without the timestamp.
Please refer to Section 4.3.2, “MySQL” for MySQL, to Section 4.3.3, “PostgreSQL” for PostgreSQL or to Section 4.3.4, “Cassandra” for Cassandra CQL. The logs table is part of the Kea database schemas.
Configuration parameters are extended by standard lease database parameters as defined in Section 8.2.2.2, “Lease Database Configuration”. The "type" parameter should be "mysql", "postgresql", "cql" or be "logfile". When it is absent or set to "logfile" files are used.
This database feature is experimental and will be likely improved, for instance to add an address / prefix index (currently the only index is the timestamp). No specific tools is provided to operate the database but standard tools are applicable, for instance to dump the logs table from a CQL database:
$ echo 'SELECT dateOf(timeuuid), log FROM logs;' | cqlsh -k database-name
system.dateof(timeuuid) | log
---------------------------------+---------------------------------------
2018-01-06 01:02:03.227000+0000 | Address: 192.2.1.100 has been renewed ...
...
(12 rows)
$
This section describes a hook application dedicated to generate flexible identifiers for host reservation. 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 using hardware address or DUID in DHCPv6. However, there are sometimes scenarios where the reservation is more complex, e.g. uses other options that mentioned above, uses part of specific options or perhaps even a combination of several options and fields to uniquely identify a client. Those scenarios are addressed by the Flexible Identifiers hook application.
Currently this library is only available to ISC customers with a support contract.
This library may only be loaded by kea-dhcp4 or kea-dhcp6 process.
The library allows for defining an expression, using notation initially used for client classification only. See Section 14.3, “Using Expressions in Classification” for detailed description of the syntax available. One notable difference is that for client classification the expression currently has to evaluate to either true or false, while the flexible identifier expression is expected to evaluate to a string that will be used as identifier. It is a valid case for the expression to evaluate to empty string (e.g. in cases where a client does not sent specific options). This expression is then evaluated for each incoming packet. 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.
The library can be loaded in similar way as other hook libraries. It takes a mandatory parameter identifier-expression and optional boolean parameter replace-client-id:
"Dhcp6": {
"hooks-libraries": [
{
"library": "/path/libdhcp_flex_id.so",
"parameters": {
"identifier-expression": "expression
",
"replace-client-id": false
}
},
...
]
}
The flexible identifier library supports both DHCPv4 and DHCPv6.
EXAMPLE: Let's consider a case of an IPv6 network that has an independent interface for each of the 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 verified that the interface-id is unique for each customer facing interface. Therefore it is suitable for usage as reservation. However, only the first 6 bytes of the interface-id are interesting, because remaining bytes are either randomly changed or not unique between devices. Therefore the customer decided to use first 6 bytes of the interface-id option inserted by the relay agent. After adding "flex-id" host-reservation-identifiers goal can be achieved by using the following configuration:
"Dhcp6": { "subnet6": [{ ..., // subnet definition starts here "reservations": ["flex-id": "'port1234'"
, // value of the first 8 bytes of the interface-id "ip-addresses": [ "2001:db8::1" ] ], }], // end of subnet definitions "host-reservation-identifiers": ["duid", "flex-id"], // add "flex-id" to reservation identifiers "hooks-libraries": [ { "library": "/path/libdhcp_flex_id.so", "parameters": { "identifier-expression": "substring(relay6[0].option[18].hex,0,8)
" } }, ... ] }
NOTE: Care should be taken when adjusting the expression. If the expression changes, then all the flex-id values may change, possibly rendering all reservations based on flex-id unusable until they're manually updated. Therefore it is strongly recommended to start with the expression and a handful reservations, adjust the expression as needed and only after it was confirmed the expression does exactly what is expected out of it go forward with host reservations on any broader scale.
flex-id values in host reservations can be specified in two ways. First, they can be expressed as hex string, e.g. bar string can be represented as 626174. Alternatively, it can be expressed as quoted value (using double and single quotes), e.g. "'bar'". The former is more convenient for printable characters, while hex string values are more convenient for non-printable characters and does not require the use of the hexstring operator.
"Dhcp6": { "subnet6": [{ ..., // subnet definition starts here "reservations": ["flex-id": "01:02:03:04:05:06"
, // value of the first 8 bytes of the interface-id "ip-addresses": [ "2001:db8::1" ] ], }], // end of subnet definitions "host-reservation-identifiers": ["duid", "flex-id"], // add "flex-id" to reservation identifiers "hooks-libraries": [ { "library": "/path/libdhcp_flex_id.so", "parameters": { "identifier-expression": "vendor[4491].option[1026].hex
" } }, ... ] }
When "replace-client-id" is set to false (which is the default setting), the flex-id hook library uses evaluated flexible identifier solely for identifying host reservations, i.e. searching for reservations within a database. This is a functional equivalent of other identifiers, similar to hardware address or circuit-id. However, this mode of operation has an implication that if a client device is replaced, it may cause a conflict between an existing lease (allocated for old device) and the new lease being allocated for the new device. The conflict arises because the same flexible identifier is computed for the replaced device and the server will try to allocate the same lease. The mismatch between client identifiers sent by new device and old device causes the server to refuse this new allocation until the old lease expires. A manifestation of this problem is dependant on specific expression used as flexible identifier and is likely to appear if you only use options and other parameters that are identifying where the device is connected (e.g. circuit-id), rather than the device identification itself (e.g. MAC address).
The flex-id library offers a way to overcome the problem with lease conflicts by dynamically replacing client identifier (or DUID in DHCPv6 case) with a value derived from flexible identifier. The server processes the client's query as if flexible identifier was sent in the client identifier (or DUID) option. This guarantees that 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.
The following is a stub configuration that enables this behavior:
"Dhcp4": {
"hooks-libraries": [
{
"library": "/path/libdhcp_flex_id.so",
"parameters": {
"identifier-expression": "expression
",
"replace-client-id": true
}
},
...
]
}
In the DHCPv4 case, the value derived from the flexible identifier is formed by prepending 1 byte with a value of zero to flexible identifier. In the IPv6 case, it is formed by prepanding two zero bytes before the flexible identifier.
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. "match-client-id" must be set to true. See Section 8.2.21, “Using Client Identifier and Hardware Address” for details. No additional settings are required for DHCPv6.
If "replace-client-id" option is set to true, the value of "echo-client-id" parameter (that governs whether to send back a client-id option or not) is ignored.
The Section 15.4.5, “lease_cmds: Lease Commands” section describes commands used to retrieve, update and delete leases using various identifiers, e.g. "hw-address", "client-id". The lease_cmds library doesn't natively support querying for leases by flexible identifier. However, when "replace-client-id" is set to true, it makes it possible to query for leases using a value derived from the flexible identifier. In the DHCPv4 case, the query will look similar to this:
{
"command": "lease4-get",
"arguments": {
"identifier-type": "client-id",
"identifier": "00:54:64:45:66
",
"subnet-id": 44
}
}
where hexadecimal value of "54:64:45:66" is a flexible identifier computed for the client.
In the DHCPv6 case, the corresponding query will look similar to this:
{
"command": "lease6-get",
"arguments": {
"identifier-type": "duid",
"identifier": "00:00:54:64:45:66
",
"subnet-id": 10
}
}
This section describes a hook application that offers a number of new commands used to query and manipulate host reservations. 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 will be rejected. Those commands are exposed via command channel (JSON over unix sockets) and Control Agent (JSON over RESTful interface). Additional commands and capabilities related to host reservations will be added in the future.
Currently this library is only available to ISC customers with a support contract.
This library may only be loaded by kea-dhcp4 or kea-dhcp6 process.
Currently five commands are supported: reservation-add (which adds new host reservation), reservation-get (which returns existing reservation if specified criteria are matched), reservation-get-all (which returns all reservations in a specified subnet), reservation-get-page (variant of reservation-get-all which returns all reservations in a specified subnet by pages) and reservation-del (which attempts to delete a reservation matching specified criteria). To use commands that change the reservation information (currently these are reservation-add and reservation-del, but this rule applies to other commands that may be implemented in the future), hosts database must be specified (see hosts-databases description in Section 8.2.3.1, “DHCPv4 Hosts Database Configuration” and Section 9.2.3.1, “DHCPv6 Hosts Database Configuration”) and it must not operate in read-only mode. If the hosts-databases are not specified or are running in read-only mode, the host_cmds library will load, but any attempts to use reservation-add or reservation-del will fail.
Additional host reservation commands are planned in the future. For a description of envisaged commands, see Control API Requirements document.
All commands are using JSON syntax. They can be issued either using control channel (see Chapter 17, Management API) or via Control Agent (see Chapter 7, The Kea Control Agent).
The library can be loaded in similar way as other hook libraries. It does not take any parameters. It supports both DHCPv4 and DHCPv6 servers.
"Dhcp6": {
"hooks-libraries": [
{
"library": "/path/libdhcp_host_cmds.so"
}
...
]
}
Prior to diving into the individual commands, it is worth discussing the parameter, subnet-id. Currently it is mandatory for all of the commands supplied by this library. Prior to Kea 1.5.0, reservations had to belong to specific subnet. Beginning with Kea 1.5.0, reservations may now be specified globally. In other words, they are not 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 the host commands, it is necessary to explicitly identify the scope to which the reservation belongs. This is done via the subnet-id parameter. For global reservations, use a value of zero (0). For reservations scoped to a specific subnet, use that subnet's ID.
reservation-add 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 Section 8.3, “Host Reservation in DHCPv4” and Section 9.3, “Host Reservation in DHCPv6”. The subnet-id is manadatory. Use a value of zero (0) to add a global reservation, or the id of the subnet to which the reservation should be added. An example command can be as simple as:
{
"command": "reservation-add",
"arguments": {
"reservation": {
"subnet-id": 1,
"hw-address": "1a:1b:1c:1d:1e:1f",
"ip-address": "192.0.2.202"
}
}
}
but can also take many more parameters, for example:
{
"command": "reservation-add",
"arguments": {
"reservation":
{
"subnet-id":1,
"client-id": "01:0a:0b:0c:0d:0e:0f",
"ip-address": "192.0.2.205",
"next-server": "192.0.2.1",
"server-hostname": "hal9000",
"boot-file-name": "/dev/null",
"option-data": [
{
"name": "domain-name-servers",
"data": "10.1.1.202,10.1.1.203"
}
],
"client-classes": [ "special_snowflake", "office" ]
}
}
}
Here is an example of complex IPv6 reservation:
{
"command": "reservation-add",
"arguments": {
"reservation":
{
"subnet-id":1,
"duid": "01:02:03:04:05:06:07:08:09:0A",
"ip-addresses": [ "2001:db8:1:cafe::1" ],
"prefixes": [ "2001:db8:2:abcd::/64" ],
"hostname": "foo.example.com",
"option-data": [
{
"name": "vendor-opts",
"data": "4491"
},
{
"name": "tftp-servers",
"space": "vendor-4491",
"data": "3000:1::234"
}
]
}
}
}
The command returns a status that indicates either a success (result 0) or a failure (result 1). Failed command always includes text parameter that explains the cause of failure. Example results:
{ "result": 0, "text": "Host added." }
Example failure:
{ "result": 1, "text": "Mandatory 'subnet-id' parameter missing." }
As reservation-add is expected to store the host, hosts-databases parameter must be specified in your configuration and databases must not run in read-only mode. In the future versions it will be possible to modify the reservations read from a configuration file. Please contact ISC if you are interested in this functionality.
reservation-get can be used to query the host database and retrieve existing reservations. There are two types of parameters this command supports: (subnet-id, address) or (subnet-id, identifier-type, identifier). The first type of query is used when the address (either IPv4 or IPv6) is known, but the details of the reservation aren't. One common use case of this type of query is to find out whether a given address is reserved or not. The second query uses identifiers. For maximum flexibility, Kea stores the host identifying information as a pair of values: type and the actual identifier. Currently supported identifiers are "hw-address", "duid", "circuit-id", "client-id" and "flex-id", but additional types may be added in the future. If any new identifier types are defined in the future, reservation-get command will support them automatically. The subnet-id is mandatory. Use a value of zero (0) to fetch a global reservation, or the id of the subnet to which the reservation belongs.
An example command for getting a host reservation by (subnet-id, address) pair looks as follows:
{ "command": "reservation-get", "arguments": { "subnet-id": 1, "ip-address": "192.0.2.202" } }
An example query by (subnet-id, identifier-type, identifier) looks as follows:
{ "command": "reservation-get", "arguments": { "subnet-id": 4, "identifier-type": "hw-address", "identifier": "01:02:03:04:05:06" } }
reservation-get typically returns result 0 when the query was conducted properly. In particular, 0 is returned when the host was not found. If the query was successful a number of host parameters will be returned. An example of a query that did not find the host looks as follows:
{ "result": 0, "text": "Host not found." }
An example result returned when the host was found:
{ "arguments": { "boot-file-name": "bootfile.efi", "client-classes": [ ], "hostname": "somehost.example.org", "hw-address": "01:02:03:04:05:06", "ip-address": "192.0.2.100", "next-server": "192.0.0.2", "option-data": [ ], "server-hostname": "server-hostname.example.org" }, "result": 0, "text": "Host found." }
An example result returned when the query was malformed:
{ "result": 1, "text": "No 'ip-address' provided and 'identifier-type' is either missing or not a string." }
reservation-get-all can be used to query the host database and retrieve all reservations in a specified subnet. This command uses parameters providing the mandatory subnet-id. Global host reservations can be retrieved by using subnet-id value of zero (0).
For instance for retrieving host reservations for the subnet 1:
{
"command": "reservation-get-all",
"arguments": {
"subnet-id": 1
}
}
returns found some IPv4 hosts:
{ "arguments": { "hosts": [ { "boot-file-name": "bootfile.efi", "client-classes": [ ], "hostname": "somehost.example.org", "hw-address": "01:02:03:04:05:06", "ip-address": "192.0.2.100", "next-server": "192.0.0.2", "option-data": [ ], "server-hostname": "server-hostname.example.org" }, ... { "boot-file-name": "bootfile.efi", "client-classes": [ ], "hostname": "otherhost.example.org", "hw-address": "01:02:03:04:05:ff", "ip-address": "192.0.2.200", "next-server": "192.0.0.2", "option-data": [ ], "server-hostname": "server-hostname.example.org" } ] }, "result": 0, "text": "72 IPv4 host(s) found." }
The response returned by reservation-get-all can be very long. The DHCP server does not handle DHCP traffic when preparing a response to reservation-get-all. If there are many reservations in a subnet, this may be disruptive. Use with caution. For larger deployments, please consider using reservation-get-page instead (see Section 15.4.4.5, “reservation-get-page command”).
For a reference, see Section A.109, “reservation-get-all reference”.
reservation-get-page 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 subnet-id. Use a value of zero (0) to fetch global reservations. The second mandatory parameter is the page size limit. Optional source-index and from host id, both defaulting to 0, are uses to chain page queries.
The usage of from and source-index parameters requires additional explanation. For the first call those parameters should not be specified (or specified as zeros). For any follow up calls they should be set to the values returned in previous calls in a next map holding from and source-index values. The subsequent calls should be issued until all reservations are returned. The end is reached once the returned list is empty, count is 0, no next map is present and result status 3 (empty) is returned.
The from and source-index parameters are reflecting internal state of the search. There is no need to understand what they represent, it's simply a value that is supposed to be copied from one response to the next query. However, if you are curious, from field represents a 64 bits representation of host identifier used by a host backend. The source-index represents internal representation of multiple host backends: 0 is used to represent hosts defined in a configuration file, 1 represents the first database backend. In some uncommon cases there may be more than one database backend configured, so potentially there may be 2. In any case, Kea will iterate over all backends configured.
For instance for retrieving host reservations for the subnet 1 requesting the first page can be done by:
{
"command": "reservation-get-page",
"arguments": {
"subnet-id": 1,
"limit": 10
}
}
Since this is the first call, source-index and from should not be specified. They will default to their zero default values.
Some hosts are returned with informations to get the next page:
{ "arguments": { "count": 72, "hosts": [ { "boot-file-name": "bootfile.efi", "client-classes": [ ], "hostname": "somehost.example.org", "hw-address": "01:02:03:04:05:06", "ip-address": "192.0.2.100", "next-server": "192.0.0.2", "option-data": [ ], "server-hostname": "server-hostname.example.org" }, ... { "boot-file-name": "bootfile.efi", "client-classes": [ ], "hostname": "otherhost.example.org", "hw-address": "01:02:03:04:05:ff", "ip-address": "192.0.2.200", "next-server": "192.0.0.2", "option-data": [ ], "server-hostname": "server-hostname.example.org" } ], "next": { "from": 1234567, "source-index": 1 } }, "result": 0, "text": "72 IPv4 host(s) found." }
Note that from and source-index 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:
{
"command": "reservation-get-page",
"arguments": {
"subnet-id": 1,
"source-index": 1,
"from": 1234567,
"limit": 10
}
}
. The response will contain a list of hosts with updated source-index and from fields. Continue calling the command until you get the last page. Its response will look like this:
{ "arguments": { "count": 0, "hosts": [ ], }, "result": 3, "0 IPv4 host(s) found." }
This command is more complex than reservation-get-all, but lets users retrieve larger host reservations lists by smaller chunks. For small deployments with few reservations, is it easier to use reservation-get-all (see Section 15.4.4.4, “reservation-get-all command”.
For a reference, see Section A.110, “reservation-get-page reference”.
Currently reservation-get-page is not supported by the Cassandra host backend.
reservation-del can be used to delete a reservation from the host database. There are two types of parameters this command supports: (subnet-id, address) or (subnet-id, identifier-type, identifier). The first type of query is used when the address (either IPv4 or IPv6) is known, but the details of the reservation aren't. One common use case of this type of query is to remove a reservation (e.g. you want a specific address to no longer be reserved). The second query uses identifiers. For maximum flexibility, Kea stores the host identifying information as a pair of values: type and the actual identifier. Currently supported identifiers are "hw-address", "duid", "circuit-id", "client-id" and "flex-id", but additional types may be added in the future. If any new identifier types are defined in the future, reservation-get command will support them automatically. The subnet-id is manadatory. Use a value of zero (0) to delete a global reservation, or the id of the subnet from which the reservation should be deleted.
An example command for deleting a host reservation by (subnet-id, address) pair looks as follows:
{ "command": "reservation-del", "arguments": { "subnet-id": 1, "ip-address": "192.0.2.202" } }
An example deletion by (subnet-id, identifier-type, identifier) looks as follows:
{ "command": "reservation-del", "arguments": "subnet-id": 4, "identifier-type": "hw-address", "identifier": "01:02:03:04:05:06" } }
reservation-del returns result 0 when the host deletion was successful or 1 if it was not. A descriptive text is provided in case of error. Example results look as follows:
{ "result": 1, "text": "Host not deleted (not found)." }
{ "result": 0, "text": "Host deleted." }
{ "result": 1, "text": "Unable to delete a host because there is no hosts-database configured." }
This section describes the hook library with commands used to manage leases. Kea provides a way to store lease information in several backends (memfile, MySQL, PostgreSQL and Cassandra), and this library provides a interface that can manipulate leases in a unified, safe way. In particular, it allows things 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. It can also catch more obscure errors, like an attempt to add a lease with a subnet-id 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.
This library may only be loaded by the kea-dhcp4 or the kea-dhcp6 process.
There are many use cases 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 sysadmin knows for sure that it will not be coming back. The "get" queries may be useful for automating certain management and monitoring tasks. They can also act as preparatory steps for lease updates and removals.
This library provides the following commands:
lease4-add - adds a new IPv4 lease;
lease6-add - adds a new IPv6 lease;
lease6-bulk-apply - creates, updates and/or deletes multiple IPv6 leases in a single transaction;
lease4-get - checks whether an IPv4 lease with the specified parameters exists and returns it if it does;
lease6-get - checks whether an IPv6 lease with the specified parameters exists and returns it if it does;
lease4-get-all - returns all IPv4 leases or all IPv4 leases for the specified subnets;
lease6-get-all - returns all IPv6 leases or all IPv6 leases for the specified subnets;
lease4-get-page - returns a set ("page") 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;
lease6-get-page - returns a set ("page") 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;
lease4-del - deletes an IPv4 lease with the specified parameters;
lease6-del - deletes an IPv6 lease with the specified parameters;
lease4-update - updates an IPv4 lease;
lease6-update - updates an IPv6 lease;
lease4-wipe - removes all leases from a specific IPv4 subnet or from all subnets;
lease6-wipe - removes all leases from a specific IPv6 subnet or from all subnets;
The lease commands library is part of the open source code and is available to every Kea user.
All commands use JSON syntax and can be issued either using control channel (see Chapter 17, Management API) or Control Agent (see Chapter 7, The Kea Control Agent).
The library can be loaded in the same way as other hook libraries, and it does not take any parameters. It supports both DHCPv4 and DHCPv6 servers.
"Dhcp6": {
"hooks-libraries": [
{
"library": "/path/libdhcp_lease_cmds.so"
}
...
]
}
The lease4-add and lease6-add commands allow for the creation of a new lease. Typically Kea creates a lease when it first sees a new device; however, sometimes it may be convenient to create the lease manually. The lease4-add command requires at least two parameters: an IPv4 address and an identifier, i.e. hardware (MAC) address. A third parameter, subnet-id, is optional. If the subnet-id is not specified or the specified value is 0, Kea will try 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:
{ "command": "lease4-add", "arguments": { "ip-address": "192.0.2.202", "hw-address": "1a:1b:1c:1d:1e:1f" } }
The lease6-add command requires three parameters: an IPv6 address, an IAID value (identity association identifier, a value sent by clients), and a DUID. As with lease4-add, the subnet-id parameter is optional. If the subnet-id is not specified or the provided value is 0, Kea will try to determine the value by running a subnet-selection procedure. If specified, however, its value must match the existing subnet. For example:
{ "command": "lease6-add", "arguments": { "subnet-id": 66, "ip-address": "2001:db8::3", "duid": "1a:1b:1c:1d:1e:1f:20:21:22:23:24", "iaid": 1234 } }
lease6-add can also be used to add leases for IPv6 prefixes. In this case there are three additional parameters that must be specified: subnet-id, type (set to value of "IA_PD"), and prefix length. The actual prefix is set using ip-address field. Note that Kea cannot guess subnet-id 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:
{ "command": "lease6-add", "arguments": { "subnet-id": 66, "type": "IA_PD", "ip-address": "2001:db8:abcd::", "prefix-len": 48, "duid": "1a:1b:1c:1d:1e:1f:20:21:22:23:24", "iaid": 1234 } }
The commands can take a number of additional optional parameters:
valid-lft - specifies the lifetime of the lease, expressed in seconds. If not specified, the value configured in the subnet related to the specified subnet-id is used.
expire - creates a timestamp of the lease expiration time, expressed in unix format (seconds since 1 Jan 1970). If not specified, the default value is now + the lease lifetime (the value of valid-lft).
fqdn-fwd - specifies whether the lease should be marked as if a forward DNS update were conducted. Note this only affects the 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 false. The hostname parameter must be specified if fqdn-fwd is set to true.
fqdn-rev - specifies whether the lease should be marked as if reverse DNS update were conducted. Note this only affects the 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 false. The hostname parameter must be specified if fqdn-fwd is set to true.
hostname - specifies the hostname to be associated with this lease. Its value must be non-empty if either fqdn-fwd or fwdn-rev are set to true. If not specified, the default value is an empty string.
hw-address - optionally specifies a hardware (MAC) address for an IPv6 lease. It is a mandatory parameter for an IPv4 lease.
client-id - optionally specifies a client identifier for an IPv4 lease.
preferred-lft - optionally specifies a preferred lifetime for IPv6 leases. If not specified, the value configured for the subnet corresponding to the specified subnet-id is used. This parameter is not used when adding an IPv4 lease.
user-context - specifies the user context to be associated with this lease. It must be a JSON map.
Here is an example of a more complex lease addition:
{ "command": "lease6-add", "arguments": { "subnet-id": 66, "ip-address": "2001:db8::3", "duid": "01:02:03:04:05:06:07:08", "iaid": 1234, "hw-address": "1a:1b:1c:1d:1e:1f", "preferred-lft": 500, "valid-lft": 1000, "expire": 12345678, "fqdn-fwd": true, "fqdn-rev": true, "hostname": "urania.example.org", "user-context": { "version": 1 } } }
The command returns a status that indicates either a success (result 0) or a failure (result 1). A failed command always includes a text parameter that explains the cause of failure. For example:
{ "result": 0, "text": "Lease added." }
Example failure:
{ "result": 1, "text": "missing parameter 'ip-address' (<string>:3:19)" }
The lease6-bulk-apply was implemented to address the performance penalty in the High Availability 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. That may result in allocation of 4 leases. In addition, the DHCPv6 may assign different address than requested by the client during the renew or rebind and delete the leases previously used by this client. The are 6 of lease changes sent between the HA partners is in this case. Sending these updates in individual commands, e.g. lease6-update is highly inefficient and produces unnecessary delays in communication between the HA partners and in sending the response to the DHCPv6 client.
The lease6-bulk-apply command deals with this problem by aggregating all lease changes in a single command. Both deleted leases and new/updated leases are conveyed 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.
Even though the High Avialability is the major application for this command, it can be freely used in all cases when it is desired to send multiple lease changes in a single command.
In the following example, we ask to delete two leases and to add or update two other leases in the database:
{ "command": "lease6-bulk-apply", "arguments": { "deleted-leases": [ { "ip-address": "2001:db8:abcd::", "type": "IA_PD", }, { "ip-address": "2001:db8:abcd::234", "type": "IA_NA", } ], "leases": [ { "subnet-id": 66, "ip-address": "2001:db8:cafe::", "type": "IA_PD", ... }, { "subnet-id": 66, "ip-address": "2001:db8:abcd::333", "type": "IA_NA", ... } ] } }
If any of the leases is malformed, no leases 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 will continue to be processed for other leases. All the leases for which the command was unable to apply the changes in the database will be listed in the response.
For example:
{ "result": 0, "text": "Bulk apply of 2 IPv6 leases completed". "arguments": { "failed-deleted-leases": [ { "ip-address": "2001:db8:abcd::", "type": "IA_PD", "result": 3, "error-message": "no lease found" } ], "failed-leases": [ { "ip-address": "2001:db8:cafe::", "type": "IA_PD", "result": 1, "error-message": "unable to communicate with the lease database" } ] } }
The response above indicates that the hooks library was unable to delete the lease for prefix "2001:db8:abcd::" and add or update the lease for prefix "2001:db8:cafe::". However, there are two other lease changes which have been applied as indicated by the text message. The result is the status constant that indicates the type of the error experienced for the particular lease. The meaning 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 lease doesn't exist (empty result).
lease4-get or lease6-get can be used to query the lease database and retrieve existing leases. There are two types of parameters the lease4-get command supports: (address) or (subnet-id, identifier-type, identifier). There are also two types for lease6-get: (address,type) or (subnet-id, identifier-type, identifier, IAID, type). 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: "hw-address" (IPv4 only), "client-id" (IPv4 only), and "duid" (IPv6 only).
An example lease4-get command for getting a lease using an IPv4 address is:
{ "command": "lease4-get", "arguments": { "ip-address": "192.0.2.1" } }
An example of the lease6-get query is:
{ "command": "lease6-get", "arguments": { "ip-address": "2001:db8:1234:ab::", "type": "IA_PD" } }
An example query by "hw-address" for an IPv4 lease looks as follows:
{ "command": "lease4-get", "arguments": { "identifier-type": "hw-address", "identifier": "08:08:08:08:08:08", "subnet-id": 44 } }
An example query by "client-id" for an IPv4 lease looks as follows:
{ "command": "lease4-get", "arguments": { "identifier-type": "client-id", "identifier": "01:01:02:03:04:05:06", "subnet-id": 44 } }
An example query by (subnet-id, identifier-type, identifier, iaid, type) for an IPv6 lease is:
{ "command": "lease4-get", "arguments": { "identifier-type": "duid", "identifier": "08:08:08:08:08:08", "iaid": 1234567, "type": "IA_NA", "subnet-id": 44 } }
The type is an optional parameter. Supported values are: IA_NA (non-temporary address) and IA_PD (IPv6 prefix). If not specified, IA_NA is assumed.
leaseX-get returns a result that indicates a result of the operation and lease details, if found. It has one of the following values: 0 (success), 1 (error), or 2 (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.
An example result returned when the host was found:
{ "arguments": { "client-id": "42:42:42:42:42:42:42:42", "cltt": 12345678, "fqdn-fwd": false, "fqdn-rev": true, "hostname": "myhost.example.com.", "hw-address": "08:08:08:08:08:08", "ip-address": "192.0.2.1", "state": 0, "subnet-id": 44, "valid-lft": 3600 }, "result": 0, "text": "IPv4 lease found." }
lease4-get-all and lease6-get-all 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:
{ "command": "lease4-get-all" }
If the arguments are provided, it is expected that they contain the "subnets" parameter, which is a list of subnet identifiers for which the leases should be returned. For example, in order to retrieve all IPv6 leases belonging to the subnets with identifiers 1, 2, 3, and 4:
{ "command": "lease6-get-all", "arguments": { "subnets": [ 1, 2, 3, 4 ] } }
The returned response contains a detailed list of leases in the following format:
{ "arguments": { "leases": [ { "cltt": 12345678, "duid": "42:42:42:42:42:42:42:42", "fqdn-fwd": false, "fqdn-rev": true, "hostname": "myhost.example.com.", "hw-address": "08:08:08:08:08:08", "iaid": 1, "ip-address": "2001:db8:2::1", "preferred-lft": 500, "state": 0, "subnet-id": 44, "type": "IA_NA", "valid-lft": 3600 }, { "cltt": 12345678, "duid": "21:21:21:21:21:21:21:21", "fqdn-fwd": false, "fqdn-rev": true, "hostname": "", "iaid": 1, "ip-address": "2001:db8:0:0:2::", "preferred-lft": 500, "prefix-len": 80, "state": 0, "subnet-id": 44, "type": "IA_PD", "valid-lft": 3600 } ] }, "result": 0, "text": "2 IPv6 lease(s) found." }
The lease4-get-all and lease6-get-all commands may result in very large responses. This may have a negative impact on the DHCP server's 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.
The lease4-get-all and lease6-get-all 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 case of large lease databases it is usually better to retrieve leases in chunks, using the paging mechanism. lease4-get-page and lease6-get-page implement a paging mechanism for DHCPv4 and DHCPv6 servers respectively. The following command retrieves the first 1024 IPv4 leases:
{ "command": "lease4-get-page", "arguments": { "from": "start", "limit": 1024 } }
The keyword start denotes that the first page of leases should be retrieved. Alternatively, an IPv4 zero address can be specified to retrieve the first page:
{ "command": "lease4-get-page", "arguments": { "from": "0.0.0.0", "limit": 1024 } }
Similarly, the IPv6 zero address can be specified in the lease6-get-page command:
{ "command": "lease6-get-page", "arguments": { "from": "::", "limit": 6 } }
The response has the following structure:
{ "arguments": { "leases": [ { "ip-address": "2001:db8:2::1", ... }, { "ip-address": "2001:db8:2::9", ... }, { "ip-address": "2001:db8:3::1", ... }, { "ip-address": "2001:db8:5::3", ... } { "ip-address": "2001:db8:4::1", ... }, { "ip-address": "2001:db8:2::7", ... } ], "count": 6 }, "result": 0, "text": "6 IPv6 lease(s) found." }
Note that the leases' details were excluded from the response above for brevity.
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. In cases of highly distributed databases, such as Cassandra, ordering may be inefficient or even impossible.
The count parameter contains the number of returned leases on the page.
To fetch the next page, the client must use the last address of the current page as an input to the next lease4-get-page or lease6-get-page command call. In this example it is:
{ "command": "lease6-get-page", "arguments": { "from": "2001:db8:2::7", "count": 6 } }
because 2001:db8:2::7 is the last address on the current page.
The client may assume that it has reached the last page when the count value is lower than that specified in the command; this includes the case when the count is equal to 0, meaning that no leases were found.
leaseX-del can be used to delete a lease from the lease database. There are two types of parameters this command supports, similar to leaseX-get commands: (address) for both v4 and v6, (subnet-id, identifier-type, identifier) for v4, and (subnet-id, identifier-type, identifier, type, IAID) 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: type and the actual identifier. The currently supported identifiers are "hw-address" (IPv4 only), "client-id" (IPv4 only), and "duid" (IPv6 only).
An example command for deleting a lease by address is:
{ "command": "lease4-del", "arguments": { "ip-address": "192.0.2.202" } }
An example IPv4 lease deletion by "hw-address" is:
{ "command": "lease4-del", "arguments": { "identifier": "08:08:08:08:08:08", "identifier-type": "hw-address", "subnet-id": 44 } }
leaseX-del returns 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.
The lease4-update and lease6-update 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 leaseX-del followed by leaseX-add.
The subnet-id parameter is optional. If not specified, or if the specified value is 0, Kea will try to determine its value by running a subnet-selection procedure. If specified, however, its value must match the existing subnet.
The optional boolean parameter "force-create" specifies whether the lease should be created if it doesn't exist in the database. It defaults to false, which indicates that the lease is not created if it doesn't exist. In such a case, an error is returned as a result of trying to update a non-existing lease. If the "force-create" parameter is set to true and the updated lease does not exist, the new lease is created as a result of receiving the leaseX-update.
An example of a command to update an IPv4 lease is:
{ "command": "lease4-update", "arguments": { "ip-address": "192.0.2.1", "hostname": "newhostname.example.org", "hw-address": "1a:1b:1c:1d:1e:1f", "subnet-id": 44, "force-create": true } }
An example of a command to update an IPv6 lease is:
{ "command": "lease6-update", "arguments": { "ip-address": "2001:db8::1", "duid": "88:88:88:88:88:88:88:88", "iaid": 7654321, "hostname": "newhostname.example.org", "subnet-id": 66, "force-create": false } }
lease4-wipe and lease6-wipe 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. Note that 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.
An example of lease4-wipe is:
{ "command": "lease4-wipe", "arguments": { "subnet-id": 44 } }
An example of lease6-wipe is:
{ "command": "lease6-wipe", "arguments": { "subnet-id": 66 } }
The commands return a text description of the number of leases removed, plus the status code 0 (success) if any leases were removed or 2 (empty) if there were no leases. Status code 1 (error) may be returned if the parameters are incorrect or some other exception is encountered.
Subnet-id 0 has a special meaning; it tells Kea to delete leases from all configured subnets. Also, the subnet-id parameter may be omitted. If not specified, leases from all subnets are wiped.
Note: not all backends support this command.
This section describes a hook application that offers a number of new commands used to query and manipulate subnet and shared network configurations in Kea. This application is very useful in deployments with a large number of subnets being managed by the DHCP servers and when the subnets are frequently updated. The commands offer lightweight approach for manipulating subnets without a need to fully reconfigure the server and without affecting existing servers' configurations. An ability to manage shared networks (listing, retrieving details, adding new ones, removing existing ones, adding subnets to and removing from shared networks) is also provided.
Currently this library is only available to ISC customers with a support contract.
This library may only be loaded by kea-dhcp4 or kea-dhcp6 process.
The following commands are currently supported:
This command is used to list all currently configured subnets. The subnets are returned in a brief form, i.e. a subnet identifier and subnet prefix is included for each subnet. In order to retrieve the detailed information about the subnet the subnet4-get should be used.
This command has the simple structure:
{ "command": "subnet4-list" }
The list of subnets returned as a result of this command is returned in the following format:
{ "result": 0, "text": "2 IPv4 subnets found", "arguments": { "subnets": [ { "id": 10, "subnet": "10.0.0.0/8" }, { "id": 100, "subnet": "192.0.2.0/24" } ] }
If no IPv4 subnets are found, an error code is returned along with the error description.
This command is used to list all currently configured subnets. The subnets are returned in a brief form, i.e. a subnet identifier and subnet prefix is included for each subnet. In order to retrieve the detailed information about the subnet the subnet6-get should be used.
This command has the simple structure:
{ "command": "subnet6-list" }
The list of subnets returned as a result of this command is returned in the following format:
{ "result": 0, "text": "2 IPv6 subnets found", "arguments": { "subnets": [ { "id": 11, "subnet": "2001:db8:1::/64" }, { "id": 233, "subnet": "3000::/16" } ] }
If no IPv6 subnets are found, an error code is returned along with the error description.
This command is used to retrieve detailed information about the specified subnet. This command usually follows the subnet4-list, which is used to discover available subnets with their respective subnet identifiers and prefixes. Any of those parameters can be then used in subnet4-get to fetch subnet information:
{ "command": "subnet4-get", "arguments": { "id": 10 } }
or
{ "command": "subnet4-get", "arguments": { "subnet": "10.0.0.0/8" } }
If the subnet exists the response will be similar to this:
{ "result": 0, "text": "Info about IPv4 subnet 10.0.0.0/8 (id 10) returned", "arguments": { "subnets": [ { "subnet": "10.0.0.0/8", "id": 1, "option-data": [ .... ] ... } ] } }
This command is used to retrieve detailed information about the specified subnet. This command usually follows the subnet6-list, which is used to discover available subnets with their respective subnet identifiers and prefixes. Any of those parameters can be then used in subnet6-get to fetch subnet information:
{ "command": "subnet6-get", "arguments": { "id": 11 } }
or
{ "command": "subnet6-get", "arguments": { "subnet": "2001:db8:1::/64" } }
If the subnet exists the response will be similar to this:
{ "result": 0, "text": "Info about IPv6 subnet 2001:db8:1::/64 (id 11) returned", "arguments": { "subnets": [ { "subnet": "2001:db8:1::/64", "id": 1, "option-data": [ ... ] .... } ] } }
This command is used to create and add 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.
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 must not be specified within subnet4-add. The commands described in Section 15.4.4, “host_cmds: Host Commands” should be used to add, remove and modify static reservations.
{ "command": "subnet4-add", "arguments": { "subnet4": [ { "id": 123, "subnet": "10.20.30.0/24", ... } ] } }
The response to this command has the following structure:
{ "result": 0, "text": "IPv4 subnet added", "arguments": { "subnet4": [ { "id": 123, "subnet": "10.20.30.0/24" } ] } }
This command is used to create and add 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.
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 must not be specified within subnet6-add. The commands described in Section 15.4.4, “host_cmds: Host Commands” should be used to add, remove and modify static reservations.
{ "command": "subnet6-add", "arguments": { "subnet6": [ { "id": 234, "subnet": "2001:db8:1::/64", ... } ] } }
The response to this command has the following structure:
{ "result": 0, "text": "IPv6 subnet added", "arguments": { "subnet6": [ { "id": 234, "subnet": "2001:db8:1::/64" } ] } }
It is recommended, but not mandatory to specify subnet id. If not specified, Kea will try to assign the next subnet-id value. This automatic ID value generator is simple. It returns a previously automatically assigned value increased by 1. This works well, unless you manually create a subnet with a value bigger than previously used. For example, if you call subnet4-add five times, each without id, Kea will assign IDs: 1,2,3,4 and 5 and it will work just fine. However, if you try to call subnet4-add five times, with the first subnet having subnet-id of value 3 and remaining ones having no subnet-id, it will fail. The first command (with explicit value) will use subnet-id 3, the second command will create a subnet with id of 1, the third will use value of 2 and finally the fourth will have the subnet-id value auto-generated as 3. However, since there is already a subnet with that id, it will fail.
The general recommendation is to either: never use explicit values (so the auto-generated values will always work) or always use explicit values (so the auto-generation is never used). You can mix those two approaches only if you understand how the internal automatic subnet-id generation works.
This command is used to update a 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.
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 must not be specified within subnet4-update. The commands described in Section 15.4.4, “host_cmds: Host Commands” should be used to update, remove and modify static reservations.
{ "command": "subnet4-update", "arguments": { "subnet4": [ { "id": 123, "subnet": "10.20.30.0/24", ... } ] } }
The response to this command has the following structure:
{ "result": 0, "text": "IPv4 subnet updated", "arguments": { "subnet4": [ { "id": 123, "subnet": "10.20.30.0/24" } ] } }
This command is used to update a 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.
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 must not be specified within subnet6-update. The commands described in Section 15.4.4, “host_cmds: Host Commands” should be used to update, remove and modify static reservations.
{ "command": "subnet6-update", "arguments": { "subnet6": [ { "id": 234, "subnet": "2001:db8:1::/64", ... } ] } }
The response to this command has the following structure:
{ "result": 0, "text": "IPv6 subnet updated", "arguments": { "subnet6": [ { "id": 234, "subnet": "2001:db8:1::/64" } ] } }
This command is used to remove a subnet from the server's configuration. This command has no effect on other configured subnets but removing a subnet has certain implications which the server's administrator should be aware of.
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 subnet4-del removes neither the leases nor host reservations associated with a subnet. This is the safest approach because the server doesn't loose track of leases assigned to the 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 is used with extreme caution.
This command can also be used to completely delete an IPv4 subnet that is part of a shared network. If you want to simply remove the subnet from a shared network and keep the subnet configuration, use network4-subnet-del command instead.
The command has the fo