multiple-options.json 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. // This is an example configuration file for the DHCPv4 server in Kea.
  2. // It demonstrates simple configuration of the options for a subnet.
  3. { "Dhcp4":
  4. {
  5. // Kea is told to listen on ethX interface only.
  6. "interfaces-config": {
  7. "interfaces": [ "ethX" ]
  8. },
  9. // We need to specify the the database used to store leases. As of
  10. // September 2016, four database backends are supported: MySQL,
  11. // PostgreSQL, Cassandra, and the in-memory database, Memfile.
  12. // We'll use memfile because it doesn't require any prior set up.
  13. "lease-database": {
  14. "type": "memfile"
  15. },
  16. // Addresses will be assigned with a lifetime of 4000 seconds.
  17. "valid-lifetime": 4000,
  18. // Renew and rebind timers are commented out. This implies that options
  19. // 58 and 59 will not be sent to the client. In this case it is up to
  20. // the client to pick the timer values according to RFC2131. Uncomment the
  21. // timers to send these options to the client.
  22. // "renew-timer": 1000,
  23. // "rebind-timer": 2000,
  24. // Defining a subnet. There are some DHCP options returned to the
  25. // clients connected to this subnet. The first and third options are
  26. // clients connected to this subnet. The first two options are
  27. // identified by the name. The third option is identified by the
  28. // option code.
  29. // There is an address pool defined within this subnet. Pool
  30. // specific value for option domain-name-servers is defined
  31. // for the pool.
  32. "subnet4": [
  33. {
  34. "subnet": "192.0.2.0/24",
  35. "interface": "ethX",
  36. "option-data": [
  37. // When specifying options, you typically need to specify
  38. // one of (name or code) and data. The full option specification
  39. // covers name, code, space, csv-format and data.
  40. // space defaults to "dhcp4" which is usually correct, unless you
  41. // use encapsulate options. csv-format defaults to "true", so
  42. // this is also correct, unless you want to specify the whole
  43. // option value as long hex string. For example, to specify
  44. // domain-name-servers you could do this:
  45. // {
  46. // "name": "domain-name-servers",
  47. // "code": 6,
  48. // "csv-format": "true",
  49. // "space": "dhcp4",
  50. // "data": "192.0.2.1, 192.0.2.2"
  51. // }
  52. // but it's a lot of writing, so it's easier to do this instead:
  53. {
  54. "name": "domain-name-servers",
  55. "data": "192.0.2.1, 192.0.2.2"
  56. },
  57. // Note the Kea provides some of the options on its own. In
  58. // particular:
  59. // - IP address lease time (option 51) is governed by
  60. // valid-lifetime parameter, so you don't need to specify
  61. // it as option.
  62. // - Subnet mask (option 1) is calculated automatically from the
  63. // subnet parameter specified for each "subnet4" entry.
  64. // - renewal-timer (option 58) is calculated from renew-timer
  65. // parameter
  66. // - rebind timer (option 59) is calculated from rebind-timer
  67. // parameter
  68. // For each IPv4 subnet you most likely need to specify at least
  69. // one router.
  70. {
  71. "name": "routers",
  72. "data": "192.0.2.1"
  73. },
  74. // Typically people prefer to refer to options by their
  75. // names, so they don't need to remember the code names.
  76. // However, some people like to use numerical values. For
  77. // example, option "domain-name" uses option code 15, so you
  78. // can reference to it either by
  79. // "name": "domain-name" or "code": 15.
  80. {
  81. "code": 15,
  82. "data": "example.org"
  83. },
  84. // Domain search is also a popular option. It tells the client to
  85. // attempt to resolve names within those specificed domains. For
  86. // example, name "foo" would be attempted to be resolved as
  87. // foo.mydomain.example.com and if it fails, then as
  88. // foo.example.com
  89. {
  90. "name": "domain-search",
  91. "data": "mydomain.example.com, example.com"
  92. },
  93. // String options that have a comma in their values need to have
  94. // it escaped (i.e. each comma is predeced by two backslashes).
  95. // That's because commas are reserved for separating fields in
  96. // compound options. At the same time, we need to be conformant
  97. // with JSON spec, that does not allow "\,". Therefore the
  98. // slightly uncommon double backslashes notation is needed.
  99. // Legal JSON escapes are \ followed by "\/bfnrt character
  100. // or \u followed by 4 hexa-decimal numbers (currently Kea
  101. // supports only \u0000 to \u00ff code points).
  102. // CSV processing translates '\\' into '\' and '\,' into ','
  103. // only so for instance '\x' is translated into '\x'. But
  104. // as it works on a JSON string value each of these '\'
  105. // characters must be doubled on JSON input.
  106. {
  107. "name": "boot-file-name",
  108. "data": "EST5EDT4\\,M3.2.0/02:00\\,M11.1.0/02:00"
  109. },
  110. // Options that take integer values can either be specified in
  111. // dec or hex format. Hex format could be either plain (e.g. abcd)
  112. // or prefixed with 0x (e.g. 0xabcd).
  113. {
  114. "name": "default-ip-ttl",
  115. "data": "0xf0"
  116. }
  117. ],
  118. // Now we define pools. There are two pools here.
  119. "pools": [ {
  120. // This is the first pool. Nothing spectacular here, just a range
  121. // of addresses.
  122. "pool": "192.0.2.10 - 192.0.2.100"
  123. }, {
  124. // This second pool is more interesting. Anyone who gets an
  125. // address from this pool will also get this specific option
  126. // value if asks for DNS servers configuration. This value,
  127. // being more specific, overrides any values that were specified
  128. // on either global or subnet scope.
  129. "pool": "192.0.2.101 - 192.0.2.200",
  130. "option-data": [
  131. {
  132. "name": "domain-name-servers",
  133. "data": "192.0.2.3, 192.0.2.4"
  134. }
  135. ]
  136. } ]
  137. } ]
  138. },
  139. // The following configures logging. It assumes that messages with at
  140. // least informational level (info, warn, error and fatal) should be
  141. // logged to stdout.
  142. "Logging": {
  143. "loggers": [
  144. {
  145. "name": "kea-dhcp4",
  146. "output_options": [
  147. {
  148. "output": "stdout"
  149. }
  150. ],
  151. "severity": "INFO"
  152. }
  153. ]
  154. }
  155. }