config.xml 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
  4. <!ENTITY mdash "&#x2014;" >
  5. ]>
  6. <chapter id="kea-config">
  7. <title>Kea Configuration</title>
  8. <para>Kea is using JSON structures to handle configuration. Previously
  9. we there was a concept of other configuration backends, but that never was
  10. implemented and the idea was abandoned.</para>
  11. <section id="json">
  12. <title>JSON Configuration</title>
  13. <para>JSON is notation used throughout the Kea project. The most obvious
  14. usage is for configuration file, but it is also used for sending commands
  15. over Management API (see <xref linkend="ctrl-channel"/>) and for
  16. communicating between DHCP servers and DDNS update daemon.</para>
  17. <para>Typical usage assumes that the servers are started from the command line
  18. (either directly or using a script, e.g. <filename>keactrl</filename>).
  19. The JSON backend uses certain signals to influence Kea. The
  20. configuration file is specified upon startup using the -c parameter.</para>
  21. <section id="json-format">
  22. <title>JSON Syntax</title>
  23. <para>Configuration files for DHCPv4, DHCPv6 and DDNS modules are defined
  24. in an extended JSON format. Basic JSON is defined in <ulink
  25. url="http://tools.ietf.org/html/rfc7159">RFC 7159</ulink>. Note that Kea
  26. 1.2 introduces a new parser that is better at following the JSON spec. In
  27. particular, the only values allowed for boolean are true or false (all
  28. lowercase). The capitalized versions (True or False) are not accepted.
  29. </para>
  30. <para>Kea components use an extended JSON with additional features
  31. allowed:
  32. <itemizedlist>
  33. <listitem>
  34. <simpara>shell comments: any text after the hash (#)
  35. character is ignored. Dhcp6 allows # in any column, while
  36. Dhcp4 and Ddns require hash to be in the first
  37. column.</simpara>
  38. </listitem>
  39. <listitem>
  40. <simpara>C comments: any text after the double slashes (//)
  41. character is ignored. We're in a process of
  42. migrating the configuation parsers and currently only Dhcp6
  43. supports this feature.</simpara>
  44. </listitem>
  45. <listitem>
  46. <simpara>Multiline comments: any text between /* and */ is
  47. ignored. This commenting can span multiple lines. We're in a
  48. process of migrating the configuation parsers and currently
  49. only Dhcp6 supports this feature.</simpara>
  50. </listitem>
  51. <listitem>
  52. <simpara>File inclusion: JSON files can include other JSON
  53. files. This can be done by using &lt;?include
  54. "file.json"?&gt;. We're in a process of migrating the
  55. configuation parsers and currently only Dhcp6 supports this
  56. feature.</simpara>
  57. </listitem>
  58. </itemizedlist>
  59. </para>
  60. <para>The configuration file consists of a single object (often colloquially
  61. called a map) started with a curly bracket. It comprises the "Dhcp4", "Dhcp6",
  62. "DhcpDdns" and/or "Logging" objects. It is possible to define additional
  63. elements, but they will be ignored. For example, it is possible to define
  64. Dhcp4, Dhcp6 and Logging elements in a single configuration file that can
  65. be used to start both the DHCPv4 and DHCPv6 components. When starting,
  66. the DHCPv4 component will use Dhcp4 object to configure itself and the
  67. Logging object to configure logging parameters; it will ignore the Dhcp6
  68. object.</para>
  69. <para>A very simple configuration for both DHCPv4 and
  70. DHCPv6 could look like this:
  71. <screen>
  72. # The whole configuration starts here.
  73. {
  74. # DHCPv4 specific configuration starts here.
  75. "Dhcp4": {
  76. "interfaces-config": {
  77. "interfaces": [ "eth0" ],
  78. "dhcp-socket-type": "raw"
  79. },
  80. "valid-lifetime": 4000,
  81. "renew-timer": 1000,
  82. "rebind-timer": 2000,
  83. "subnet4": [{
  84. "pools": [ { "pool": "192.0.2.1-192.0.2.200" } ],
  85. "subnet": "192.0.2.0/24"
  86. }]
  87. },
  88. # DHCPv4 specific configuration ends here.
  89. # DHCPv6 specific configuration starts here.
  90. "Dhcp6": {
  91. "interfaces-config": {
  92. "interfaces": [ "eth1" ]
  93. },
  94. "preferred-lifetime": 3000,
  95. "valid-lifetime": 4000,
  96. "renew-timer": 1000,
  97. "rebind-timer": 2000,
  98. "subnet6": [{
  99. "pools": [ { "pool": "2001:db8::/80" } ],
  100. "subnet": "2001:db8::/64"
  101. }]
  102. },
  103. # DHCPv6 specific configuration ends here.
  104. # Logger parameters (that could be shared among several components) start here.
  105. # This section is used by both the DHCPv4 and DHCPv6 servers.
  106. "Logging": {
  107. "loggers": [{
  108. "name": "*",
  109. "severity": "DEBUG"
  110. }]
  111. }
  112. # Logger parameters end here.
  113. # The whole configuration structure ends here.
  114. }
  115. </screen>
  116. </para>
  117. <para>More examples are available in the installed
  118. <filename>share/doc/kea/examples</filename> directory.</para>
  119. <para>To avoid repetition of mostly similar structures, examples in the
  120. rest of this guide will showcase only the subset of parameters appropriate for a given
  121. context. For example, when discussing the IPv6 subnets configuration in
  122. DHCPv6, only subnet6 parameters will be mentioned. It is implied that
  123. the remaining elements (the global map that holds Dhcp6, Logging and possibly
  124. DhcpDdns) are present, but they are omitted for clarity. Usually, locations
  125. where extra parameters may appear are denoted by an ellipsis.</para>
  126. </section>
  127. <section>
  128. <title>Simplified Notation</title>
  129. <para>It is sometimes convenient to refer to a specific element in the
  130. configuration hierarchy. Each hierarchy level is separated by a slash.
  131. If there is an array, a specific instance within that array is referenced by
  132. a number in square brackets (with numbering starting at zero). For example, in the above configuration the
  133. valid-lifetime in the Dhcp6 component can be referred to as
  134. Dhcp6/valid-lifetime and the pool in the first subnet defined in the DHCPv6
  135. configuration as Dhcp6/subnet6[0]/pool.</para>
  136. <!-- @todo Add a reference here after #3422 is done -->
  137. </section>
  138. </section>
  139. </chapter>