dhcp4-srv.xml 134 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
<!ENTITY mdash  "&#x2014;" >
]>

  <chapter id="dhcp4">
    <title>The DHCPv4 Server</title>

    <section id="dhcp4-start-stop">
      <title>Starting and Stopping the DHCPv4 Server</title>

13 14
      <!-- @todo Rewrite this section once #3422 is done -->

15
      <para>
16
      It is recommended that the Kea DHCPv4 server be started and stopped
Jeremy C. Reed's avatar
Jeremy C. Reed committed
17
      using <command>keactrl</command> (described in <xref linkend="keactrl"/>).
18 19
      However, it is also possible to run the server directly: it accepts
      the following command-line switches:
20
      </para>
21 22 23

      <itemizedlist>
          <listitem>
24 25 26 27
            <simpara>
            <command>-c <replaceable>file</replaceable></command> -
            specifies the configuration file. This is the only mandatory
            switch.</simpara>
28 29
          </listitem>
          <listitem>
30
            <simpara>
Tomek Mrugalski's avatar
Tomek Mrugalski committed
31 32
            <command>-d</command> - specifies whether the server
            logging should be switched to debug/verbose mode. In verbose mode,
33
            the logging severity and debuglevel specified in the configuration
34 35 36 37
            file are ignored and "debug" severity and the maximum debuglevel
            (99) are assumed. The flag is convenient, for temporarily
            switching the server into maximum verbosity, e.g. when
            debugging.</simpara>
38 39
          </listitem>
          <listitem>
40 41 42 43 44 45
            <simpara>
            <command>-p <replaceable>port</replaceable></command> -
            specifies UDP port the server will listen on. This is only
            useful during testing, as the DHCPv4 server listening on
            ports other than default DHCPv4 ports will not be able to
            handle regular DHCPv4 queries.</simpara>
46
          </listitem>
Tomek Mrugalski's avatar
Tomek Mrugalski committed
47 48
          <listitem>
            <simpara>
Tomek Mrugalski's avatar
Tomek Mrugalski committed
49
              <command>-v</command> - prints out Kea version and exits.
Tomek Mrugalski's avatar
Tomek Mrugalski committed
50 51 52 53 54
            </simpara>
          </listitem>
          <listitem>
            <simpara>
              <command>-V</command> - prints out Kea extended version with
Tomek Mrugalski's avatar
Tomek Mrugalski committed
55
              additional parameters and exits.
Tomek Mrugalski's avatar
Tomek Mrugalski committed
56 57
            </simpara>
          </listitem>
58 59 60 61 62 63
          <listitem>
            <simpara>
              <command>-W</command> - prints out Kea configuration report
              and exits.
            </simpara>
          </listitem>
64 65
      </itemizedlist>

66
      <para>
Francis Dupont's avatar
Francis Dupont committed
67 68
            The <command>-V</command> command returns the versions of the
            external libraries dynamically linked.
69 70
      </para>

71
      <para>
Francis Dupont's avatar
Francis Dupont committed
72 73 74 75 76 77 78 79 80 81 82 83
            The <command>-W</command> command describes the environment used
            to build Kea.  This command displays a copy of the
            <filename>config.report</filename> file produced by
            <userinput>./configure</userinput> that is embedded in the
            executable binary.
      </para>

      <para>
            The <filename>config.report</filename> may also be accessed more
            directly.  The following command may be used to extract this
            information.  The binary <userinput>path</userinput> may be found
            in the install directory or in the <filename>.libs</filename>
84 85 86
            subdirectory in the source treee. For example
            <filename>kea/src/bin/dhcp4/.libs/kea-dhcp4</filename>.

87 88 89 90 91
<screen>
strings <userinput>path</userinput>/kea-dhcp4 | sed -n 's/;;;; //p'
</screen>
      </para>

92
      <para>
93 94 95
	    When running in a console, the server can be shut down by
	    pressing ctrl-c. It detects the key combination and shuts
	    down gracefully.
96 97 98 99
      </para>

      <para>
        On start-up, the server will detect available network interfaces
100 101
        and will attempt to open UDP sockets on all interfaces
        mentioned in the configuration file.
102
      </para>
103

104
      <para>
105 106 107 108 109 110 111
        Since the DHCPv4 server opens privileged ports, it requires root
        access. Make sure you run this daemon as root.
      </para>

    </section>

    <section id="dhcp4-configuration">
112
      <title>DHCPv4 Server Configuration</title>
113 114
<section>
  <title>Introduction</title>
115
      <para>
116
        This section explains how to configure the DHCPv4 server using the
117 118
        Kea configuration backend. (Kea configuration using any other
        backends is outside of scope of this document.) Before DHCPv4
119
        is started, its configuration file has to be created. The
120
        basic configuration is as follows:
121
<screen>
122 123 124 125 126 127 128 129 130
{
# DHCPv4 configuration starts in this line
"Dhcp4": {

# First we set up global values
    "valid-lifetime": 4000,
    "renew-timer": 1000,
    "rebind-timer": 2000,

131 132 133 134 135 136
# Next we setup the interfaces to be used by the server.
    "interfaces-config": {
        "interfaces": [ "eth0" ]
    },

# And we specify the type of lease database
137
    "lease-database": {
Tomek Mrugalski's avatar
Tomek Mrugalski committed
138
        "type": "memfile",
139
        "persist": true,
Tomek Mrugalski's avatar
Tomek Mrugalski committed
140
        "name": "/var/kea/dhcp4.leases"
141 142 143 144 145 146
    },

# Finally, we list the subnets from which we will be leasing addresses.
    "subnet4": [
        {
            "subnet": "192.0.2.0/24",
147 148 149
            "pools": [
                { "pool": "192.0.2.1 - 192.0.2.200" }
            ]
150 151 152 153 154 155 156
        }
    ]

# DHCPv4 configuration ends with this line
}

} </screen>
157
</para>
158

159 160 161 162
<para>The following paragraphs provide a brief overview of the parameters in
the above example and
their format. Subsequent sections of this chapter go into much greater detail
for these and other parameters.</para>
163

