dhcp4-srv.xml 110 KB

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