dhcp4-srv.xml 87 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995
  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="dhcp4">
  7. <title>The DHCPv4 Server</title>
  8. <section id="dhcp4-start-stop">
  9. <title>Starting and Stopping the DHCPv4 Server</title>
  10. <!-- @todo Rewrite this section once #3422 is done -->
  11. <para>
  12. It is recommended that the Kea DHCPv4 server be started and stopped
  13. using <command>keactrl</command> (described in <xref linkend="keactrl"/>).
  14. However, it is also possible to run the server directly: it accepts
  15. the following command-line switches:
  16. </para>
  17. <itemizedlist>
  18. <listitem>
  19. <simpara>
  20. <command>-c <replaceable>file</replaceable></command> -
  21. specifies the configuration file. This is the only mandatory
  22. switch.</simpara>
  23. </listitem>
  24. <listitem>
  25. <simpara>
  26. <command>-d</command> - specifies whether the server
  27. logging should be switched to debug/verbose mode. In verbose mode,
  28. the logging severity and debuglevel specified in the configuration
  29. file are ignored and "debug" severity and the maximum debuglevel
  30. (99) are assumed. The flag is convenient, for temporarily
  31. switching the server into maximum verbosity, e.g. when
  32. debugging.</simpara>
  33. </listitem>
  34. <listitem>
  35. <simpara>
  36. <command>-p <replaceable>port</replaceable></command> -
  37. specifies UDP port the server will listen on. This is only
  38. useful during testing, as the DHCPv4 server listening on
  39. ports other than default DHCPv4 ports will not be able to
  40. handle regular DHCPv4 queries.</simpara>
  41. </listitem>
  42. <listitem>
  43. <simpara>
  44. <command>-v</command> - prints out Kea version and exits.
  45. </simpara>
  46. </listitem>
  47. <listitem>
  48. <simpara>
  49. <command>-V</command> - prints out Kea extended version with
  50. additional parameters and exits.
  51. </simpara>
  52. </listitem>
  53. </itemizedlist>
  54. <para>
  55. When running in a console, the server can be shut down by
  56. pressing ctrl-c. It detects the key combination and shuts
  57. down gracefully.
  58. </para>
  59. <para>
  60. On start-up, the server will detect available network interfaces
  61. and will attempt to open UDP sockets on all interfaces
  62. mentioned in the configuration file.
  63. </para>
  64. <para>
  65. Since the DHCPv4 server opens privileged ports, it requires root
  66. access. Make sure you run this daemon as root.
  67. </para>
  68. </section>
  69. <section id="dhcp4-configuration">
  70. <title>DHCPv4 Server Configuration</title>
  71. <section>
  72. <title>Introduction</title>
  73. <para>
  74. This section explains how to configure the DHCPv4 server using the
  75. Kea configuration backend. (Kea configuration using any other
  76. backends is outside of scope of this document.) Before DHCPv4
  77. is started, its configuration file has to be created. The
  78. basic configuration is as follows:
  79. <screen>
  80. {
  81. # DHCPv4 configuration starts in this line
  82. "Dhcp4": {
  83. # First we set up global values
  84. "interfaces": [ "eth0" ],
  85. "valid-lifetime": 4000,
  86. "renew-timer": 1000,
  87. "rebind-timer": 2000,
  88. # Next we specify the type of lease database
  89. "lease-database": {
  90. "type": "memfile",
  91. "persist": true,
  92. "name": "/var/kea/dhcp4.leases"
  93. },
  94. # Finally, we list the subnets from which we will be leasing addresses.
  95. "subnet4": [
  96. {
  97. "subnet": "192.0.2.0/24",
  98. "pools": [
  99. { "pool": "192.0.2.1 - 192.0.2.200" }
  100. ]
  101. }
  102. ]
  103. # DHCPv4 configuration ends with this line
  104. }
  105. } </screen>
  106. </para>
  107. <para>The following paragraphs provide a brief overview of the parameters in
  108. the above example and
  109. their format. Subsequent sections of this chapter go into much greater detail
  110. for these and other parameters.</para>
  111. <para>The lines starting with a hash (#) are comments and are ignored by
  112. the server; they do not impact its
  113. operation in any way.</para>
  114. <para>The configuration starts in the first line with the initial
  115. opening curly bracket (or brace). Each configuration consists of
  116. one or more objects. In this specific example, we have only one
  117. object called Dhcp4. This is a simplified configuration, as usually
  118. there will be additional objects, like <command>Logging</command> or
  119. <command>DhcpDns</command>, but we omit them now for clarity. The Dhcp4
  120. configuration starts with the <command>"Dhcp4": {</command> line
  121. and ends with the corresponding closing brace (in the above example,
  122. the brace after the last comment). Everything defined between those
  123. lines is considered to be the Dhcp4 configuration.</para>
  124. <para>In the general case, the order in which those parameters appear does not
  125. matter. There are two caveats here though. The first one is to remember that
  126. the configuration file must be well formed JSON. That means that the parameters
  127. for any given scope must be separated by a comma and there must not be a comma
  128. after the last parameter. When reordering a configuration file, keep in mind that
  129. moving a parameter to or from the last position in a given scope may also require
  130. moving the comma. The second caveat is that it is uncommon &mdash; although
  131. legal JSON &mdash; to
  132. repeat the same parameter multiple times. If that happens, the last occurrence of a
  133. given parameter in a given scope is used while all previous instances are
  134. ignored. This is unlikely to cause any confusion as there are no real life
  135. reasons to keep multiple copies of the same parameter in your configuration
  136. file.</para>
  137. <para>Moving onto the DHCPv4 configuration elements,
  138. the line defining <command>interfaces</command> parameter specifies a list
  139. of network interfaces on which the server should listen.
  140. Lists are opened and closed with square brackets, with elements
  141. separated by commas. Had we wanted to listen on two interfaces, the line could
  142. look like this:
  143. <screen>
  144. "interfaces": [ "eth0", "eth1" ],
  145. </screen>
  146. As "<command>interfaces</command>" is not the last parameter in the configuration,
  147. a trailing comma is required.</para>
  148. <para>A number of other parameters
  149. follow. <command>valid-lifetime</command> defines for how long the addresses (leases) given out by the
  150. server are valid. If nothing changes, a client that got an address is allowed to
  151. use it for 4000 seconds. (Note that integer numbers are specified as is,
  152. without any quotes around them.) <command>renew-timer</command> and
  153. <command>rebind-timer</command> are values that
  154. define T1 and T2 timers that govern when the client will begin the renewal and
  155. rebind procedures. Note that <command>renew-timer</command> and
  156. <command>rebind-timer</command> are optional. If they are not specified the
  157. client will select values for T1 and T2 timers according to the
  158. <ulink url="http://tools.ietf.org/html/rfc2131">RFC 2131</ulink>.</para>
  159. <para>The next couple of lines define the lease database, the place where the server
  160. stores its lease information. This particular example tells the server to use
  161. <command>memfile</command>, which is the simplest (and fastest) database
  162. backend. It uses an in-memory database and stores leases on disk in a CSV
  163. file. This is a very simple configuration. Usually, lease database configuration
  164. is more extensive and contains additional parameters. Note that
  165. <command>lease-database</command>
  166. is an object and opens up a new scope, using an opening brace.
  167. Its parameters (just one in this example -- <command>type</command>)
  168. follow. Had there been more than one, they would be separated by commas. This
  169. scope is closed with a closing brace. As more parameters follow, a trailing
  170. comma is present.</para>
  171. <para>Finally, we need to define a list of IPv4 subnets. This is the
  172. most important DHCPv4 configuration structure as the server uses that
  173. information to process clients' requests. It defines all subnets from
  174. which the server is expected to receive DHCP requests. The subnets are
  175. specified with the <command>subnet4</command> parameter. It is a list,
  176. so it starts and ends with square brackets. Each subnet definition in
  177. the list has several attributes associated with it, so it is a structure
  178. and is opened and closed with braces. At a minimum, a subnet definition
  179. has to have at least two parameters: <command>subnet</command> (that
  180. defines the whole subnet) and <command>pools</command> (which is a list of
  181. dynamically allocated pools that are governed by the DHCP server).</para>
  182. <para>The example contains a single subnet. Had more than one been defined,
  183. additional elements
  184. in the <command>subnet4</command> parameter would be specified and
  185. separated by commas. For example, to define three subnets, the following
  186. syntax would be used:
  187. <screen>
  188. "subnet4": [
  189. {
  190. "pools": [ { "pool": "192.0.2.1 - 192.0.2.200" } ],
  191. "subnet": "192.0.2.0/24"
  192. },
  193. {
  194. "pools": [ { "pool": "192.0.3.100 - 192.0.3.200" } ],
  195. "subnet": "192.0.3.0/24"
  196. },
  197. {
  198. "pools": [ { "pool": "192.0.4.1 - 192.0.4.254" } ],
  199. "subnet": "192.0.4.0/24"
  200. }
  201. ]
  202. </screen>
  203. </para>
  204. <para>After all parameters are specified, we have two contexts open:
  205. global and Dhcp4, hence we need two closing curly brackets to close them.
  206. In a real life configuration file there most likely would be additional
  207. components defined such as Logging or DhcpDdns, so the closing brace would
  208. be followed by a comma and another object definition.</para>
  209. <para>Kea 0.9 does not have configuration syntax validation
  210. implemented yet. Such a feature is planned for the near future. For
  211. the time being, it is convenient to use on-line JSON validators and/or
  212. viewers to check whether the syntax is correct. One example of such a
  213. JSON validator is available at <ulink
  214. url="http://jsonviewer.stack.hu/"/>.
  215. </para>
  216. </section>
  217. <section>
  218. <title>Lease Storage</title>
  219. <para>All leases issued by the server are stored in the lease database.
  220. Currently there are three database backends available:
  221. memfile (which is the default backend), MySQL and PostgreSQL.</para>
  222. <section>
  223. <title>Memfile - Basic Storage for Leases</title>
  224. <para>The server is able to store lease data in different repositories. Larger
  225. deployments may elect to store leases in a database. <xref
  226. linkend="database-configuration4"/> describes this option. In typical
  227. smaller deployments though, the server will use a CSV file rather than a database to
  228. store lease information. As well as requiring less administration, an
  229. advantage of using a file for storage is that it
  230. eliminates a dependency on third-party database software.</para>
  231. <para>The configuration of the file backend (Memfile) is controlled through
  232. the Dhcp4/lease-database parameters. <!-- @todo: we don't have default
  233. parameters. Let's comment this out When default parameters are used, the
  234. Memfile backend will write leases to a disk in the
  235. [kea-install-dir]/var/kea/kea-leases4.csv. -->
  236. The following configuration sets the name of the lease file to
  237. <filename>/tmp/kea-leases4.csv</filename>:
  238. <screen>
  239. "Dhcp4": {
  240. "lease-database": {
  241. <userinput>"type": "memfile"</userinput>,
  242. <userinput>"persist": true</userinput>,
  243. <userinput>"name": "/tmp/kea-leases4.csv"</userinput>
  244. }
  245. ...
  246. }
  247. </screen>
  248. </para>
  249. <para>The "persist" parameter controls whether the leases are written to disk.
  250. It is strongly recommended that this parameter is set to
  251. <command>true</command> at all times during the normal operation of the
  252. server. (Not writing leases to disk will mean that if a server is restarted
  253. (e.g. after a power failure), it will not know what addresses have been
  254. assigned. As a result, it may hand out addresses to new clients that are
  255. already in use.)</para>
  256. </section>
  257. <section id="database-configuration4">
  258. <title>Database Configuration</title>
  259. <note>
  260. <para>Database access information must be configured for the DHCPv4 server,
  261. even if it has already been configured for the DHCPv6 server. The servers
  262. store their information independently, so each server can use a separate
  263. database or both servers can use the same database.</para>
  264. </note>
  265. <para>Database configuration is controlled through the Dhcp4/lease-database
  266. parameters. The type of the database must be set to "mysql" or "postgresql",
  267. e.g.
  268. <screen>
  269. "Dhcp4": { "lease-database": { <userinput>"type": "mysql"</userinput>, ... }, ... }
  270. </screen>
  271. Next, the name of the database to hold the leases must be set: this is the
  272. name used when the lease database was created (see <xref linkend="mysql-database-create"/>
  273. or <xref linkend="pgsql-database-create"/>).
  274. <screen>
  275. "Dhcp4": { "lease-database": { <userinput>"name": "<replaceable>database-name</replaceable>" </userinput>, ... }, ... }
  276. </screen>
  277. If the database is located on a different system to the DHCPv4 server, the
  278. database host name must also be specified (although it should be noted that this
  279. configuration may have a severe impact on server performance):
  280. <screen>
  281. "Dhcp4": { "lease-database": { <userinput>"host": <replaceable>remote-host-name</replaceable>"</userinput>, ... }, ... }
  282. </screen>
  283. The usual state of affairs will be to have the database on the same machine as
  284. the DHCPv4 server. In this case, set the value to the empty string:
  285. <screen>
  286. "Dhcp4": { "lease-database": { <userinput>"host" : ""</userinput>, ... }, ... }
  287. </screen>
  288. </para>
  289. <para>Finally, the credentials of the account under which the server will
  290. access the database should be set:
  291. <screen>
  292. "Dhcp4": { "lease-database": { <userinput>"user": "<replaceable>user-name</replaceable>"</userinput>,
  293. <userinput>"password": "<replaceable>password</replaceable>"</userinput>,
  294. ... },
  295. ... }
  296. </screen>
  297. If there is no password to the account, set the password to the empty string
  298. "". (This is also the default.)</para>
  299. </section>
  300. </section>
  301. <section id="dhcp4-interface-selection">
  302. <title>Interface selection</title>
  303. <para>The DHCPv4 server has to be configured to listen on specific network
  304. interfaces. The simplest network interface configuration tells the server to
  305. listen on all available interfaces:
  306. <screen>
  307. "Dhcp4": { <userinput>"interfaces": ["*"]</userinput>, ... }</screen>
  308. The asterisk plays the role of a wildcard and means "listen on all interfaces".
  309. However, it is usually a good idea to explicitly specify interface names:
  310. <screen>
  311. "Dhcp4": { <userinput>"interfaces": [ "eth1", "eth3" ]</userinput>, ... }</screen>
  312. </para>
  313. <para>It is possible to use wildcard interface name (asterisk) concurrently
  314. with explicit interface names:
  315. <screen>
  316. "Dhcp4": { <userinput>"interfaces": [ "eth1", "eth3", "*" ]</userinput>, ... }</screen>
  317. It is anticipated that this form of usage will only be used when it is desired to
  318. temporarily override a list of interface names and listen on all interfaces.
  319. </para>
  320. <para>Some deployments of the DHCP servers require that the servers listen
  321. on the interfaces with multiple IPv4 addresses configured. In some cases,
  322. multiple instances of the DHCP servers are running concurrently and each
  323. instance should be bound to a different address on the particular interface.
  324. In these situations, the address to use can be selected by
  325. appending an IPv4 address to the interface name in the following manner:
  326. <screen>
  327. "Dhcp4": { <userinput>"interfaces": [ "eth1/10.0.0.1", "eth3/192.0.2.3" ]</userinput>, ... }</screen>
  328. Note that only one address can be specified on each interface.
  329. </para>
  330. </section>
  331. <section id="ipv4-subnet-id">
  332. <title>IPv4 Subnet Identifier</title>
  333. <para>
  334. The subnet identifier is a unique number associated with a particular subnet.
  335. In principle, it is used to associate clients' leases with their respective subnets.
  336. When a subnet identifier is not specified for a subnet being configured, it will
  337. be automatically assigned by the configuration mechanism. The identifiers
  338. are assigned from 1 and are monotonically increased for each subsequent
  339. subnet: 1, 2, 3 ....
  340. </para>
  341. <para>
  342. If there are multiple subnets configured with auto-generated identifiers and
  343. one of them is removed, the subnet identifiers may be renumbered. For example:
  344. if there are four subnets and the third is removed the last subnet will be assigned
  345. the identifier that the third subnet had before removal. As a result, the leases
  346. stored in the lease database for subnet 3 are now associated with
  347. subnet 4, something that may have unexpected consequences. It is planned
  348. to implement a mechanism to preserve auto-generated subnet ids in a
  349. future version of Kea. However, the only remedy for this issue
  350. at present is to
  351. manually specify a unique identifier for each subnet.
  352. </para>
  353. <para>
  354. The following configuration will assign the specified subnet
  355. identifier to the newly configured subnet:
  356. <screen>
  357. "Dhcp4": {
  358. "subnet4": [
  359. "subnet": "192.0.2.0/24",
  360. <userinput>"id": 1024</userinput>,
  361. ...
  362. ]
  363. }
  364. </screen>
  365. This identifier will not change for this subnet unless the "id" parameter is
  366. removed or set to 0. The value of 0 forces auto-generation of the subnet
  367. identifier.
  368. </para>
  369. <!-- @todo: describe whether database needs to be updated after changing
  370. id -->
  371. </section>
  372. <section id="dhcp4-address-config">
  373. <title>Configuration of IPv4 Address Pools</title>
  374. <para>
  375. The essential role of DHCPv4 server is address assignment. The server has to
  376. be configured with at least one subnet and one pool of dynamic addresses to
  377. be managed. For example, assume that the server is connected to a network
  378. segment that uses the 192.0.2.0/24 prefix. The Administrator of that network
  379. has decided that addresses from range 192.0.2.10 to 192.0.2.20 are going to
  380. be managed by the Dhcp4 server. Such a configuration can be achieved in the
  381. following way:
  382. <screen>
  383. "Dhcp4": {
  384. <userinput>"subnet4": [
  385. "subnet": "192.0.2.0/24",
  386. "pools": [
  387. {
  388. "pool": "192.0.2.10 - 192.0.2.20"
  389. }
  390. ]</userinput>,
  391. ...
  392. ]
  393. }</screen>
  394. Note that subnet is defined as a simple string, but the 'pools' parameter is
  395. actually a list of pools: for this reason, the pool definition is enclosed
  396. in square brackets, even though only one range of addresses is
  397. specified in this example.</para>
  398. <para>Each <command>pool</command> is a structure that contains the parameters
  399. that describe a single pool. Currently there is only one parameter,
  400. <command>pool</command>, which gives the range of addresses
  401. in the pool. Additional parameters will be added in future
  402. releases of Kea.</para>
  403. <para>It is possible to define more than one pool in a subnet: continuing
  404. the previous example, further assume that 192.0.2.64/26 should be also be
  405. managed by the server. It could be written as 192.0.2.64 to
  406. 192.0.2.127. Alternatively, it can be expressed more simply as
  407. 192.0.2.64/26. Both formats are supported by Dhcp4 and can be mixed in the
  408. pool list. For example, one could define the following pools:
  409. <screen>
  410. "Dhcp4": {
  411. "subnet4": [
  412. <userinput>"pools": [
  413. { "pool": "192.0.2.10-192.0.2.20" },
  414. { "pool": "192.0.2.64/26" }
  415. ]</userinput>,
  416. ...
  417. ],
  418. ...
  419. }
  420. </screen>
  421. The number of pools is not limited, but for performance reasons it is recommended to
  422. use as few as possible. White space in pool definitions is ignored, so
  423. spaces before and after the hyphen are optional. They can be used to improve readability.
  424. </para>
  425. <para>
  426. The server may be configured to serve more than one subnet:
  427. <screen>
  428. "Dhcp4": {
  429. "subnet4": [
  430. {
  431. "subnet": "192.0.2.0/24",
  432. "pools": [ { "pool": "192.0.2.1 - 192.0.2.200" } ],
  433. ...
  434. },
  435. {
  436. "subnet": "192.0.3.0/24",
  437. "pools": [ { "pool": "192.0.3.100 - 192.0.3.200" } ],
  438. ...
  439. },
  440. {
  441. "subnet": "192.0.4.0/24",
  442. "pools": [ { "pool": "192.0.4.1 - 192.0.4.254" } ],
  443. ...
  444. }
  445. ]
  446. }
  447. </screen>
  448. </para>
  449. <para>
  450. When configuring a DHCPv4 server using prefix/length notation, please pay
  451. attention to the boundary values. When specifying that the server can use
  452. a given pool, it will also be able to allocate the first (typically network
  453. address) and the last (typically broadcast address) address from that pool.
  454. In the aforementioned example of pool 192.0.3.0/24, both 192.0.3.0 and
  455. 192.0.3.255 addresses may be assigned as well. This may be invalid in some
  456. network configurations. If you want to avoid this, please use the "min-max" notation.
  457. </para>
  458. </section>
  459. <section id="dhcp4-std-options">
  460. <title>Standard DHCPv4 options</title>
  461. <para>
  462. One of the major features of the DHCPv4 server is to provide configuration
  463. options to clients. Although there are several options that require
  464. special behavior, most options are sent by the server only if the client
  465. explicitly requests them. The following example shows how to
  466. configure the addresses of DNS servers, which is one of the most frequently used
  467. options. Options specified in this way are considered global and apply
  468. to all configured subnets.
  469. <screen>
  470. "Dhcp4": {
  471. "option-data": [
  472. {
  473. <userinput>"name": "domain-name-servers",
  474. "code": 6,
  475. "space": "dhcp4",
  476. "csv-format": true,
  477. "data": "192.0.2.1, 192.0.2.2"</userinput>
  478. },
  479. ...
  480. ]
  481. }
  482. </screen>
  483. </para>
  484. <para>
  485. The <command>name</command> parameter specifies the
  486. option name. For a complete list of currently supported names,
  487. see <xref linkend="dhcp4-std-options-list"/> below.
  488. The <command>code</command> parameter specifies the option code, which must match one of the
  489. values from that list. The next line specifies the option space, which must always
  490. be set to "dhcp4" as these are standard DHCPv4 options. For
  491. other option spaces, including custom option spaces, see <xref
  492. linkend="dhcp4-option-spaces"/>. The next line specifies the format in
  493. which the data will be entered: use of CSV (comma
  494. separated values) is recommended. The sixth line gives the actual value to
  495. be sent to clients. Data is specified as normal text, with
  496. values separated by commas if more than one value is
  497. allowed.
  498. </para>
  499. <para>
  500. Options can also be configured as hexadecimal values. If
  501. <command>csv-format</command> is
  502. set to false, option data must be specified as a hexadecimal string. The
  503. following commands configure the domain-name-servers option for all
  504. subnets with the following addresses: 192.0.3.1 and 192.0.3.2.
  505. Note that <command>csv-format</command> is set to false.
  506. <screen>
  507. "Dhcp4": {
  508. "option-data": [
  509. {
  510. <userinput>"name": "domain-name-servers",
  511. "code": 6,
  512. "space": "dhcp4",
  513. "csv-format": false,
  514. "data": "C0 00 03 01 C0 00 03 02"</userinput>
  515. },
  516. ...
  517. ],
  518. ...
  519. }</screen>
  520. </para>
  521. <para>
  522. Most of the parameters in the "option-data" structure are optional and
  523. can be omitted in some circumstances as discussed in the
  524. <xref linkend="dhcp4-option-data-defaults"/>.
  525. </para>
  526. <para>
  527. It is possible to specify or override options on a per-subnet basis. If
  528. clients connected to most of your subnets are expected to get the
  529. same values of a given option, you should use global options: you
  530. can then override specific values for a small number of subnets.
  531. On the other hand, if you use different values in each subnet,
  532. it does not make sense to specify global option values
  533. (Dhcp4/option-data), rather you should set only subnet-specific values
  534. (Dhcp4/subnet[X]/option-data[Y]).
  535. </para>
  536. <para>
  537. The following commands override the global
  538. DNS servers option for a particular subnet, setting a single DNS
  539. server with address 192.0.2.3.
  540. <screen>
  541. "Dhcp4": {
  542. "subnet4": [
  543. {
  544. <userinput>"option-data": [
  545. {
  546. "name": "domain-name-servers",
  547. "code": 6,
  548. "space": "dhcp4",
  549. "csv-format": true,
  550. "data": "192.0.2.3"
  551. },
  552. ...
  553. ]</userinput>,
  554. ...
  555. },
  556. ...
  557. ],
  558. ...
  559. }
  560. </screen>
  561. </para>
  562. <para>
  563. The currently supported standard DHCPv4 options are
  564. listed in <xref linkend="dhcp4-std-options-list"/>
  565. and <xref linkend="dhcp4-std-options-list-part2"/>.
  566. The "Name" and "Code"
  567. are the values that should be used as a name in the option-data
  568. structures. "Type" designates the format of the data: the meanings of
  569. the various types is given in <xref linkend="dhcp-types"/>.
  570. </para>
  571. <para>
  572. Some options are designated as arrays, which means that more than one
  573. value is allowed in such an option. For example the option time-servers
  574. allows the specification of more than one IPv4 address, so allowing
  575. clients to obtain the addresses of multiple NTP servers.
  576. </para>
  577. <!-- @todo: describe record types -->
  578. <para>
  579. The <xref linkend="dhcp4-custom-options"/> describes the configuration
  580. syntax to create custom option definitions (formats). It is generally not
  581. allowed to create custom definitions for standard options, even if the
  582. definition being created matches the actual option format defined in the
  583. RFCs. There is an exception from this rule for standard options for which
  584. Kea does not provide a definition yet. In order to use such options,
  585. a server administrator must create a definition as described in
  586. <xref linkend="dhcp4-custom-options"/> in the 'dhcp4' option space. This
  587. definition should match the option format described in the relevant
  588. RFC but the configuration mechanism will allow any option format as it has
  589. no means to validate the format at the moment.
  590. </para>
  591. <para>
  592. <table frame="all" id="dhcp4-std-options-list">
  593. <title>List of standard DHCPv4 options</title>
  594. <tgroup cols='4'>
  595. <colspec colname='name'/>
  596. <colspec colname='code' align='center'/>
  597. <colspec colname='type' align='center'/>
  598. <colspec colname='array' align='center'/>
  599. <thead>
  600. <row>
  601. <entry>Name</entry>
  602. <entry>Code</entry>
  603. <entry>Type</entry>
  604. <entry>Array?</entry>
  605. </row>
  606. </thead>
  607. <tbody>
  608. <row><entry>subnet-mask</entry><entry>1</entry><entry>ipv4-address</entry><entry>false</entry></row>
  609. <row><entry>time-offset</entry><entry>2</entry><entry>int32</entry><entry>false</entry></row>
  610. <row><entry>routers</entry><entry>3</entry><entry>ipv4-address</entry><entry>true</entry></row>
  611. <row><entry>time-servers</entry><entry>4</entry><entry>ipv4-address</entry><entry>true</entry></row>
  612. <row><entry>name-servers</entry><entry>5</entry><entry>ipv4-address</entry><entry>false</entry></row>
  613. <row><entry>domain-name-servers</entry><entry>6</entry><entry>ipv4-address</entry><entry>true</entry></row>
  614. <row><entry>log-servers</entry><entry>7</entry><entry>ipv4-address</entry><entry>true</entry></row>
  615. <row><entry>cookie-servers</entry><entry>8</entry><entry>ipv4-address</entry><entry>true</entry></row>
  616. <row><entry>lpr-servers</entry><entry>9</entry><entry>ipv4-address</entry><entry>true</entry></row>
  617. <row><entry>impress-servers</entry><entry>10</entry><entry>ipv4-address</entry><entry>true</entry></row>
  618. <row><entry>resource-location-servers</entry><entry>11</entry><entry>ipv4-address</entry><entry>true</entry></row>
  619. <row><entry>host-name</entry><entry>12</entry><entry>string</entry><entry>false</entry></row>
  620. <row><entry>boot-size</entry><entry>13</entry><entry>uint16</entry><entry>false</entry></row>
  621. <row><entry>merit-dump</entry><entry>14</entry><entry>string</entry><entry>false</entry></row>
  622. <row><entry>domain-name</entry><entry>15</entry><entry>fqdn</entry><entry>false</entry></row>
  623. <row><entry>swap-server</entry><entry>16</entry><entry>ipv4-address</entry><entry>false</entry></row>
  624. <row><entry>root-path</entry><entry>17</entry><entry>string</entry><entry>false</entry></row>
  625. <row><entry>extensions-path</entry><entry>18</entry><entry>string</entry><entry>false</entry></row>
  626. <row><entry>ip-forwarding</entry><entry>19</entry><entry>boolean</entry><entry>false</entry></row>
  627. <row><entry>non-local-source-routing</entry><entry>20</entry><entry>boolean</entry><entry>false</entry></row>
  628. <row><entry>policy-filter</entry><entry>21</entry><entry>ipv4-address</entry><entry>true</entry></row>
  629. <row><entry>max-dgram-reassembly</entry><entry>22</entry><entry>uint16</entry><entry>false</entry></row>
  630. <row><entry>default-ip-ttl</entry><entry>23</entry><entry>uint8</entry><entry>false</entry></row>
  631. <row><entry>path-mtu-aging-timeout</entry><entry>24</entry><entry>uint32</entry><entry>false</entry></row>
  632. <row><entry>path-mtu-plateau-table</entry><entry>25</entry><entry>uint16</entry><entry>true</entry></row>
  633. <row><entry>interface-mtu</entry><entry>26</entry><entry>uint16</entry><entry>false</entry></row>
  634. <row><entry>all-subnets-local</entry><entry>27</entry><entry>boolean</entry><entry>false</entry></row>
  635. <row><entry>broadcast-address</entry><entry>28</entry><entry>ipv4-address</entry><entry>false</entry></row>
  636. <row><entry>perform-mask-discovery</entry><entry>29</entry><entry>boolean</entry><entry>false</entry></row>
  637. <row><entry>mask-supplier</entry><entry>30</entry><entry>boolean</entry><entry>false</entry></row>
  638. <row><entry>router-discovery</entry><entry>31</entry><entry>boolean</entry><entry>false</entry></row>
  639. <row><entry>router-solicitation-address</entry><entry>32</entry><entry>ipv4-address</entry><entry>false</entry></row>
  640. <row><entry>static-routes</entry><entry>33</entry><entry>ipv4-address</entry><entry>true</entry></row>
  641. <row><entry>trailer-encapsulation</entry><entry>34</entry><entry>boolean</entry><entry>false</entry></row>
  642. <row><entry>arp-cache-timeout</entry><entry>35</entry><entry>uint32</entry><entry>false</entry></row>
  643. <row><entry>ieee802-3-encapsulation</entry><entry>36</entry><entry>boolean</entry><entry>false</entry></row>
  644. <row><entry>default-tcp-ttl</entry><entry>37</entry><entry>uint8</entry><entry>false</entry></row>
  645. <row><entry>tcp-keepalive-interval</entry><entry>38</entry><entry>uint32</entry><entry>false</entry></row>
  646. <row><entry>tcp-keepalive-garbage</entry><entry>39</entry><entry>boolean</entry><entry>false</entry></row>
  647. </tbody>
  648. </tgroup>
  649. </table>
  650. </para>
  651. <para>
  652. <table frame="all" id="dhcp4-std-options-list-part2">
  653. <title>List of standard DHCPv4 options (continued)</title>
  654. <tgroup cols='4'>
  655. <colspec colname='name'/>
  656. <colspec colname='code'/>
  657. <colspec colname='type'/>
  658. <colspec colname='array'/>
  659. <thead>
  660. <row>
  661. <entry>Name</entry>
  662. <entry>Code</entry>
  663. <entry>Type</entry>
  664. <entry>Array?</entry>
  665. </row>
  666. </thead>
  667. <tbody>
  668. <row><entry>nis-domain</entry><entry>40</entry><entry>string</entry><entry>false</entry></row>
  669. <row><entry>nis-servers</entry><entry>41</entry><entry>ipv4-address</entry><entry>true</entry></row>
  670. <row><entry>ntp-servers</entry><entry>42</entry><entry>ipv4-address</entry><entry>true</entry></row>
  671. <row><entry>vendor-encapsulated-options</entry><entry>43</entry><entry>empty</entry><entry>false</entry></row>
  672. <row><entry>netbios-name-servers</entry><entry>44</entry><entry>ipv4-address</entry><entry>true</entry></row>
  673. <row><entry>netbios-dd-server</entry><entry>45</entry><entry>ipv4-address</entry><entry>true</entry></row>
  674. <row><entry>netbios-node-type</entry><entry>46</entry><entry>uint8</entry><entry>false</entry></row>
  675. <row><entry>netbios-scope</entry><entry>47</entry><entry>string</entry><entry>false</entry></row>
  676. <row><entry>font-servers</entry><entry>48</entry><entry>ipv4-address</entry><entry>true</entry></row>
  677. <row><entry>x-display-manager</entry><entry>49</entry><entry>ipv4-address</entry><entry>true</entry></row>
  678. <row><entry>dhcp-requested-address</entry><entry>50</entry><entry>ipv4-address</entry><entry>false</entry></row>
  679. <!-- Lease time should not be configured by a user.
  680. <row><entry>dhcp-lease-time</entry><entry>51</entry><entry>uint32</entry><entry>false</entry></row>
  681. -->
  682. <row><entry>dhcp-option-overload</entry><entry>52</entry><entry>uint8</entry><entry>false</entry></row>
  683. <!-- Message Type, Server Identifier and Parameter Request List should not be configured by a user.
  684. <row><entry>dhcp-message-type</entry><entry>53</entry><entry>uint8</entry><entry>false</entry></row>
  685. <row><entry>dhcp-server-identifier</entry><entry>54</entry><entry>ipv4-address</entry><entry>false</entry></row>
  686. <row><entry>dhcp-parameter-request-list</entry><entry>55</entry><entry>uint8</entry><entry>true</entry></row>
  687. -->
  688. <row><entry>dhcp-message</entry><entry>56</entry><entry>string</entry><entry>false</entry></row>
  689. <row><entry>dhcp-max-message-size</entry><entry>57</entry><entry>uint16</entry><entry>false</entry></row>
  690. <!-- Renewal and rebinding time should not be configured by a user.
  691. <row><entry>dhcp-renewal-time</entry><entry>58</entry><entry>uint32</entry><entry>false</entry></row>
  692. <row><entry>dhcp-rebinding-time</entry><entry>59</entry><entry>uint32</entry><entry>false</entry></row>
  693. -->
  694. <row><entry>vendor-class-identifier</entry><entry>60</entry><entry>binary</entry><entry>false</entry></row>
  695. <!-- Client identifier should not be configured by a user.
  696. <row><entry>dhcp-client-identifier</entry><entry>61</entry><entry>binary</entry><entry>false</entry></row>
  697. -->
  698. <row><entry>nwip-domain-name</entry><entry>62</entry><entry>string</entry><entry>false</entry></row>
  699. <row><entry>nwip-suboptions</entry><entry>63</entry><entry>binary</entry><entry>false</entry></row>
  700. <row><entry>tftp-server-name</entry><entry>66</entry><entry>string</entry><entry>false</entry></row>
  701. <row><entry>boot-file-name</entry><entry>67</entry><entry>string</entry><entry>false</entry></row>
  702. <row><entry>user-class</entry><entry>77</entry><entry>binary</entry><entry>false</entry></row>
  703. <row><entry>fqdn</entry><entry>81</entry><entry>record</entry><entry>false</entry></row>
  704. <row><entry>dhcp-agent-options</entry><entry>82</entry><entry>empty</entry><entry>false</entry></row>
  705. <row><entry>authenticate</entry><entry>90</entry><entry>binary</entry><entry>false</entry></row>
  706. <row><entry>client-last-transaction-time</entry><entry>91</entry><entry>uint32</entry><entry>false</entry></row>
  707. <row><entry>associated-ip</entry><entry>92</entry><entry>ipv4-address</entry><entry>true</entry></row>
  708. <row><entry>subnet-selection</entry><entry>118</entry><entry>ipv4-address</entry><entry>false</entry></row>
  709. <row><entry>domain-search</entry><entry>119</entry><entry>binary</entry><entry>false</entry></row>
  710. <row><entry>vivco-suboptions</entry><entry>124</entry><entry>binary</entry><entry>false</entry></row>
  711. <row><entry>vivso-suboptions</entry><entry>125</entry><entry>binary</entry><entry>false</entry></row>
  712. </tbody>
  713. </tgroup>
  714. </table>
  715. </para>
  716. <para>
  717. <table frame="all" id="dhcp-types">
  718. <title>List of standard DHCP option types</title>
  719. <tgroup cols='2'>
  720. <colspec colname='name'/>
  721. <colspec colname='meaning'/>
  722. <thead>
  723. <row><entry>Name</entry><entry>Meaning</entry></row>
  724. </thead>
  725. <tbody>
  726. <row><entry>binary</entry><entry>An arbitrary string of bytes, specified as a set of hexadecimal digits.</entry></row>
  727. <row><entry>boolean</entry><entry>Boolean value with allowed values true or false</entry></row>
  728. <row><entry>empty</entry><entry>No value, data is carried in suboptions</entry></row>
  729. <row><entry>fqdn</entry><entry>Fully qualified domain name (e.g. www.example.com)</entry></row>
  730. <row><entry>ipv4-address</entry><entry>IPv4 address in the usual dotted-decimal notation (e.g. 192.0.2.1)</entry></row>
  731. <row><entry>ipv6-address</entry><entry>IPv6 address in the usual colon notation (e.g. 2001:db8::1)</entry></row>
  732. <row><entry>record</entry><entry>Structured data that may comprise any types (except "record" and "empty")</entry></row>
  733. <row><entry>string</entry><entry>Any text</entry></row>
  734. <row><entry>uint8</entry><entry>8 bit unsigned integer with allowed values 0 to 255</entry></row>
  735. <row><entry>uint16</entry><entry>16 bit unsigned integer with allowed values 0 to 65535</entry></row>
  736. <row><entry>uint32</entry><entry>32 bit unsigned integer with allowed values 0 to 4294967295</entry></row>
  737. </tbody>
  738. </tgroup>
  739. </table>
  740. </para>
  741. </section>
  742. <section id="dhcp4-custom-options">
  743. <title>Custom DHCPv4 options</title>
  744. <para>Kea supports custom (non-standard) DHCPv4 options. Assume
  745. that we want to define a new DHCPv4 option called "foo" which
  746. will have code 222 and will convey a single unsigned 32 bit
  747. integer value. We can define such an option by using the
  748. following entry in the configuration file:
  749. <screen>
  750. "Dhcp4": {
  751. "option-def": [
  752. {
  753. <userinput>"name": "foo",
  754. "code": 222,
  755. "type": "uint32",
  756. "array": false,
  757. "record-types": "",
  758. "space": "dhcp4",
  759. "encapsulate": ""</userinput>
  760. }, ...
  761. ],
  762. ...
  763. }
  764. </screen>
  765. The <command>false</command> value of the <command>array</command>
  766. parameter determines that the option does NOT comprise an array of
  767. "uint32" values but rather a single value. Two other parameters have been
  768. left blank: <command>record-types</command> and
  769. <command>encapsulate</command>. The former specifies the comma separated
  770. list of option data fields if the option comprises a record of data
  771. fields. This should be non-empty if the <command>type</command> is set to
  772. "record". Otherwise it must be left blank. The latter parameter specifies
  773. the name of the option space being encapsulated by the particular
  774. option. If the particular option does not encapsulate any option space it
  775. should be left blank. Note that the above set of comments define the
  776. format of the new option and do not set its values.
  777. </para>
  778. <note>
  779. <para>
  780. In the current release the default values are not propagated to the
  781. parser when the new configuration is being set. Therefore, all
  782. parameters must be specified at all times, even if their values are
  783. left blank.
  784. </para>
  785. </note>
  786. <para>Once the new option format is defined, its value is set
  787. in the same way as for a standard option. For example the following
  788. commands set a global value that applies to all subnets.
  789. <screen>
  790. "Dhcp4": {
  791. "option-data": [
  792. {
  793. <userinput>"name": "foo",
  794. "code": 222,
  795. "space": "dhcp4",
  796. "csv-format": true,
  797. "data": "12345"</userinput>
  798. }, ...
  799. ],
  800. ...
  801. }
  802. </screen>
  803. </para>
  804. <para>New options can take more complex forms than simple use of
  805. primitives (uint8, string, ipv4-address etc): it is possible to
  806. define an option comprising a number of existing primitives.
  807. Assume we want to define a new option that will consist of
  808. an IPv4 address, followed by an unsigned 16 bit integer, followed by
  809. a boolean value, followed by a text string. Such an option could
  810. be defined in the following way:
  811. <screen>
  812. "Dhcp4": {
  813. "option-def": [
  814. {
  815. <userinput>"name": "bar",
  816. "code": 223,
  817. "space": "dhcp4",
  818. "type": "record",
  819. "array": false,
  820. "record-types": "ipv4-address, uint16, boolean, string",
  821. "encapsulate": ""</userinput>
  822. }, ...
  823. ],
  824. ...
  825. }
  826. </screen>
  827. The <command>type</command> is set to "record" to indicate that the option contains
  828. multiple values of different types. These types are given as a comma-separated
  829. list in the <command>record-types</command> field and should be those listed in <xref linkend="dhcp-types"/>.
  830. </para>
  831. <para>
  832. The values of the option are set as follows:
  833. <screen>
  834. "Dhcp4": {
  835. "option-data": [
  836. {
  837. <userinput>"name": "bar",
  838. "space": "dhcp4",
  839. "code": 223,
  840. "csv-format": true,
  841. "data": "192.0.2.100, 123, true, Hello World"</userinput>
  842. }
  843. ],
  844. ...
  845. }</screen>
  846. <command>csv-format</command> is set to <command>true</command> to indicate
  847. that the <command>data</command> field comprises a command-separated list
  848. of values. The values in the <command>data</command> must correspond to
  849. the types set in the <command>record-types</command> field of the option
  850. definition.
  851. </para>
  852. <note>
  853. <para>In the general case, boolean values are specified as <command>true</command> or
  854. <command>false</command>, without quotes. Some specific boolean parameters may
  855. accept also <command>"true"</command>, <command>"false"</command>,
  856. <command>0</command>, <command>1</command>, <command>"0"</command> and
  857. <command>"1"</command>. Future Kea versions will accept all those values
  858. for all boolean parameters.</para>
  859. </note>
  860. </section>
  861. <section id="dhcp4-vendor-opts">
  862. <title>DHCPv4 Vendor Specific Options</title>
  863. <para>
  864. Currently there are three option spaces defined: "dhcp4" (used by the DHCPv4 daemon)
  865. and "dhcp6" (for the DHCPv6 daemon); there is also "vendor-encapsulated-options-space",
  866. which is empty by default, but options
  867. can be defined in it. Those options are called vendor-specific
  868. information options. The following examples show how to define
  869. an option "foo" with code 1 that consists of an IPv4 address, an
  870. unsigned 16 bit integer and a string. The "foo" option is conveyed
  871. in a vendor specific information option.
  872. </para>
  873. <para>
  874. The first step is to define the format of the option:
  875. <screen>
  876. "Dhcp4": {
  877. "option-def": [
  878. {
  879. <userinput>"name": "foo",
  880. "code": 1,
  881. "space": "vendor-encapsulated-options-space",
  882. "type": "record",
  883. "array": false,
  884. "record-types": "ipv4-address, uint16, string",
  885. "encapsulates": ""</userinput>
  886. }
  887. ],
  888. ...
  889. }</screen>
  890. (Note that the option space is set to "vendor-encapsulated-options-space".)
  891. Once the option format is defined, the next step is to define actual values
  892. for that option:
  893. <screen>
  894. "Dhcp4": {
  895. "option-data": [
  896. {
  897. <userinput>"name": "foo"
  898. "space": "vendor-encapsulated-options-space",
  899. "code": 1,
  900. "csv-format": true,
  901. "data": "192.0.2.3, 123, Hello World"</userinput>
  902. }
  903. ],
  904. ...
  905. }</screen>
  906. We also set up a dummy value for "vendor-encapsulated-options", the option that conveys our sub-option "foo".
  907. This is required else the option will not be included in messages sent to the client.
  908. <screen>
  909. "Dhcp4": {
  910. "option-data": [
  911. {
  912. <userinput>"name": "vendor-encapsulated-options"
  913. "space": "dhcp4",
  914. "code": 43,
  915. "csv-format": false,
  916. "data": ""</userinput>
  917. }
  918. ],
  919. ...
  920. }</screen>
  921. </para>
  922. <note>
  923. <para>
  924. With this version of Kea, the "vendor-encapsulated-options" option
  925. must be specified in the configuration although it has no configurable
  926. parameters. If it is not specified, the server will assume that it is
  927. not configured and will not send it to a client. In the future there
  928. will be no need to include this option in the configuration.
  929. </para>
  930. </note>
  931. </section>
  932. <section id="dhcp4-option-spaces">
  933. <title>Nested DHCPv4 Options (Custom Option Spaces)</title>
  934. <para>It is sometimes useful to define completely new option
  935. space. This is the case when user creates new option in the
  936. standard option space ("dhcp4 or "dhcp6") and wants this option
  937. to convey sub-options. Since they are in a separate space,
  938. sub-option codes will have a separate numbering scheme and may
  939. overlap with the codes of standard options.
  940. </para>
  941. <para>Note that creation of a new option space when defining
  942. sub-options for a standard option is not required, because it is
  943. created by default if the standard option is meant to convey any
  944. sub-options (see <xref linkend="dhcp4-vendor-opts"/>).
  945. </para>
  946. <para>
  947. Assume that we want to have a DHCPv4 option called "container" with
  948. code 222 that conveys two sub-options with codes 1 and 2.
  949. First we need to define the new sub-options:
  950. <screen>
  951. "Dhcp4": {
  952. "option-def": [
  953. {
  954. <userinput>"name": "subopt1",
  955. "code": 1,
  956. "space": "isc",
  957. "type": "ipv4-address".
  958. "record-types": "",
  959. "array": false,
  960. "encapsulate ""
  961. },
  962. {
  963. "name": "subopt2",
  964. "code": 2,
  965. "space": "isc",
  966. "type": "string",
  967. "record-types": "",
  968. "array": false
  969. "encapsulate": ""</userinput>
  970. }
  971. ],
  972. ...
  973. }</screen>
  974. Note that we have defined the options to belong to a new option space
  975. (in this case, "isc").
  976. </para>
  977. <para>
  978. The next step is to define a regular DHCPv4 option with our desired
  979. code and specify that it should include options from the new option space:
  980. <screen>
  981. "Dhcp4": {
  982. "option-def": [
  983. ...,
  984. {
  985. <userinput>"name": "container",
  986. "code": 222,
  987. "space": "dhcp4",
  988. "type": "empty",
  989. "array": false,
  990. "record-types": "",
  991. "encapsulate": "isc"</userinput>
  992. }
  993. ],
  994. ...
  995. }</screen>
  996. The name of the option space in which the sub-options are defined
  997. is set in the "encapsulate" field. The "type" field is set to "empty"
  998. to indicate that this option does not carry any data other than
  999. sub-options.
  1000. </para>
  1001. <para>
  1002. Finally, we can set values for the new options:
  1003. <screen>
  1004. "Dhcp4": {
  1005. "option-data": [
  1006. {
  1007. <userinput>"name": "subopt1",
  1008. "space": "isc",
  1009. "code": 1,
  1010. "csv-format": true,
  1011. "data": "192.0.2.3"</userinput>
  1012. },
  1013. }
  1014. <userinput>"name": "subopt2",
  1015. "space": "isc",
  1016. "code": 2,
  1017. "csv-format": true,
  1018. "data": "Hello world"</userinput>
  1019. },
  1020. {
  1021. <userinput>"name": "container",
  1022. "space": "dhcp4",
  1023. "code": 222,
  1024. "csv-format": true,
  1025. "data": ""</userinput>
  1026. }
  1027. ],
  1028. ...
  1029. }
  1030. </screen>
  1031. Even though the "container" option does not carry any data except
  1032. sub-options, the "data" field must be explicitly set to an empty value.
  1033. This is required because in the current version of Kea, the
  1034. default configuration values are not propagated to the configuration parsers:
  1035. if the "data" is not set the parser will assume that this
  1036. parameter is not specified and an error will be reported.
  1037. </para>
  1038. <para>Note that it is possible to create an option which carries some data
  1039. in addition to the sub-options defined in the encapsulated option space. For example,
  1040. if the "container" option from the previous example was required to carry an uint16
  1041. value as well as the sub-options, the "type" value would have to be set to "uint16" in
  1042. the option definition. (Such an option would then have the following
  1043. data structure: DHCP header, uint16 value, sub-options.) The value specified
  1044. with the "data" parameter &mdash; which should be a valid integer enclosed in quotes,
  1045. e.g. "123" &mdash; would then be assigned to the uint16 field in the "container" option.
  1046. </para>
  1047. </section>
  1048. <section id="dhcp4-option-data-defaults">
  1049. <title>Unspecified parameters for DHCPv4 option configuration</title>
  1050. <para>In many cases it is not required to specify all parameters for
  1051. an option configuration and the default values may be used. However, it is
  1052. important to understand the implications of not specifing some of them
  1053. as it may result in configuration errors. The list below explains
  1054. the behavior of the server when a particular parameter is not explicitly
  1055. specified:
  1056. <itemizedlist>
  1057. <listitem>
  1058. <simpara><command>name</command> - the server requires an option name or
  1059. option code to identify an option. If this parameter is unspecified, the
  1060. option code must be specified.
  1061. </simpara>
  1062. </listitem>
  1063. <listitem>
  1064. <simpara><command>code</command> - the server requires an option name or
  1065. option code to identify an option. This parameter may be left unspecified if
  1066. the <command>name</command> parameter is specified. However, this also
  1067. requires that the particular option has its definition (it is either a
  1068. standard option or an administrator created a definition for the option
  1069. using an 'option-def' structure), as the option definition associates an
  1070. option with a particular name. It is possible to configure an option
  1071. for which there is no definition (unspecified option format).
  1072. Configuration of such options requires the use of option code.
  1073. </simpara>
  1074. </listitem>
  1075. <listitem>
  1076. <simpara><command>space</command> - if the option space is unspecified it
  1077. will default to 'dhcp4' which is an option space holding DHCPv4 standard
  1078. options.
  1079. </simpara>
  1080. </listitem>
  1081. <listitem>
  1082. <simpara><command>data</command> - if the option data is unspecified it
  1083. defaults to an empty value. The empty value is mostly used for the
  1084. options which have no payload (boolean options), but it is legal to specify
  1085. empty values for some options which carry variable length data and which
  1086. spec allows for the length of 0. For such options, the data parameter
  1087. may be omitted in the configuration.</simpara>
  1088. </listitem>
  1089. <listitem>
  1090. <simpara><command>csv-format</command> - if this value is not specified
  1091. and the definition for the particular option exists, the server will assume
  1092. that the option data is specified as a list of comma separated values to be
  1093. assigned to individual fields of the DHCP option. If the definition
  1094. does not exist for this option, the server will assume that the data
  1095. parameter contains the option payload in the binary format (represented
  1096. as a string of hexadecimal digits). Note that not specifying this
  1097. parameter doesn't imply that it defaults to a fixed value, but
  1098. the configuration data interpretation also depends on the presence
  1099. of the option definition. An administrator must be aware if the
  1100. definition for the particular option exists when this parameter
  1101. is not specified. It is generally recommended to not specify this
  1102. parameter only for the options for which the definition exists, e.g.
  1103. standard options. Setting <command>csv-format</command> to an explicit
  1104. value will cause the server to strictly check the format of the option
  1105. data specified.
  1106. </simpara>
  1107. </listitem>
  1108. </itemizedlist>
  1109. </para>
  1110. </section>
  1111. <section id="dhcp4-stateless-configuration">
  1112. <title>Stateless Configuration of DHCPv4 clients</title>
  1113. <para>The DHCPv4 server supports the stateless client configuration whereby the
  1114. client has an IP address configured (e.g. using manual configuration) and only
  1115. contacts the server to obtain other configuration parameters, e.g. DNS servers' addresses.
  1116. In order to obtain the stateless configuration parameters the client sends the
  1117. DHCPINFORM message to the server with the "ciaddr" set to the address that the
  1118. client is currently using. The server unicasts the DHCPACK message to the
  1119. client that includes the stateless configuration ("yiaddr" not set).
  1120. </para>
  1121. <para>The server will respond to the DHCPINFORM when the client is associated
  1122. with the particular subnet defined in the server's configuration. The example
  1123. subnet configuration will look like this:
  1124. <screen>
  1125. "Dhcp4": {
  1126. "subnet4": [
  1127. {
  1128. "subnet": "192.0.2.0/24"
  1129. "option-data": [ {"
  1130. "name": "domain-name-servers",
  1131. "code": 6,
  1132. "data": "192.0.2.200,192.0.2.201",
  1133. "csv-format": true,
  1134. "space": "dhcp4"
  1135. } ]
  1136. }
  1137. ]
  1138. }</screen>
  1139. </para>
  1140. <para>This subnet specifies the single option which will be included in
  1141. the DHCPACK message to the client in response to DHCPINFORM. Note that
  1142. the subnet definition does not require the address pool configuration
  1143. if it will be used solely for the stateless configuration.
  1144. </para>
  1145. <para>This server will associate the subnet with the client if one of
  1146. the following conditions is met:
  1147. <itemizedlist>
  1148. <listitem>
  1149. <simpara>The DHCPINFORM is relayed and the giaddr matches the
  1150. configured subnet.</simpara>
  1151. </listitem>
  1152. <listitem>
  1153. <simpara>The DHCPINFORM is unicast from the client and the ciaddr
  1154. matches the configured subnet.</simpara>
  1155. </listitem>
  1156. <listitem>
  1157. <simpara>The DHCPINFORM is unicast from the client, the ciaddr is
  1158. not set but the source address of the IP packet matches the
  1159. configured subnet.</simpara>
  1160. </listitem>
  1161. <listitem>
  1162. <simpara>The DHCPINFORM is not relayed and the IP address on the
  1163. interface on which the message is received matches the configured
  1164. subnet.</simpara>
  1165. </listitem>
  1166. </itemizedlist>
  1167. </para>
  1168. </section>
  1169. <section id="dhcp4-client-classifier">
  1170. <title>Client Classification in DHCPv4</title>
  1171. <note>
  1172. <para>
  1173. The DHCPv4 server has been extended to support limited client classification.
  1174. Although the current capability is modest, it is expected to be expanded
  1175. in the future. However, it is envisaged that the majority of client classification
  1176. extensions will be using hooks extensions.
  1177. </para>
  1178. </note>
  1179. <para>In certain cases it is useful to differentiate between different
  1180. types of clients and treat them differently. The process of doing
  1181. classification is conducted in two steps. The first step is to assess an
  1182. incoming packet and assign it to zero or more classes. This classification
  1183. is currently simple, but is expected to grow in capability soon. Currently
  1184. the server checks whether an incoming packet includes the vendor class identifier
  1185. option (60). If it does, the content of that option is prepended with
  1186. &quot;VENDOR_CLASS_&quot; then it is interpreted as a class. For example,
  1187. modern cable modems will send this option with value &quot;docsis3.0&quot;
  1188. and as a result the packet will belong to class &quot;VENDOR_CLASS_docsis3.0&quot;.
  1189. </para>
  1190. <para>It is envisaged that the client classification will be used for changing the
  1191. behavior of almost any part of the DHCP message processing, including assigning
  1192. leases from different pools, assigning different options (or different values of
  1193. the same options) etc. For now, there are only two mechanisms that are taking
  1194. advantage of client classification: specific processing for cable modems and
  1195. subnet selection.</para>
  1196. <para>
  1197. For clients that belong to the VENDOR_CLASS_docsis3.0 class, the siaddr
  1198. field is set to the value of next-server (if specified in a subnet). If
  1199. there is a boot-file-name option specified, its value is also set in the
  1200. file field in the DHCPv4 packet. For eRouter1.0 class, the siaddr is
  1201. always set to 0.0.0.0. That capability is expected to be moved to
  1202. an external hook library that will be dedicated to cable modems.
  1203. </para>
  1204. <para>
  1205. Kea can be instructed to limit access to given subnets based on class information.
  1206. This is particularly useful for cases where two types of devices share the
  1207. same link and are expected to be served from two different subnets. The
  1208. primary use case for such a scenario is cable networks. There are two
  1209. classes of devices: the cable modem itself, which should be handed a lease
  1210. from subnet A and all other devices behind the modem that should get a lease
  1211. from subnet B. That segregation is essential to prevent overly curious
  1212. users from playing with their cable modems. For details on how to set up
  1213. class restrictions on subnets, see <xref linkend="dhcp4-subnet-class"/>.
  1214. </para>
  1215. <section id="dhcp4-subnet-class">
  1216. <title>Limiting Access to IPv4 Subnet to Certain Classes</title>
  1217. <para>
  1218. In certain cases it beneficial to restrict access to certain subnets
  1219. only to clients that belong to a given subnet. For details on client
  1220. classes, see <xref linkend="dhcp4-client-classifier"/>. This is an
  1221. extension of a previous example from <xref linkend="dhcp4-address-config"/>.
  1222. Let's assume that the server is connected to a network segment that uses
  1223. the 192.0.2.0/24 prefix. The Administrator of that network has decided
  1224. that addresses from range 192.0.2.10 to 192.0.2.20 are going to be
  1225. managed by the Dhcp4 server. Only clients belonging to client class
  1226. VENDOR_CLASS_docsis3.0 are allowed to use this subnet. Such a
  1227. configuration can be achieved in the following way:
  1228. <screen>
  1229. "Dhcp4": {
  1230. "subnet4": [
  1231. {
  1232. <userinput>"subnet": "192.0.2.0/24",
  1233. "pools": [ { "pool": "192.0.2.10 - 192.0.2.20" } ],
  1234. "client-class": "VENDOR_CLASS_docsis3.0"</userinput>
  1235. }
  1236. ],
  1237. ...
  1238. }</screen>
  1239. </para>
  1240. <para>
  1241. Care should be taken with client classification as it is easy for
  1242. clients that do not meet class criteria to be denied any service altogether.
  1243. </para>
  1244. </section>
  1245. </section>
  1246. <section id="dhcp4-ddns-config">
  1247. <title>Configuring DHCPv4 for DDNS</title>
  1248. <para>
  1249. As mentioned earlier, kea-dhcp4 can be configured to generate requests to the
  1250. DHCP-DDNS server (referred to here as "D2" ) to update DNS entries. These requests are known as
  1251. NameChangeRequests or NCRs. Each NCR contains the following information:
  1252. <orderedlist>
  1253. <listitem><para>
  1254. Whether it is a request to add (update) or remove DNS entries
  1255. </para></listitem>
  1256. <listitem><para>
  1257. Whether the change requests forward DNS updates (A records), reverse
  1258. DNS updates (PTR records), or both.
  1259. </para></listitem>
  1260. <listitem><para>
  1261. The FQDN, lease address, and DHCID
  1262. </para></listitem>
  1263. </orderedlist>
  1264. The parameters for controlling the generation of NCRs for submission to D2
  1265. are contained in the <command>dhcp-ddns</command> section of the kea-dhcp4 server
  1266. configuration. The default values for this section are as follows:
  1267. <screen>
  1268. "Dhcp4": {
  1269. "dhcp-ddns": {
  1270. <userinput>"enable-updates": true,
  1271. "server-ip": "127.0.0.1",
  1272. "server-port": 53001,
  1273. "sender-ip": "",
  1274. "sender-port": 0,
  1275. "max-queue-size": 1024,
  1276. "ncr-protocol": "UDP",
  1277. "ncr-format": "JSON",
  1278. "override-no-update": false,
  1279. "override-client-update": false,
  1280. "replace-client-name": false,
  1281. "generated-prefix": "myhost",
  1282. "qualifying-suffix": "example.com"</userinput>
  1283. },
  1284. ...
  1285. }
  1286. </screen>
  1287. </para>
  1288. <section id="dhcpv4-d2-io-config">
  1289. <title>DHCP-DDNS Server Connectivity</title>
  1290. <para>
  1291. In order for NCRs to reach the D2 server, kea-dhcp4 must be able
  1292. to communicate with it. kea-dhcp4 uses the following configuration
  1293. parameters to control how it communications with D2:
  1294. <itemizedlist>
  1295. <listitem><simpara>
  1296. <command>enable-updates</command> - determines whether or not kea-dhcp4 will
  1297. generate NCRs. By default, this value is false hence DDNS updates are
  1298. disabled. To enable DDNS updates set this value to true:
  1299. </simpara></listitem>
  1300. <listitem><simpara>
  1301. <command>server-ip</command> - IP address on which D2 listens for requests. The default is
  1302. the local loopback interface at address 127.0.0.1. You may specify
  1303. either an IPv4 or IPv6 address.
  1304. </simpara></listitem>
  1305. <listitem><simpara>
  1306. <command>server-port</command> - port on which D2 listens for requests. The default value
  1307. is 53001.
  1308. </simpara></listitem>
  1309. <listitem><simpara>
  1310. <command>sender-ip</command> - IP address which kea-dhcp4 should use to send requests to D2.
  1311. The default value is blank which instructs kea-dhcp4 to select a suitable
  1312. address.
  1313. </simpara></listitem>
  1314. <listitem><simpara>
  1315. <command>sender-port</command> - port which kea-dhcp4 should use to send requests to D2. The
  1316. default value of 0 instructs kea-dhcp4 to select a suitable port.
  1317. </simpara></listitem>
  1318. <listitem><simpara>
  1319. <command>max-queue-size</command> - maximum number of requests allowed to queue waiting to
  1320. be sent to D2. This value guards against requests accumulating
  1321. uncontrollably if they are being generated faster than they can be
  1322. delivered. If the number of requests queued for transmission reaches
  1323. this value, DDNS updating will be turned off until the queue backlog has
  1324. been sufficiently reduced. The intention is to allow the kea-dhcp4 server to
  1325. continue lease operations without running the risk that its memory usage
  1326. grows without limit. The default value is 1024.
  1327. </simpara></listitem>
  1328. <listitem><simpara>
  1329. <command>ncr-format</command> - socket protocol use when sending requests to D2. Currently
  1330. only UDP is supported. TCP may be available in an upcoming release.
  1331. </simpara></listitem>
  1332. <listitem><simpara>
  1333. <command>ncr-protocol</command> - packet format to use when sending requests to D2.
  1334. Currently only JSON format is supported. Other formats may be available
  1335. in future releases.
  1336. </simpara></listitem>
  1337. </itemizedlist>
  1338. By default, kea-dhcp-ddns is assumed to be running on the same machine as kea-dhcp4, and
  1339. all of the default values mentioned above should be sufficient.
  1340. If, however, D2 has been configured to listen on a different address or
  1341. port, these values must be altered accordingly. For example, if D2 has been
  1342. configured to listen on 192.168.1.10 port 900, the following configuration
  1343. would be required:
  1344. <screen>
  1345. "Dhcp4": {
  1346. "dhcp-ddns": {
  1347. <userinput>"server-ip": "192.168.1.10",
  1348. "server-port": 900</userinput>,
  1349. ...
  1350. },
  1351. ...
  1352. }
  1353. </screen>
  1354. </para>
  1355. </section>
  1356. <section id="dhcpv4-d2-rules-config">
  1357. <title>When Does the kea-dhcp4 Server Generate DDNS Requests?</title>
  1358. <para>kea-dhcp4 follows the behavior prescribed for DHCP servers in
  1359. <ulink url="http://tools.ietf.org/html/rfc4702">RFC 4702</ulink>.
  1360. It is important to keep in mind that kea-dhcp4 provides the initial decision
  1361. making of when and what to update and forwards that information to D2 in
  1362. the form of NCRs. Carrying out the actual DNS updates and dealing with
  1363. such things as conflict resolution are within the purview of D2 itself (<xref linkend="dhcp-ddns-server"/>).
  1364. This section describes when kea-dhcp4 will generate NCRs and the
  1365. configuration parameters that can be used to influence this decision.
  1366. It assumes that the "enable-updates" parameter is true.
  1367. </para>
  1368. <para>
  1369. In general, kea-dhcp4 will generate DDNS update requests when:
  1370. <orderedlist>
  1371. <listitem><para>
  1372. A new lease is granted in response to a DHCP REQUEST
  1373. </para></listitem>
  1374. <listitem><para>
  1375. An existing lease is renewed but the FQDN associated with it has
  1376. changed.
  1377. </para></listitem>
  1378. <listitem><para>
  1379. An existing lease is released in response to a DHCP RELEASE
  1380. </para></listitem>
  1381. </orderedlist>
  1382. In the second case, lease renewal, two DDNS requests will be issued: one
  1383. request to remove entries for the previous FQDN and a second request to
  1384. add entries for the new FQDN. In the last case, a lease release, a
  1385. single DDNS request to remove its entries will be made. The decision
  1386. making involved when granting a new lease (the first case) is more
  1387. involved and is discussed next.
  1388. </para>
  1389. <para>
  1390. When a new lease is granted, kea-dhcp4 will generate a DDNS
  1391. update request if the DHCP REQUEST contains either the FQDN option
  1392. (code 81) or the Host Name option (code 12). If both are present,
  1393. the server will use the FQDN option. By default kea-dhcp4
  1394. will respect the FQDN N and S flags specified by the client as shown
  1395. in the following table:
  1396. </para>
  1397. <table id="fqdn-flag-table">
  1398. <title>Default FQDN Flag Behavior</title>
  1399. <tgroup cols='4' align='left'>
  1400. <colspec colname='cflags'/>
  1401. <colspec colname='meaning'/>
  1402. <colspec colname='response'/>
  1403. <colspec colname='sflags'/>
  1404. <thead>
  1405. <row>
  1406. <entry>Client Flags:N-S</entry>
  1407. <entry>Client Intent</entry>
  1408. <entry>Server Response</entry>
  1409. <entry>Server Flags:N-S-O</entry>
  1410. </row>
  1411. </thead>
  1412. <tbody>
  1413. <row>
  1414. <entry>0-0</entry>
  1415. <entry>
  1416. Client wants to do forward updates, server should do reverse updates
  1417. </entry>
  1418. <entry>Server generates reverse-only request</entry>
  1419. <entry>1-0-0</entry>
  1420. </row>
  1421. <row>
  1422. <entry>0-1</entry>
  1423. <entry>Server should do both forward and reverse updates</entry>
  1424. <entry>Server generates request to update both directions</entry>
  1425. <entry>0-1-0</entry>
  1426. </row>
  1427. <row>
  1428. <entry>1-0</entry>
  1429. <entry>Client wants no updates done</entry>
  1430. <entry>Server does not generate a request</entry>
  1431. <entry>1-0-0</entry>
  1432. </row>
  1433. </tbody>
  1434. </tgroup>
  1435. </table>
  1436. <para>
  1437. The first row in the table above represents "client delegation". Here
  1438. the DHCP client states that it intends to do the forward DNS updates and
  1439. the server should do the reverse updates. By default, kea-dhcp4 will honor
  1440. the client's wishes and generate a DDNS request to the DHCP-DDNS server to update only
  1441. reverse DNS data. The parameter <command>override-client-update</command> can be used
  1442. to instruct the server to override client delegation requests. When
  1443. this parameter is true, kea-dhcp4 will disregard requests for client
  1444. delegation and generate a DDNS request to update both forward and
  1445. reverse DNS data. In this case, the N-S-O flags in the server's
  1446. response to the client will be 0-1-1 respectively.
  1447. </para>
  1448. <para>
  1449. (Note that the flag combination N=1, S=1 is prohibited according to
  1450. <ulink url="http://tools.ietf.org/html/rfc4702">RFC 4702</ulink>. If such a combination is received from the client, the packet
  1451. will be dropped by kea-dhcp4.)
  1452. </para>
  1453. <para>
  1454. To override client delegation, set the following values in your configuration
  1455. file:
  1456. </para>
  1457. <screen>
  1458. "Dhcp4": {
  1459. "dhcp-ddns": {
  1460. <userinput>"override-client-update": true</userinput>,
  1461. ...
  1462. },
  1463. ...
  1464. }
  1465. </screen>
  1466. <para>
  1467. The third row in the table above describes the case in which the client
  1468. requests that no DNS updates be done. The parameter, <command>override-no-update</command>,
  1469. can be used to instruct the server to disregard the client's wishes. When
  1470. this parameter is true, kea-dhcp4 will generate a DDNS update request to kea-dhcp-ddns
  1471. even if the client requests that no updates be done. The N-S-O flags in the
  1472. server's response to the client will be 0-1-1.
  1473. </para>
  1474. <para>
  1475. To override client delegation, the following values should be set in your configuration:
  1476. </para>
  1477. <screen>
  1478. "Dhcp4": {
  1479. "dhcp-ddns": {
  1480. <userinput>"override-no-update": true</userinput>,
  1481. ...
  1482. },
  1483. ...
  1484. }
  1485. </screen>
  1486. <para>
  1487. kea-dhcp4 will always generate DDNS update requests if the client request
  1488. only contains the Host Name option. In addition it will include an FQDN
  1489. option in the response to the client with the FQDN N-S-O flags set to
  1490. 0-1-0 respectively. The domain name portion of the FQDN option will be
  1491. the name submitted to D2 in the DDNS update request.
  1492. </para>
  1493. </section>
  1494. <section id="dhcpv4-fqdn-name-generation">
  1495. <title>kea-dhcp4 name generation for DDNS update requests</title>
  1496. <para>Each NameChangeRequest must of course include the fully qualified domain
  1497. name whose DNS entries are to be affected. kea-dhcp4 can be configured to
  1498. supply a portion or all of that name based upon what it receives from
  1499. the client in the DHCP REQUEST.</para>
  1500. <para>
  1501. The rules for determining the FQDN option are as follows:
  1502. <orderedlist>
  1503. <listitem><para>
  1504. If configured to do, so ignore the REQUEST contents and generate a
  1505. FQDN using a configurable prefix and suffix.
  1506. </para></listitem>
  1507. <listitem><para>
  1508. If the REQUEST contains the client FQDN option, the candidate
  1509. name is taken from there, otherwise it is taken from the Host Name option.
  1510. The candidate name may then be modified:
  1511. <orderedlist>
  1512. <listitem><para>
  1513. If the candidate name is a fully qualified domain name, use it.
  1514. </para></listitem>
  1515. <listitem><para>
  1516. If the candidate name is a partial (i.e. unqualified) name then
  1517. add a configurable suffix to the name and use the result as the FQDN.
  1518. </para></listitem>
  1519. <listitem><para>
  1520. If the candidate name is a empty, generate a FQDN using a
  1521. configurable prefix and suffix.
  1522. </para></listitem>
  1523. </orderedlist>
  1524. </para></listitem>
  1525. </orderedlist>
  1526. To instruct kea-dhcp4 to always generate the FQDN for a client, set the
  1527. parameter <command>replace-client-name</command> to true as follows:
  1528. </para>
  1529. <screen>
  1530. "Dhcp4": {
  1531. "dhcp-ddns": {
  1532. <userinput>"replace-client-name": true</userinput>,
  1533. ...
  1534. },
  1535. ...
  1536. }
  1537. </screen>
  1538. <para>
  1539. The prefix used in the generation of a FQDN is specified by the
  1540. <command>generated-prefix</command> parameter. The default value is "myhost". To alter
  1541. its value simply set it to the desired string:
  1542. </para>
  1543. <screen>
  1544. "Dhcp4": {
  1545. "dhcp-ddns": {
  1546. <userinput>"generated-prefix": "another.host"</userinput>,
  1547. ...
  1548. },
  1549. ...
  1550. }
  1551. </screen>
  1552. <para>
  1553. The suffix used when generating a FQDN or when qualifying a partial name
  1554. is specified by the <command>qualifying-suffix</command> parameter. There
  1555. is no default value. To set its value simply set it to the desired string:
  1556. </para>
  1557. <screen>
  1558. "Dhcp4": {
  1559. "dhcp-ddns": {
  1560. <userinput>"qualifying-suffix": "foo.example.org"</userinput>,
  1561. ...
  1562. },
  1563. ...
  1564. }
  1565. </screen>
  1566. </section>
  1567. <para>
  1568. When generating a name, kea-dhcp4 will construct name of the format:
  1569. </para>
  1570. <para>
  1571. [generated-prefix]-[address-text].[qualifying-suffix].
  1572. </para>
  1573. <para>
  1574. where address-text is simply the lease IP address converted to a
  1575. hyphenated string. For example, if the lease address is 172.16.1.10 and
  1576. default values are used for
  1577. <command>generated-prefix</command> and <command>qualifying-suffix</command>, the
  1578. generated FQDN would be:
  1579. </para>
  1580. <para>
  1581. myhost-172-16-1-10.example.com.
  1582. </para>
  1583. </section>
  1584. <section id="dhcp4-next-server">
  1585. <title>Next Server (siaddr)</title>
  1586. <para>In some cases, clients want to obtain configuration from the TFTP server.
  1587. Although there is a dedicated option for it, some devices may use the siaddr field
  1588. in the DHCPv4 packet for that purpose. That specific field can be configured
  1589. using <command>next-server</command> directive. It is possible to define it in the global scope or
  1590. for a given subnet only. If both are defined, the subnet value takes precedence.
  1591. The value in subnet can be set to 0.0.0.0, which means that <command>next-server</command> should
  1592. not be sent. It may also be set to an empty string, which means the same as if
  1593. it was not defined at all, i.e. use the global value.
  1594. </para>
  1595. <screen>
  1596. "Dhcp4": {
  1597. <userinput>"next-server": "192.0.2.123"</userinput>,
  1598. ...,
  1599. "subnet4": {
  1600. [
  1601. <userinput>"next-server": "192.0.2.234"</userinput>,
  1602. ...
  1603. ]
  1604. }
  1605. }
  1606. </screen>
  1607. </section>
  1608. <section id="dhcp4-echo-client-id">
  1609. <title>Echoing Client-ID (RFC 6842)</title>
  1610. <para>The original DHCPv4 specification
  1611. (<ulink url="http://tools.ietf.org/html/rfc2131">RFC 2131</ulink>)
  1612. states that the DHCPv4
  1613. server must not send back client-id options when responding to
  1614. clients. However, in some cases that confused clients that did
  1615. not have MAC address or client-id; see
  1616. <ulink url="http://tools.ietf.org/html/rfc6842">RFC 6842</ulink>.
  1617. for details. That
  1618. behavior has changed with the publication of
  1619. <ulink url="http://tools.ietf.org/html/rfc6842">RFC 6842</ulink>.
  1620. which updated
  1621. <ulink url="http://tools.ietf.org/html/rfc2131">RFC 2131</ulink>.
  1622. That update now states that the server must
  1623. send client-id if the client sent it. That is the default behaviour
  1624. that Kea offers. However, in some cases older devices that do
  1625. not support
  1626. <ulink url="http://tools.ietf.org/html/rfc6842">RFC 6842</ulink>.
  1627. may refuse to accept responses that include the
  1628. client-id option. To enable backward compatibility, an optional
  1629. configuration parameter has been introduced. To configure it,
  1630. use the following configuration statement:</para>
  1631. <screen>
  1632. "Dhcp4": {
  1633. <userinput>"echo-client-id": false</userinput>,
  1634. ...
  1635. }
  1636. </screen>
  1637. </section>
  1638. </section> <!-- end of configuring kea-dhcp4 server section with many subsections -->
  1639. <section id="dhcp4-serverid">
  1640. <title>Server Identifier in DHCPv4</title>
  1641. <para>
  1642. The DHCPv4 protocol uses a "server identifier" to allow clients
  1643. to discriminate between several servers present on the same link: this
  1644. value is an IPv4 address of the server. The server chooses the IPv4 address
  1645. of the interface on which the message from the client (or relay) has been
  1646. received. A single server instance will use multiple server identifiers
  1647. if it is receiving queries on multiple interfaces.
  1648. </para>
  1649. <para>
  1650. Currently there is no mechanism to override the default server identifiers
  1651. by an administrator. In the future, the configuration mechanism will be used
  1652. to specify the custom server identifier.
  1653. </para>
  1654. </section>
  1655. <section id="dhcp4-subnet-selection">
  1656. <title>How the DHCPv4 Server Selects a Subnet for the Client</title>
  1657. <para>
  1658. The DHCPv4 server differentiates between the directly connected clients,
  1659. clients trying to renew leases and clients sending their messages through
  1660. relays. For the directly connected clients the server will check the
  1661. configuration for the interface on which the message has been received, and
  1662. if the server configuration doesn't match any configured subnet the
  1663. message is discarded.</para>
  1664. <para>Assuming that the server's interface is configured with the
  1665. IPv4 address 192.0.2.3, the server will only process messages received through
  1666. this interface from a directly connected client if there is a subnet
  1667. configured to which this IPv4 address belongs, e.g. 192.0.2.0/24.
  1668. The server will use this subnet to assign IPv4 address for the client.
  1669. </para>
  1670. <para>
  1671. The rule above does not apply when the client unicasts its message, i.e.
  1672. is trying to renew its lease. Such a message is accepted through any
  1673. interface. The renewing client sets ciaddr to the currently used IPv4
  1674. address. The server uses this address to select the subnet for the client
  1675. (in particular, to extend the lease using this address).
  1676. </para>
  1677. <para>
  1678. If the message is relayed it is accepted through any interface. The giaddr
  1679. set by the relay agent is used to select the subnet for the client.
  1680. </para>
  1681. <para>
  1682. It is also possible to specify a relay IPv4 address for a given subnet. It
  1683. can be used to match incoming packets into a subnet in uncommon configurations,
  1684. e.g. shared subnets. See <xref linkend="dhcp4-relay-override"/> for details.
  1685. </para>
  1686. <note>
  1687. <para>The subnet selection mechanism described in this section is based
  1688. on the assumption that client classification is not used. The classification
  1689. mechanism alters the way in which a subnet is selected for the client,
  1690. depending on the classes to which the client belongs.</para>
  1691. </note>
  1692. <section id="dhcp4-relay-override">
  1693. <title>Using a Specific Relay Agent for a Subnet</title>
  1694. <para>
  1695. The relay has to have an interface connected to the link on which
  1696. the clients are being configured. Typically the relay has an IPv4
  1697. address configured on that interface that belongs to the subnet from which
  1698. the server will assign addresses. In the typical case, the
  1699. server is able to use the IPv4 address inserted by the relay (in the giaddr
  1700. field of the DHCPv4 packet) to select the appropriate subnet.
  1701. </para>
  1702. <para>
  1703. However, that is not always the case. In certain uncommon &mdash;
  1704. valid &mdash; deployments, the relay address may not match the subnet. This
  1705. usually means that there is more than one subnet allocated for a given
  1706. link. The two most common examples where this is the case are long lasting
  1707. network renumbering (where both old and new address space is still being
  1708. used) and a cable network. In a cable network both cable modems and the
  1709. devices behind them are physically connected to the same link, yet
  1710. they use distinct addressing. In such a case, the DHCPv4 server needs
  1711. additional information (the IPv4 address of the relay) to properly select
  1712. an appropriate subnet.
  1713. </para>
  1714. <para>
  1715. The following example assumes that there is a subnet 192.0.2.0/24
  1716. that is accessible via a relay that uses 10.0.0.1 as its IPv4 address.
  1717. The server will be able to select this subnet for any incoming packets
  1718. that came from a relay that has an address in 192.0.2.0/24 subnet.
  1719. It will also select that subnet for a relay with address 10.0.0.1.
  1720. <screen>
  1721. "Dhcp4": {
  1722. "subnet4": [
  1723. {
  1724. "subnet": "192.0.2.0/24",
  1725. "pools": [ { "pool": "192.0.2.10 - 192.0.2.20" } ],
  1726. <userinput>"relay": {
  1727. "ip-address": "10.0.0.1"
  1728. }</userinput>,
  1729. ...
  1730. }
  1731. ],
  1732. ...
  1733. }
  1734. </screen>
  1735. </para>
  1736. </section>
  1737. <section id="dhcp4-srv-example-client-class-relay">
  1738. <title>Segregating IPv4 Clients in a Cable Network</title>
  1739. <para>
  1740. In certain cases, it is useful to mix relay address information,
  1741. introduced in <xref linkend="dhcp4-relay-override"/> with client
  1742. classification, explained in <xref linkend="dhcp4-subnet-class"/>.
  1743. One specific example is cable network, where typically modems
  1744. get addresses from a different subnet than all devices connected
  1745. behind them.
  1746. </para>
  1747. <para>
  1748. Let's assume that there is one CMTS (Cable Modem Termination System)
  1749. with one CM MAC (a physical link that modems are connected to).
  1750. We want the modems to get addresses from the 10.1.1.0/24 subnet, while
  1751. everything connected behind modems should get addresses from another
  1752. subnet (192.0.2.0/24). The CMTS that acts as a relay uses address
  1753. 10.1.1.1. The following configuration can serve that configuration:
  1754. <screen>
  1755. "Dhcp4": {
  1756. "subnet4": [
  1757. {
  1758. "subnet": "10.1.1.0/24",
  1759. "pools": [ { "pool": "10.1.1.2 - 10.1.1.20" } ],
  1760. <userinput>"client-class" "docsis3.0",
  1761. "relay": {
  1762. "ip-address": "10.1.1.1"
  1763. }</userinput>
  1764. },
  1765. {
  1766. "subnet": "192.0.2.0/24",
  1767. "pools": [ { "pool": "192.0.2.10 - 192.0.2.20" } ],
  1768. <userinput>"relay": {
  1769. "ip-address": "10.1.1.1"
  1770. }</userinput>
  1771. }
  1772. ],
  1773. ...
  1774. }
  1775. </screen>
  1776. </para>
  1777. </section>
  1778. </section>
  1779. <section id="dhcp4-std">
  1780. <title>Supported DHCP Standards</title>
  1781. <para>The following standards are currently supported:</para>
  1782. <itemizedlist>
  1783. <listitem>
  1784. <simpara><emphasis>Dynamic Host Configuration Protocol</emphasis>,
  1785. <ulink url="http://tools.ietf.org/html/rfc2131">RFC 2131</ulink>:
  1786. Supported messages are DISCOVER (1), OFFER (2),
  1787. REQUEST (3), RELEASE (7), INFORM (8), ACK (5), and NAK(6).</simpara>
  1788. </listitem>
  1789. <listitem>
  1790. <simpara><emphasis>DHCP Options and BOOTP Vendor Extensions</emphasis>,
  1791. <ulink url="http://tools.ietf.org/html/rfc2132">RFC 2132</ulink>:
  1792. Supported options are: PAD (0),
  1793. END(255), Message Type(53), DHCP Server Identifier (54),
  1794. Domain Name (15), DNS Servers (6), IP Address Lease Time
  1795. (51), Subnet mask (1), and Routers (3).</simpara>
  1796. </listitem>
  1797. <listitem>
  1798. <simpara><emphasis>DHCP Relay Agent Information Option</emphasis>,
  1799. <ulink url="http://tools.ietf.org/html/rfc3046">RFC 3046</ulink>:
  1800. Relay Agent Information option is supported.</simpara>
  1801. </listitem>
  1802. <listitem>
  1803. <simpara><emphasis>Vendor-Identifying Vendor Options for
  1804. Dynamic Host Configuration Protocol version 4</emphasis>,
  1805. <ulink url="http://tools.ietf.org/html/rfc3925">RFC 3925</ulink>:
  1806. Vendor-Identifying Vendor Class and Vendor-Identifying Vendor-Specific
  1807. Information options are supported.</simpara>
  1808. </listitem>
  1809. <listitem>
  1810. <simpara><emphasis>Client Identifier Option in DHCP Server Replies</emphasis>,
  1811. <ulink url="http://tools.ietf.org/html/rfc6842">RFC 6842</ulink>:
  1812. Server by default sends back client-id option. That capability may be
  1813. disabled. See <xref linkend="dhcp4-echo-client-id"/> for details.
  1814. </simpara>
  1815. </listitem>
  1816. </itemizedlist>
  1817. </section>
  1818. <section id="dhcp4-limit">
  1819. <title>DHCPv4 Server Limitations</title>
  1820. <para>These are the current limitations of the DHCPv4 server
  1821. software. Most of them are reflections of the current stage of
  1822. development and should be treated as <quote>not implemented
  1823. yet</quote>, rather than actual limitations. However, some of them
  1824. are implications of the design choices made. Those are clearly
  1825. marked as such.</para>
  1826. <itemizedlist>
  1827. <listitem> <!-- see tickets #3234, #3281 -->
  1828. <simpara>
  1829. Removal of a subnet during server reconfiguration may cause renumbering
  1830. of auto-generated subnet identifiers, as described in section
  1831. <xref linkend="ipv4-subnet-id"/>.
  1832. </simpara>
  1833. </listitem>
  1834. <listitem>
  1835. <simpara>Host reservation (static addresses) is not supported yet.</simpara>
  1836. </listitem>
  1837. <listitem>
  1838. <simpara>Full featured client classification is not supported yet.</simpara>
  1839. </listitem>
  1840. <listitem>
  1841. <simpara>
  1842. BOOTP (<ulink url="http://tools.ietf.org/html/rfc951">RFC 951</ulink>)
  1843. is not supported. This is a design choice. BOOTP support is not planned.
  1844. </simpara>
  1845. </listitem>
  1846. <listitem>
  1847. <simpara>On Linux and BSD system families the DHCP messages are sent
  1848. and received over the raw sockets (using LPF and BPF) and all packet
  1849. headers (including data link layer, IP and UDP headers) are created and
  1850. parsed by Kea, rather than the system kernel. Currently, Kea can
  1851. only parse the data link layer headers with a format adhering to
  1852. IEEE 802.3 standard and assumes this data link layer header format
  1853. for all interfaces. Hence, Kea will fail to work on interfaces
  1854. which use different data link layer header formats (e.g. Infiniband).
  1855. </simpara>
  1856. </listitem>
  1857. <listitem>
  1858. <simpara>The DHCPv4 server does not verify that
  1859. assigned address is unused. According to <ulink url="http://tools.ietf.org/html/rfc2131">RFC 2131</ulink>, the
  1860. allocating server should verify that address is not used by
  1861. sending ICMP echo request.</simpara>
  1862. </listitem>
  1863. <listitem>
  1864. <simpara>Address duplication report (DECLINE) is not supported yet.</simpara>
  1865. </listitem>
  1866. <listitem>
  1867. <simpara>
  1868. The server doesn't act upon expired leases. In particular,
  1869. when a lease expires, the server doesn't request the removal
  1870. of the DNS records associated with it. Expired leases can be
  1871. recycled.
  1872. </simpara>
  1873. </listitem>
  1874. </itemizedlist>
  1875. </section>
  1876. <!--
  1877. <section id="dhcp4-srv-examples">
  1878. <title>Kea DHCPv4 server examples</title>
  1879. <para>
  1880. This section provides easy to use example. Each example can be read
  1881. separately. It is not intended to be read sequentially as there will
  1882. be many repetitions between examples. They are expected to serve as
  1883. easy to use copy-paste solutions to many common deployments.
  1884. </para>
  1885. @todo: add simple configuration for direct clients
  1886. @todo: add configuration for relayed clients
  1887. @todo: add client classification example
  1888. </section> -->
  1889. </chapter>