164 165
<para>The lines starting with a hash (#) are comments and are ignored by
the server; they do not impact its
166 167
operation in any way.</para>

168 169 170 171 172 173
<para>The configuration starts in the first line with the initial
opening curly bracket (or brace). Each configuration consists of
one or more objects. In this specific example, we have only one
object called Dhcp4. This is a simplified configuration, as usually
there will be additional objects, like <command>Logging</command> or
<command>DhcpDns</command>, but we omit them now for clarity. The Dhcp4
174
configuration starts with the <command>"Dhcp4": {</command> line
175 176 177 178
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.</para>

179
<para>In the general case, the order in which those parameters appear does not
180
matter. There are two caveats here though. The first one is to remember that
181 182 183 184 185
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 &mdash; although
186
legal JSON &mdash; to
187
repeat the same parameter multiple times. If that happens, the last occurrence of a
188
given parameter in a given scope is used while all previous instances are
189
ignored. This is unlikely to cause any confusion as there are no real life
190 191 192
reasons to keep multiple copies of the same parameter in your configuration
file.</para>

193 194
<para>Moving onto the DHCPv4 configuration elements, the very first few elements
define some global parameters. <command>valid-lifetime</command> defines for how long the addresses (leases) given out by the
195
server are valid. If nothing changes, a client that got an address is allowed to
196 197 198
use it for 4000 seconds. (Note that integer numbers are specified as is,
without any quotes around them.) <command>renew-timer</command> and
<command>rebind-timer</command> are values that
199
define T1 and T2 timers that govern when the client will begin the renewal and
200 201 202 203
rebind procedures. Note that <command>renew-timer</command> and
<command>rebind-timer</command> are optional. If they are not specified the
client will select values for T1 and T2 timers according to the
<ulink url="http://tools.ietf.org/html/rfc2131">RFC 2131</ulink>.</para>
204

205 206 207 208 209 210 211 212 213 214 215 216 217 218
<para>The <command>interfaces-config</command> map specifies the server
configuration concerning the network interfaces, on which the server should
listen to the DHCP messages. The <command>interfaces</command> 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. Had we wanted to listen on two interfaces, the
<command>interfaces-config</command> would look like this:
<screen>
"interfaces-config": {
    "interfaces": [ "eth0", "eth1" ]
},
</screen>
</para>

219
<para>The next couple of lines define the lease database, the place where the server
220
stores its lease information. This particular example tells the server to use
221
<command>memfile</command>, which is the simplest (and fastest) database
222
backend. It uses an in-memory database and stores leases on disk in a CSV
223
file. This is a very simple configuration. Usually, lease database configuration
224 225 226 227 228 229 230 231 232 233
is more extensive and contains additional parameters.  Note that
<command>lease-database</command>
is an object and opens up a new scope, using an opening brace.
Its parameters (just one in this example -- <command>type</command>)
follow. Had there been more than one, they would be separated by commas. This
scope is closed with a closing brace. As more parameters follow, a trailing
comma is present.</para>

<para>Finally, we need to define a list of IPv4 subnets. This is the
most important DHCPv4 configuration structure as the server uses that
234 235
information to process clients' requests. It defines all subnets from
which the server is expected to receive DHCP requests. The subnets are
236 237
specified with the <command>subnet4</command> parameter.  It is a list,
so it starts and ends with square brackets.  Each subnet definition in
238 239
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
240
has to have at least two parameters: <command>subnet</command> (that
241
defines the whole subnet) and <command>pools</command> (which is a list of
242
dynamically allocated pools that are governed by the DHCP server).</para>
243 244 245 246 247 248

<para>The example contains a single subnet. Had more than one been defined,
additional elements
in the <command>subnet4</command> parameter would be specified and
separated by commas. For example, to define three subnets, the following
syntax would be used:
249
<screen>
250 251
"subnet4": [
    {
252
        "pools": [ { "pool":  "192.0.2.1 - 192.0.2.200" } ],
253 254 255
        "subnet": "192.0.2.0/24"
    },
    {
256
        "pools": [ { "pool": "192.0.3.100 - 192.0.3.200" } ],
257 258 259
        "subnet": "192.0.3.0/24"
    },
    {
Adam Osuchowski's avatar
Adam Osuchowski committed
260
        "pools": [ { "pool": "192.0.4.1 - 192.0.4.254" } ],
261 262 263
        "subnet": "192.0.4.0/24"
    }
]
264 265 266
</screen>
</para>

267 268
<para>After all parameters are specified, we have two contexts open:
global and Dhcp4, hence we need two closing curly brackets to close them.
269 270
In a real life configuration file there most likely would be additional
components defined such as Logging or DhcpDdns, so the closing brace would
271 272
be followed by a comma and another object definition.</para>
</section>
273

274
<section>
275 276 277 278 279
  <title>Lease Storage</title>
  <para>All leases issued by the server are stored in the lease database.
  Currently there are three database backends available:
  memfile (which is the default backend), MySQL and PostgreSQL.</para>
<section>
280
  <title>Memfile, Basic Storage for Leases</title>
281 282 283

  <para>The server is able to store lease data in different repositories. Larger
  deployments may elect to store leases in a database. <xref
284 285 286 287 288
  linkend="database-configuration4"/> describes this option. In typical
  smaller deployments though, the server will use a CSV file rather than a database to
  store lease information. 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.</para>
289 290

  <para>The configuration of the file backend (Memfile) is controlled through
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334
  the Dhcp4/lease-database parameters. The <command>type</command> parameter
  is mandatory and it specifies which storage for leases the server should use.
  The value of <userinput>"memfile"</userinput> indicates that the file should
  be used as the storage. The following list presents the remaining, not mandatory
  parameters, which can be used to configure the Memfile backend.

  <itemizedlist>
    <listitem>
      <simpara><command>persist</command>: controls whether the new leases and
      updates to existing leases are written to the file. It is strongly
      recommended that the value of this parameter is set to
      <userinput>true</userinput> at all times, during the server's normal
      operation. Not writing leases to disk will mean 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 <userinput>false</userinput> is mostly useful
      for performance testing purposes. The default value of the
      <command>persist</command> parameter is <userinput>true</userinput>,
      which enables writing lease updates
      to the lease file.
      </simpara>
    </listitem>

    <listitem>
      <simpara><command>name</command>: specifies an absolute location of the lease
      file in which new leases and lease updates will be recorded. The default value
      for this parameter is <userinput>"[kea-install-dir]/var/kea/kea-leases4.csv"
      </userinput>.</simpara>
    </listitem>

    <listitem>
      <simpara><command>lfc-interval</command>: specifies the interval in seconds, at
      which the server (Memfile backend) will perform a lease file cleanup (LFC),
      which removes the redundant (historical) information from the lease file
      and effectively reduces the lease file size. The cleanup process is described
      in more detailed fashion further in this section. The default value of the
      <command>lfc-interval</command> is <userinput>0</userinput>, which disables
      the LFC.</simpara>
    </listitem>

  </itemizedlist>
  </para>

  <para>The example configuration of the Memfile backend is presented below:
Jeremy C. Reed's avatar
Jeremy C. Reed committed
335

336
<screen>
337 338 339
"Dhcp4": {
    "lease-database": {
        <userinput>"type": "memfile"</userinput>,
340
        <userinput>"persist": true</userinput>,
341 342
        <userinput>"name": "/tmp/kea-leases4.csv",</userinput>
        <userinput>"lfc-interval": 1800</userinput>
343 344
    }
}
345
</screen>
346 347

    This configuration selects the <filename>/tmp/kea-leases4.csv</filename> as
348
    the storage for lease information and enables persistence (writing lease updates
349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395
    to this file). It also configures the backend perform the periodic cleanup
    of the lease files, executed every 30 minutes.
  </para>

  <para>It is important to know how the lease file contents are organized
  to understand why the periodic lease file cleanup is needed. Every time when
  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 supersede the existing client's lease, as it would require
  the lookup of the specific lease entry, but simply appends the new lease
  information at the end of the lease 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. This means 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 bloated lease file and impairs the performance of
  the server's startup and reconfiguration, as it needs to process larger number
  of lease entries.
  </para>

  <para>The lease file cleanup 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 renewals are, the lesser
  value of the <command>lfc-interval</command> should be. Note however, that the
  LFC takes time and thus it is possible (although unlikely) that new cleanup
  is started while the previous cleanup instance is still running, if the
  <command>lfc-interval</command> is too short. The server would recover from
  this by skipping the new cleanup when it detects that the previous cleanup
  is still in progress. But, this implies that the actual cleanups will be
  triggered more rarely than configured. Moreover, triggering a new cleanup
  adds an 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 <command>lfc-interval</command> value
  is selected in a way that would allow for completing the cleanup before the
  new cleanup is triggered.
  </para>

  <para>The LFC is performed by a separate process (in background) to avoid
  performance impact on the server process. In order to avoid the conflicts
  between the two processes both using the same lease files, the LFC process
  operates on the copy of the original lease file, rather than on the lease
  file used by the server to record lease updates. There are also other files
  being created as a side effect of the lease file cleanup. The detailed
  description of the LFC is located on the Kea wiki:
  <ulink url="http://kea.isc.org/wiki/LFCDesign"/>.
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410
  </para>

</section>

<section id="database-configuration4">
  <title>Database Configuration</title>

  <note>
    <para>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.</para>
  </note>

  <para>Database configuration is controlled through the Dhcp4/lease-database
411 412
  parameters. The type of the database must be set to "mysql" or "postgresql",
  e.g.
413
<screen>
414
"Dhcp4": { "lease-database": { <userinput>"type": "mysql"</userinput>, ... }, ... }
415
</screen>
416
  Next, the name of the database to hold the leases must be set: this is the
417 418
  name used when the lease database was created (see <xref linkend="mysql-database-create"/>
  or <xref linkend="pgsql-database-create"/>).
419
<screen>
420
"Dhcp4": { "lease-database": { <userinput>"name": "<replaceable>database-name</replaceable>" </userinput>, ... }, ... }
421
</screen>
422
  If the database is located on a different system to the DHCPv4 server, the
423
  database host name must also be specified (although it should be noted that this
424
  configuration may have a severe impact on server performance):
425
<screen>
426
"Dhcp4": { "lease-database": { <userinput>"host": <replaceable>remote-host-name</replaceable></userinput>, ... }, ... }
427
</screen>
428 429
  The usual state of affairs will be to have the database on the same machine as
  the DHCPv4 server.  In this case, set the value to the empty string:
430
<screen>
431
"Dhcp4": { "lease-database": { <userinput>"host" : ""</userinput>, ... }, ... }
432
</screen>
433 434 435
  </para>
  <para>Finally, the credentials of the account under which the server will
  access the database should be set:
436
<screen>
437
"Dhcp4": { "lease-database": { <userinput>"user": "<replaceable>user-name</replaceable>"</userinput>,
438
                               <userinput>"password": "<replaceable>password</replaceable>"</userinput>,
439 440
                              ... },
           ... }
441
</screen>
442 443 444
  If there is no password to the account, set the password to the empty string
  "". (This is also the default.)</para>
</section>
445
</section>
446

447 448
<section id="dhcp4-interface-configuration">
  <title>Interface configuration</title>
449
  <para>The DHCPv4 server has to be configured to listen on specific network
450 451 452
  interfaces.  The simplest network interface configuration tells the server to
  listen on all available interfaces:
  <screen>
453 454 455 456 457 458 459
"Dhcp4": {
    "interfaces-config": {
        "interfaces": [ <userinput>"*"</userinput> ]
    }
    ...
},
  </screen>
460 461
  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:
462
  <screen>
463 464 465 466 467 468 469
"Dhcp4": {
    "interfaces-config": {
        "interfaces": [ <userinput>"eth1", "eth3"</userinput> ]
    },
    ...
}
  </screen>
470 471 472 473
  </para>
  <para>It is possible to use wildcard interface name (asterisk) concurrently
  with explicit interface names:
  <screen>
474 475 476 477 478 479 480
"Dhcp4": {
    "interfaces-config": {
        "interfaces": [ <userinput>"eth1", "eth3", "*"</userinput> ]
    },
    ...
}
  </screen>
481
It is anticipated that this form of usage will only be used when it is desired to
482
temporarily override a list of interface names and listen on all interfaces.
483
  </para>
484
  <para>Some deployments of the DHCP servers require that the servers listen
485 486 487
  on the 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:
488 489 490 491 492 493 494 495
  <screen>
"Dhcp4": {
    "interfaces-config": {
        "interfaces": [ <userinput>"eth1/10.0.0.1", "eth3/192.0.2.3"</userinput> ]
    },
    ...
}
  </screen>
496
  </para>
497

498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513
  <para>If it is desired that the server listens on multiple IPv4 addresses assigned
  to the same interface, multiple addresses can be specified for this interface
  as in the example below:
  <screen>
"Dhcp4": {
    "interfaces-config": {
        "interfaces": [ <userinput>"eth1/10.0.0.1", "eth1/10.0.0.2"</userinput> ]
    },
    ...
}
  </screen>
  </para>

  <para>Alternatively, if the server should listen on all addresses for the particular
  interface, an interface name without any address should be specified.</para>

514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535
  <para>Kea supports responding to directly connected clients which don't have
  an address configured on the interface yet. This requires that the server
  injects the hardware address of the destination into the data link layer
  of the packet being sent to the client. The DHCPv4 server utilizes the
  raw sockets to achieve this, and builds the entire IP/UDP stack for the
  outgoing packets. The down side 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 and 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 the deployments where the server doesn't
  have to provision the directly connected clients and only receives the
  unicast packets from the relay agents, it is desired to configure the
  DHCP server to utilize the IP/UDP datagram sockets, instead of raw sockets.
  The following configuration demonstrates how this can be achieved:

  <screen>
"Dhcp4": {
    "interfaces-config": {
        "interfaces": [ <userinput>"eth1", "eth3"</userinput> ],
536
        "dhcp-socket-type": "udp"
537 538 539 540
    },
    ...
}
  </screen>
541
  The <command>dhcp-socket-type</command> specifies that the IP/UDP sockets will
542
  be opened on all interfaces on which the server listens, i.e. "eth1" and
543
  "eth3" in our case. If the <command>dhcp-socket-type</command> is set to
544
  <userinput>raw</userinput>, it configures the server to use raw sockets
545
  instead. If the <command>dhcp-socket-type</command> value is not specified, the
546 547 548
  default value <userinput>raw</userinput> is used.
  </para>

549 550 551 552 553 554 555 556 557 558 559 560 561 562
  <para>Using UDP sockets automatically disables the reception of brodcast
  packets from directly connected clients. This effectively means that the
  UDP sockets can be used for relayed traffic only. When using the raw sockets,
  both the traffic from the directly connected clients and the relayed traffic
  will be 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 brodcast address
  all sockets on this link will receive this message and multiple responses
  will be sent to the client. Hence, 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.
  </para>

563 564 565 566 567 568
  <note>
    <para>Specifying the value <userinput>raw</userinput> 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 the particular OS, the server will issue a warning and
569
    fall back to use the IP/UDP sockets.</para>
570
  </note>
571 572 573 574 575
</section>

<section id="ipv4-subnet-id">
  <title>IPv4 Subnet Identifier</title>
  <para>
576
    The subnet identifier is a unique number associated with a particular subnet.
577
    In principle, it is used to associate clients' leases with their respective subnets.
578
    When a subnet identifier is not specified for a subnet being configured, it will
579 580 581 582 583 584 585
    be automatically assigned by the configuration mechanism. The identifiers
    are assigned from 1 and are monotonically increased for each subsequent
    subnet: 1, 2, 3 ....
  </para>
  <para>
    If there are multiple subnets configured with auto-generated identifiers and
    one of them is removed, the subnet identifiers may be renumbered. For example:
586 587
    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
588 589
    stored in the lease database for subnet 3 are now associated with
    subnet 4, something that may have unexpected consequences. It is planned
590
    to implement a mechanism to preserve auto-generated subnet ids in a
591 592 593
    future version of Kea.  However, the only remedy for this issue
    at present is to
    manually specify a unique identifier for each subnet.
594
  </para>
595
      <para>
596
	The following configuration will assign the specified subnet
597 598
	identifier to the newly configured subnet:

599
        <screen>
600 601
"Dhcp4": {
    "subnet4": [
602 603 604 605 606
        {
            "subnet": "192.0.2.0/24",
            <userinput>"id": 1024</userinput>,
            ...
        }
607 608 609
    ]
}
</screen>
610 611
    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
612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630
    identifier.
  </para>
    <!-- @todo: describe whether database needs to be updated after changing
      id -->
</section>

<section id="dhcp4-address-config">
  <title>Configuration of IPv4 Address Pools</title>
  <para>
    The essential role of DHCPv4 server is address assignment. The server has to
    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
    has decided 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:
    <screen>
"Dhcp4": {
    <userinput>"subnet4": [
631 632 633 634 635 636 637 638
        {
            "subnet": "192.0.2.0/24",
            "pools": [
                { "pool": "192.0.2.10 - 192.0.2.20" }
            ],
            ...
        }
    ]</userinput>
639 640
}</screen>

641 642
    Note that subnet is defined as a simple string, but the <command>pools</command> parameter is
    actually a list of pools: for this reason, the pools definition is enclosed
643
    in square brackets, even though only one range of addresses is
644
    specified in this example.</para>
645

646
    <para>Each pool is a structure that contains the parameters
647
    that describe a single pool. Currently there is only one parameter,
648 649 650 651
    <command>pool</command>, which gives the range of addresses
    in the pool. Additional parameters will be added in future
    releases of Kea.</para>

652 653 654 655 656 657 658 659 660
    <para>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:
<screen>
"Dhcp4": {
    "subnet4": [
661 662 663 664 665 666 667 668
        {
            "subnet": "192.0.2.0/24",
            <userinput>"pools": [
                { "pool": "192.0.2.10-192.0.2.20" },
                { "pool": "192.0.2.64/26" }
            ]</userinput>,
            ...
        }
669 670 671 672 673
    ],
    ...
}
</screen>
    The number of pools is not limited, but for performance reasons it is recommended to
674
    use as few as possible. White space in pool definitions is ignored, so
675
    spaces before and after the hyphen are optional. They can be used to improve readability.
676 677 678 679
  </para>
  <para>
    The server may be configured to serve more than one subnet:
<screen>
680 681 682 683
"Dhcp4": {
    "subnet4": [
        {
            "subnet": "192.0.2.0/24",
684
            "pools": [ { "pool": "192.0.2.1 - 192.0.2.200" } ],
685 686 687 688
            ...
        },
        {
            "subnet": "192.0.3.0/24",
689
            "pools": [ { "pool": "192.0.3.100 - 192.0.3.200" } ],
690 691 692 693
            ...
        },
        {
            "subnet": "192.0.4.0/24",
694
            "pools": [ { "pool": "192.0.4.1 - 192.0.4.254" } ],
695 696 697 698
            ...
        }
    ]
}
699 700 701 702
</screen>
  </para>
  <para>
    When configuring a DHCPv4 server using prefix/length notation, please pay
703 704
    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 network
705 706 707 708 709 710
    address) and the last (typically broadcast address) address from that pool.
    In the aforementioned example of pool 192.0.3.0/24, both 192.0.3.0 and
    192.0.3.255 addresses may be assigned as well. This may be invalid in some
    network configurations. If you want to avoid this, please use the "min-max" notation.
  </para>
</section>
711 712 713 714

    <section id="dhcp4-std-options">
      <title>Standard DHCPv4 options</title>
      <para>
715
        One of the major features of the DHCPv4 server is to provide configuration
716
        options to clients.  Although there are several options that require
717
        special behavior, most options are sent by the server only if the client
718
        explicitly requests them.  The following example shows how to
719
        configure the addresses of DNS servers, which is one of the most frequently used
720 721 722 723
        options. Options specified in this way are considered global and apply
        to all configured subnets.

        <screen>
724 725 726 727 728 729
"Dhcp4": {
    "option-data": [
        {
           <userinput>"name": "domain-name-servers",
           "code": 6,
           "space": "dhcp4",
730
           "csv-format": true,
731 732 733 734 735
           "data": "192.0.2.1, 192.0.2.2"</userinput>
        },
        ...
    ]
}
736 737 738
</screen>
      </para>
    <para>
739
      The <command>name</command> parameter specifies the
740 741
      option name. For a complete list of currently supported names,
      see <xref linkend="dhcp4-std-options-list"/> below.
742
      The <command>code</command> parameter specifies the option code, which must match one of the
743
      values from that list. The next line specifies the option space, which must always
744 745
      be set to "dhcp4" as these are standard DHCPv4 options. For
      other option spaces, including custom option spaces, see <xref
746
      linkend="dhcp4-option-spaces"/>. The next line specifies the format in
747 748
      which the data will be entered: use of CSV (comma
      separated values) is recommended. The sixth line gives the actual value to
749
      be sent to clients. Data is specified as normal text, with
750 751 752 753 754
      values separated by commas if more than one value is
      allowed.
    </para>

    <para>
755 756 757
      Options can also be configured as hexadecimal values. If
      <command>csv-format</command> is
      set to false, option data must be specified as a hexadecimal string. The
758 759
      following commands configure the domain-name-servers option for all
      subnets with the following addresses: 192.0.3.1 and 192.0.3.2.
760
      Note that <command>csv-format</command> is set to false.
761
      <screen>
762 763 764 765 766 767
"Dhcp4": {
    "option-data": [
        {
            <userinput>"name": "domain-name-servers",
            "code": 6,
            "space": "dhcp4",
768
            "csv-format": false,
769 770 771 772 773 774
            "data": "C0 00 03 01 C0 00 03 02"</userinput>
        },
        ...
    ],
    ...
}</screen>
775 776
      </para>

777 778 779 780 781 782
      <para>
        Most of the parameters in the "option-data" structure are optional and
        can be omitted in some circumstances as discussed in the
        <xref linkend="dhcp4-option-data-defaults"/>.
      </para>

783
      <para>
784
        It is possible to specify or override options on a per-subnet basis.  If
785 786 787 788 789 790 791 792 793 794 795 796
        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
        (Dhcp4/option-data), rather you should set only subnet-specific values
        (Dhcp4/subnet[X]/option-data[Y]).
      </para>
      <para>
        The following commands override the global
        DNS servers option for a particular subnet, setting a single DNS
        server with address 192.0.2.3.
797 798 799 800 801 802 803 804
<screen>
"Dhcp4": {
    "subnet4": [
        {
            <userinput>"option-data": [
                {
                    "name": "domain-name-servers",
                    "code": 6,
Jeremy C. Reed's avatar
Jeremy C. Reed committed
805
                    "space": "dhcp4",
806
                    "csv-format": true,
807 808 809 810 811 812 813 814 815 816 817
                    "data": "192.0.2.3"
                },
                ...
            ]</userinput>,
            ...
        },
        ...
    ],
    ...
}
</screen>
818 819 820 821 822 823 824 825 826 827 828 829 830 831 832
      </para>

      <para>
        The currently supported standard DHCPv4 options are
        listed in <xref linkend="dhcp4-std-options-list"/>
        and <xref linkend="dhcp4-std-options-list-part2"/>.
        The "Name" and "Code"
        are the values that should be used as a name in the option-data
        structures. "Type" designates the format of the data: the meanings of
        the various types is given in <xref linkend="dhcp-types"/>.
      </para>
      <para>
        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, so allowing
833
        clients to obtain the addresses of multiple NTP servers.
834 835 836 837 838 839 840 841 842 843 844 845 846
      </para>
      <!-- @todo: describe record types -->

      <para>
        The <xref linkend="dhcp4-custom-options"/> describes the configuration
        syntax to create custom option definitions (formats). It is generally not
        allowed to create custom definitions for standard options, even if the
        definition being created matches the actual option format defined in the
        RFCs. There is an exception from this rule for standard options for which
        Kea does not provide a definition yet. In order to use such options,
        a server administrator must create a definition as described in
        <xref linkend="dhcp4-custom-options"/> in the 'dhcp4' option space. This
        definition should match the option format described in the relevant
847 848
        RFC but the configuration mechanism will allow any option format as it has
        no means to validate the format at the moment.
849 850 851 852 853 854 855
      </para>

      <para>
        <table frame="all" id="dhcp4-std-options-list">
          <title>List of standard DHCPv4 options</title>
          <tgroup cols='4'>
          <colspec colname='name'/>
856 857 858
          <colspec colname='code' align='center'/>
          <colspec colname='type' align='center'/>
          <colspec colname='array' align='center'/>
859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904
          <thead>
            <row>
              <entry>Name</entry>
              <entry>Code</entry>
              <entry>Type</entry>
              <entry>Array?</entry>
            </row>
          </thead>
          <tbody>
<row><entry>subnet-mask</entry><entry>1</entry><entry>ipv4-address</entry><entry>false</entry></row>
<row><entry>time-offset</entry><entry>2</entry><entry>int32</entry><entry>false</entry></row>
<row><entry>routers</entry><entry>3</entry><entry>ipv4-address</entry><entry>true</entry></row>
<row><entry>time-servers</entry><entry>4</entry><entry>ipv4-address</entry><entry>true</entry></row>
<row><entry>name-servers</entry><entry>5</entry><entry>ipv4-address</entry><entry>false</entry></row>
<row><entry>domain-name-servers</entry><entry>6</entry><entry>ipv4-address</entry><entry>true</entry></row>
<row><entry>log-servers</entry><entry>7</entry><entry>ipv4-address</entry><entry>true</entry></row>
<row><entry>cookie-servers</entry><entry>8</entry><entry>ipv4-address</entry><entry>true</entry></row>
<row><entry>lpr-servers</entry><entry>9</entry><entry>ipv4-address</entry><entry>true</entry></row>
<row><entry>impress-servers</entry><entry>10</entry><entry>ipv4-address</entry><entry>true</entry></row>
<row><entry>resource-location-servers</entry><entry>11</entry><entry>ipv4-address</entry><entry>true</entry></row>
<row><entry>host-name</entry><entry>12</entry><entry>string</entry><entry>false</entry></row>
<row><entry>boot-size</entry><entry>13</entry><entry>uint16</entry><entry>false</entry></row>
<row><entry>merit-dump</entry><entry>14</entry><entry>string</entry><entry>false</entry></row>
<row><entry>domain-name</entry><entry>15</entry><entry>fqdn</entry><entry>false</entry></row>
<row><entry>swap-server</entry><entry>16</entry><entry>ipv4-address</entry><entry>false</entry></row>
<row><entry>root-path</entry><entry>17</entry><entry>string</entry><entry>false</entry></row>
<row><entry>extensions-path</entry><entry>18</entry><entry>string</entry><entry>false</entry></row>
<row><entry>ip-forwarding</entry><entry>19</entry><entry>boolean</entry><entry>false</entry></row>
<row><entry>non-local-source-routing</entry><entry>20</entry><entry>boolean</entry><entry>false</entry></row>
<row><entry>policy-filter</entry><entry>21</entry><entry>ipv4-address</entry><entry>true</entry></row>
<row><entry>max-dgram-reassembly</entry><entry>22</entry><entry>uint16</entry><entry>false</entry></row>
<row><entry>default-ip-ttl</entry><entry>23</entry><entry>uint8</entry><entry>false</entry></row>
<row><entry>path-mtu-aging-timeout</entry><entry>24</entry><entry>uint32</entry><entry>false</entry></row>
<row><entry>path-mtu-plateau-table</entry><entry>25</entry><entry>uint16</entry><entry>true</entry></row>
<row><entry>interface-mtu</entry><entry>26</entry><entry>uint16</entry><entry>false</entry></row>
<row><entry>all-subnets-local</entry><entry>27</entry><entry>boolean</entry><entry>false</entry></row>
<row><entry>broadcast-address</entry><entry>28</entry><entry>ipv4-address</entry><entry>false</entry></row>
<row><entry>perform-mask-discovery</entry><entry>29</entry><entry>boolean</entry><entry>false</entry></row>
<row><entry>mask-supplier</entry><entry>30</entry><entry>boolean</entry><entry>false</entry></row>
<row><entry>router-discovery</entry><entry>31</entry><entry>boolean</entry><entry>false</entry></row>
<row><entry>router-solicitation-address</entry><entry>32</entry><entry>ipv4-address</entry><entry>false</entry></row>
<row><entry>static-routes</entry><entry>33</entry><entry>ipv4-address</entry><entry>true</entry></row>
<row><entry>trailer-encapsulation</entry><entry>34</entry><entry>boolean</entry><entry>false</entry></row>
<row><entry>arp-cache-timeout</entry><entry>35</entry><entry>uint32</entry><entry>false</entry></row>
<row><entry>ieee802-3-encapsulation</entry><entry>36</entry><entry>boolean</entry><entry>false</entry></row>
<row><entry>default-tcp-ttl</entry><entry>37</entry><entry>uint8</entry><entry>false</entry></row>
905
<row><entry>tcp-keepalive-interval</entry><entry>38</entry><entry>uint32</entry><entry>false</entry></row>
906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998
<row><entry>tcp-keepalive-garbage</entry><entry>39</entry><entry>boolean</entry><entry>false</entry></row>

          </tbody>
          </tgroup>
        </table>
      </para>

      <para>
        <table frame="all" id="dhcp4-std-options-list-part2">
          <title>List of standard DHCPv4 options (continued)</title>
          <tgroup cols='4'>
          <colspec colname='name'/>
          <colspec colname='code'/>
          <colspec colname='type'/>
          <colspec colname='array'/>
          <thead>
            <row>
              <entry>Name</entry>
              <entry>Code</entry>
              <entry>Type</entry>
              <entry>Array?</entry>
            </row>
          </thead>
          <tbody>

<row><entry>nis-domain</entry><entry>40</entry><entry>string</entry><entry>false</entry></row>
<row><entry>nis-servers</entry><entry>41</entry><entry>ipv4-address</entry><entry>true</entry></row>
<row><entry>ntp-servers</entry><entry>42</entry><entry>ipv4-address</entry><entry>true</entry></row>
<row><entry>vendor-encapsulated-options</entry><entry>43</entry><entry>empty</entry><entry>false</entry></row>
<row><entry>netbios-name-servers</entry><entry>44</entry><entry>ipv4-address</entry><entry>true</entry></row>
<row><entry>netbios-dd-server</entry><entry>45</entry><entry>ipv4-address</entry><entry>true</entry></row>
<row><entry>netbios-node-type</entry><entry>46</entry><entry>uint8</entry><entry>false</entry></row>
<row><entry>netbios-scope</entry><entry>47</entry><entry>string</entry><entry>false</entry></row>
<row><entry>font-servers</entry><entry>48</entry><entry>ipv4-address</entry><entry>true</entry></row>
<row><entry>x-display-manager</entry><entry>49</entry><entry>ipv4-address</entry><entry>true</entry></row>
<row><entry>dhcp-requested-address</entry><entry>50</entry><entry>ipv4-address</entry><entry>false</entry></row>
<!-- Lease time should not be configured by a user.
<row><entry>dhcp-lease-time</entry><entry>51</entry><entry>uint32</entry><entry>false</entry></row>
-->
<row><entry>dhcp-option-overload</entry><entry>52</entry><entry>uint8</entry><entry>false</entry></row>
<!-- Message Type, Server Identifier and Parameter Request List should not be configured by a user.
<row><entry>dhcp-message-type</entry><entry>53</entry><entry>uint8</entry><entry>false</entry></row>
<row><entry>dhcp-server-identifier</entry><entry>54</entry><entry>ipv4-address</entry><entry>false</entry></row>
<row><entry>dhcp-parameter-request-list</entry><entry>55</entry><entry>uint8</entry><entry>true</entry></row>
-->
<row><entry>dhcp-message</entry><entry>56</entry><entry>string</entry><entry>false</entry></row>
<row><entry>dhcp-max-message-size</entry><entry>57</entry><entry>uint16</entry><entry>false</entry></row>
<!-- Renewal and rebinding time should not be configured by a user.
<row><entry>dhcp-renewal-time</entry><entry>58</entry><entry>uint32</entry><entry>false</entry></row>
<row><entry>dhcp-rebinding-time</entry><entry>59</entry><entry>uint32</entry><entry>false</entry></row>
-->
<row><entry>vendor-class-identifier</entry><entry>60</entry><entry>binary</entry><entry>false</entry></row>
<!-- Client identifier should not be configured by a user.
<row><entry>dhcp-client-identifier</entry><entry>61</entry><entry>binary</entry><entry>false</entry></row>
-->
<row><entry>nwip-domain-name</entry><entry>62</entry><entry>string</entry><entry>false</entry></row>
<row><entry>nwip-suboptions</entry><entry>63</entry><entry>binary</entry><entry>false</entry></row>
<row><entry>tftp-server-name</entry><entry>66</entry><entry>string</entry><entry>false</entry></row>
<row><entry>boot-file-name</entry><entry>67</entry><entry>string</entry><entry>false</entry></row>
<row><entry>user-class</entry><entry>77</entry><entry>binary</entry><entry>false</entry></row>
<row><entry>fqdn</entry><entry>81</entry><entry>record</entry><entry>false</entry></row>
<row><entry>dhcp-agent-options</entry><entry>82</entry><entry>empty</entry><entry>false</entry></row>
<row><entry>authenticate</entry><entry>90</entry><entry>binary</entry><entry>false</entry></row>
<row><entry>client-last-transaction-time</entry><entry>91</entry><entry>uint32</entry><entry>false</entry></row>
<row><entry>associated-ip</entry><entry>92</entry><entry>ipv4-address</entry><entry>true</entry></row>
<row><entry>subnet-selection</entry><entry>118</entry><entry>ipv4-address</entry><entry>false</entry></row>
<row><entry>domain-search</entry><entry>119</entry><entry>binary</entry><entry>false</entry></row>
<row><entry>vivco-suboptions</entry><entry>124</entry><entry>binary</entry><entry>false</entry></row>
<row><entry>vivso-suboptions</entry><entry>125</entry><entry>binary</entry><entry>false</entry></row>
          </tbody>
          </tgroup>
        </table>

      </para>
      <para>
        <table frame="all" id="dhcp-types">
          <title>List of standard DHCP option types</title>
          <tgroup cols='2'>
          <colspec colname='name'/>
          <colspec colname='meaning'/>
          <thead>
            <row><entry>Name</entry><entry>Meaning</entry></row>
          </thead>
          <tbody>
            <row><entry>binary</entry><entry>An arbitrary string of bytes, specified as a set of hexadecimal digits.</entry></row>
            <row><entry>boolean</entry><entry>Boolean value with allowed values true or false</entry></row>
            <row><entry>empty</entry><entry>No value, data is carried in suboptions</entry></row>
            <row><entry>fqdn</entry><entry>Fully qualified domain name (e.g. www.example.com)</entry></row>
            <row><entry>ipv4-address</entry><entry>IPv4 address in the usual dotted-decimal notation (e.g. 192.0.2.1)</entry></row>
            <row><entry>ipv6-address</entry><entry>IPv6 address in the usual colon notation (e.g. 2001:db8::1)</entry></row>
            <row><entry>record</entry><entry>Structured data that may comprise any types (except "record" and "empty")</entry></row>
            <row><entry>string</entry><entry>Any text</entry></row>
            <row><entry>uint8</entry><entry>8 bit unsigned integer with allowed values 0 to 255</entry></row>
999
            <row><entry>uint16</entry><entry>16 bit unsigned integer with allowed values 0 to 65535</entry></row>
1000 1001 1002 1003 1004 1005 1006 1007 1008
            <row><entry>uint32</entry><entry>32 bit unsigned integer with allowed values 0 to 4294967295</entry></row>
          </tbody>
          </tgroup>
       </table>
      </para>
    </section>

    <section id="dhcp4-custom-options">
      <title>Custom DHCPv4 options</title>
1009 1010 1011 1012
      <para>Kea supports custom (non-standard) DHCPv4 options. Assume
      that we want to define a new DHCPv4 option called "foo" which
      will have code 222 and will convey a single unsigned 32 bit
      integer value. We can define such an option by using the
1013
      following entry in the configuration file:
1014 1015 1016 1017 1018 1019 1020
<screen>
"Dhcp4": {
    "option-def": [
        {
            <userinput>"name": "foo",
            "code": 222,
            "type": "uint32",
1021
            "array": false,
1022 1023 1024 1025 1026 1027 1028 1029
            "record-types": "",
            "space": "dhcp4",
            "encapsulate": ""</userinput>
        }, ...
    ],
    ...
}
</screen>
1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041
      The <command>false</command> value of the <command>array</command>
      parameter determines that the option does NOT comprise an array of
      "uint32" values but rather a single value.  Two other parameters have been
      left blank: <command>record-types</command> and
      <command>encapsulate</command>.  The former specifies the comma separated
      list of option data fields if the option comprises a record of data
      fields. This should be non-empty if the <command>type</command> 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 set of comments define the
      format of the new option and do not set its values.
1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054
      </para>
      <note>
        <para>
          In the current release the default values are not propagated to the
          parser when the new configuration is being set. Therefore, all
          parameters must be specified at all times, even if their values are
          left blank.
        </para>
      </note>

      <para>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.
1055 1056 1057 1058
<screen>
"Dhcp4": {
    "option-data": [
        {
1059
            <userinput>"name": "foo",
1060 1061
            "code": 222,
            "space": "dhcp4",
1062
            "csv-format": true,
1063 1064 1065 1066 1067 1068
            "data": "12345"</userinput>
        }, ...
    ],
    ...
}
</screen>
1069 1070 1071 1072 1073
      </para>

      <para>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.
1074
      Assume we want to define a new option that will consist of
1075
      an IPv4 address, followed by an unsigned 16 bit integer, followed by
1076 1077 1078
      a boolean value, followed by a text string. Such an option could
      be defined in the following way:
<screen>
1079 1080 1081 1082 1083 1084 1085
"Dhcp4": {
    "option-def": [
        {
            <userinput>"name": "bar",
            "code": 223,
            "space": "dhcp4",
            "type": "record",
1086
            "array": false,
1087 1088 1089 1090 1091 1092
            "record-types": "ipv4-address, uint16, boolean, string",
            "encapsulate": ""</userinput>
        }, ...
    ],
    ...
}
1093
</screen>
1094
      The <command>type</command> is set to "record" to indicate that the option contains
1095
      multiple values of different types.  These types are given as a comma-separated
1096
      list in the <command>record-types</command> field and should be those listed in <xref linkend="dhcp-types"/>.
1097 1098 1099 1100
      </para>
      <para>
      The values of the option are set as follows:
<screen>
1101 1102 1103 1104 1105 1106
"Dhcp4": {
    "option-data": [
        {
            <userinput>"name": "bar",
            "space": "dhcp4",
            "code": 223,
1107
            "csv-format": true,
1108 1109 1110 1111 1112
            "data": "192.0.2.100, 123, true, Hello World"</userinput>
        }
    ],
    ...
}</screen>
1113
      <command>csv-format</command> is set to <command>true</command> to indicate
1114 1115 1116 1117
      that the <command>data</command> field comprises a command-separated list
      of values.  The values in the <command>data</command> must correspond to
      the types set in the <command>record-types</command> field of the option
      definition.
1118 1119
     </para>
     <note>
1120
       <para>In the general case, boolean values are specified as <command>true</command> or
1121 1122 1123 1124 1125
       <command>false</command>, without quotes. Some specific boolean parameters may
       accept also <command>"true"</command>, <command>"false"</command>,
       <command>0</command>, <command>1</command>, <command>"0"</command> and
       <command>"1"</command>. Future Kea versions will accept all those values
       for all boolean parameters.</para>
1126 1127 1128 1129
     </note>
    </section>

    <section id="dhcp4-vendor-opts">
1130
      <title>DHCPv4 Vendor Specific Options</title>
1131
      <para>
1132 1133 1134
      Currently there are three option spaces defined: "dhcp4" (used by the DHCPv4 daemon)
      and "dhcp6" (for the DHCPv6 daemon); there is also "vendor-encapsulated-options-space",
      which is empty by default, but options
1135 1136 1137 1138 1139 1140 1141 1142 1143
      can be defined in it. Those options are called vendor-specific
      information options. The following examples show how to define
      an option "foo" with code 1 that consists of an IPv4 address, an
      unsigned 16 bit integer and a string. The "foo" option is conveyed
      in a vendor specific information option.
      </para>
      <para>
      The first step is to define the format of the option:
<screen>
1144 1145 1146 1147 1148 1149 1150
"Dhcp4": {
    "option-def": [
        {
            <userinput>"name": "foo",
            "code": 1,
            "space": "vendor-encapsulated-options-space",
            "type": "record",
1151
            "array": false,
1152 1153 1154 1155 1156 1157
            "record-types": "ipv4-address, uint16, string",
            "encapsulates": ""</userinput>
        }
    ],
    ...
}</screen>
1158 1159 1160
     (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:
1161 1162 1163 1164
<screen>
"Dhcp4": {
    "option-data": [
        {
1165
            <userinput>"name": "foo",
1166 1167
            "space": "vendor-encapsulated-options-space",
            "code": 1,
1168
            "csv-format": true,
1169 1170 1171 1172 1173
            "data": "192.0.2.3, 123, Hello World"</userinput>
        }
    ],
    ...
}</screen>
1174
    We also set up a dummy value for "vendor-encapsulated-options", the option that conveys our sub-option "foo".
1175
    This is required else the option will not be included in messages sent to the client.
1176 1177 1178 1179
<screen>
"Dhcp4": {
    "option-data": [
        {
1180
            <userinput>"name": "vendor-encapsulated-options",
1181 1182
            "space": "dhcp4",
            "code": 43,
1183
            "csv-format": false,
1184
            "data": ""</userinput>
1185 1186 1187 1188
        }
    ],
    ...
}</screen>
1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204
      </para>

      <note>
        <para>
          With this version of Kea, the "vendor-encapsulated-options" option
          must be specified in the configuration although it has no configurable
          parameters. If it is not specified, the server will assume that it is
          not configured and will not send it to a client. In the future there
          will be no need to include this option in the configuration.
        </para>
      </note>

    </section>

    <section id="dhcp4-option-spaces">

1205
      <title>Nested DHCPv4 Options (Custom Option Spaces)</title>
1206