config.xml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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. Both Dhcp4 and Dhcp6 allow # in any column,
  36. while Ddns requires hash to be in the first column.</simpara>
  37. </listitem>
  38. <listitem>
  39. <simpara>C comments: any text after the double slashes (//)
  40. character is ignored. Both Dhcp4 and Dhcp6 supports this
  41. feature.</simpara>
  42. </listitem>
  43. <listitem>
  44. <simpara>Multiline comments: any text between /* and */ is
  45. ignored. This commenting can span multiple lines. Both Dhcp4 and
  46. Dhcp6 supports this feature.</simpara>
  47. </listitem>
  48. <listitem>
  49. <simpara>File inclusion: JSON files can include other JSON
  50. files. This can be done by using &lt;?include
  51. "file.json"?&gt;. Both Dhcp4 and Dhcp6 supports this
  52. feature.</simpara>
  53. </listitem>
  54. </itemizedlist>
  55. </para>
  56. <para>The configuration file consists of a single object (often colloquially
  57. called a map) started with a curly bracket. It comprises the "Dhcp4", "Dhcp6",
  58. "DhcpDdns" and/or "Logging" objects. It is possible to define additional
  59. elements, but they will be ignored. For example, it is possible to define
  60. Dhcp4, Dhcp6 and Logging elements in a single configuration file that can
  61. be used to start both the DHCPv4 and DHCPv6 components. When starting,
  62. the DHCPv4 component will use Dhcp4 object to configure itself and the
  63. Logging object to configure logging parameters; it will ignore the Dhcp6
  64. object.</para>
  65. <para>A very simple configuration for both DHCPv4 and
  66. DHCPv6 could look like this:
  67. <screen>
  68. # The whole configuration starts here.
  69. {
  70. # DHCPv4 specific configuration starts here.
  71. "Dhcp4": {
  72. "interfaces-config": {
  73. "interfaces": [ "eth0" ],
  74. "dhcp-socket-type": "raw"
  75. },
  76. "valid-lifetime": 4000,
  77. "renew-timer": 1000,
  78. "rebind-timer": 2000,
  79. "subnet4": [{
  80. "pools": [ { "pool": "192.0.2.1-192.0.2.200" } ],
  81. "subnet": "192.0.2.0/24"
  82. }]
  83. },
  84. # DHCPv4 specific configuration ends here.
  85. # DHCPv6 specific configuration starts here.
  86. "Dhcp6": {
  87. "interfaces-config": {
  88. "interfaces": [ "eth1" ]
  89. },
  90. "preferred-lifetime": 3000,
  91. "valid-lifetime": 4000,
  92. "renew-timer": 1000,
  93. "rebind-timer": 2000,
  94. "subnet6": [{
  95. "pools": [ { "pool": "2001:db8::/80" } ],
  96. "subnet": "2001:db8::/64"
  97. }]
  98. },
  99. # DHCPv6 specific configuration ends here.
  100. # Logger parameters (that could be shared among several components) start here.
  101. # This section is used by both the DHCPv4 and DHCPv6 servers.
  102. "Logging": {
  103. "loggers": [{
  104. "name": "*",
  105. "severity": "DEBUG"
  106. }]
  107. }
  108. # Logger parameters end here.
  109. # The whole configuration structure ends here.
  110. }
  111. </screen>
  112. </para>
  113. <para>More examples are available in the installed
  114. <filename>share/doc/kea/examples</filename> directory.</para>
  115. <para>To avoid repetition of mostly similar structures, examples in the
  116. rest of this guide will showcase only the subset of parameters appropriate for a given
  117. context. For example, when discussing the IPv6 subnets configuration in
  118. DHCPv6, only subnet6 parameters will be mentioned. It is implied that
  119. the remaining elements (the global map that holds Dhcp6, Logging and possibly
  120. DhcpDdns) are present, but they are omitted for clarity. Usually, locations
  121. where extra parameters may appear are denoted by an ellipsis.</para>
  122. </section>
  123. <section>
  124. <title>Simplified Notation</title>
  125. <para>It is sometimes convenient to refer to a specific element in the
  126. configuration hierarchy. Each hierarchy level is separated by a slash.
  127. If there is an array, a specific instance within that array is referenced by
  128. a number in square brackets (with numbering starting at zero). For example, in the above configuration the
  129. valid-lifetime in the Dhcp6 component can be referred to as
  130. Dhcp6/valid-lifetime and the pool in the first subnet defined in the DHCPv6
  131. configuration as Dhcp6/subnet6[0]/pool.</para>
  132. <!-- @todo Add a reference here after #3422 is done -->
  133. </section>
  134. </section>
  135. </chapter>