dhcp4-srv.xml 172 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850
  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. <para>
  11. It is recommended that the Kea DHCPv4 server be started and stopped
  12. using <command>keactrl</command> (described in <xref linkend="keactrl"/>).
  13. However, it is also possible to run the server directly: it accepts
  14. the following command-line switches:
  15. </para>
  16. <itemizedlist>
  17. <listitem>
  18. <simpara>
  19. <command>-c <replaceable>file</replaceable></command> -
  20. specifies the configuration file. This is the only mandatory
  21. switch.</simpara>
  22. </listitem>
  23. <listitem>
  24. <simpara>
  25. <command>-d</command> - specifies whether the server
  26. logging should be switched to debug/verbose mode. In verbose mode,
  27. the logging severity and debuglevel specified in the configuration
  28. file are ignored and "debug" severity and the maximum debuglevel
  29. (99) are assumed. The flag is convenient, for temporarily
  30. switching the server into maximum verbosity, e.g. when
  31. debugging.</simpara>
  32. </listitem>
  33. <listitem>
  34. <simpara>
  35. <command>-p <replaceable>port</replaceable></command> -
  36. specifies UDP port on which the server will listen. This is only
  37. useful during testing, as a DHCPv4 server listening on
  38. ports other than the standard ones will not be able to
  39. handle regular DHCPv4 queries.</simpara>
  40. </listitem>
  41. <listitem>
  42. <simpara>
  43. <command>-v</command> - prints out the Kea version and exits.
  44. </simpara>
  45. </listitem>
  46. <listitem>
  47. <simpara>
  48. <command>-V</command> - prints out the Kea extended version with
  49. additional parameters and exits. The listing includes the versions
  50. of the libraries dynamically linked to Kea.
  51. </simpara>
  52. </listitem>
  53. <listitem>
  54. <simpara>
  55. <command>-W</command> - prints out the Kea configuration report
  56. and exits. The report is a copy of the
  57. <filename>config.report</filename> file produced by
  58. <userinput>./configure</userinput>: it is embedded in the
  59. executable binary.
  60. </simpara>
  61. </listitem>
  62. </itemizedlist>
  63. <para>
  64. The <filename>config.report</filename> may also be accessed more
  65. directly. The following command may be used to extract this
  66. information. The binary <userinput>path</userinput> may be found
  67. in the install directory or in the <filename>.libs</filename>
  68. subdirectory in the source tree. For example
  69. <filename>kea/src/bin/dhcp4/.libs/kea-dhcp4</filename>.
  70. <screen>
  71. strings <userinput>path</userinput>/kea-dhcp4 | sed -n 's/;;;; //p'
  72. </screen>
  73. </para>
  74. <para>
  75. On start-up, the server will detect available network interfaces
  76. and will attempt to open UDP sockets on all interfaces
  77. mentioned in the configuration file.
  78. Since the DHCPv4 server opens privileged ports, it requires root
  79. access. Make sure you run this daemon as root.
  80. </para>
  81. <para>
  82. During startup the server will attempt to create a PID file of the
  83. form: localstatedir]/[conf name].kea-dhcp6.pid where:
  84. <itemizedlist>
  85. <listitem>
  86. <simpara><command>localstatedir</command>: The value as passed into the
  87. build configure script. It defaults to "/usr/local/var". (Note
  88. that this value may be overridden at run time by setting the environment
  89. variable KEA_PIDFILE_DIR. This is intended primarily for testing purposes.)
  90. </simpara>
  91. </listitem>
  92. <listitem>
  93. <simpara><command>conf name</command>: The configuration file name
  94. used to start the server, minus all preceding path and file extension.
  95. For example, given a pathname of "/usr/local/etc/kea/myconf.txt", the
  96. portion used would be "myconf".
  97. </simpara>
  98. </listitem>
  99. </itemizedlist>
  100. If the file already exists and contains the PID of a live process,
  101. the server will issue a DHCP4_ALREADY_RUNNING log message and exit. It
  102. is possible, though unlikely, that the file is a remnant of a system crash
  103. and the process to which the PID belongs is unrelated to Kea. In such a
  104. case it would be necessary to manually delete the PID file.
  105. </para>
  106. <para>
  107. The server can be stopped using the <command>kill</command> command.
  108. When running in a console, the server can also be shut down by
  109. pressing ctrl-c. It detects the key combination and shuts
  110. down gracefully.
  111. </para>
  112. </section>
  113. <section id="dhcp4-configuration">
  114. <title>DHCPv4 Server Configuration</title>
  115. <section>
  116. <title>Introduction</title>
  117. <para>
  118. This section explains how to configure the DHCPv4 server using the
  119. Kea configuration backend. (Kea configuration using any other
  120. backends is outside of scope of this document.) Before DHCPv4
  121. is started, its configuration file has to be created. The
  122. basic configuration is as follows:
  123. <screen>
  124. {
  125. # DHCPv4 configuration starts in this line
  126. "Dhcp4": {
  127. # First we set up global values
  128. "valid-lifetime": 4000,
  129. "renew-timer": 1000,
  130. "rebind-timer": 2000,
  131. # Next we setup the interfaces to be used by the server.
  132. "interfaces-config": {
  133. "interfaces": [ "eth0" ]
  134. },
  135. # And we specify the type of lease database
  136. "lease-database": {
  137. "type": "memfile",
  138. "persist": true,
  139. "name": "/var/kea/dhcp4.leases"
  140. },
  141. # Finally, we list the subnets from which we will be leasing addresses.
  142. "subnet4": [
  143. {
  144. "subnet": "192.0.2.0/24",
  145. "pools": [
  146. {
  147. "pool": "192.0.2.1 - 192.0.2.200"
  148. }
  149. ]
  150. }
  151. ]
  152. # DHCPv4 configuration ends with the next line
  153. }
  154. } </screen>
  155. </para>
  156. <para>The following paragraphs provide a brief overview of the parameters in
  157. the above example together with
  158. their format. Subsequent sections of this chapter go into much greater detail
  159. for these and other parameters.</para>
  160. <para>The lines starting with a hash (#) are comments and are ignored by
  161. the server; they do not impact its
  162. operation in any way.</para>
  163. <para>The configuration starts in the first line with the initial
  164. opening curly bracket (or brace). Each configuration consists of
  165. one or more objects. In this specific example, we have only one
  166. object, called Dhcp4. This is a simplified configuration, as usually
  167. there will be additional objects, like <command>Logging</command> or
  168. <command>DhcpDns</command>, but we omit them now for clarity. The Dhcp4
  169. configuration starts with the <command>"Dhcp4": {</command> line
  170. and ends with the corresponding closing brace (in the above example,
  171. the brace after the last comment). Everything defined between those
  172. lines is considered to be the Dhcp4 configuration.</para>
  173. <para>In the general case, the order in which those parameters appear does not
  174. matter. There are two caveats here though. The first one is to remember that
  175. the configuration file must be well formed JSON. That means that the parameters
  176. for any given scope must be separated by a comma and there must not be a comma
  177. after the last parameter. When reordering a configuration file, keep in mind that
  178. moving a parameter to or from the last position in a given scope may also require
  179. moving the comma. The second caveat is that it is uncommon &mdash; although
  180. legal JSON &mdash; to
  181. repeat the same parameter multiple times. If that happens, the last occurrence of a
  182. given parameter in a given scope is used while all previous instances are
  183. ignored. This is unlikely to cause any confusion as there are no real life
  184. reasons to keep multiple copies of the same parameter in your configuration
  185. file.</para>
  186. <para>Moving onto the DHCPv4 configuration elements, the first few elements
  187. define some global parameters. <command>valid-lifetime</command>
  188. defines for how long the addresses (leases) given out by the
  189. server are valid. If nothing changes, a client that got an address is allowed to
  190. use it for 4000 seconds. (Note that integer numbers are specified as is,
  191. without any quotes around them.) <command>renew-timer</command> and
  192. <command>rebind-timer</command> are values (also in seconds) that
  193. define T1 and T2 timers that govern when the client will begin the renewal and
  194. rebind procedures. Note that <command>renew-timer</command> and
  195. <command>rebind-timer</command> are optional. If they are not specified the
  196. client will select values for T1 and T2 timers according to the
  197. <ulink url="http://tools.ietf.org/html/rfc2131">RFC 2131</ulink>.</para>
  198. <para>The <command>interfaces-config</command> map specifies the server
  199. configuration concerning the network interfaces, on which the server should
  200. listen to the DHCP messages. The <command>interfaces</command> parameter
  201. specifies a list of network interfaces on which the server should listen.
  202. Lists are opened and closed with square brackets, with elements separated
  203. by commas. Had we wanted to listen on two interfaces, the
  204. <command>interfaces-config</command> would look like this:
  205. <screen>
  206. "interfaces-config": {
  207. "interfaces": [ "eth0", "eth1" ]
  208. },
  209. </screen>
  210. </para>
  211. <para>The next couple of lines define the lease database, the place where the server
  212. stores its lease information. This particular example tells the server to use
  213. <command>memfile</command>, which is the simplest (and fastest) database
  214. backend. It uses an in-memory database and stores leases on disk in a CSV
  215. file. This is a very simple configuration. Usually the lease database configuration
  216. is more extensive and contains additional parameters. Note that
  217. <command>lease-database</command>
  218. is an object and opens up a new scope, using an opening brace.
  219. Its parameters (just one in this example - <command>type</command>)
  220. follow. Had there been more than one, they would be separated by commas. This
  221. scope is closed with a closing brace. As more parameters for the Dhcp4 definition
  222. follow, a trailing comma is present.</para>
  223. <para>Finally, we need to define a list of IPv4 subnets. This is the
  224. most important DHCPv4 configuration structure as the server uses that
  225. information to process clients' requests. It defines all subnets from
  226. which the server is expected to receive DHCP requests. The subnets are
  227. specified with the <command>subnet4</command> parameter. It is a list,
  228. so it starts and ends with square brackets. Each subnet definition in
  229. the list has several attributes associated with it, so it is a structure
  230. and is opened and closed with braces. At a minimum, a subnet definition
  231. has to have at least two parameters: <command>subnet</command> (that
  232. defines the whole subnet) and <command>pools</command> (which is a list of
  233. dynamically allocated pools that are governed by the DHCP server).</para>
  234. <para>The example contains a single subnet. Had more than one been defined,
  235. additional elements
  236. in the <command>subnet4</command> parameter would be specified and
  237. separated by commas. For example, to define three subnets, the following
  238. syntax would be used:
  239. <screen>
  240. "subnet4": [
  241. {
  242. "pools": [ { "pool": "192.0.2.1 - 192.0.2.200" } ],
  243. "subnet": "192.0.2.0/24"
  244. },
  245. {
  246. "pools": [ { "pool": "192.0.3.100 - 192.0.3.200" } ],
  247. "subnet": "192.0.3.0/24"
  248. },
  249. {
  250. "pools": [ { "pool": "192.0.4.1 - 192.0.4.254" } ],
  251. "subnet": "192.0.4.0/24"
  252. }
  253. ]
  254. </screen>
  255. Note that indentation is optional and is used for aesthetic purposes only.
  256. In some cases in may be preferable to use more compact notation.
  257. </para>
  258. <para>After all the parameters have been specified, we have two contexts open:
  259. global and Dhcp4, hence we need two closing curly brackets to close them.
  260. In a real life configuration file there most likely would be additional
  261. components defined such as Logging or DhcpDdns, so the closing brace would
  262. be followed by a comma and another object definition.</para>
  263. </section>
  264. <section>
  265. <title>Lease Storage</title>
  266. <para>All leases issued by the server are stored in the lease database.
  267. Currently there are four database backends available: memfile (which is the
  268. default backend), MySQL, PostgreSQL and Cassandra.</para>
  269. <section>
  270. <title>Memfile - Basic Storage for Leases</title>
  271. <para>The server is able to store lease data in different repositories. Larger
  272. deployments may elect to store leases in a database. <xref
  273. linkend="database-configuration4"/> describes this option. In typical
  274. smaller deployments though, the server will store lease information in a CSV file rather
  275. than a database. As well as requiring less administration, an
  276. advantage of using a file for storage is that it
  277. eliminates a dependency on third-party database software.</para>
  278. <para>The configuration of the file backend (Memfile) is controlled through
  279. the Dhcp4/lease-database parameters. The <command>type</command> parameter
  280. is mandatory and it specifies which storage for leases the server should use.
  281. The value of <userinput>"memfile"</userinput> indicates that the file should
  282. be used as the storage. The following list gives additional, optional,
  283. parameters that can be used to configure the Memfile backend.
  284. <itemizedlist>
  285. <listitem>
  286. <simpara><command>persist</command>: controls whether the new leases and
  287. updates to existing leases are written to the file. It is strongly
  288. recommended that the value of this parameter is set to
  289. <userinput>true</userinput> at all times, during the server's normal
  290. operation. Not writing leases to disk will mean that if a server is restarted
  291. (e.g. after a power failure), it will not know what addresses have been
  292. assigned. As a result, it may hand out addresses to new clients that are
  293. already in use. The value of <userinput>false</userinput> is mostly useful
  294. for performance testing purposes. The default value of the
  295. <command>persist</command> parameter is <userinput>true</userinput>,
  296. which enables writing lease updates
  297. to the lease file.
  298. </simpara>
  299. </listitem>
  300. <listitem>
  301. <simpara><command>name</command>: specifies an absolute location of the lease
  302. file in which new leases and lease updates will be recorded. The default value
  303. for this parameter is <userinput>"[kea-install-dir]/var/kea/kea-leases4.csv"
  304. </userinput>.</simpara>
  305. </listitem>
  306. <listitem>
  307. <simpara><command>lfc-interval</command>: specifies the interval in seconds, at
  308. which the server will perform a lease file cleanup (LFC). This
  309. removes redundant (historical) information from the lease file
  310. and effectively reduces the lease file size. The cleanup process is described
  311. in more detailed fashion further in this section. The default value of the
  312. <command>lfc-interval</command> is <userinput>0</userinput>, which disables
  313. the LFC.</simpara>
  314. </listitem>
  315. </itemizedlist>
  316. </para>
  317. <para>An example configuration of the Memfile backend is presented below:
  318. <screen>
  319. "Dhcp4": {
  320. "lease-database": {
  321. <userinput>"type": "memfile"</userinput>,
  322. <userinput>"persist": true</userinput>,
  323. <userinput>"name": "/tmp/kea-leases4.csv",</userinput>
  324. <userinput>"lfc-interval": 1800</userinput>
  325. }
  326. }
  327. </screen>
  328. This configuration selects the <filename>/tmp/kea-leases4.csv</filename> as
  329. the storage for lease information and enables persistence (writing lease updates
  330. to this file). It also configures the backend perform the periodic cleanup
  331. of the lease files, executed every 30 minutes.
  332. </para>
  333. <para>It is important to know how the lease file contents are organized
  334. to understand why the periodic lease file cleanup is needed. Every time
  335. the server updates a lease or creates a new lease for the client, the new
  336. lease information must be recorded in the lease file. For performance reasons,
  337. the server does not update the existing client's lease in the file, as it would
  338. potentially require rewriting the entire file. Instead, it simply appends the new lease
  339. information to the end of the file: the previous lease entries for the
  340. client are not removed. When the server loads leases from the lease file, e.g.
  341. at the server startup, it assumes that the latest lease entry for the client
  342. is the valid one. The previous entries are discarded. This means that the
  343. server can re-construct the accurate information about the leases even though
  344. there may be many lease entries for each client. However, storing many entries
  345. for each client results in bloated lease file and impairs the performance of
  346. the server's startup and reconfiguration as it needs to process a larger number
  347. of lease entries.
  348. </para>
  349. <para>Lease file cleanup (LFC) removes all previous entries for each client and
  350. leaves only the latest ones. The interval at which the cleanup is performed
  351. is configurable, and it should be selected according to the frequency of lease
  352. renewals initiated by the clients. The more frequent the renewals, the smaller
  353. the value of <command>lfc-interval</command> should be. Note however, that the
  354. LFC takes time and thus it is possible (although unlikely) that new cleanup
  355. is started while the previous cleanup instance is still running, if the
  356. <command>lfc-interval</command> is too short. The server would recover from
  357. this by skipping the new cleanup when it detects that the previous cleanup
  358. is still in progress. But it implies that the actual cleanups will be
  359. triggered more rarely than configured. Moreover, triggering a new cleanup
  360. adds an overhead to the server which will not be able to respond to new
  361. requests for a short period of time when the new cleanup process is spawned.
  362. Therefore, it is recommended that the <command>lfc-interval</command> value
  363. is selected in a way that would allow for the LFC to complete the cleanup before a
  364. new cleanup is triggered.
  365. </para>
  366. <para>Lease file cleanup is performed by a separate process (in background) to avoid
  367. a performance impact on the server process. In order to avoid the conflicts
  368. between two processes both using the same lease files, the LFC process
  369. operates on the copy of the original lease file, rather than on the lease
  370. file used by the server to record lease updates. There are also other files
  371. being created as a side effect of the lease file cleanup. The detailed
  372. description of the LFC is located on the Kea wiki:
  373. <ulink url="http://kea.isc.org/wiki/LFCDesign"/>.
  374. </para>
  375. </section>
  376. <section id="database-configuration4">
  377. <title>Lease Database Configuration</title>
  378. <note>
  379. <para>Lease database access information must be configured for the DHCPv4 server,
  380. even if it has already been configured for the DHCPv6 server. The servers
  381. store their information independently, so each server can use a separate
  382. database or both servers can use the same database.</para>
  383. </note>
  384. <para>Lease database configuration is controlled through the Dhcp4/lease-database
  385. parameters. The type of the database must be set to "memfile", "mysql", "postgresql" or
  386. "cql", e.g.
  387. <screen>
  388. "Dhcp4": { "lease-database": { <userinput>"type": "mysql"</userinput>, ... }, ... }
  389. </screen>
  390. Next, the name of the database to hold the leases must be set: this is the
  391. name used when the database was created
  392. (see <xref linkend="mysql-database-create"/>,
  393. <xref linkend="pgsql-database-create"/> or
  394. <xref linkend="cql-database-create"/>).
  395. <screen>
  396. "Dhcp4": { "lease-database": { <userinput>"name": "<replaceable>database-name</replaceable>" </userinput>, ... }, ... }
  397. </screen>
  398. If the database is located on a different system to the DHCPv4 server, the
  399. database host name must also be specified. (It should be noted that this
  400. configuration may have a severe impact on server performance.):
  401. <screen>
  402. "Dhcp4": { "lease-database": { <userinput>"host": <replaceable>remote-host-name</replaceable></userinput>, ... }, ... }
  403. </screen>
  404. The usual state of affairs will be to have the database on the same machine as
  405. the DHCPv4 server. In this case, set the value to the empty string:
  406. <screen>
  407. "Dhcp4": { "lease-database": { <userinput>"host" : ""</userinput>, ... }, ... }
  408. </screen>
  409. Should the database be located on a different system, you may need to specify a longer interval
  410. for the connection timeout:
  411. <screen>
  412. "Dhcp4": { "lease-database": { <userinput>"connect-timeout" : <replaceable>timeout-in-seconds</replaceable></userinput>, ... }, ... }
  413. </screen>
  414. The default value of five seconds should be more than adequate for local connections.
  415. If a timeout is given though, it should be an integer greater than zero.
  416. </para>
  417. <para>Finally, the credentials of the account under which the server will
  418. access the database should be set:
  419. <screen>
  420. "Dhcp4": { "lease-database": { <userinput>"user": "<replaceable>user-name</replaceable>"</userinput>,
  421. <userinput>"password": "<replaceable>password</replaceable>"</userinput>,
  422. ... },
  423. ... }
  424. </screen>
  425. If there is no password to the account, set the password to the empty string
  426. "". (This is also the default.)</para>
  427. </section>
  428. </section>
  429. <section id="hosts4-storage">
  430. <title>Hosts Storage</title>
  431. <para>Kea is also able to store information about host reservations in the
  432. database. The hosts database configuration uses the same syntax as the lease
  433. database. In fact, a Kea server opens independent connections for each
  434. purpose, be it lease or hosts information. This arrangement gives the most
  435. flexibility. Kea can be used to keep leases and host reservations
  436. separately, but can also point to the same database. Currently the
  437. supported hosts database types are MySQL and PostgreSQL. The Cassandra
  438. backend does not support host reservations yet.</para>
  439. <para>Please note that usage of hosts storage is optional. A user can define
  440. all host reservations in the configuration file. That is the recommended way
  441. if the number of reservations is small. However, when the number of
  442. reservations grows it's more convenient to use host storage. Please note
  443. that both storage methods (configuration file and one of the supported databases)
  444. can be used together. If hosts are defined in both places, the definitions
  445. from the configuration file are checked first and external storage is checked
  446. later, if necessary.</para>
  447. <section id="hosts-database-configuration4">
  448. <title>DHCPv4 Hosts Database Configuration</title>
  449. <para>Hosts database configuration is controlled through the Dhcp4/hosts-database
  450. parameters. If enabled, the type of the database must be set to "mysql" or
  451. "postgresql". Other hosts backends may be added in later versions of Kea.
  452. <screen>
  453. "Dhcp4": { "hosts-database": { <userinput>"type": "mysql"</userinput>, ... }, ... }
  454. </screen>
  455. Next, the name of the database to hold the reservations must be set: this is the
  456. name used when the lease database was created (see <xref linkend="supported-databases"/>
  457. for instructions how to setup the desired database type).
  458. <screen>
  459. "Dhcp4": { "hosts-database": { <userinput>"name": "<replaceable>database-name</replaceable>" </userinput>, ... }, ... }
  460. </screen>
  461. If the database is located on a different system than the DHCPv4 server, the
  462. database host name must also be specified. (Again it should be noted that this
  463. configuration may have a severe impact on server performance.):
  464. <screen>
  465. "Dhcp4": { "hosts-database": { <userinput>"host": <replaceable>remote-host-name</replaceable></userinput>, ... }, ... }
  466. </screen>
  467. The usual state of affairs will be to have the database on the same machine as
  468. the DHCPv4 server. In this case, set the value to the empty string:
  469. <screen>
  470. "Dhcp4": { "hosts-database": { <userinput>"host" : ""</userinput>, ... }, ... }
  471. </screen>
  472. </para>
  473. <para>Finally, the credentials of the account under which the server will
  474. access the database should be set:
  475. <screen>
  476. "Dhcp4": { "hosts-database": { <userinput>"user": "<replaceable>user-name</replaceable>"</userinput>,
  477. <userinput>"password": "<replaceable>password</replaceable>"</userinput>,
  478. ... },
  479. ... }
  480. </screen>
  481. If there is no password to the account, set the password to the empty string
  482. "". (This is also the default.)</para>
  483. </section>
  484. <section id="read-only-database-configuration4">
  485. <title>Using Read-Only Databases for Host Reservations</title>
  486. <para>
  487. In some deployments the database user whose name is specified in the database backend
  488. configuration may not have write privileges to the database. This is often
  489. required by the policy within a given network to secure the data from being
  490. unintentionally modified. In many cases administrators have inventory databases
  491. deployed, which contain substantially more information about the hosts than
  492. static reservations assigned to them. The inventory database can be used to create
  493. a view of a Kea hosts database and such view is often read only.
  494. </para>
  495. <para>
  496. Kea host database backends operate with an implicit configuration to both
  497. read from and write to the database. If the database user does not have
  498. write access to the host database, the backend will fail to start and the
  499. server will refuse to start (or reconfigure). However, if access to a read
  500. only host database is required for retrieving reservations for clients
  501. and/or assign specific addresses and options, it is possible to explicitly
  502. configure Kea to start in "read-only" mode. This is controlled by the
  503. <command>readonly</command> boolean parameter as follows:
  504. <screen>
  505. "Dhcp4": { "hosts-database": { <userinput>"readonly": true</userinput>, ... }, ... }
  506. </screen>
  507. Setting this parameter to <userinput>false</userinput> would configure the
  508. database backend to operate in "read-write" mode, which is also a default
  509. configuration if the parameter is not specified.
  510. </para>
  511. <note><para>The <command>readonly</command> parameter is currently only supported
  512. for MySQL and PostgreSQL databases.</para></note>
  513. </section>
  514. </section>
  515. <section id="dhcp4-interface-configuration">
  516. <title>Interface Configuration</title>
  517. <para>The DHCPv4 server has to be configured to listen on specific network
  518. interfaces. The simplest network interface configuration tells the server to
  519. listen on all available interfaces:
  520. <screen>
  521. "Dhcp4": {
  522. "interfaces-config": {
  523. "interfaces": [ <userinput>"*"</userinput> ]
  524. }
  525. ...
  526. },
  527. </screen>
  528. The asterisk plays the role of a wildcard and means "listen on all interfaces".
  529. However, it is usually a good idea to explicitly specify interface names:
  530. <screen>
  531. "Dhcp4": {
  532. "interfaces-config": {
  533. "interfaces": [ <userinput>"eth1", "eth3"</userinput> ]
  534. },
  535. ...
  536. }
  537. </screen>
  538. </para>
  539. <para>It is possible to use wildcard interface name (asterisk) concurrently
  540. with explicit interface names:
  541. <screen>
  542. "Dhcp4": {
  543. "interfaces-config": {
  544. "interfaces": [ <userinput>"eth1", "eth3", "*"</userinput> ]
  545. },
  546. ...
  547. }
  548. </screen>
  549. It is anticipated that this form of usage will only be used when it is desired to
  550. temporarily override a list of interface names and listen on all interfaces.
  551. </para>
  552. <para>Some deployments of DHCP servers require that the servers listen
  553. on the interfaces with multiple IPv4 addresses configured. In these situations,
  554. the address to use can be selected by appending an IPv4 address to the interface
  555. name in the following manner:
  556. <screen>
  557. "Dhcp4": {
  558. "interfaces-config": {
  559. "interfaces": [ <userinput>"eth1/10.0.0.1", "eth3/192.0.2.3"</userinput> ]
  560. },
  561. ...
  562. }
  563. </screen>
  564. </para>
  565. <para>Should the server be required to listen on multiple IPv4 addresses assigned
  566. to the same interface, multiple addresses can be specified for an interface
  567. as in the example below:
  568. <screen>
  569. "Dhcp4": {
  570. "interfaces-config": {
  571. "interfaces": [ <userinput>"eth1/10.0.0.1", "eth1/10.0.0.2"</userinput> ]
  572. },
  573. ...
  574. }
  575. </screen>
  576. </para>
  577. <para>Alternatively, if the server should listen on all addresses for the particular
  578. interface, an interface name without any address should be specified.</para>
  579. <para>Kea supports responding to directly connected clients which don't have
  580. an address configured. This requires that the server
  581. injects the hardware address of the destination into the data link layer
  582. of the packet being sent to the client. The DHCPv4 server utilizes the
  583. raw sockets to achieve this, and builds the entire IP/UDP stack for the
  584. outgoing packets. The down side of raw socket use, however, is that incoming
  585. and outgoing packets bypass the firewalls (e.g. iptables). It is also
  586. troublesome to handle traffic on multiple IPv4 addresses assigned to the
  587. same interface, as raw sockets are bound to the interface and advanced
  588. packet filtering techniques (e.g. using the BPF) have to be used to
  589. receive unicast traffic on the desired addresses assigned to the interface,
  590. rather than capturing whole traffic reaching the interface to which the raw
  591. socket is bound. Therefore, in the deployments where the server doesn't
  592. have to provision the directly connected clients and only receives the
  593. unicast packets from the relay agents, the
  594. DHCP server should be configured to utilize IP/UDP datagram sockets instead of raw sockets.
  595. The following configuration demonstrates how this can be achieved:
  596. <screen>
  597. "Dhcp4": {
  598. "interfaces-config": {
  599. "interfaces": [ <userinput>"eth1", "eth3"</userinput> ],
  600. "dhcp-socket-type": "udp"
  601. },
  602. ...
  603. }
  604. </screen>
  605. The <command>dhcp-socket-type</command> specifies that the IP/UDP sockets will
  606. be opened on all interfaces on which the server listens, i.e. "eth1" and
  607. "eth3" in our case. If the <command>dhcp-socket-type</command> is set to
  608. <userinput>raw</userinput>, it configures the server to use raw sockets
  609. instead. If the <command>dhcp-socket-type</command> value is not specified, the
  610. default value <userinput>raw</userinput> is used.
  611. </para>
  612. <para>Using UDP sockets automatically disables the reception of broadcast
  613. packets from directly connected clients. This effectively means that the
  614. UDP sockets can be used for relayed traffic only. When using the raw sockets,
  615. both the traffic from the directly connected clients and the relayed traffic
  616. will be handled. Caution should be taken when configuring the server to open
  617. multiple raw sockets on the interface with several IPv4 addresses assigned.
  618. If the directly connected client sends the message to the broadcast address
  619. all sockets on this link will receive this message and multiple responses
  620. will be sent to the client. Hence, the configuration with multiple IPv4
  621. addresses assigned to the interface should not be used when the directly
  622. connected clients are operating on that link. To use a single address on
  623. such interface, the "interface-name/address" notation should be used.
  624. </para>
  625. <note>
  626. <para>Specifying the value <userinput>raw</userinput> as the socket type,
  627. doesn't guarantee that the raw sockets will be used! The use of raw sockets
  628. to handle the traffic from the directly connected clients is currently
  629. supported on Linux and BSD systems only. If the raw sockets are not
  630. supported on the particular OS, the server will issue a warning and
  631. fall back to use IP/UDP sockets.</para>
  632. </note>
  633. </section>
  634. <section id="dhcpinform-unicast-issues">
  635. <title>Issues with Unicast Responses to DHCPINFORM</title>
  636. <para>The use of UDP sockets has certain benefits in deployments
  637. where the server receives only relayed traffic; these benefits are
  638. mentioned in <xref linkend="dhcp4-interface-configuration"/>. From
  639. the administrator's perspective it is often desirable to
  640. configure the system's firewall to filter out the unwanted traffic, and
  641. the use of UDP sockets facilitates this. However, the administrator must
  642. also be aware of the implications related to filtering certain types
  643. of traffic as it may impair the DHCP server's operation.
  644. </para>
  645. <para>In this section we are focusing on the case when the server
  646. receives the DHCPINFORM message from the client via a relay. According
  647. to <ulink url="http://tools.ietf.org/html/rfc2131">RFC 2131</ulink>,
  648. the server should unicast the DHCPACK response to the address carried in
  649. the "ciaddr" field. When the UDP socket is in use, the DHCP server
  650. relies on the low level functions of an operating system to build the
  651. data link, IP and UDP layers of the outgoing message. Typically, the
  652. OS will first use ARP to obtain the client's link layer address to be
  653. inserted into the frame's header, if the address is not cached from
  654. a previous transaction that the client had with the server.
  655. When the ARP exchange is successful, the DHCP message can be unicast
  656. to the client, using the obtained address.
  657. </para>
  658. <para>Some system administrators block ARP messages in their network,
  659. which causes issues for the server when it responds to the
  660. DHCPINFORM messages, because the server is unable to send the
  661. DHCPACK if the preceding ARP communication fails. Since the OS is
  662. entirely responsible for the ARP communication and then sending
  663. the DHCP packet over the wire, the DHCP server has no means to
  664. determine that the ARP exchange failed and the DHCP response message
  665. was dropped. Thus, the server does not log any error messages when
  666. the outgoing DHCP response is dropped. At the same time, all hooks
  667. pertaining to the packet sending operation will be called, even
  668. though the message never reaches its destination.
  669. </para>
  670. <para>Note that the issue described in this section is not observed
  671. when the raw sockets are in use, because, in this case, the DHCP server
  672. builds all the layers of the outgoing message on its own and does not
  673. use ARP. Instead, it inserts the value carried in the 'chaddr' field
  674. of the DHCPINFORM message into the link layer.
  675. </para>
  676. <para>Server administrators willing to support DHCPINFORM
  677. messages via relays should not block ARP traffic in their
  678. networks or should use raw sockets instead of UDP sockets.
  679. </para>
  680. </section>
  681. <section id="ipv4-subnet-id">
  682. <title>IPv4 Subnet Identifier</title>
  683. <para>
  684. The subnet identifier is a unique number associated with a particular subnet.
  685. In principle, it is used to associate clients' leases with their respective subnets.
  686. When a subnet identifier is not specified for a subnet being configured, it will
  687. be automatically assigned by the configuration mechanism. The identifiers
  688. are assigned from 1 and are monotonically increased for each subsequent
  689. subnet: 1, 2, 3 ....
  690. </para>
  691. <para>
  692. If there are multiple subnets configured with auto-generated identifiers and
  693. one of them is removed, the subnet identifiers may be renumbered. For example:
  694. if there are four subnets and the third is removed the last subnet will be assigned
  695. the identifier that the third subnet had before removal. As a result, the leases
  696. stored in the lease database for subnet 3 are now associated with
  697. subnet 4, something that may have unexpected consequences. It is planned
  698. to implement a mechanism to preserve auto-generated subnet ids in a
  699. future version of Kea. However, the only remedy for this issue
  700. at present is to
  701. manually specify a unique identifier for each subnet.
  702. </para>
  703. <para>
  704. The following configuration will assign the specified subnet
  705. identifier to the newly configured subnet:
  706. <screen>
  707. "Dhcp4": {
  708. "subnet4": [
  709. {
  710. "subnet": "192.0.2.0/24",
  711. <userinput>"id": 1024</userinput>,
  712. ...
  713. }
  714. ]
  715. }
  716. </screen>
  717. This identifier will not change for this subnet unless the "id" parameter is
  718. removed or set to 0. The value of 0 forces auto-generation of the subnet
  719. identifier.
  720. </para>
  721. <!-- @todo: describe whether database needs to be updated after changing
  722. id -->
  723. </section>
  724. <section id="dhcp4-address-config">
  725. <title>Configuration of IPv4 Address Pools</title>
  726. <para>
  727. The main role of a DHCPv4 server is address assignment. For this, the server has to
  728. be configured with at least one subnet and one pool of dynamic addresses for it to manage.
  729. For example, assume that the server is connected to a network
  730. segment that uses the 192.0.2.0/24 prefix. The Administrator of that network
  731. has decided that addresses from range 192.0.2.10 to 192.0.2.20 are going to
  732. be managed by the Dhcp4 server. Such a configuration can be achieved in the
  733. following way:
  734. <screen>
  735. "Dhcp4": {
  736. <userinput>"subnet4": [
  737. {
  738. "subnet": "192.0.2.0/24",
  739. "pools": [
  740. { "pool": "192.0.2.10 - 192.0.2.20" }
  741. ],
  742. ...
  743. }
  744. ]</userinput>
  745. }</screen>
  746. Note that <command>subnet</command> is defined as a simple string, but
  747. the <command>pools</command> parameter is actually a list of pools: for
  748. this reason, the pool definition is enclosed in square brackets, even
  749. though only one range of addresses is specified.</para>
  750. <para>Each <command>pool</command> is a structure that contains the
  751. parameters that describe a single pool. Currently there is only one
  752. parameter, <command>pool</command>, which gives the range of addresses
  753. in the pool. Additional parameters will be added in future releases of
  754. Kea.</para>
  755. <para>It is possible to define more than one pool in a subnet: continuing
  756. the previous example, further assume that 192.0.2.64/26 should be also be
  757. managed by the server. It could be written as 192.0.2.64 to
  758. 192.0.2.127. Alternatively, it can be expressed more simply as
  759. 192.0.2.64/26. Both formats are supported by Dhcp4 and can be mixed in the
  760. pool list. For example, one could define the following pools:
  761. <screen>
  762. "Dhcp4": {
  763. "subnet4": [
  764. {
  765. "subnet": "192.0.2.0/24",
  766. <userinput>"pools": [
  767. { "pool": "192.0.2.10-192.0.2.20" },
  768. { "pool": "192.0.2.64/26" }
  769. ]</userinput>,
  770. ...
  771. }
  772. ],
  773. ...
  774. }
  775. </screen>
  776. White space in pool definitions is ignored, so spaces before and after the hyphen are optional.
  777. They can be used to improve readability.
  778. </para>
  779. <para>
  780. The number of pools is not limited, but for performance reasons it is recommended to
  781. use as few as possible.
  782. </para>
  783. <para>
  784. The server may be configured to serve more than one subnet:
  785. <screen>
  786. "Dhcp4": {
  787. "subnet4": [
  788. {
  789. "subnet": "192.0.2.0/24",
  790. "pools": [ { "pool": "192.0.2.1 - 192.0.2.200" } ],
  791. ...
  792. },
  793. {
  794. "subnet": "192.0.3.0/24",
  795. "pools": [ { "pool": "192.0.3.100 - 192.0.3.200" } ],
  796. ...
  797. },
  798. {
  799. "subnet": "192.0.4.0/24",
  800. "pools": [ { "pool": "192.0.4.1 - 192.0.4.254" } ],
  801. ...
  802. }
  803. ]
  804. }
  805. </screen>
  806. </para>
  807. <para>
  808. When configuring a DHCPv4 server using prefix/length notation, please pay
  809. attention to the boundary values. When specifying that the server can use
  810. a given pool, it will also be able to allocate the first (typically network
  811. address) and the last (typically broadcast address) address from that pool.
  812. In the aforementioned example of pool 192.0.3.0/24, both 192.0.3.0 and
  813. 192.0.3.255 addresses may be assigned as well. This may be invalid in some
  814. network configurations. If you want to avoid this, please use the "min-max" notation.
  815. </para>
  816. </section>
  817. <section id="dhcp4-std-options">
  818. <title>Standard DHCPv4 Options</title>
  819. <para>
  820. One of the major features of the DHCPv4 server is to provide configuration
  821. options to clients. Most of the options are sent by the server only if the
  822. client explicitly requests them using the Parameter Request List option.
  823. Those that do not require inclusion in the Parameter Request List
  824. option are commonly used options, e.g. "Domain Server", and options which
  825. require special behavior, e.g. "Client FQDN" is returned to the client
  826. if the client has included this option in its message to the server.
  827. </para>
  828. <para>
  829. <xref linkend="dhcp4-std-options-list"/> comprises the list of the
  830. standard DHCPv4 options whose values can be configured using the
  831. configuration structures described in this section. This table excludes
  832. the options which require special processing and thus cannot be configured
  833. with some fixed values. The last column of the table indicates which
  834. options can be sent by the server even when they are not requested in
  835. the Parameter Request list option, and those which are sent only when
  836. explicitly requested.
  837. </para>
  838. <para>
  839. The following example shows how to configure the addresses of DNS
  840. servers, which is one of the most frequently used options. Options
  841. specified in this way are considered global and apply to all
  842. configured subnets.
  843. <screen>
  844. "Dhcp4": {
  845. "option-data": [
  846. {
  847. <userinput>"name": "domain-name-servers",
  848. "code": 6,
  849. "space": "dhcp4",
  850. "csv-format": true,
  851. "data": "192.0.2.1, 192.0.2.2"</userinput>
  852. },
  853. ...
  854. ]
  855. }
  856. </screen>
  857. </para>
  858. <para>
  859. The <command>name</command> parameter specifies the
  860. option name. For a list of currently supported names, see
  861. <xref linkend="dhcp4-std-options-list"/> below.
  862. The <command>code</command> parameter specifies the option code, which must match one of the
  863. values from that list. The next line specifies the option space, which must always
  864. be set to "dhcp4" as these are standard DHCPv4 options. For
  865. other option spaces, including custom option spaces, see <xref
  866. linkend="dhcp4-option-spaces"/>. The next line specifies the format in
  867. which the data will be entered: use of CSV (comma
  868. separated values) is recommended. The sixth line gives the actual value to
  869. be sent to clients. Data is specified as normal text, with
  870. values separated by commas if more than one value is
  871. allowed.
  872. </para>
  873. <para>
  874. Options can also be configured as hexadecimal values. If
  875. <command>csv-format</command> is
  876. set to false, option data must be specified as a hexadecimal string. The
  877. following commands configure the domain-name-servers option for all
  878. subnets with the following addresses: 192.0.3.1 and 192.0.3.2.
  879. Note that <command>csv-format</command> is set to false.
  880. <screen>
  881. "Dhcp4": {
  882. "option-data": [
  883. {
  884. <userinput>"name": "domain-name-servers",
  885. "code": 6,
  886. "space": "dhcp4",
  887. "csv-format": false,
  888. "data": "C0 00 03 01 C0 00 03 02"</userinput>
  889. },
  890. ...
  891. ],
  892. ...
  893. }</screen>
  894. </para>
  895. <para>
  896. Most of the parameters in the "option-data" structure are optional and
  897. can be omitted in some circumstances as discussed in the
  898. <xref linkend="dhcp4-option-data-defaults"/>.
  899. </para>
  900. <para>
  901. It is possible to specify or override options on a per-subnet basis. If
  902. clients connected to most of your subnets are expected to get the
  903. same values of a given option, you should use global options: you
  904. can then override specific values for a small number of subnets.
  905. On the other hand, if you use different values in each subnet,
  906. it does not make sense to specify global option values
  907. (Dhcp4/option-data), rather you should set only subnet-specific values
  908. (Dhcp4/subnet[X]/option-data[Y]).
  909. </para>
  910. <para>
  911. The following commands override the global
  912. DNS servers option for a particular subnet, setting a single DNS
  913. server with address 192.0.2.3.
  914. <screen>
  915. "Dhcp4": {
  916. "subnet4": [
  917. {
  918. <userinput>"option-data": [
  919. {
  920. "name": "domain-name-servers",
  921. "code": 6,
  922. "space": "dhcp4",
  923. "csv-format": true,
  924. "data": "192.0.2.3"
  925. },
  926. ...
  927. ]</userinput>,
  928. ...
  929. },
  930. ...
  931. ],
  932. ...
  933. }
  934. </screen>
  935. </para>
  936. <para>
  937. The currently supported standard DHCPv4 options are
  938. listed in <xref linkend="dhcp4-std-options-list"/>
  939. and <xref linkend="dhcp4-std-options-list-part2"/>.
  940. The "Name" and "Code"
  941. are the values that should be used as a name in the option-data
  942. structures. "Type" designates the format of the data: the meanings of
  943. the various types is given in <xref linkend="dhcp-types"/>.
  944. </para>
  945. <para>When a data field is a string, and that string contains the comma
  946. (,; U+002C) character, the comma must be escaped with a double reverse solidus
  947. character (\; U+005C). This double escape is required, because both the
  948. routine splitting CSV data into fields and JSON use the same escape
  949. character: a single escape (\,) would make the JSON invalid.
  950. For example, the string &quot;foo,bar&quot; would be represented as:
  951. <screen>
  952. "Dhcp4": {
  953. "subnet4": [
  954. {
  955. "pools": [
  956. {
  957. <userinput>"option-data": [
  958. {
  959. "name": "boot-file-name",
  960. "data": "foo\\,bar"
  961. }
  962. ]</userinput>
  963. },
  964. ...
  965. ],
  966. ...
  967. },
  968. ...
  969. ],
  970. ...
  971. }
  972. </screen>
  973. </para>
  974. <para>
  975. Some options are designated as arrays, which means that more than one
  976. value is allowed in such an option. For example the option time-servers
  977. allows the specification of more than one IPv4 address, so allowing
  978. clients to obtain the addresses of multiple NTP servers.
  979. </para>
  980. <!-- @todo: describe record types -->
  981. <para>
  982. The <xref linkend="dhcp4-custom-options"/> describes the configuration
  983. syntax to create custom option definitions (formats). It is generally not
  984. allowed to create custom definitions for standard options, even if the
  985. definition being created matches the actual option format defined in the
  986. RFCs. There is an exception from this rule for standard options for which
  987. Kea currently does not provide a definition. In order to use such options,
  988. a server administrator must create a definition as described in
  989. <xref linkend="dhcp4-custom-options"/> in the 'dhcp4' option space. This
  990. definition should match the option format described in the relevant
  991. RFC but the configuration mechanism will allow any option format as it
  992. presently has no means to validate it.
  993. </para>
  994. <para>
  995. <table frame="all" id="dhcp4-std-options-list">
  996. <title>List of standard DHCPv4 options</title>
  997. <tgroup cols='5'>
  998. <colspec colname='name'/>
  999. <colspec colname='code' align='center'/>
  1000. <colspec colname='type' align='center'/>
  1001. <colspec colname='array' align='center'/>
  1002. <colspec colname='always-returned' align='center'/>
  1003. <thead>
  1004. <row>
  1005. <entry>Name</entry>
  1006. <entry>Code</entry>
  1007. <entry>Type</entry>
  1008. <entry>Array?</entry>
  1009. <entry>Returned if not requested?</entry>
  1010. </row>
  1011. </thead>
  1012. <tbody>
  1013. <!-- Subnet Mask option is not configured by the user
  1014. <row><entry>subnet-mask</entry><entry>1</entry><entry>ipv4-address</entry><entry>false</entry><entry>true</entry></row>
  1015. -->
  1016. <row><entry>time-offset</entry><entry>2</entry><entry>int32</entry><entry>false</entry><entry>false</entry></row>
  1017. <row><entry>routers</entry><entry>3</entry><entry>ipv4-address</entry><entry>true</entry><entry>true</entry></row>
  1018. <row><entry>time-servers</entry><entry>4</entry><entry>ipv4-address</entry><entry>true</entry><entry>false</entry></row>
  1019. <row><entry>name-servers</entry><entry>5</entry><entry>ipv4-address</entry><entry>true</entry><entry>false</entry></row>
  1020. <row><entry>domain-name-servers</entry><entry>6</entry><entry>ipv4-address</entry><entry>true</entry><entry>true</entry></row>
  1021. <row><entry>log-servers</entry><entry>7</entry><entry>ipv4-address</entry><entry>true</entry><entry>false</entry></row>
  1022. <row><entry>cookie-servers</entry><entry>8</entry><entry>ipv4-address</entry><entry>true</entry><entry>false</entry></row>
  1023. <row><entry>lpr-servers</entry><entry>9</entry><entry>ipv4-address</entry><entry>true</entry><entry>false</entry></row>
  1024. <row><entry>impress-servers</entry><entry>10</entry><entry>ipv4-address</entry><entry>true</entry><entry>false</entry></row>
  1025. <row><entry>resource-location-servers</entry><entry>11</entry><entry>ipv4-address</entry><entry>true</entry><entry>false</entry></row>
  1026. <!-- Hostname option value is not explicitly configured by the user.
  1027. This rather belong to the DDNS configuration
  1028. <row><entry>host-name</entry><entry>12</entry><entry>string</entry><entry>false</entry><entry>true</entry></row>
  1029. -->
  1030. <row><entry>boot-size</entry><entry>13</entry><entry>uint16</entry><entry>false</entry><entry>false</entry></row>
  1031. <row><entry>merit-dump</entry><entry>14</entry><entry>string</entry><entry>false</entry><entry>false</entry></row>
  1032. <row><entry>domain-name</entry><entry>15</entry><entry>fqdn</entry><entry>false</entry><entry>true</entry></row>
  1033. <row><entry>swap-server</entry><entry>16</entry><entry>ipv4-address</entry><entry>false</entry><entry>false</entry></row>
  1034. <row><entry>root-path</entry><entry>17</entry><entry>string</entry><entry>false</entry><entry>false</entry></row>
  1035. <row><entry>extensions-path</entry><entry>18</entry><entry>string</entry><entry>false</entry><entry>false</entry></row>
  1036. <row><entry>ip-forwarding</entry><entry>19</entry><entry>boolean</entry><entry>false</entry><entry>false</entry></row>
  1037. <row><entry>non-local-source-routing</entry><entry>20</entry><entry>boolean</entry><entry>false</entry><entry>false</entry></row>
  1038. <row><entry>policy-filter</entry><entry>21</entry><entry>ipv4-address</entry><entry>true</entry><entry>false</entry></row>
  1039. <row><entry>max-dgram-reassembly</entry><entry>22</entry><entry>uint16</entry><entry>false</entry><entry>false</entry></row>
  1040. <row><entry>default-ip-ttl</entry><entry>23</entry><entry>uint8</entry><entry>false</entry><entry>false</entry></row>
  1041. <row><entry>path-mtu-aging-timeout</entry><entry>24</entry><entry>uint32</entry><entry>false</entry><entry>false</entry></row>
  1042. <row><entry>path-mtu-plateau-table</entry><entry>25</entry><entry>uint16</entry><entry>true</entry><entry>false</entry></row>
  1043. <row><entry>interface-mtu</entry><entry>26</entry><entry>uint16</entry><entry>false</entry><entry>false</entry></row>
  1044. <row><entry>all-subnets-local</entry><entry>27</entry><entry>boolean</entry><entry>false</entry><entry>false</entry></row>
  1045. <row><entry>broadcast-address</entry><entry>28</entry><entry>ipv4-address</entry><entry>false</entry><entry>false</entry></row>
  1046. <row><entry>perform-mask-discovery</entry><entry>29</entry><entry>boolean</entry><entry>false</entry><entry>false</entry></row>
  1047. <row><entry>mask-supplier</entry><entry>30</entry><entry>boolean</entry><entry>false</entry><entry>false</entry></row>
  1048. <row><entry>router-discovery</entry><entry>31</entry><entry>boolean</entry><entry>false</entry><entry>false</entry></row>
  1049. <row><entry>router-solicitation-address</entry><entry>32</entry><entry>ipv4-address</entry><entry>false</entry><entry>false</entry></row>
  1050. <row><entry>static-routes</entry><entry>33</entry><entry>ipv4-address</entry><entry>true</entry><entry>false</entry></row>
  1051. <row><entry>trailer-encapsulation</entry><entry>34</entry><entry>boolean</entry><entry>false</entry><entry>false</entry></row>
  1052. <row><entry>arp-cache-timeout</entry><entry>35</entry><entry>uint32</entry><entry>false</entry><entry>false</entry></row>
  1053. <row><entry>ieee802-3-encapsulation</entry><entry>36</entry><entry>boolean</entry><entry>false</entry><entry>false</entry></row>
  1054. <row><entry>default-tcp-ttl</entry><entry>37</entry><entry>uint8</entry><entry>false</entry><entry>false</entry></row>
  1055. <row><entry>tcp-keepalive-interval</entry><entry>38</entry><entry>uint32</entry><entry>false</entry><entry>false</entry></row>
  1056. <row><entry>tcp-keepalive-garbage</entry><entry>39</entry><entry>boolean</entry><entry>false</entry><entry>false</entry></row>
  1057. </tbody>
  1058. </tgroup>
  1059. </table>
  1060. </para>
  1061. <para>
  1062. <table frame="all" id="dhcp4-std-options-list-part2">
  1063. <title>List of standard DHCPv4 options (continued)</title>
  1064. <tgroup cols='5'>
  1065. <colspec colname='name'/>
  1066. <colspec colname='code' align='center'/>
  1067. <colspec colname='type' align='center'/>
  1068. <colspec colname='array' align='center'/>
  1069. <colspec colname='always-returned' align='center'/>
  1070. <thead>
  1071. <row>
  1072. <entry>Name</entry>
  1073. <entry>Code</entry>
  1074. <entry>Type</entry>
  1075. <entry>Array?</entry>
  1076. <entry>Returned if not requested?</entry>
  1077. </row>
  1078. </thead>
  1079. <tbody>
  1080. <row><entry>nis-domain</entry><entry>40</entry><entry>string</entry><entry>false</entry><entry>false</entry></row>
  1081. <row><entry>nis-servers</entry><entry>41</entry><entry>ipv4-address</entry><entry>true</entry><entry>false</entry></row>
  1082. <row><entry>ntp-servers</entry><entry>42</entry><entry>ipv4-address</entry><entry>true</entry><entry>false</entry></row>
  1083. <row><entry>vendor-encapsulated-options</entry><entry>43</entry><entry>empty</entry><entry>false</entry><entry>false</entry></row>
  1084. <row><entry>netbios-name-servers</entry><entry>44</entry><entry>ipv4-address</entry><entry>true</entry><entry>false</entry></row>
  1085. <row><entry>netbios-dd-server</entry><entry>45</entry><entry>ipv4-address</entry><entry>true</entry><entry>false</entry></row>
  1086. <row><entry>netbios-node-type</entry><entry>46</entry><entry>uint8</entry><entry>false</entry><entry>false</entry></row>
  1087. <row><entry>netbios-scope</entry><entry>47</entry><entry>string</entry><entry>false</entry><entry>false</entry></row>
  1088. <row><entry>font-servers</entry><entry>48</entry><entry>ipv4-address</entry><entry>true</entry><entry>false</entry></row>
  1089. <row><entry>x-display-manager</entry><entry>49</entry><entry>ipv4-address</entry><entry>true</entry><entry>false</entry></row>
  1090. <!-- Lease time and requested address should not be configured by a user.
  1091. <row><entry>dhcp-requested-address</entry><entry>50</entry><entry>ipv4-address</entry><entry>false</entry><entry>true</entry></row>
  1092. <row><entry>dhcp-lease-time</entry><entry>51</entry><entry>uint32</entry><entry>false</entry><entry>true</entry></row>
  1093. -->
  1094. <row><entry>dhcp-option-overload</entry><entry>52</entry><entry>uint8</entry><entry>false</entry><entry>false</entry></row>
  1095. <!-- Message Type, Server Identifier and Parameter Request List should not be configured by a user.
  1096. <row><entry>dhcp-message-type</entry><entry>53</entry><entry>uint8</entry><entry>false</entry><entry>false</entry></row>
  1097. <row><entry>dhcp-server-identifier</entry><entry>54</entry><entry>ipv4-address</entry><entry>false</entry><entry>true</entry></row>
  1098. <row><entry>dhcp-parameter-request-list</entry><entry>55</entry><entry>uint8</entry><entry>true</entry><entry>true</entry></row>
  1099. -->
  1100. <row><entry>dhcp-message</entry><entry>56</entry><entry>string</entry><entry>false</entry><entry>false</entry></row>
  1101. <row><entry>dhcp-max-message-size</entry><entry>57</entry><entry>uint16</entry><entry>false</entry><entry>false</entry></row>
  1102. <!-- Renewal and rebinding time should not be configured by a user.
  1103. <row><entry>dhcp-renewal-time</entry><entry>58</entry><entry>uint32</entry><entry>false</entry><entry>true</entry></row>
  1104. <row><entry>dhcp-rebinding-time</entry><entry>59</entry><entry>uint32</entry><entry>false</entry><entry>true</entry></row>
  1105. -->
  1106. <row><entry>vendor-class-identifier</entry><entry>60</entry><entry>binary</entry><entry>false</entry><entry>false</entry></row>
  1107. <!-- Client identifier should not be configured by a user.
  1108. <row><entry>dhcp-client-identifier</entry><entry>61</entry><entry>binary</entry><entry>false</entry><entry>true</entry></row>
  1109. -->
  1110. <row><entry>nwip-domain-name</entry><entry>62</entry><entry>string</entry><entry>false</entry><entry>false</entry></row>
  1111. <row><entry>nwip-suboptions</entry><entry>63</entry><entry>binary</entry><entry>false</entry><entry>false</entry></row>
  1112. <row><entry>nisplus-domain-name</entry><entry>64</entry><entry>string</entry><entry>false</entry><entry>false</entry></row>
  1113. <row><entry>nisplus-servers</entry><entry>65</entry><entry>ipv4-address</entry><entry>true</entry><entry>false</entry></row>
  1114. <row><entry>tftp-server-name</entry><entry>66</entry><entry>string</entry><entry>false</entry><entry>false</entry></row>
  1115. <row><entry>boot-file-name</entry><entry>67</entry><entry>string</entry><entry>false</entry><entry>false</entry></row>
  1116. <row><entry>mobile-ip-home-agent</entry><entry>68</entry><entry>ipv4-address</entry><entry>true</entry><entry>false</entry></row>
  1117. <row><entry>smtp-server</entry><entry>69</entry><entry>ipv4-address</entry><entry>true</entry><entry>false</entry></row>
  1118. <row><entry>pop-server</entry><entry>70</entry><entry>ipv4-address</entry><entry>true</entry><entry>false</entry></row>
  1119. <row><entry>nntp-server</entry><entry>71</entry><entry>ipv4-address</entry><entry>true</entry><entry>false</entry></row>
  1120. <row><entry>www-server</entry><entry>72</entry><entry>ipv4-address</entry><entry>true</entry><entry>false</entry></row>
  1121. <row><entry>finger-server</entry><entry>73</entry><entry>ipv4-address</entry><entry>true</entry><entry>false</entry></row>
  1122. <row><entry>irc-server</entry><entry>74</entry><entry>ipv4-address</entry><entry>true</entry><entry>false</entry></row>
  1123. <row><entry>streettalk-server</entry><entry>75</entry><entry>ipv4-address</entry><entry>true</entry><entry>false</entry></row>
  1124. <row><entry>streettalk-directory-assistance-server</entry><entry>76</entry><entry>ipv4-address</entry><entry>true</entry><entry>false</entry></row>
  1125. <row><entry>user-class</entry><entry>77</entry><entry>binary</entry><entry>false</entry><entry>false</entry></row>
  1126. <!-- The Client FQDN option value is not explicitly configured.
  1127. It is a part of the DDNS/D2 configuration
  1128. <row><entry>fqdn</entry><entry>81</entry><entry>record</entry><entry>false</entry><entry>true</entry></row>
  1129. -->
  1130. <!-- Relay Agent Information is not configured by the user.
  1131. It is merely echoed by the server
  1132. <row><entry>dhcp-agent-options</entry><entry>82</entry><entry>empty</entry><entry>false</entry><entry>false</entry></row>
  1133. -->
  1134. <!-- Authentication option requires special processing
  1135. <row><entry>authenticate</entry><entry>90</entry><entry>binary</entry><entry>false</entry><entry>false</entry></row>
  1136. -->
  1137. <!-- Last transaction time and associated IP is dynamically calculated
  1138. <row><entry>client-last-transaction-time</entry><entry>91</entry><entry>uint32</entry><entry>false</entry><entry>false</entry></row>
  1139. <row><entry>associated-ip</entry><entry>92</entry><entry>ipv4-address</entry><entry>true</entry><entry>false</entry></row>
  1140. -->
  1141. <row><entry>client-system</entry><entry>93</entry><entry>uint16</entry><entry>true</entry><entry>false</entry></row>
  1142. <row><entry>client-ndi</entry><entry>94</entry><entry>record (uint8, uint8, uint8)</entry><entry>false</entry><entry>false</entry></row>
  1143. <row><entry>uuid-guid</entry><entry>97</entry><entry>record (uint8, binary)</entry><entry>false</entry><entry>false</entry></row>
  1144. <row><entry>subnet-selection</entry><entry>118</entry><entry>ipv4-address</entry><entry>false</entry><entry>false</entry></row>
  1145. <row><entry>domain-search</entry><entry>119</entry><entry>binary</entry><entry>false</entry><entry>false</entry></row>
  1146. <row><entry>vivco-suboptions</entry><entry>124</entry><entry>binary</entry><entry>false</entry><entry>false</entry></row>
  1147. <row><entry>vivso-suboptions</entry><entry>125</entry><entry>binary</entry><entry>false</entry><entry>false</entry></row>
  1148. </tbody>
  1149. </tgroup>
  1150. </table>
  1151. </para>
  1152. <para>
  1153. <table frame="all" id="dhcp-types">
  1154. <title>List of standard DHCP option types</title>
  1155. <tgroup cols='2'>
  1156. <colspec colname='name'/>
  1157. <colspec colname='meaning'/>
  1158. <thead>
  1159. <row><entry>Name</entry><entry>Meaning</entry></row>
  1160. </thead>
  1161. <tbody>
  1162. <row><entry>binary</entry><entry>An arbitrary string of bytes, specified as a set of hexadecimal digits.</entry></row>
  1163. <row><entry>boolean</entry><entry>Boolean value with allowed values true or false</entry></row>
  1164. <row><entry>empty</entry><entry>No value, data is carried in suboptions</entry></row>
  1165. <row><entry>fqdn</entry><entry>Fully qualified domain name (e.g. www.example.com)</entry></row>
  1166. <row><entry>ipv4-address</entry><entry>IPv4 address in the usual dotted-decimal notation (e.g. 192.0.2.1)</entry></row>
  1167. <row><entry>ipv6-address</entry><entry>IPv6 address in the usual colon notation (e.g. 2001:db8::1)</entry></row>
  1168. <row><entry>ipv6-prefix</entry><entry>IPv6 prefix and prefix length specified using CIDR notation, e.g. 2001:db8:1::/64. This data type is used to represent an 8-bit field conveying a prefix length and the variable length prefix value</entry></row>
  1169. <row><entry>psid</entry><entry>PSID and PSID length separated by a slash, e.g. 3/4 specifies PSID=3 and PSID length=4. In the wire format it is represented by an 8-bit field carrying PSID length (in this case equal to 4) and the 16-bits long PSID value field (in this case equal to "0011000000000000b" using binary notation). Allowed values for a PSID length are 0 to 16. See <ulink url="http://tools.ietf.org/html/rfc7597">RFC 7597</ulink> for the details about the PSID wire representation</entry></row>
  1170. <row><entry>record</entry><entry>Structured data that may comprise any types (except "record" and "empty")</entry></row>
  1171. <row><entry>string</entry><entry>Any text</entry></row>
  1172. <row><entry>uint8</entry><entry>8 bit unsigned integer with allowed values 0 to 255</entry></row>
  1173. <row><entry>uint16</entry><entry>16 bit unsigned integer with allowed values 0 to 65535</entry></row>
  1174. <row><entry>uint32</entry><entry>32 bit unsigned integer with allowed values 0 to 4294967295</entry></row>
  1175. </tbody>
  1176. </tgroup>
  1177. </table>
  1178. </para>
  1179. </section>
  1180. <section id="dhcp4-custom-options">
  1181. <title>Custom DHCPv4 options</title>
  1182. <para>Kea supports custom (non-standard) DHCPv4 options. Assume
  1183. that we want to define a new DHCPv4 option called "foo" which
  1184. will have a code 222 and will convey a single unsigned 32 bit
  1185. integer value. We can define such an option by using the
  1186. following entry in the configuration file:
  1187. <screen>
  1188. "Dhcp4": {
  1189. "option-def": [
  1190. {
  1191. <userinput>"name": "foo",
  1192. "code": 222,
  1193. "type": "uint32",
  1194. "array": false,
  1195. "record-types": "",
  1196. "space": "dhcp4",
  1197. "encapsulate": ""</userinput>
  1198. }, ...
  1199. ],
  1200. ...
  1201. }
  1202. </screen>
  1203. The <command>false</command> value of the <command>array</command>
  1204. parameter determines that the option does NOT comprise an array of
  1205. "uint32" values but is, instead, a single value. Two other parameters have been
  1206. left blank: <command>record-types</command> and
  1207. <command>encapsulate</command>. The former specifies the comma separated
  1208. list of option data fields if the option comprises a record of data
  1209. fields. This should be non-empty if the <command>type</command> is set to
  1210. "record". Otherwise it must be left blank. The latter parameter specifies
  1211. the name of the option space being encapsulated by the particular
  1212. option. If the particular option does not encapsulate any option space it
  1213. should be left blank. Note that the above set of comments define the
  1214. format of the new option and do not set its values.
  1215. </para>
  1216. <para>The <command>name</command>, <command>code</command> and
  1217. <command>type</command> parameters are required, all others are
  1218. optional. The <command>array</command> default value is
  1219. <command>false</command>. The <command>record-types</command>
  1220. and <command>encapsulate</command> default values are blank
  1221. (i.e. ""). The default <command>space</command> is "dhcp4".
  1222. </para>
  1223. <para>Once the new option format is defined, its value is set
  1224. in the same way as for a standard option. For example the following
  1225. commands set a global value that applies to all subnets.
  1226. <screen>
  1227. "Dhcp4": {
  1228. "option-data": [
  1229. {
  1230. <userinput>"name": "foo",
  1231. "code": 222,
  1232. "space": "dhcp4",
  1233. "csv-format": true,
  1234. "data": "12345"</userinput>
  1235. }, ...
  1236. ],
  1237. ...
  1238. }
  1239. </screen>
  1240. </para>
  1241. <para>New options can take more complex forms than simple use of
  1242. primitives (uint8, string, ipv4-address etc): it is possible to
  1243. define an option comprising a number of existing primitives.
  1244. Assume we want to define a new option that will consist of
  1245. an IPv4 address, followed by an unsigned 16 bit integer, followed by
  1246. a boolean value, followed by a text string. Such an option could
  1247. be defined in the following way:
  1248. <screen>
  1249. "Dhcp4": {
  1250. "option-def": [
  1251. {
  1252. <userinput>"name": "bar",
  1253. "code": 223,
  1254. "space": "dhcp4",
  1255. "type": "record",
  1256. "array": false,
  1257. "record-types": "ipv4-address, uint16, boolean, string",
  1258. "encapsulate": ""</userinput>
  1259. }, ...
  1260. ],
  1261. ...
  1262. }
  1263. </screen>
  1264. The <command>type</command> is set to "record" to indicate that the option contains
  1265. multiple values of different types. These types are given as a comma-separated
  1266. list in the <command>record-types</command> field and should be ones from those listed in <xref linkend="dhcp-types"/>.
  1267. </para>
  1268. <para>
  1269. The values of the option are set as follows:
  1270. <screen>
  1271. "Dhcp4": {
  1272. "option-data": [
  1273. {
  1274. <userinput>"name": "bar",
  1275. "space": "dhcp4",
  1276. "code": 223,
  1277. "csv-format": true,
  1278. "data": "192.0.2.100, 123, true, Hello World"</userinput>
  1279. }
  1280. ],
  1281. ...
  1282. }</screen>
  1283. <command>csv-format</command> is set to <command>true</command> to indicate
  1284. that the <command>data</command> field comprises a command-separated list
  1285. of values. The values in the <command>data</command> must correspond to
  1286. the types set in the <command>record-types</command> field of the option
  1287. definition.
  1288. </para>
  1289. <note>
  1290. <para>In the general case, boolean values are specified as <command>true</command> or
  1291. <command>false</command>, without quotes. Some specific boolean parameters may
  1292. accept also <command>"true"</command>, <command>"false"</command>,
  1293. <command>0</command>, <command>1</command>, <command>"0"</command> and
  1294. <command>"1"</command>. Future versions of Kea will accept all those values
  1295. for all boolean parameters.</para>
  1296. </note>
  1297. </section>
  1298. <section id="dhcp4-vendor-opts">
  1299. <title>DHCPv4 Vendor Specific Options</title>
  1300. <para>
  1301. Currently there are two option spaces defined for the DHCPv4 daemon:
  1302. "dhcp4" (for the top level DHCPv4 options) and
  1303. "vendor-encapsulated-options-space", which is empty by default but
  1304. in which options can be defined. Such options will be carried in the
  1305. Vendor Specific Information option (code 43). The following examples
  1306. show how to define an option "foo" in that space that has a code 1,
  1307. and comprises an
  1308. IPv4 address, an unsigned 16 bit integer and a string. The "foo"
  1309. option is conveyed in a Vendor Specific Information option.
  1310. </para>
  1311. <para>
  1312. The first step is to define the format of the option:
  1313. <screen>
  1314. "Dhcp4": {
  1315. "option-def": [
  1316. {
  1317. <userinput>"name": "foo",
  1318. "code": 1,
  1319. "space": "vendor-encapsulated-options-space",
  1320. "type": "record",
  1321. "array": false,
  1322. "record-types": "ipv4-address, uint16, string",
  1323. "encapsulate": ""</userinput>
  1324. }
  1325. ],
  1326. ...
  1327. }</screen>
  1328. (Note that the option space is set to "vendor-encapsulated-options-space".)
  1329. Once the option format is defined, the next step is to define actual values
  1330. for that option:
  1331. <screen>
  1332. "Dhcp4": {
  1333. "option-data": [
  1334. {
  1335. <userinput>"name": "foo",
  1336. "space": "vendor-encapsulated-options-space",
  1337. "code": 1,
  1338. "csv-format": true,
  1339. "data": "192.0.2.3, 123, Hello World"</userinput>
  1340. }
  1341. ],
  1342. ...
  1343. }</screen>
  1344. We also include the Vendor Specific Information option, the option
  1345. that conveys our sub-option "foo". This is required, else the option
  1346. will not be included in messages sent to the client.
  1347. <screen>
  1348. "Dhcp4": {
  1349. "option-data": [
  1350. {
  1351. <userinput>"name": "vendor-encapsulated-options"</userinput>
  1352. }
  1353. ],
  1354. ...
  1355. }</screen>
  1356. Alternatively, the option can be specified using its code.
  1357. <screen>
  1358. "Dhcp4": {
  1359. "option-data": [
  1360. {
  1361. <userinput>"code": 43</userinput>
  1362. }
  1363. ],
  1364. ...
  1365. }</screen>
  1366. </para>
  1367. </section>
  1368. <section id="dhcp4-option-spaces">
  1369. <title>Nested DHCPv4 Options (Custom Option Spaces)</title>
  1370. <para>It is sometimes useful to define a completely new option
  1371. space. This is the case when user creates new option in the
  1372. standard option space ("dhcp4") and wants this option
  1373. to convey sub-options. Since they are in a separate space,
  1374. sub-option codes will have a separate numbering scheme and may
  1375. overlap with the codes of standard options.
  1376. </para>
  1377. <para>Note that creation of a new option space when defining
  1378. sub-options for a standard option is not required, because it is
  1379. created by default if the standard option is meant to convey any
  1380. sub-options (see <xref linkend="dhcp4-vendor-opts"/>).
  1381. </para>
  1382. <para>
  1383. Assume that we want to have a DHCPv4 option called "container" with
  1384. code 222 that conveys two sub-options with codes 1 and 2.
  1385. First we need to define the new sub-options:
  1386. <screen>
  1387. "Dhcp4": {
  1388. "option-def": [
  1389. {
  1390. <userinput>"name": "subopt1",
  1391. "code": 1,
  1392. "space": "isc",
  1393. "type": "ipv4-address",
  1394. "record-types": "",
  1395. "array": false,
  1396. "encapsulate": ""
  1397. },
  1398. {
  1399. "name": "subopt2",
  1400. "code": 2,
  1401. "space": "isc",
  1402. "type": "string",
  1403. "record-types": "",
  1404. "array": false,
  1405. "encapsulate": ""</userinput>
  1406. }
  1407. ],
  1408. ...
  1409. }</screen>
  1410. Note that we have defined the options to belong to a new option space
  1411. (in this case, "isc").
  1412. </para>
  1413. <para>
  1414. The next step is to define a regular DHCPv4 option with our desired
  1415. code and specify that it should include options from the new option space:
  1416. <screen>
  1417. "Dhcp4": {
  1418. "option-def": [
  1419. ...,
  1420. {
  1421. <userinput>"name": "container",
  1422. "code": 222,
  1423. "space": "dhcp4",
  1424. "type": "empty",
  1425. "array": false,
  1426. "record-types": "",
  1427. "encapsulate": "isc"</userinput>
  1428. }
  1429. ],
  1430. ...
  1431. }</screen>
  1432. The name of the option space in which the sub-options are defined
  1433. is set in the <command>encapsulate</command> field. The <command>type</command> field is set to "empty"
  1434. to indicate that this option does not carry any data other than
  1435. sub-options.
  1436. </para>
  1437. <para>
  1438. Finally, we can set values for the new options:
  1439. <screen>
  1440. "Dhcp4": {
  1441. "option-data": [
  1442. {
  1443. <userinput>"name": "subopt1",
  1444. "code": 1,
  1445. "space": "isc",
  1446. "data": "192.0.2.3"</userinput>
  1447. },
  1448. }
  1449. <userinput>"name": "subopt2",
  1450. "code": 2,
  1451. "space": "isc",
  1452. "data": "Hello world"</userinput>
  1453. },
  1454. {
  1455. <userinput>"name": "container",
  1456. "code": 222,
  1457. "space": "dhcp4"</userinput>
  1458. }
  1459. ],
  1460. ...
  1461. }
  1462. </screen>
  1463. </para>
  1464. <para>Note that it is possible to create an option which carries some data
  1465. in addition to the sub-options defined in the encapsulated option space. For example,
  1466. if the "container" option from the previous example was required to carry an uint16
  1467. value as well as the sub-options, the <command>type</command> value would have to be set to "uint16" in
  1468. the option definition. (Such an option would then have the following
  1469. data structure: DHCP header, uint16 value, sub-options.) The value specified
  1470. with the <command>data</command> parameter &mdash; which should be a valid integer enclosed in quotes,
  1471. e.g. "123" &mdash; would then be assigned to the uint16 field in the "container" option.
  1472. </para>
  1473. </section>
  1474. <section id="dhcp4-option-data-defaults">
  1475. <title>Unspecified Parameters for DHCPv4 Option Configuration</title>
  1476. <para>In many cases it is not required to specify all parameters for
  1477. an option configuration and the default values may be used. However, it is
  1478. important to understand the implications of not specifying some of them
  1479. as it may result in configuration errors. The list below explains
  1480. the behavior of the server when a particular parameter is not explicitly
  1481. specified:
  1482. <itemizedlist>
  1483. <listitem>
  1484. <simpara><command>name</command> - the server requires an option name or
  1485. option code to identify an option. If this parameter is unspecified, the
  1486. option code must be specified.
  1487. </simpara>
  1488. </listitem>
  1489. <listitem>
  1490. <simpara><command>code</command> - the server requires an option name or
  1491. option code to identify an option. This parameter may be left unspecified if
  1492. the <command>name</command> parameter is specified. However, this also
  1493. requires that the particular option has its definition (it is either a
  1494. standard option or an administrator created a definition for the option
  1495. using an 'option-def' structure), as the option definition associates an
  1496. option with a particular name. It is possible to configure an option
  1497. for which there is no definition (unspecified option format).
  1498. Configuration of such options requires the use of option code.
  1499. </simpara>
  1500. </listitem>
  1501. <listitem>
  1502. <simpara><command>space</command> - if the option space is unspecified it
  1503. will default to 'dhcp4' which is an option space holding DHCPv4 standard
  1504. options.
  1505. </simpara>
  1506. </listitem>
  1507. <listitem>
  1508. <simpara><command>data</command> - if the option data is unspecified it
  1509. defaults to an empty value. The empty value is mostly used for the
  1510. options which have no payload (boolean options), but it is legal to specify
  1511. empty values for some options which carry variable length data and which
  1512. the specification allows for the length of 0. For such options, the data parameter
  1513. may be omitted in the configuration.</simpara>
  1514. </listitem>
  1515. <listitem>
  1516. <simpara><command>csv-format</command> - if this value is not
  1517. specified the server will assume that the option data is specified as
  1518. a list of comma separated values to be assigned to individual fields
  1519. of the DHCP option. This behavior has changed in Kea 1.2. Older
  1520. versions used additional logic to determine whether the csv-format
  1521. should be true or false. That is no longer the case.
  1522. </simpara>
  1523. </listitem>
  1524. </itemizedlist>
  1525. </para>
  1526. </section>
  1527. <section id="dhcp4-stateless-configuration">
  1528. <title>Stateless Configuration of DHCPv4 Clients</title>
  1529. <para>The DHCPv4 server supports the stateless client configuration whereby the
  1530. client has an IP address configured (e.g. using manual configuration) and only
  1531. contacts the server to obtain other configuration parameters, e.g. addresses of DNS servers.
  1532. In order to obtain the stateless configuration parameters the client sends the
  1533. DHCPINFORM message to the server with the "ciaddr" set to the address that the
  1534. client is currently using. The server unicasts the DHCPACK message to the
  1535. client that includes the stateless configuration ("yiaddr" not set).
  1536. </para>
  1537. <para>The server will respond to the DHCPINFORM when the client is associated
  1538. with a subnet defined in the server's configuration. An example
  1539. subnet configuration will look like this:
  1540. <screen>
  1541. "Dhcp4": {
  1542. "subnet4": [
  1543. {
  1544. "subnet": "192.0.2.0/24"
  1545. "option-data": [ {
  1546. "name": "domain-name-servers",
  1547. "code": 6,
  1548. "data": "192.0.2.200,192.0.2.201",
  1549. "csv-format": true,
  1550. "space": "dhcp4"
  1551. } ]
  1552. }
  1553. ]
  1554. }</screen>
  1555. </para>
  1556. <para>This subnet specifies the single option which will be included in
  1557. the DHCPACK message to the client in response to DHCPINFORM. Note that
  1558. the subnet definition does not require the address pool configuration
  1559. if it will be used solely for the stateless configuration.
  1560. </para>
  1561. <para>This server will associate the subnet with the client if one of
  1562. the following conditions is met:
  1563. <itemizedlist>
  1564. <listitem>
  1565. <simpara>The DHCPINFORM is relayed and the giaddr matches the
  1566. configured subnet.</simpara>
  1567. </listitem>
  1568. <listitem>
  1569. <simpara>The DHCPINFORM is unicast from the client and the ciaddr
  1570. matches the configured subnet.</simpara>
  1571. </listitem>
  1572. <listitem>
  1573. <simpara>The DHCPINFORM is unicast from the client, the ciaddr is
  1574. not set but the source address of the IP packet matches the
  1575. configured subnet.</simpara>
  1576. </listitem>
  1577. <listitem>
  1578. <simpara>The DHCPINFORM is not relayed and the IP address on the
  1579. interface on which the message is received matches the configured
  1580. subnet.</simpara>
  1581. </listitem>
  1582. </itemizedlist>
  1583. </para>
  1584. </section>
  1585. <section id="dhcp4-client-classifier">
  1586. <title>Client Classification in DHCPv4</title>
  1587. <para>
  1588. The DHCPv4 server includes support for client classification. For a deeper
  1589. discussion of the classification process see <xref linkend="classify"/>.
  1590. </para>
  1591. <para>
  1592. In certain cases it is useful to differentiate between different types of
  1593. clients and treat them accordingly. It is envisaged that client
  1594. classification will be used for changing the behavior of almost any part of
  1595. the DHCP message processing, including the assignment of leases from different
  1596. pools, the assignment of different options (or different values of the same
  1597. options) etc. In the current release of the software however, there are
  1598. only three mechanisms that take advantage of client classification:
  1599. subnet selection, assignment of different options, and, for cable modems, there
  1600. are specific options for use with the TFTP server address and the boot file field.
  1601. </para>
  1602. <para>
  1603. Kea can be instructed to limit access to given subnets based on class information.
  1604. This is particularly useful for cases where two types of devices share the
  1605. same link and are expected to be served from two different subnets. The
  1606. primary use case for such a scenario is cable networks. Here, there are two
  1607. classes of devices: the cable modem itself, which should be handed a lease
  1608. from subnet A and all other devices behind the modem that should get a lease
  1609. from subnet B. That segregation is essential to prevent overly curious
  1610. users from playing with their cable modems. For details on how to set up
  1611. class restrictions on subnets, see <xref linkend="classification-subnets"/>.
  1612. </para>
  1613. <para>
  1614. The process of doing classification is conducted in three steps. The first step
  1615. is to assess an incoming packet and assign it to zero or more classes. The
  1616. second step is to choose a subnet, possibly based on the class information.
  1617. The third step is to assign options, again possibly based on the class
  1618. information.
  1619. </para>
  1620. <para>
  1621. There are two methods of doing classification. The first is automatic and relies
  1622. on examining the values in the vendor class options. Information from these
  1623. options is extracted and a class name is constructed from it and added to
  1624. the class list for the packet. The second allows you to specify an expression
  1625. that is evaluated for each packet. If the result is true the packet is
  1626. a member of the class.
  1627. </para>
  1628. <note><para>
  1629. Care should be taken with client classification as it is easy for
  1630. clients that do not meet class criteria to be denied any service altogether.
  1631. </para></note>
  1632. <section>
  1633. <title>Setting Fixed Fields in Classification</title>
  1634. <para>
  1635. It is possible to specify that clients belonging to a particular class
  1636. should receive packets with specific values in certain fixed fields.
  1637. In particular, three fixed fields are supported:
  1638. <command>next-server</command> (that conveys an IPv4 address, which is
  1639. set in the siaddr field), <command>server-hostname</command> (that
  1640. conveys a server hostname, can be up to 64 bytes long and will be sent
  1641. in the sname field) and <command>boot-file-name</command> (that
  1642. conveys the configuration file, can be up to 128 bytes long and will
  1643. be sent using file field).
  1644. </para>
  1645. <para>
  1646. Obviously, there are many ways to assign clients to specific classes,
  1647. but for the PXE clients the client architecture type option (code 93)
  1648. seems to be particularly suited to
  1649. make the distinction. The following example checks if the client
  1650. identifies itself as PXE device with architecture EFI x86-64, and
  1651. sets several fields if it does. See
  1652. <ulink url="https://tools.ietf.org/html/rfc4578#section-2.1">Section 2.1 of RFC 4578</ulink>)
  1653. or the documentation of your client for specific values.
  1654. </para>
  1655. <screen>
  1656. "Dhcp4": {
  1657. "client-classes": [
  1658. {
  1659. "name": "ipxe_efi_x64",
  1660. "test": "option[93].hex == 0x0009",
  1661. <userinput>"next-server": "192.0.2.254",
  1662. "server-hostname": "hal9000",
  1663. "boot-file-name": "/dev/null"</userinput>
  1664. },
  1665. ...
  1666. ],
  1667. ...
  1668. }</screen>
  1669. <para>
  1670. If there are multiple classes defined and an incoming packet is matched
  1671. to multiple classes, the class whose name is alphabetically the first
  1672. is used.
  1673. </para>
  1674. </section>
  1675. <section>
  1676. <title>Using Vendor Class Information in Classification</title>
  1677. <para>
  1678. The server checks whether an incoming packet includes the vendor class identifier
  1679. option (60). If it does, the content of that option is prepended with
  1680. &quot;VENDOR_CLASS_&quot;, it is interpreted as a class. For example,
  1681. modern cable modems will send this option with value &quot;docsis3.0&quot;
  1682. and as a result the packet will belong to class &quot;VENDOR_CLASS_docsis3.0&quot;.
  1683. </para>
  1684. <note>
  1685. <para>
  1686. Kea 1.0 and earlier versions performed special actions for
  1687. clients that were in VENDOR_CLASS_docsis3.0. This is no longer the
  1688. case in Kea 1.1 and later. In these versions the old behavior
  1689. can be achieved by defining VENDOR_CLASS_docsis3.0 and setting
  1690. its next-server and boot-file-name values appropriately.
  1691. </para>
  1692. </note>
  1693. <para>
  1694. This example shows a configuration using an automatically generated
  1695. "VENDOR_CLASS_" class. The administrator of the network has
  1696. decided that addresses from range 192.0.2.10 to 192.0.2.20 are
  1697. going to be managed by the Dhcp4 server and only clients belonging to the
  1698. docsis3.0 client class are allowed to use that pool.
  1699. <screen>
  1700. "Dhcp4": {
  1701. "subnet4": [
  1702. {
  1703. "subnet": "192.0.2.0/24",
  1704. "pools": [ { "pool": "192.0.2.10 - 192.0.2.20" } ],
  1705. <userinput>"client-class": "VENDOR_CLASS_docsis3.0"</userinput>
  1706. }
  1707. ],
  1708. ...
  1709. }</screen>
  1710. </para>
  1711. </section>
  1712. <section>
  1713. <title>Defining and Using Custom Classes</title>
  1714. <para>
  1715. The following example shows how to configure a class using an expression
  1716. and a subnet that makes use of the class. This configuration defines the
  1717. class named &quot;Client_foo&quot;.
  1718. It is comprised of all clients who's client ids (option 61) start with the
  1719. string &quot;foo&quot;. Members of this class will be given addresses from
  1720. 192.0.2.10 to 192.0.2.20 and the addresses of their DNS servers
  1721. set to 192.0.2.1 and 192.0.2.2.
  1722. <screen>
  1723. "Dhcp4": {
  1724. "client-classes": [
  1725. {<userinput>
  1726. "name": "Client_foo",
  1727. "test": "substring(option[61].hex,0,3) == 'foo'",
  1728. "option-data": [
  1729. {
  1730. "name": "domain-name-servers",
  1731. "code": 6,
  1732. "space": "dhcp4",
  1733. "csv-format": true,
  1734. "data": "192.0.2.1, 192.0.2.2"
  1735. }
  1736. ]</userinput>
  1737. },
  1738. ...
  1739. ],
  1740. "subnet4": [
  1741. {
  1742. "subnet": "192.0.2.0/24",
  1743. "pools": [ { "pool": "192.0.2.10 - 192.0.2.20" } ],
  1744. <userinput>"client-class": "Client_foo"</userinput>
  1745. },
  1746. ...
  1747. ],
  1748. ...
  1749. }</screen>
  1750. </para>
  1751. </section>
  1752. </section>
  1753. <section id="dhcp4-ddns-config">
  1754. <title>DDNS for DHCPv4</title>
  1755. <para>
  1756. As mentioned earlier, kea-dhcp4 can be configured to generate requests to the
  1757. DHCP-DDNS server (referred to here as "D2" ) to update DNS entries. These requests are known as
  1758. NameChangeRequests or NCRs. Each NCR contains the following information:
  1759. <orderedlist>
  1760. <listitem><para>
  1761. Whether it is a request to add (update) or remove DNS entries
  1762. </para></listitem>
  1763. <listitem><para>
  1764. Whether the change requests forward DNS updates (A records), reverse
  1765. DNS updates (PTR records), or both.
  1766. </para></listitem>
  1767. <listitem><para>
  1768. The FQDN, lease address, and DHCID
  1769. </para></listitem>
  1770. </orderedlist>
  1771. The parameters for controlling the generation of NCRs for submission to D2
  1772. are contained in the <command>dhcp-ddns</command> section of the kea-dhcp4 server
  1773. configuration. The mandatory parameters for the DHCP DDNS configuration
  1774. are <command>enable-updates</command> which is unconditionally
  1775. required, and <command>qualifying-suffix</command> which has no
  1776. default value and is required when <command>enable-updates</command>
  1777. is set to <command>true</command>.
  1778. The two (disabled and enabled) minimal DHCP DDNS configurations are:
  1779. <screen>
  1780. "Dhcp4": {
  1781. "dhcp-ddns": {
  1782. <userinput>"enable-updates": false</userinput>
  1783. },
  1784. ...
  1785. }
  1786. </screen>
  1787. and for example:
  1788. <screen>
  1789. "Dhcp4": {
  1790. "dhcp-ddns": {
  1791. <userinput>"enable-updates": true,
  1792. "qualifying-suffix": "example."</userinput>
  1793. },
  1794. ...
  1795. }
  1796. </screen>
  1797. The default values for the "dhcp-ddns" section are as follows:
  1798. <itemizedlist>
  1799. <listitem><simpara>
  1800. <command>"server-ip": "127.0.0.1"</command>
  1801. </simpara></listitem>
  1802. <listitem><simpara>
  1803. <command>"server-port": 53001</command>
  1804. </simpara></listitem>
  1805. <listitem><simpara>
  1806. <command>"sender-ip": ""</command>
  1807. </simpara></listitem>
  1808. <listitem><simpara>
  1809. <command>"sender-port": 0</command>
  1810. </simpara></listitem>
  1811. <listitem><simpara>
  1812. <command>"max-queue-size": 1024</command>
  1813. </simpara></listitem>
  1814. <listitem><simpara>
  1815. <command>"ncr-protocol": "UDP"</command>
  1816. </simpara></listitem>
  1817. <listitem><simpara>
  1818. <command>"ncr-format": "JSON"</command>
  1819. </simpara></listitem>
  1820. <listitem><simpara>
  1821. <command>"override-no-update": false</command>
  1822. </simpara></listitem>
  1823. <listitem><simpara>
  1824. <command>"override-client-update": false</command>
  1825. </simpara></listitem>
  1826. <listitem><simpara>
  1827. <command>"replace-client-name": "never"</command>
  1828. </simpara></listitem>
  1829. <listitem><simpara>
  1830. <command>"generated-prefix": "myhost"</command>
  1831. </simpara></listitem>
  1832. </itemizedlist>
  1833. </para>
  1834. <section id="dhcpv4-d2-io-config">
  1835. <title>DHCP-DDNS Server Connectivity</title>
  1836. <para>
  1837. In order for NCRs to reach the D2 server, kea-dhcp4 must be able
  1838. to communicate with it. kea-dhcp4 uses the following configuration
  1839. parameters to control this communication:
  1840. <itemizedlist>
  1841. <listitem><simpara>
  1842. <command>enable-updates</command> - determines whether or not kea-dhcp4 will
  1843. generate NCRs. By default, this value is false hence DDNS updates are
  1844. disabled. To enable DDNS updates set this value to true:
  1845. </simpara></listitem>
  1846. <listitem><simpara>
  1847. <command>server-ip</command> - IP address on which D2 listens for requests. The default is
  1848. the local loopback interface at address 127.0.0.1. You may specify
  1849. either an IPv4 or IPv6 address.
  1850. </simpara></listitem>
  1851. <listitem><simpara>
  1852. <command>server-port</command> - port on which D2 listens for requests. The default value
  1853. is 53001.
  1854. </simpara></listitem>
  1855. <listitem><simpara>
  1856. <command>sender-ip</command> - IP address which kea-dhcp4 should use to send requests to D2.
  1857. The default value is blank which instructs kea-dhcp4 to select a suitable
  1858. address.
  1859. </simpara></listitem>
  1860. <listitem><simpara>
  1861. <command>sender-port</command> - port which kea-dhcp4 should use to send requests to D2. The
  1862. default value of 0 instructs kea-dhcp4 to select a suitable port.
  1863. </simpara></listitem>
  1864. <listitem><simpara>
  1865. <command>max-queue-size</command> - maximum number of requests allowed to queue waiting to
  1866. be sent to D2. This value guards against requests accumulating
  1867. uncontrollably if they are being generated faster than they can be
  1868. delivered. If the number of requests queued for transmission reaches
  1869. this value, DDNS updating will be turned off until the queue backlog has
  1870. been sufficiently reduced. The intention is to allow the kea-dhcp4 server to
  1871. continue lease operations without running the risk that its memory usage
  1872. grows without limit. The default value is 1024.
  1873. </simpara></listitem>
  1874. <listitem><simpara>
  1875. <command>ncr-protocol</command> - socket protocol use when sending requests to D2. Currently
  1876. only UDP is supported. TCP may be available in an upcoming release.
  1877. </simpara></listitem>
  1878. <listitem><simpara>
  1879. <command>ncr-format</command> - packet format to use when sending requests to D2.
  1880. Currently only JSON format is supported. Other formats may be available
  1881. in future releases.
  1882. </simpara></listitem>
  1883. </itemizedlist>
  1884. By default, kea-dhcp-ddns is assumed to be running on the same machine as kea-dhcp4, and
  1885. all of the default values mentioned above should be sufficient.
  1886. If, however, D2 has been configured to listen on a different address or
  1887. port, these values must be altered accordingly. For example, if D2 has been
  1888. configured to listen on 192.168.1.10 port 900, the following configuration
  1889. would be required:
  1890. <screen>
  1891. "Dhcp4": {
  1892. "dhcp-ddns": {
  1893. <userinput>"server-ip": "192.168.1.10",
  1894. "server-port": 900</userinput>,
  1895. ...
  1896. },
  1897. ...
  1898. }
  1899. </screen>
  1900. </para>
  1901. </section>
  1902. <section id="dhcpv4-d2-rules-config">
  1903. <title>When Does the kea-dhcp4 Server Generate DDNS Requests?</title>
  1904. <para>kea-dhcp4 follows the behavior prescribed for DHCP servers in
  1905. <ulink url="http://tools.ietf.org/html/rfc4702">RFC 4702</ulink>.
  1906. It is important to keep in mind that kea-dhcp4 provides the initial decision
  1907. making of when and what to update and forwards that information to D2 in
  1908. the form of NCRs. Carrying out the actual DNS updates and dealing with
  1909. such things as conflict resolution are within the purview of D2 itself (<xref linkend="dhcp-ddns-server"/>).
  1910. This section describes when kea-dhcp4 will generate NCRs and the
  1911. configuration parameters that can be used to influence this decision.
  1912. It assumes that the <command>enable-updates</command> parameter is true.
  1913. </para>
  1914. <para>
  1915. In general, kea-dhcp4 will generate DDNS update requests when:
  1916. <orderedlist>
  1917. <listitem><para>
  1918. A new lease is granted in response to a DHCP REQUEST
  1919. </para></listitem>
  1920. <listitem><para>
  1921. An existing lease is renewed but the FQDN associated with it has
  1922. changed.
  1923. </para></listitem>
  1924. <listitem><para>
  1925. An existing lease is released in response to a DHCP RELEASE
  1926. </para></listitem>
  1927. </orderedlist>
  1928. In the second case, lease renewal, two DDNS requests will be issued: one
  1929. request to remove entries for the previous FQDN and a second request to
  1930. add entries for the new FQDN. In the last case, a lease release, a
  1931. single DDNS request to remove its entries will be made.
  1932. </para>
  1933. <para>
  1934. The decision making involved when granting a new lease (the first case) is more
  1935. involved. When a new lease is granted, kea-dhcp4 will generate a DDNS
  1936. update request if the DHCP REQUEST contains either the FQDN option
  1937. (code 81) or the Host Name option (code 12). If both are present,
  1938. the server will use the FQDN option. By default kea-dhcp4
  1939. will respect the FQDN N and S flags specified by the client as shown
  1940. in the following table:
  1941. </para>
  1942. <table id="fqdn-flag-table">
  1943. <title>Default FQDN Flag Behavior</title>
  1944. <tgroup cols='4' align='left'>
  1945. <colspec colname='cflags'/>
  1946. <colspec colname='meaning'/>
  1947. <colspec colname='response'/>
  1948. <colspec colname='sflags'/>
  1949. <thead>
  1950. <row>
  1951. <entry>Client Flags:N-S</entry>
  1952. <entry>Client Intent</entry>
  1953. <entry>Server Response</entry>
  1954. <entry>Server Flags:N-S-O</entry>
  1955. </row>
  1956. </thead>
  1957. <tbody>
  1958. <row>
  1959. <entry>0-0</entry>
  1960. <entry>
  1961. Client wants to do forward updates, server should do reverse updates
  1962. </entry>
  1963. <entry>Server generates reverse-only request</entry>
  1964. <entry>1-0-0</entry>
  1965. </row>
  1966. <row>
  1967. <entry>0-1</entry>
  1968. <entry>Server should do both forward and reverse updates</entry>
  1969. <entry>Server generates request to update both directions</entry>
  1970. <entry>0-1-0</entry>
  1971. </row>
  1972. <row>
  1973. <entry>1-0</entry>
  1974. <entry>Client wants no updates done</entry>
  1975. <entry>Server does not generate a request</entry>
  1976. <entry>1-0-0</entry>
  1977. </row>
  1978. </tbody>
  1979. </tgroup>
  1980. </table>
  1981. <para>
  1982. The first row in the table above represents "client delegation". Here
  1983. the DHCP client states that it intends to do the forward DNS updates and
  1984. the server should do the reverse updates. By default, kea-dhcp4 will honor
  1985. the client's wishes and generate a DDNS request to the D2 server to update only
  1986. reverse DNS data. The parameter <command>override-client-update</command> can be used
  1987. to instruct the server to override client delegation requests. When
  1988. this parameter is true, kea-dhcp4 will disregard requests for client
  1989. delegation and generate a DDNS request to update both forward and
  1990. reverse DNS data. In this case, the N-S-O flags in the server's
  1991. response to the client will be 0-1-1 respectively.
  1992. </para>
  1993. <para>
  1994. (Note that the flag combination N=1, S=1 is prohibited according to
  1995. <ulink url="http://tools.ietf.org/html/rfc4702">RFC 4702</ulink>. If such a
  1996. combination is received from the client, the packet will be dropped by kea-dhcp4.)
  1997. </para>
  1998. <para>
  1999. To override client delegation, set the following values in the configuration file:
  2000. </para>
  2001. <screen>
  2002. "Dhcp4": {
  2003. "dhcp-ddns": {
  2004. <userinput>"override-client-update": true</userinput>,
  2005. ...
  2006. },
  2007. ...
  2008. }
  2009. </screen>
  2010. <para>
  2011. The third row in the table above describes the case in which the client
  2012. requests that no DNS updates be done. The parameter, <command>override-no-update</command>,
  2013. can be used to instruct the server to disregard the client's wishes. When
  2014. this parameter is true, kea-dhcp4 will generate DDNS update requests to kea-dhcp-ddns
  2015. even if the client requests that no updates be done. The N-S-O flags in the
  2016. server's response to the client will be 0-1-1.
  2017. </para>
  2018. <para>
  2019. To override client delegation, the following values should be set in your configuration:
  2020. </para>
  2021. <screen>
  2022. "Dhcp4": {
  2023. "dhcp-ddns": {
  2024. <userinput>"override-no-update": true</userinput>,
  2025. ...
  2026. },
  2027. ...
  2028. }
  2029. </screen>
  2030. <para>
  2031. kea-dhcp4 will always generate DDNS update requests if the client request
  2032. only contains the Host Name option. In addition it will include an FQDN
  2033. option in the response to the client with the FQDN N-S-O flags set to
  2034. 0-1-0 respectively. The domain name portion of the FQDN option will be
  2035. the name submitted to D2 in the DDNS update request.
  2036. </para>
  2037. </section>
  2038. <section id="dhcpv4-fqdn-name-generation">
  2039. <title>kea-dhcp4 name generation for DDNS update requests</title>
  2040. <para>Each NameChangeRequest must of course include the fully qualified domain
  2041. name whose DNS entries are to be affected. kea-dhcp4 can be configured to
  2042. supply a portion or all of that name based upon what it receives from
  2043. the client in the DHCP REQUEST.</para>
  2044. <para>
  2045. The default rules for constructing the FQDN that will be used for DNS
  2046. entries are:
  2047. <orderedlist>
  2048. <listitem><para>
  2049. If the DHCPREQUEST contains the client FQDN option, the candidate name
  2050. is taken from there, otherwise it is taken from the Host Name option.
  2051. </para></listitem>
  2052. <listitem><para>
  2053. If the candidate name is a partial (i.e. unqualified) name then add a
  2054. configurable suffix to the name and use the result as the FQDN.
  2055. </para></listitem>
  2056. <listitem><para>
  2057. If the candidate name provided is empty, generate a FQDN using a
  2058. configurable prefix and suffix.
  2059. </para></listitem>
  2060. <listitem><para>
  2061. If the client provided neither option, then no DNS action will be taken.
  2062. </para></listitem>
  2063. </orderedlist>
  2064. These rules can amended by setting the
  2065. <command>replace-client-name</command> parameter which provides the
  2066. following modes of behavior:
  2067. <itemizedlist>
  2068. <listitem><para>
  2069. <command>never</command> - Use the name the client sent. If the client
  2070. sent no name, do not generate one. This is the default mode.
  2071. </para></listitem>
  2072. <listitem><para>
  2073. <command>always</command> - Replace the name the client sent. If the
  2074. client sent no name, generate one for the client.
  2075. </para></listitem>
  2076. <listitem><para>
  2077. <command>when-present</command> - Replace the name the client sent.
  2078. If the client sent no name, do not generate one.
  2079. </para></listitem>
  2080. <listitem><para>
  2081. <command>when-not-present</command> - Use the name the client sent.
  2082. If the client sent no name, generate one for the client.
  2083. </para></listitem>
  2084. </itemizedlist>
  2085. <note>
  2086. Note that formerly, this parameter was a boolean and permitted only values
  2087. of <command>true</command> and <command>false</command>. Boolean values
  2088. have been deprecated and are no longer accepted. If you are currently using
  2089. booleans, you must replace them with the desired mode name. A value of
  2090. <command>true</command> maps to <command>"when-present"</command>, while
  2091. <command>false</command> maps to <command>"never"</command>.
  2092. </note>
  2093. For example, To instruct kea-dhcp4 to always generate the FQDN for a
  2094. client, set the parameter <command>replace-client-name</command> to
  2095. <command>always</command> as follows:
  2096. </para>
  2097. <screen>
  2098. "Dhcp4": {
  2099. "dhcp-ddns": {
  2100. <userinput>"replace-client-name": "always"</userinput>,
  2101. ...
  2102. },
  2103. ...
  2104. }
  2105. </screen>
  2106. <para>
  2107. The prefix used in the generation of a FQDN is specified by the
  2108. <command>generated-prefix</command> parameter. The default value is "myhost". To alter
  2109. its value, simply set it to the desired string:
  2110. </para>
  2111. <screen>
  2112. "Dhcp4": {
  2113. "dhcp-ddns": {
  2114. <userinput>"generated-prefix": "another.host"</userinput>,
  2115. ...
  2116. },
  2117. ...
  2118. }
  2119. </screen>
  2120. <para>
  2121. The suffix used when generating a FQDN or when qualifying a
  2122. partial name is specified by
  2123. the <command>qualifying-suffix</command> parameter. This
  2124. parameter has no default value, thus it is mandatory when
  2125. DDNS updates are enabled.
  2126. To set its value simply set it to the desired string:
  2127. </para>
  2128. <screen>
  2129. "Dhcp4": {
  2130. "dhcp-ddns": {
  2131. <userinput>"qualifying-suffix": "foo.example.org"</userinput>,
  2132. ...
  2133. },
  2134. ...
  2135. }
  2136. </screen>
  2137. </section>
  2138. <para>
  2139. When generating a name, kea-dhcp4 will construct name of the format:
  2140. </para>
  2141. <para>
  2142. [generated-prefix]-[address-text].[qualifying-suffix].
  2143. </para>
  2144. <para>
  2145. where address-text is simply the lease IP address converted to a
  2146. hyphenated string. For example, if the lease address is 172.16.1.10,
  2147. the qualifying suffix "example.com", and the default value is used for
  2148. <command>generated-prefix</command>, the generated FQDN would be:
  2149. </para>
  2150. <para>
  2151. myhost-172-16-1-10.example.com.
  2152. </para>
  2153. </section>
  2154. <section id="dhcp4-next-server">
  2155. <title>Next Server (siaddr)</title>
  2156. <para>In some cases, clients want to obtain configuration from a TFTP server.
  2157. Although there is a dedicated option for it, some devices may use the siaddr field
  2158. in the DHCPv4 packet for that purpose. That specific field can be configured
  2159. using <command>next-server</command> directive. It is possible to define it in the global scope or
  2160. for a given subnet only. If both are defined, the subnet value takes precedence.
  2161. The value in subnet can be set to 0.0.0.0, which means that <command>next-server</command> should
  2162. not be sent. It may also be set to an empty string, which means the same as if
  2163. it was not defined at all, i.e. use the global value.
  2164. </para>
  2165. <screen>
  2166. "Dhcp4": {
  2167. <userinput>"next-server": "192.0.2.123"</userinput>,
  2168. ...,
  2169. "subnet4": [
  2170. {
  2171. <userinput>"next-server": "192.0.2.234"</userinput>,
  2172. ...
  2173. }
  2174. ]
  2175. }
  2176. </screen>
  2177. </section>
  2178. <section id="dhcp4-echo-client-id">
  2179. <title>Echoing Client-ID (RFC 6842)</title>
  2180. <para>The original DHCPv4 specification
  2181. (<ulink url="http://tools.ietf.org/html/rfc2131">RFC 2131</ulink>)
  2182. states that the DHCPv4
  2183. server must not send back client-id options when responding to
  2184. clients. However, in some cases that confused clients that did
  2185. not have MAC address or client-id; see
  2186. <ulink url="http://tools.ietf.org/html/rfc6842">RFC 6842</ulink>.
  2187. for details. That
  2188. behavior has changed with the publication of
  2189. <ulink url="http://tools.ietf.org/html/rfc6842">RFC 6842</ulink>
  2190. which updated
  2191. <ulink url="http://tools.ietf.org/html/rfc2131">RFC 2131</ulink>.
  2192. That update states that the server must
  2193. send client-id if the client sent it. That is Kea's default behavior.
  2194. However, in some cases older devices that do not support
  2195. <ulink url="http://tools.ietf.org/html/rfc6842">RFC 6842</ulink>.
  2196. may refuse to accept responses that include the
  2197. client-id option. To enable backward compatibility, an optional
  2198. configuration parameter has been introduced. To configure it,
  2199. use the following configuration statement:</para>
  2200. <screen>
  2201. "Dhcp4": {
  2202. <userinput>"echo-client-id": false</userinput>,
  2203. ...
  2204. }
  2205. </screen>
  2206. </section>
  2207. <section id="dhcp4-match-client-id">
  2208. <title>Using Client Identifier and Hardware Address</title>
  2209. <para>The DHCP server must be able to identify the client (and distinguish it from
  2210. other clients) from which it receives the message. There are many reasons
  2211. why this identification is required and the most important ones are:
  2212. <itemizedlist>
  2213. <listitem><simpara>When the client contacts the server to allocate a new
  2214. lease, the server must store the client identification information in
  2215. the lease database as a search key.</simpara></listitem>
  2216. <listitem><simpara>When the client is trying to renew or release the existing
  2217. lease, the server must be able to find the existing lease entry in the
  2218. database for this client, using the client identification information as a
  2219. search key.</simpara></listitem>
  2220. <listitem><simpara>Some configurations use static reservations for the IP
  2221. addresses and other configuration information. The server's administrator
  2222. uses client identification information to create these static assignments.
  2223. </simpara></listitem>
  2224. <listitem><simpara>In the dual stack networks there is often a need to
  2225. correlate the lease information stored in DHCPv4 and DHCPv6 server for
  2226. a particular host. Using common identification information by the DHCPv4
  2227. and DHCPv6 client allows the network administrator to achieve this
  2228. correlation and better administer the network.</simpara></listitem>
  2229. </itemizedlist>
  2230. </para>
  2231. <para>DHCPv4 makes use of two distinct identifiers which are placed
  2232. by the client in the queries sent to the server and copied by the server
  2233. to its responses to the client: "chaddr" and "client identifier". The
  2234. former was introduced as a part of the BOOTP specification and it is also
  2235. used by DHCP to carry the hardware address of the interface used to send
  2236. the query to the server (MAC address for the Ethernet). The latter is
  2237. carried in the Client-identifier option, introduced in
  2238. <ulink url="http://tools.ietf.org/html/rfc2132">RFC 2132</ulink>.
  2239. </para>
  2240. <para><ulink url="http://tools.ietf.org/html/rfc2131">RFC 2131</ulink>
  2241. indicates that the server may use both of these identifiers to identify
  2242. the client but the "client identifier", if present, takes precedence
  2243. over "chaddr". One of the reasons for this is that "client identifier"
  2244. is independent from the hardware used by the client to communicate with
  2245. the server. For example, if the client obtained the lease using one
  2246. network card and then the network card is moved to another host, the
  2247. server will wrongly identify this host is the one which has obtained
  2248. the lease. Moreover,
  2249. <ulink url="https://tools.ietf.org/html/rfc4361">RFC 4361</ulink> gives
  2250. the recommendation to use a DUID
  2251. (see <ulink url="https://tools.ietf.org/html/rfc3315">RFC 3315</ulink>,
  2252. the DHCPv6 specification)
  2253. carried as "client identifier" when dual stack networks are in use
  2254. to provide consistent identification information of the client, regardless
  2255. of the protocol type it is using. Kea adheres to these specifications and
  2256. the "client identifier" by default takes precedence over the value carried
  2257. in "chaddr" field when the server searches, creates, updates or removes
  2258. the client's lease.
  2259. </para>
  2260. <para>When the server receives a DHCPDISCOVER or DHCPREQUEST message from the
  2261. client, it will try to find out if the client already has a lease in the
  2262. database and will hand out that lease rather than allocate
  2263. a new one. Each lease in the lease database is associated with the
  2264. "client identifier" and/or "chaddr". The server will first use the
  2265. "client identifier" (if present) to search the lease. If the lease is
  2266. found, the server will treat this lease as belonging to the client
  2267. even if the current "chaddr" and the "chaddr" associated with
  2268. the lease do not match. This facilitates the scenario when the network card
  2269. on the client system has been replaced and thus the new MAC address
  2270. appears in the messages sent by the DHCP client. If the server fails
  2271. to find the lease using the "client identifier" it will perform another lookup
  2272. using the "chaddr". If this lookup returns no result, the client is
  2273. considered as not having a lease and the new lease will be created.
  2274. </para>
  2275. <para>A common problem reported by network operators is that poor
  2276. client implementations do not use stable client identifiers, instead
  2277. generating a new "client identifier" each time the client connects
  2278. to the network. Another well known case is when the client changes its
  2279. "client identifier" during the multi-stage boot process (PXE). In such
  2280. cases, the MAC address of the client's interface remains stable and
  2281. using "chaddr" field to identify the client guarantees that the
  2282. particular system is considered to be the same client, even though its
  2283. "client identifier" changes.
  2284. </para>
  2285. <para>To address this problem, Kea includes a configuration option
  2286. which enables client identification using "chaddr" only by instructing
  2287. the server to disregard server to "ignore" the "client identifier" during
  2288. lease lookups and allocations for a particular subnet. Consider the following
  2289. simplified server configuration:</para>
  2290. <screen>
  2291. "Dhcp4": {
  2292. ...
  2293. <userinput>"match-client-id": true,</userinput>
  2294. ...
  2295. "subnet4": [
  2296. {
  2297. "subnet": "192.0.10.0/24",
  2298. "pools": [ { "pool": "192.0.2.23-192.0.2.87" } ],
  2299. <userinput>"match-client-id": false</userinput>
  2300. },
  2301. {
  2302. "subnet": "10.0.0.0/8",
  2303. "pools": [ { "pool": "10.0.0.23-10.0.2.99" } ],
  2304. }
  2305. ]
  2306. }
  2307. </screen>
  2308. <para>The <command>match-client-id</command> is a boolean value which
  2309. controls this behavior. The default value of <userinput>true</userinput>
  2310. indicates that the server will use the "client identifier" for lease
  2311. lookups and "chaddr" if the first lookup returns no results. The
  2312. <command>false</command> means that the server will only
  2313. use the "chaddr" to search for client"s lease. Whether the DHCID for
  2314. DNS updates is generated from the "client identifier" or "chaddr" is
  2315. controlled through the same parameter accordingly.</para>
  2316. <para>The <command>match-client-id</command> parameter may appear
  2317. both in the global configuration scope and/or under any subnet
  2318. declaration. In the example shown above, the effective value of the
  2319. <command>match-client-id</command> will be <userinput>false</userinput>
  2320. for the subnet 192.0.10.0/24, because the subnet specific setting
  2321. of the parameter overrides the global value of the parameter. The
  2322. effective value of the <command>match-client-id</command> for the subnet
  2323. 10.0.0.0/8 will be set to <userinput>true</userinput> because the
  2324. subnet declaration lacks this parameter and the global setting is
  2325. by default used for this subnet. In fact, the global entry for this
  2326. parameter could be omitted in this case, because
  2327. <userinput>true</userinput> is the default value.
  2328. </para>
  2329. <para>It is important to explain what happens when the client obtains
  2330. its lease for one setting of the <command>match-client-id</command>
  2331. and then renews when the setting has been changed. First consider
  2332. the case when the client obtains the lease when the
  2333. <command>match-client-id</command> is set to <userinput>true</userinput>.
  2334. The server will store the lease information including "client identifier"
  2335. (if supplied) and "chaddr" in the lease database. When the setting is
  2336. changed and the client renews the lease the server will determine that
  2337. it should use the "chaddr" to search for the existing lease. If the
  2338. client hasn't changed its MAC address the server should successfully
  2339. find the existing lease. The "client identifier" associated with the
  2340. returned lease is ignored and the client is allowed to use this lease.
  2341. When the lease is renewed only the "chaddr" is recorded for this
  2342. lease according to the new server setting.
  2343. </para>
  2344. <para>In the second case the client has the lease with only a "chaddr"
  2345. value recorded. When the setting is changed to
  2346. <command>match-client-id</command> set to <userinput>true</userinput>
  2347. the server will first try to use the "client identifier" to find the
  2348. existing client's lease. This will return no results because the
  2349. "client identifier" was not recorded for this lease. The server will
  2350. then use the "chaddr" and the lease will be found. If the lease appears
  2351. to have no "client identifier" recorded, the server will assume that
  2352. this lease belongs to the client and that it was created with the previous
  2353. setting of the <command>match-client-id</command>.
  2354. However, if the lease contains "client identifier" which is different
  2355. from the "client identifier" used by the client the lease will be
  2356. assumed to belong to another client and the new lease will be
  2357. allocated.
  2358. </para>
  2359. </section>
  2360. <section id="dhcp4-dhcp4o6-config">
  2361. <title>DHCPv4-over-DHCPv6: DHCPv4 Side</title>
  2362. <para>
  2363. The support of DHCPv4-over-DHCPv6 transport is described in
  2364. <ulink url="http://tools.ietf.org/html/rfc7341">RFC 7341</ulink>
  2365. and is implemented using cooperating DHCPv4 and DHCPv6 servers.
  2366. This section is about the configuration of the DHCPv4 side
  2367. (the DHCPv6 side is described in <xref linkend="dhcp6-dhcp4o6-config"/>).
  2368. </para>
  2369. <note>
  2370. DHCPv4-over-DHCPv6 support is experimental and the details of
  2371. the inter-process communication can change: both the
  2372. DHCPv4 and DHCPv6 sides should be running the same version of Kea.
  2373. </note>
  2374. <para>
  2375. The <command>dhcp4o6-port</command> global parameter specifies
  2376. the first of the two consecutive ports of the UDP sockets used
  2377. for the communication between the DHCPv6 and DHCPv4 servers
  2378. (the DHCPv4 server is bound to ::1 on <command>port</command> + 1
  2379. and connected to ::1 on <command>port</command>).
  2380. </para>
  2381. <para>
  2382. With DHCPv4-over-DHCPv6 the DHCPv4 server does not have access
  2383. to several of the identifiers it would normally use to select a
  2384. subnet. In order to address this issue three new configuration
  2385. entries have been added. The presence of any of these allows the
  2386. subnet to be used with DHCPv4-over-DHCPv6. These entries are:
  2387. <itemizedlist>
  2388. <listitem>
  2389. <simpara><command>4o6-subnet</command>: Takes a prefix (i.e., an
  2390. IPv6 address followed by a slash and a prefix length) which is
  2391. matched against the source address.
  2392. </simpara>
  2393. </listitem>
  2394. <listitem>
  2395. <simpara><command>4o6-interface-id</command>: Takes a relay interface
  2396. ID option value.
  2397. </simpara>
  2398. </listitem>
  2399. <listitem>
  2400. <simpara><command>4o6-interface</command>: Takes an interface name
  2401. which is matched against the incoming interface name.
  2402. </simpara>
  2403. </listitem>
  2404. </itemizedlist>
  2405. </para>
  2406. <para>
  2407. The following configuration was used during some tests:
  2408. <screen>
  2409. {
  2410. # DHCPv4 conf
  2411. "Dhcp4": {
  2412. "interfaces-config": {
  2413. "interfaces": [ "eno33554984" ]
  2414. },
  2415. "lease-database": {
  2416. "type": "memfile",
  2417. "name": "leases4"
  2418. },
  2419. "valid-lifetime": 4000,
  2420. "subnet4": [ {
  2421. "subnet": "10.10.10.0/24",
  2422. <userinput>"4o6-interface": "eno33554984",</userinput>
  2423. <userinput>"4o6-subnet": "2001:db8:1:1::/64",</userinput>
  2424. "pools": [ { "pool": "10.10.10.100 - 10.10.10.199" } ]
  2425. } ],
  2426. <userinput>"dhcp4o6-port": 6767</userinput>
  2427. },
  2428. "Logging": {
  2429. "loggers": [ {
  2430. "name": "kea-dhcp4",
  2431. "output_options": [ {
  2432. "output": "/tmp/kea-dhcp4.log"
  2433. } ],
  2434. "severity": "DEBUG",
  2435. "debuglevel": 0
  2436. } ]
  2437. }
  2438. }
  2439. </screen>
  2440. </para>
  2441. </section>
  2442. </section> <!-- end of configuring kea-dhcp4 server section -->
  2443. <!-- Host reservation is a large topic. There will be many subsections,
  2444. so it should be a section on its own. -->
  2445. <section id="host-reservation-v4">
  2446. <title>Host Reservation in DHCPv4</title>
  2447. <para>There are many cases where it is useful to provide a configuration on
  2448. a per host basis. The most obvious one is to reserve a specific, static
  2449. address for exclusive use by a given client (host) &dash; the returning client will
  2450. receive the same address from the server every time, and other clients will
  2451. generally not receive that address.
  2452. Another example when the host reservations are applicable is when a host
  2453. has specific requirements, e.g. a printer that needs additional DHCP options.
  2454. Yet another possible use case is to define unique names for hosts.</para>
  2455. <para>Note that there may be cases when the
  2456. new reservation has been made for the client for the address being currently
  2457. in use by another client. We call this situation a "conflict". The conflicts
  2458. get resolved automatically over time as described in subsequent sections.
  2459. Once the conflict is resolved, the client will keep receiving the reserved
  2460. configuration when it renews.</para>
  2461. <para>Host reservations are defined as parameters for each subnet. Each host
  2462. has to be identified by an identifier, for example the hardware/MAC address. There is an optional
  2463. <command>reservations</command> array in the <command>Subnet4</command>
  2464. element. Each element in that array is a structure that holds information
  2465. about reservations for a single host. In particular, the structure has
  2466. to have an identifier that uniquely identifies a host. In the DHCPv4 context, the
  2467. identifier is usually a hardware or MAC address. In most cases an IP address
  2468. will be specified. It is also possible to specify a hostname, host
  2469. specific options or fields carried within DHCPv4 message such as siaddr,
  2470. sname or file.</para>
  2471. <para>In Kea 1.0.0 it was only possible to create host reservations
  2472. using client's hardware address. Host reservations by client
  2473. identifier, DUID and circuit-id have been added in Kea 1.1.0.</para>
  2474. <para>The following example shows how to reserve addresses for specific
  2475. hosts:
  2476. <screen>
  2477. "subnet4": [
  2478. {
  2479. "pools": [ { "pool": "192.0.2.1 - 192.0.2.200" } ],
  2480. "subnet": "192.0.2.0/24",
  2481. "interface": "eth0",
  2482. <userinput>"reservations": [
  2483. {
  2484. "hw-address": "1a:1b:1c:1d:1e:1f",
  2485. "ip-address": "192.0.2.202"
  2486. },
  2487. {
  2488. "duid": "0a:0b:0c:0d:0e:0f",
  2489. "ip-address": "192.0.2.100",
  2490. "hostname": "alice-laptop"
  2491. },
  2492. {
  2493. "circuit-id": "'charter950'",
  2494. "ip-address": "192.0.2.203"
  2495. },
  2496. {
  2497. "client-id": "01:11:22:33:44:55:66",
  2498. "ip-address": "192.0.2.204"
  2499. }
  2500. ]</userinput>
  2501. }
  2502. ]
  2503. </screen>
  2504. The first entry reserves the 192.0.2.202 address for the client that uses
  2505. a MAC address of 1a:1b:1c:1d:1e:1f. The second entry reserves the address
  2506. 192.0.2.100 and the hostname of alice-laptop for the client using a DUID
  2507. 0a:0b:0c:0d:0e:0f. (Note that if you plan to do DNS updates, it
  2508. is strongly recommended for the hostnames to be unique.) The third
  2509. example reserves address 192.0.3.203 to a client whose request
  2510. would be relayed by a relay agent that inserts a circuit-it option
  2511. with the value 'charter950'. The fourth entry reserves address
  2512. 192.0.2.204 for a client that uses a client identifier with value
  2513. 01:11:22:33:44:55:66.</para>
  2514. <para>The above example is used for illustrational purposes only
  2515. and in actual deployments it is recommended to use as few types as possible
  2516. (preferably just one). See <xref linkend="reservations4-tuning"/> for a detailed
  2517. discussion of this point.</para>
  2518. <para>Making a reservation for a mobile host that may visit multiple subnets
  2519. requires a separate host definition in each subnet it is expected to visit.
  2520. It is not allowed to define multiple host definitions with the same hardware
  2521. address in a single subnet. Multiple host definitions with the same hardware
  2522. address are valid if each is in a different subnet.
  2523. </para>
  2524. <para>Adding host reservation incurs a performance penalty. In principle,
  2525. when a server that does not support host reservation responds to a query,
  2526. it needs to check whether there is a lease for a given address being
  2527. considered for allocation or renewal. The server that also supports host
  2528. reservation has to perform additional checks: not only if the address is
  2529. currently used (i.e. if there is a lease for it), but also whether the address
  2530. could be used by someone else (i.e. there is a reservation for it). That
  2531. additional check incurs additional overhead.</para>
  2532. <section id="reservation4-types">
  2533. <title>Address Reservation Types</title>
  2534. <para>In a typical scenario there is an IPv4 subnet defined,
  2535. e.g. 192.0.2.0/24, with certain part of it dedicated for dynamic allocation
  2536. by the DHCPv4 server. That dynamic part is referred to as a dynamic pool or
  2537. simply a pool. In principle, a host reservation can reserve any address
  2538. that belongs to the subnet. The reservations that specify addresses that
  2539. belong to configured pools are called "in-pool reservations".
  2540. In contrast, those that do not belong to dynamic pools are called
  2541. "out-of-pool reservations". There is no formal difference
  2542. in the reservation syntax and both reservation types are
  2543. handled uniformly. However, upcoming releases may offer improved performance
  2544. if there are only out-of-pool reservations as the server will be able
  2545. to skip reservation checks when dealing with existing leases. Therefore,
  2546. system administrators are encouraged to use out-of-pool reservations if
  2547. possible.</para>
  2548. </section>
  2549. <section id="reservation4-conflict">
  2550. <title>Conflicts in DHCPv4 Reservations</title>
  2551. <para>As the reservations and lease information are stored separately,
  2552. conflicts may arise. Consider the following series of events. The server
  2553. has configured the dynamic pool of addresses from the range of 192.0.2.10 to
  2554. 192.0.2.20. Host A requests an address and gets 192.0.2.10. Now the system
  2555. administrator decides to reserve address 192.0.2.10 for Host B.
  2556. In general, reserving an address that
  2557. is currently assigned to someone else is not recommended, but there are
  2558. valid use cases where such an operation is warranted.</para>
  2559. <para>The server now has a conflict to resolve. Let's analyze the
  2560. situation here. If Host B boots up and requests an address, the server is
  2561. not able to assign the reserved address 192.0.2.10. A naive approach
  2562. would to be immediately remove the existing lease for the Host A
  2563. and create a new one for the Host B. That would not solve the problem,
  2564. though, because as soon as the Host B gets the address, it will detect
  2565. that the address is already in use by the Host A and would send
  2566. the DHCPDECLINE message. Therefore, in this situation, the server has
  2567. to temporarily assign a different address (not matching what has been
  2568. reserved) to the Host B.</para>
  2569. <!-- let's keep this text around. It describes how that is working in v6
  2570. <para>When the Host A renews its address, the server will discover that
  2571. the address being renewed is now reserved for someone else (host
  2572. B). Therefore the server will remove the lease and will inform the Host A
  2573. that it is no longer allowed to use it by sending DHCPNAK message. Host A
  2574. will then revert to server discovery and will eventually get a different
  2575. address. The address 192.0.2.10 is now no longer used. When host B tries
  2576. to renew its temporarily assigned address, the server will detect that
  2577. it has a valid lease, but there is a reservation for a different address.
  2578. The server will send DHCPNAK to inform host B that its address is no
  2579. longer usable. The server will also remove its temporary lease. It will
  2580. revert to the server discovery phase and will eventually send a
  2581. DHCPREQUEST message. This time the server will find out that there is a
  2582. reservation for that host and the reserved address 192.0.2.10 is not used,
  2583. so it will be granted.</para> -->
  2584. <para>When Host A renews its address, the server will discover that
  2585. the address being renewed is now reserved for another host - Host
  2586. B. Therefore the server will inform the Host A that it is no longer
  2587. allowed to use it by sending a DHCPNAK message. The server will not remove the
  2588. lease, though, as there's small chance that the DHCPNAK may be lost if the
  2589. network is lossy. If that happens, the client will not receive any
  2590. responses, so it will retransmit its DHCPREQUEST packet. Once the
  2591. DHCPNAK is received by Host A, it will revert to the server
  2592. discovery and will eventually get a different address. Besides
  2593. allocating a new lease, the server will also remove the old one. As
  2594. a result, address 192.0.2.10 will become free . When Host B
  2595. tries to renew its temporarily assigned address, the server will detect
  2596. that it has a valid lease, but there is a reservation for a different
  2597. address. The server will send DHCPNAK to inform Host B that its address
  2598. is no longer usable, but will keep its lease (again, the DHCPNAK may be
  2599. lost, so the server will keep it, until the client returns for a new
  2600. address). Host B will revert to the server discovery phase and will
  2601. eventually send a DHCPREQUEST message. This time the server will find
  2602. out that there is a reservation for that host and the reserved address
  2603. 192.0.2.10 is not used, so it will be granted. It will also remove the
  2604. lease for the temporarily assigned address that Host B previously
  2605. obtained.</para>
  2606. <para>This recovery will succeed, even if other hosts will attempt to get
  2607. the reserved address. Had the Host C requested address 192.0.2.10 after
  2608. the reservation was made, the server will either offer a different
  2609. address (when responding to DHCPDISCOVER) or would send DHCPNAK
  2610. (when responding to DHCPREQUEST).</para>
  2611. <para>This recovery mechanism allows the server to fully recover from a
  2612. case where reservations conflict with the existing leases. This procedure
  2613. takes time and will roughly take as long as the value set for of renew-timer.
  2614. The best way to avoid such recovery is to not define new reservations that
  2615. conflict with existing leases. Another recommendation is to use
  2616. out-of-pool reservations. If the reserved address does not belong to a
  2617. pool, there is no way that other clients could get this address.
  2618. </para>
  2619. </section>
  2620. <section id="reservation4-hostname">
  2621. <title>Reserving a Hostname</title>
  2622. <para>When the reservation for a client includes the <command>hostname</command>,
  2623. the server will return this hostname to the client in
  2624. the Client FQDN or Hostname options. The server responds with the Client
  2625. FQDN option only if the client has included Client FQDN option in its
  2626. message to the server. The server will respond with the Hostname option
  2627. if the client included Hostname option in its message to the server
  2628. or when the client requested Hostname option using Parameter Request
  2629. List option. The server will return the Hostname option even if it is not
  2630. configured to perform DNS updates. The reserved hostname always takes
  2631. precedence over the hostname supplied by the client or the autogenerated
  2632. (from the IPv4 address) hostname.</para>
  2633. <para>The server qualifies the reserved hostname with the value
  2634. of the <command>qualifying-suffix</command> parameter. For example, the
  2635. following subnet configuration:
  2636. <screen>
  2637. {
  2638. "subnet4": [ {
  2639. "subnet": "10.0.0.0/24",
  2640. "pools": [ { "pool": "10.0.0.10-10.0.0.100" } ],
  2641. "reservations": [
  2642. {
  2643. "hw-address": "aa:bb:cc:dd:ee:ff",
  2644. "hostname": "alice-laptop"
  2645. }
  2646. ]
  2647. }],
  2648. "dhcp-ddns": {
  2649. "enable-updates": true,
  2650. "qualifying-suffix": "example.isc.org."
  2651. }
  2652. }
  2653. </screen>
  2654. will result in assigning the "alice-laptop.example.isc.org." hostname to the
  2655. client using the MAC address "aa:bb:cc:dd:ee:ff". If the <command>qualifying-suffix
  2656. </command> is not specified, the default (empty) value will be used, and
  2657. in this case the value specified as a <command>hostname</command> will
  2658. be treated as fully qualified name. Thus, by leaving the
  2659. <command>qualifying-suffix</command> empty it is possible to qualify
  2660. hostnames for the different clients with different domain names:
  2661. <screen>
  2662. {
  2663. "subnet4": [ {
  2664. "subnet": "10.0.0.0/24",
  2665. "pools": [ { "pool": "10.0.0.10-10.0.0.100" } ],
  2666. "reservations": [
  2667. {
  2668. "hw-address": "aa:bb:cc:dd:ee:ff",
  2669. "hostname": "alice-laptop.isc.org."
  2670. },
  2671. {
  2672. "hw-address": "12:34:56:78:99:AA",
  2673. "hostname": "mark-desktop.example.org."
  2674. }
  2675. ]
  2676. }],
  2677. "dhcp-ddns": {
  2678. "enable-updates": true,
  2679. }
  2680. }
  2681. </screen>
  2682. </para>
  2683. </section>
  2684. <section id="reservation4-options">
  2685. <title>Including Specific DHCPv4 Options in Reservations</title>
  2686. <para>Kea 1.1.0 introduced the ability to specify options on a
  2687. per host basis. The options follow the same rules as any other
  2688. options. These can be standard options (see <xref
  2689. linkend="dhcp4-std-options" />), custom options (see <xref
  2690. linkend="dhcp4-custom-options"/>) or vendor specific options
  2691. (see <xref linkend="dhcp4-vendor-opts" />). The following
  2692. example demonstrates how standard options can be defined.</para>
  2693. <screen>
  2694. {
  2695. "subnet4": [ {
  2696. "reservations": [
  2697. {
  2698. "hw-address": "aa:bb:cc:dd:ee:ff",
  2699. "ip-address": "192.0.2.1",
  2700. <userinput>"option-data": [
  2701. {
  2702. "name": "cookie-servers",
  2703. "data": "10.1.1.202,10.1.1.203"
  2704. },
  2705. {
  2706. "name": "log-servers",
  2707. "data": "10.1.1.200,10.1.1.201"
  2708. } ]</userinput>
  2709. } ]
  2710. } ]
  2711. }</screen>
  2712. <para>Vendor specific options can be reserved in a similar manner:</para>
  2713. <screen>
  2714. {
  2715. "subnet4": [ {
  2716. "reservations": [
  2717. {
  2718. "hw-address": "aa:bb:cc:dd:ee:ff",
  2719. "ip-address": "10.0.0.7",
  2720. <userinput>"option-data": [
  2721. {
  2722. "name": "vivso-suboptions",
  2723. "data": "4491"
  2724. },
  2725. {
  2726. "name": "tftp-servers",
  2727. "space": "vendor-4491",
  2728. "data": "10.1.1.202,10.1.1.203"
  2729. } ]</userinput>
  2730. } ]
  2731. } ]
  2732. }</screen>
  2733. <para>
  2734. Options defined on host level have the highest priority. In other words,
  2735. if there are options defined with the same type on global, subnet, class and
  2736. host level, the host specific values will be used.
  2737. </para>
  2738. </section>
  2739. <section id="reservation4-message-fields">
  2740. <title>Reserving Next Server, Server Hostname and Boot File Name</title>
  2741. <para>BOOTP/DHCPv4 messages include "siaddr", "sname" and "file" fields.
  2742. Even though, DHCPv4 includes corresponding options, such as option 66 and
  2743. option 67, some clients may not support these options. For this reason, server
  2744. administrators often use the "siaddr", "sname" and "file" fields instead.</para>
  2745. <para>With Kea, it is possible to make static reservations for these DHCPv4
  2746. message fields:</para>
  2747. <screen>
  2748. {
  2749. "subnet4": [ {
  2750. "reservations": [
  2751. {
  2752. "hw-address": "aa:bb:cc:dd:ee:ff",
  2753. <userinput>"next-server": "10.1.1.2",
  2754. "server-hostname": "server-hostname.example.org",
  2755. "boot-file-name": "/tmp/bootfile.efi"</userinput>
  2756. } ]
  2757. } ]
  2758. }</screen>
  2759. <para>Note that those parameters can be specified in combination with
  2760. other parameters for a reservation, e.g. reserved IPv4 address. These
  2761. parameters are optional, i.e. a subset of them can specified, or all of
  2762. them can be omitted.</para>
  2763. </section>
  2764. <section id="reservation4-client-classes">
  2765. <title>Reserving Client Classes in DHCPv4</title>
  2766. <para><xref linkend="classification-using-expressions"/> explains how
  2767. to configure the server to assign classes to a client based on the content
  2768. of the options that this client sends to the server. Host reservations
  2769. mechanisms also allow for statically assigning classes to the clients.
  2770. The definitions of these classes must exist in the Kea
  2771. configuration. The following configuration snippet shows how to specify
  2772. that a client belongs to classes <command>reserved-class1</command>
  2773. and <command>reserved-class2</command>. Those classes are associated with
  2774. specific options being sent to the clients which belong to them.
  2775. </para>
  2776. <screen>
  2777. {
  2778. "client-classes": [
  2779. {
  2780. "name": "reserved-class1",
  2781. "option-data": [
  2782. {
  2783. "name": "routers",
  2784. "data": "10.0.0.200"
  2785. }
  2786. ]
  2787. },
  2788. {
  2789. "name": "reserved-class2",
  2790. "option-data": [
  2791. {
  2792. "name": "domain-name-servers",
  2793. "data": "10.0.0.201"
  2794. }
  2795. ]
  2796. }
  2797. ],
  2798. "subnet4": [ {
  2799. "subnet": "10.0.0.0/24",
  2800. "pools": [ { "pool": "10.0.0.10-10.0.0.100" } ],
  2801. "reservations": [
  2802. {
  2803. "hw-address": "aa:bb:cc:dd:ee:ff",
  2804. <userinput>
  2805. "client-classes": [ "reserved-class1", "reserved-class2" ]
  2806. </userinput>
  2807. }
  2808. ]
  2809. } ]
  2810. }
  2811. </screen>
  2812. <para>Static class assignments, as shown above, can be used in conjunction
  2813. with classification using expressions.</para>
  2814. </section>
  2815. <section id="reservations4-mysql-pgsql">
  2816. <title>Storing Host Reservations in MySQL or PostgreSQL</title>
  2817. <para>
  2818. It is possible to store host reservations in MySQL or PostgreSQL database. See
  2819. <xref linkend="hosts4-storage"/> for information on how to configure Kea to use
  2820. reservations stored in MySQL or PostgreSQL. Kea does not provide any dedicated
  2821. tools for managing reservations in a database. The Kea wiki <ulink
  2822. url="http://kea.isc.org/wiki/HostReservationsHowTo" /> provides detailed
  2823. information and examples of how reservations can be inserted into the
  2824. database.
  2825. </para>
  2826. <note><simpara>In Kea 1.1.0 maximum length of an option specified per host is
  2827. arbitrarily set to 4096 bytes.</simpara></note>
  2828. </section>
  2829. <section id="reservations4-cql">
  2830. <title>Storing host reservations in CQL (Cassandra)</title>
  2831. <para>Kea currently does not support storing reservations in
  2832. Cassandra (CQL).</para>
  2833. </section>
  2834. <section id="reservations4-tuning">
  2835. <title>Fine Tuning DHCPv4 Host Reservation</title>
  2836. <para>The host reservation capability introduces additional restrictions for the
  2837. allocation engine (the component of Kea that selects an address for a client)
  2838. during lease selection and renewal. In particular, three
  2839. major checks are necessary. First, when selecting a new lease, it is not
  2840. sufficient for a candidate lease to not be used by another DHCP client. It
  2841. also must not be reserved for another client. Second, when renewing a lease,
  2842. additional check must be performed whether the address being renewed is not
  2843. reserved for another client. Finally, when a host renews an address, the server
  2844. has to check whether there is a reservation for this host, so the existing
  2845. (dynamically allocated) address should be revoked and the reserved one be
  2846. used instead.
  2847. </para>
  2848. <para>Some of those checks may be unnecessary in certain deployments and not
  2849. performing them may improve performance. The Kea server provides the
  2850. <command>reservation-mode</command> configuration parameter to select the
  2851. types of reservations allowed for the particular subnet. Each reservation
  2852. type has different constraints for the checks to be performed by the
  2853. server when allocating or renewing a lease for the client.
  2854. Allowed values are:
  2855. <itemizedlist>
  2856. <listitem><simpara> <command>all</command> - enables all host reservation
  2857. types. This is the default value. This setting is the safest and the most
  2858. flexible. It allows in-pool and out-of-pool reservations. As all checks
  2859. are conducted, it is also the slowest.
  2860. </simpara></listitem>
  2861. <listitem><simpara> <command>out-of-pool</command> - allows only out of
  2862. pool host reservations. With this setting in place, the server may assume
  2863. that all host reservations are for addresses that do not belong to the
  2864. dynamic pool. Therefore it can skip the reservation checks when dealing
  2865. with in-pool addresses, thus improving performance. Do not use this mode
  2866. if any of your reservations use in-pool address. Caution is advised when
  2867. using this setting: Kea 1.1.0 does not sanity check the reservations against
  2868. <command>reservation-mode</command> and misconfiguration may cause problems.
  2869. </simpara></listitem>
  2870. <listitem><simpara>
  2871. <command>disabled</command> - host reservation support is disabled. As there
  2872. are no reservations, the server will skip all checks. Any reservations defined
  2873. will be completely ignored. As the checks are skipped, the server may
  2874. operate faster in this mode.
  2875. </simpara></listitem>
  2876. </itemizedlist>
  2877. </para>
  2878. <para>
  2879. An example configuration that disables reservation looks like follows:
  2880. <screen>
  2881. "Dhcp4": {
  2882. "subnet4": [
  2883. {
  2884. "subnet": "192.0.2.0/24",
  2885. <userinput>"reservation-mode": "disabled"</userinput>,
  2886. ...
  2887. }
  2888. ]
  2889. }
  2890. </screen>
  2891. </para>
  2892. <para>Another aspect of the host reservations are the different types of
  2893. identifiers. Kea 1.1.0 supports four types of identifiers
  2894. (hw-address, duid, client-id and circuit-id), but more identifier types
  2895. are likely to be added in the future. This is beneficial from a
  2896. usability perspective. However, there is a drawback. For each incoming
  2897. packet Kea has to to extract each identifier type and then query the
  2898. database to see if there is a reservation done by this particular
  2899. identifier. If nothing is found, the next identifier is extracted and the next
  2900. query is issued. This process continues until either a reservation is
  2901. found or all identifier types have been checked. Over time with an increasing
  2902. number of supported identifier types, Kea would become slower and
  2903. slower.</para>
  2904. <para>To address this problem, a parameter called
  2905. <command>host-reservation-identifiers</command> has been introduced. It
  2906. takes a list of identifier types as a parameter. Kea will check only those
  2907. identifier types enumerated in host-reservation-identifiers. From a
  2908. performance perspective the number of identifier types should be kept to a
  2909. minimum, ideally limited to one. If your deployment uses several
  2910. reservation types, please enumerate them from most to least frequently
  2911. used as this increases the chances of Kea finding the reservation using the
  2912. fewest number of queries. An example of host reservation identifiers looks
  2913. as follows:
  2914. <screen>
  2915. <userinput>"host-reservation-identifiers": [ "circuit-id", "hw-address", "duid", "client-id" ],</userinput>
  2916. "subnet4": [
  2917. {
  2918. "subnet": "192.0.2.0/24",
  2919. ...
  2920. }
  2921. ]</screen>
  2922. </para>
  2923. <para>
  2924. If not specified, the default value is:
  2925. <screen>
  2926. <userinput>"host-reservation-identifiers": [ "hw-address", "duid", "circuit-id", "client-id" ]</userinput>
  2927. </screen>
  2928. <!-- see CfgHostOperations::createConfig4() in
  2929. src/lib/dhcpsrv/cfg_host_operations.cc -->
  2930. </para>
  2931. </section>
  2932. </section>
  2933. <!-- end of host reservations section -->
  2934. <section id="dhcp4-serverid">
  2935. <title>Server Identifier in DHCPv4</title>
  2936. <para>
  2937. The DHCPv4 protocol uses a "server identifier" to allow clients
  2938. to discriminate between several servers present on the same link: this
  2939. value is an IPv4 address of the server. The server chooses the IPv4 address
  2940. of the interface on which the message from the client (or relay) has been
  2941. received. A single server instance will use multiple server identifiers
  2942. if it is receiving queries on multiple interfaces.
  2943. </para>
  2944. <para>
  2945. Currently there is no mechanism to override the default server identifiers
  2946. by an administrator. In the future, the configuration mechanism will be used
  2947. to specify the custom server identifier.
  2948. </para>
  2949. </section>
  2950. <section id="dhcp4-subnet-selection">
  2951. <title>How the DHCPv4 Server Selects a Subnet for the Client</title>
  2952. <para>
  2953. The DHCPv4 server differentiates between the directly connected clients,
  2954. clients trying to renew leases and clients sending their messages through
  2955. relays. For directly connected clients, the server will check the
  2956. configuration for the interface on which the message has been received and,
  2957. if the server configuration doesn't match any configured subnet, the
  2958. message is discarded.</para>
  2959. <para>Assuming that the server's interface is configured with the
  2960. IPv4 address 192.0.2.3, the server will only process messages received through
  2961. this interface from a directly connected client if there is a subnet
  2962. configured to which this IPv4 address belongs, e.g. 192.0.2.0/24.
  2963. The server will use this subnet to assign IPv4 address for the client.
  2964. </para>
  2965. <para>
  2966. The rule above does not apply when the client unicasts its message, i.e.
  2967. is trying to renew its lease. Such a message is accepted through any
  2968. interface. The renewing client sets ciaddr to the currently used IPv4
  2969. address. The server uses this address to select the subnet for the client
  2970. (in particular, to extend the lease using this address).
  2971. </para>
  2972. <para>
  2973. If the message is relayed it is accepted through any interface. The giaddr
  2974. set by the relay agent is used to select the subnet for the client.
  2975. </para>
  2976. <para>
  2977. It is also possible to specify a relay IPv4 address for a given subnet. It
  2978. can be used to match incoming packets into a subnet in uncommon configurations,
  2979. e.g. shared subnets. See <xref linkend="dhcp4-relay-override"/> for details.
  2980. </para>
  2981. <note>
  2982. <para>The subnet selection mechanism described in this section is based
  2983. on the assumption that client classification is not used. The classification
  2984. mechanism alters the way in which a subnet is selected for the client,
  2985. depending on the classes to which the client belongs.</para>
  2986. </note>
  2987. <section id="dhcp4-relay-override">
  2988. <title>Using a Specific Relay Agent for a Subnet</title>
  2989. <para>
  2990. A relay has to have an interface connected to the link on which
  2991. the clients are being configured. Typically the relay has an IPv4
  2992. address configured on that interface that belongs to the subnet from which
  2993. the server will assign addresses. In the typical case, the
  2994. server is able to use the IPv4 address inserted by the relay (in the giaddr
  2995. field of the DHCPv4 packet) to select the appropriate subnet.
  2996. </para>
  2997. <para>
  2998. However, that is not always the case. In certain uncommon &mdash;
  2999. but valid &mdash; deployments, the relay address may not match the subnet. This
  3000. usually means that there is more than one subnet allocated for a given
  3001. link. The two most common examples where this is the case are long lasting
  3002. network renumbering (where both old and new address space is still being
  3003. used) and a cable network. In a cable network both cable modems and the
  3004. devices behind them are physically connected to the same link, yet
  3005. they use distinct addressing. In such a case, the DHCPv4 server needs
  3006. additional information (the IPv4 address of the relay) to properly select
  3007. an appropriate subnet.
  3008. </para>
  3009. <para>
  3010. The following example assumes that there is a subnet 192.0.2.0/24
  3011. that is accessible via a relay that uses 10.0.0.1 as its IPv4 address.
  3012. The server will be able to select this subnet for any incoming packets
  3013. that came from a relay that has an address in 192.0.2.0/24 subnet.
  3014. It will also select that subnet for a relay with address 10.0.0.1.
  3015. <screen>
  3016. "Dhcp4": {
  3017. "subnet4": [
  3018. {
  3019. "subnet": "192.0.2.0/24",
  3020. "pools": [ { "pool": "192.0.2.10 - 192.0.2.20" } ],
  3021. <userinput>"relay": {
  3022. "ip-address": "10.0.0.1"
  3023. }</userinput>,
  3024. ...
  3025. }
  3026. ],
  3027. ...
  3028. }
  3029. </screen>
  3030. </para>
  3031. <para>If "relay" is specified, the "ip-address" parameter within
  3032. it is mandatory.</para>
  3033. </section>
  3034. <section id="dhcp4-srv-example-client-class-relay">
  3035. <title>Segregating IPv4 Clients in a Cable Network</title>
  3036. <para>
  3037. In certain cases, it is useful to mix relay address information,
  3038. introduced in <xref linkend="dhcp4-relay-override"/> with client
  3039. classification, explained in <xref linkend="classify"/>.
  3040. One specific example is cable network, where typically modems
  3041. get addresses from a different subnet than all devices connected
  3042. behind them.
  3043. </para>
  3044. <para>
  3045. Let us assume that there is one CMTS (Cable Modem Termination System)
  3046. with one CM MAC (a physical link that modems are connected to).
  3047. We want the modems to get addresses from the 10.1.1.0/24 subnet, while
  3048. everything connected behind modems should get addresses from another
  3049. subnet (192.0.2.0/24). The CMTS that acts as a relay uses address
  3050. 10.1.1.1. The following configuration can serve that configuration:
  3051. <screen>
  3052. "Dhcp4": {
  3053. "subnet4": [
  3054. {
  3055. "subnet": "10.1.1.0/24",
  3056. "pools": [ { "pool": "10.1.1.2 - 10.1.1.20" } ],
  3057. <userinput>"client-class" "docsis3.0",
  3058. "relay": {
  3059. "ip-address": "10.1.1.1"
  3060. }</userinput>
  3061. },
  3062. {
  3063. "subnet": "192.0.2.0/24",
  3064. "pools": [ { "pool": "192.0.2.10 - 192.0.2.20" } ],
  3065. <userinput>"relay": {
  3066. "ip-address": "10.1.1.1"
  3067. }</userinput>
  3068. }
  3069. ],
  3070. ...
  3071. }
  3072. </screen>
  3073. </para>
  3074. </section>
  3075. </section>
  3076. <section id="dhcp4-decline">
  3077. <title>Duplicate Addresses (DHCPDECLINE Support)</title>
  3078. <para>The DHCPv4 server is configured with a certain pool of addresses
  3079. that it is expected to hand out to the DHCPv4 clients. It is
  3080. assumed that the server is authoritative and has complete jurisdiction
  3081. over those addresses. However, due to various reasons, such as
  3082. misconfiguration or a faulty client implementation that retains its
  3083. address beyond the valid lifetime, there may be devices connected that use
  3084. those addresses without the server's approval or knowledge.</para>
  3085. <para>Such an
  3086. unwelcome event can be detected by legitimate clients (using ARP or ICMP
  3087. Echo Request mechanisms) and reported to the DHCPv4 server using a DHCPDECLINE
  3088. message. The server will do a sanity check (if the client declining an
  3089. address really was supposed to use it), and then will conduct a clean up
  3090. operation. Any DNS entries related to that address will be removed, the
  3091. fact will be logged and hooks will be triggered. After that is done, the
  3092. address will be marked as declined (which indicates that it is used by an
  3093. unknown entity and thus not available for assignment to anyone) and a
  3094. probation time will be set on it. Unless otherwise configured, the
  3095. probation period lasts 24 hours. After that period, the server will
  3096. recover the lease (i.e. put it back into the available state) and the address will
  3097. be available for assignment again. It should be noted that if the
  3098. underlying issue of a misconfigured device is not resolved, the duplicate
  3099. address scenario will repeat. On the other hand, it provides an
  3100. opportunity to recover from such an event automatically, without any
  3101. sysadmin intervention.</para>
  3102. <para>To configure the decline probation period to a value other
  3103. than the default, the following syntax can be used:
  3104. <screen>
  3105. "Dhcp4": {
  3106. <userinput>"decline-probation-period": 3600</userinput>,
  3107. "subnet4": [ ... ],
  3108. ...
  3109. }
  3110. </screen>
  3111. The parameter is expressed in seconds, so the example above will instruct
  3112. the server to recycle declined leases after an hour.</para>
  3113. <para>There are several statistics and hook points associated with the
  3114. Decline handling procedure. The lease4_decline hook is triggered after the
  3115. incoming DHCPDECLINE message has been sanitized and the server is about to
  3116. decline the lease. The declined-addresses statistic is increased after the
  3117. hook returns (both global and subnet specific variants). (See
  3118. <xref linkend="dhcp4-stats"/> and <xref linkend="hooks-libraries"/> for more details
  3119. on DHCPv4 statistics and Kea hook points.)</para>
  3120. <para>Once the probation time elapses, the declined lease is recovered
  3121. using the standard expired lease reclamation procedure, with several
  3122. additional steps. In particular, both declined-addresses statistics
  3123. (global and subnet specific) are decreased. At the same time,
  3124. reclaimed-declined-addresses statistics (again in two variants, global and
  3125. subnet specific) are increased.</para>
  3126. <para>Note about statistics: The server does not decrease the
  3127. assigned-addresses statistics when a DHCPDECLINE is received and processed
  3128. successfully. While technically a declined address is no longer assigned,
  3129. the primary usage of the assigned-addresses statistic is to monitor pool
  3130. utilization. Most people would forget to include declined-addresses in the
  3131. calculation, and simply do assigned-addresses/total-addresses. This would
  3132. have a bias towards under-representing pool utilization. As this has a
  3133. potential for major issues, we decided not to decrease assigned addresses
  3134. immediately after receiving DHCPDECLINE, but to do it later when we
  3135. recover the address back to the available pool.</para>
  3136. </section>
  3137. <section id="dhcp4-stats">
  3138. <title>Statistics in the DHCPv4 Server</title>
  3139. <note>
  3140. <para>This section describes DHCPv4-specific statistics. For a general
  3141. overview and usage of statistics, see <xref linkend="stats" />.</para>
  3142. </note>
  3143. <para>
  3144. The DHCPv4 server supports the following statistics:
  3145. </para>
  3146. <table frame="all" id="dhcp4-statistics">
  3147. <title>DHCPv4 Statistics</title>
  3148. <tgroup cols='3'>
  3149. <colspec colname='statistic' align='center'/>
  3150. <colspec colname='type' align='center'/>
  3151. <colspec colname='description' align='left'/>
  3152. <thead>
  3153. <row>
  3154. <entry>Statistic</entry>
  3155. <entry>Data Type</entry>
  3156. <entry>Description</entry>
  3157. </row>
  3158. </thead>
  3159. <tbody>
  3160. <row>
  3161. <entry>pkt4-received</entry>
  3162. <entry>integer</entry>
  3163. <entry>
  3164. Number of DHCPv4 packets received. This includes all packets: valid,
  3165. bogus, corrupted, rejected etc. This statistic is expected to grow
  3166. rapidly.
  3167. </entry>
  3168. </row>
  3169. <row>
  3170. <entry>pkt4-discover-received</entry>
  3171. <entry>integer</entry>
  3172. <entry>
  3173. Number of DHCPDISCOVER packets received. This statistic is expected to grow.
  3174. Its increase means that clients that just booted started their configuration process
  3175. and their initial packets reached your server.
  3176. </entry>
  3177. </row>
  3178. <row>
  3179. <entry>pkt4-offer-received</entry>
  3180. <entry>integer</entry>
  3181. <entry>
  3182. Number of DHCPOFFER packets received. This statistic
  3183. is expected to remain zero at all times, as DHCPOFFER packets are sent
  3184. by the server and the server is never expected to receive them. Non-zero
  3185. value indicates an error. One likely cause would be a misbehaving relay
  3186. agent that incorrectly forwards DHCPOFFER messages towards the server,
  3187. rather back to the clients.
  3188. </entry>
  3189. </row>
  3190. <row>
  3191. <entry>pkt4-request-received</entry>
  3192. <entry>integer</entry>
  3193. <entry>
  3194. Number of DHCPREQUEST packets received. This statistic
  3195. is expected to grow. Its increase means that clients that just booted
  3196. received server's response (DHCPOFFER), accepted it and now requesting
  3197. an address (DHCPREQUEST).
  3198. </entry>
  3199. </row>
  3200. <row>
  3201. <entry>pkt4-ack-received</entry>
  3202. <entry>integer</entry>
  3203. <entry>
  3204. Number of DHCPACK packets received. This statistic
  3205. is expected to remain zero at all times, as DHCPACK packets are sent
  3206. by the server and the server is never expected to receive them. Non-zero
  3207. value indicates an error. One likely cause would be a misbehaving relay
  3208. agent that incorrectly forwards DHCPACK messages towards the server,
  3209. rather back to the clients.
  3210. </entry>
  3211. </row>
  3212. <row>
  3213. <entry>pkt4-nak-received</entry>
  3214. <entry>integer</entry>
  3215. <entry>
  3216. Number of DHCPNAK packets received. This statistic
  3217. is expected to remain zero at all times, as DHCPNAK packets are sent
  3218. by the server and the server is never expected to receive them. Non-zero
  3219. value indicates an error. One likely cause would be a misbehaving relay
  3220. agent that incorrectly forwards DHCPNAK messages towards the server,
  3221. rather back to the clients.
  3222. </entry>
  3223. </row>
  3224. <row>
  3225. <entry>pkt4-release-received</entry>
  3226. <entry>integer</entry>
  3227. <entry>
  3228. Number of DHCPRELEASE packets received. This statistic
  3229. is expected to grow. Its increase means that clients that had an address
  3230. are shutting down or stop using their addresses.
  3231. </entry>
  3232. </row>
  3233. <row>
  3234. <entry>pkt4-decline-received</entry>
  3235. <entry>integer</entry>
  3236. <entry>
  3237. Number of DHCPDECLINE packets received. This statistic
  3238. is expected to remain close to zero. Its increase means that a client
  3239. that leased an address, but discovered that the address is currently
  3240. used by an unknown device in your network.
  3241. </entry>
  3242. </row>
  3243. <row>
  3244. <entry>pkt4-inform-received</entry>
  3245. <entry>integer</entry>
  3246. <entry>
  3247. Number of DHCPINFORM packets received. This statistic
  3248. is expected to grow. Its increase means that there are clients that
  3249. either do not need an address or already have an address and are
  3250. interested only in getting additional configuration parameters.
  3251. </entry>
  3252. </row>
  3253. <row>
  3254. <entry>pkt4-unknown-received</entry>
  3255. <entry>integer</entry>
  3256. <entry>
  3257. Number of packets received of an unknown type. Non-zero
  3258. value of this statistic indicates that the server received a packet
  3259. that it wasn't able to recognize: either with unsupported type
  3260. or possibly malformed (without message type option).
  3261. </entry>
  3262. </row>
  3263. <row>
  3264. <entry>pkt4-sent</entry>
  3265. <entry>integer</entry>
  3266. <entry>
  3267. Number of DHCPv4 packets sent. This statistic is expected to grow
  3268. every time the server transmits a packet. In general, it should
  3269. roughly match pkt4-received, as most incoming packets cause
  3270. server to respond. There are exceptions (e.g. DHCPRELEASE), so
  3271. do not worry, if it is lesser than pkt4-received.
  3272. </entry>
  3273. </row>
  3274. <row>
  3275. <entry>pkt4-offer-sent</entry>
  3276. <entry>integer</entry>
  3277. <entry>
  3278. Number of DHCPOFFER packets sent. This statistic is expected to
  3279. grow in most cases after a DHCPDISCOVER is processed. There are
  3280. certain uncommon, but valid cases where incoming DHCPDISCOVER is
  3281. dropped, but in general this statistic is expected to be close to
  3282. pkt4-discover-received.
  3283. </entry>
  3284. </row>
  3285. <row>
  3286. <entry>pkt4-ack-sent</entry>
  3287. <entry>integer</entry>
  3288. <entry>
  3289. Number of DHCPACK packets sent. This statistic is expected to
  3290. grow in most cases after a DHCPREQUEST is processed. There are
  3291. certain cases where DHCPNAK is sent instead. In general, the sum of
  3292. pkt4-ack-sent and pkt4-nak-sent should be close to
  3293. pkt4-request-received.
  3294. </entry>
  3295. </row>
  3296. <row>
  3297. <entry>pkt4-nak-sent</entry>
  3298. <entry>integer</entry>
  3299. <entry>
  3300. Number of DHCPNAK packets sent. This statistic is expected
  3301. to grow when the server chooses to not honor the address
  3302. requested by a client. In general, the sum of
  3303. pkt4-ack-sent and pkt4-nak-sent should be close to
  3304. pkt4-request-received.
  3305. </entry>
  3306. </row>
  3307. <row>
  3308. <entry>pkt4-parse-failed</entry>
  3309. <entry>integer</entry>
  3310. <entry>
  3311. Number of incoming packets that could not be parsed. A non-zero value of
  3312. this statistic indicates that the server received malformed or truncated packet.
  3313. This may indicate problems in your network, faulty clients or a bug in the server.
  3314. </entry>
  3315. </row>
  3316. <row>
  3317. <entry>pkt4-receive-drop</entry>
  3318. <entry>integer</entry>
  3319. <entry>
  3320. Number of incoming packets that were dropped. The
  3321. exact reason for dropping packets is logged, but the most common
  3322. reasons may be: an unacceptable packet type, direct responses are
  3323. forbidden, or the server-id sent by the client does not match
  3324. the server's server-id.
  3325. </entry>
  3326. </row>
  3327. <row>
  3328. <entry>subnet[id].total-addresses</entry>
  3329. <entry>integer</entry>
  3330. <entry>The total number of addresses available for DHCPv4
  3331. management. In other words, this is the sum of all addresses in
  3332. all configured pools. This statistic changes only during
  3333. configuration changes. Note it does not take into account any
  3334. addresses that may be reserved due to host reservation. The
  3335. <emphasis>id</emphasis> is the subnet-id of a given subnet. This
  3336. statistic is exposed for each subnet separately. This statistic is
  3337. reset during reconfiguration event.</entry>
  3338. </row>
  3339. <row>
  3340. <entry>subnet[id].assigned-addresses</entry>
  3341. <entry>integer</entry>
  3342. <entry>This statistic shows the number of assigned addresses in a
  3343. given subnet. It increases every time a new lease is
  3344. allocated (as a result of receiving a DHCPREQUEST message) and is
  3345. decreased every time a lease is released (a DHCPRELEASE message is
  3346. received) or expires. The <emphasis>id</emphasis> is the subnet-id
  3347. of the subnet. This statistic is exposed for each subnet
  3348. separately. This statistic is reset during reconfiguration event.
  3349. </entry>
  3350. </row>
  3351. <row>
  3352. <entry>declined-addresses</entry>
  3353. <entry>integer</entry>
  3354. <entry>
  3355. This statistic shows the number of IPv4 addresses that are
  3356. currently declined, so counting the number of leases
  3357. currently unavailable. Once a lease is recovered, this
  3358. statistic will be decreased. Ideally, this statistic should be
  3359. zero. If this statistic is non-zero (or worse increasing),
  3360. a network administrator should investigate if there is
  3361. a misbehaving device in his network. This is a global statistic
  3362. that covers all subnets.
  3363. </entry>
  3364. </row>
  3365. <row>
  3366. <entry>subnet[id].declined-addresses</entry>
  3367. <entry>integer</entry>
  3368. <entry>
  3369. This statistic shows the number of IPv4 addresses that are
  3370. currently declined in a given subnet, so is a count of the
  3371. number of leases currently unavailable. Once a lease is
  3372. recovered, this statistic will be decreased. Ideally, this
  3373. statistic should be zero. If this statistic is
  3374. non-zero (or worse increasing), a network administrator should
  3375. investigate if there is a misbehaving device in his network. The
  3376. <emphasis>id</emphasis> is the subnet-id of a given subnet. This
  3377. statistic is exposed for each subnet separately.
  3378. </entry>
  3379. </row>
  3380. <row>
  3381. <entry>reclaimed-declined-addresses</entry>
  3382. <entry>integer</entry>
  3383. <entry>
  3384. This statistic shows the number of IPv4 addresses that were
  3385. declined, but have now been recovered. Unlike
  3386. declined-addresses, this statistic never decreases. It can be used
  3387. as a long term indicator of how many actual valid Declines were
  3388. processed and recovered from. This is a global statistic that
  3389. covers all subnets.
  3390. </entry>
  3391. </row>
  3392. <row>
  3393. <entry>subnet[id].reclaimed-declined-addresses</entry>
  3394. <entry>integer</entry>
  3395. <entry>
  3396. This statistic shows the number of IPv4 addresses that were
  3397. declined, but have now been recovered. Unlike
  3398. declined-addresses, this statistic never decreases. It can be used
  3399. as a long term indicator of how many actual valid Declines were
  3400. processed and recovered from. The
  3401. <emphasis>id</emphasis> is the subnet-id of a given subnet. This
  3402. statistic is exposed for each subnet separately.
  3403. </entry>
  3404. </row>
  3405. </tbody>
  3406. </tgroup>
  3407. </table>
  3408. </section>
  3409. <section id="dhcp4-ctrl-channel">
  3410. <title>Management API for the DHCPv4 Server</title>
  3411. <para>
  3412. The management API allows the issuing of specific
  3413. management commands, such as statistics retrieval, reconfiguration or shutdown.
  3414. For more details, see <xref linkend="ctrl-channel" />. Currently the only
  3415. supported communication channel type is UNIX stream socket. By default there
  3416. are no sockets open. To instruct Kea to open a socket, the following entry
  3417. in the configuration file can be used:
  3418. <screen>
  3419. "Dhcp4": {
  3420. "control-socket": {
  3421. "socket-type": "unix",
  3422. "socket-name": <userinput>"/path/to/the/unix/socket"</userinput>
  3423. },
  3424. "subnet4": [
  3425. ...
  3426. ],
  3427. ...
  3428. }
  3429. </screen>
  3430. </para>
  3431. <para>
  3432. The length of the path specified by the <command>socket-name</command>
  3433. parameter is restricted by the maximum length for the unix socket name
  3434. on your operating system, i.e. the size of the <command>sun_path</command>
  3435. field in the <command>sockaddr_un</command> structure, decreased by 1.
  3436. This value varies on different operating systems between 91 and 107
  3437. characters. Typical values are 107 on Linux and 103 on FreeBSD.
  3438. </para>
  3439. <para>
  3440. Communication over control channel is conducted using JSON structures.
  3441. See the Control Channel section in the Kea Developer's Guide for more
  3442. details.
  3443. </para>
  3444. <para>The DHCPv4 server supports the following operational commands:
  3445. <itemizedlist>
  3446. <listitem>leases-reclaim</listitem>
  3447. <listitem>list-commands</listitem>
  3448. <listitem>set-config</listitem>
  3449. <listitem>shutdown</listitem>
  3450. </itemizedlist>
  3451. as described in <xref linkend="commands-common"/>. In addition,
  3452. it supports the following statistics related commands:
  3453. <itemizedlist>
  3454. <listitem>statistic-get</listitem>
  3455. <listitem>statistic-reset</listitem>
  3456. <listitem>statistic-remove</listitem>
  3457. <listitem>statistic-get-all</listitem>
  3458. <listitem>statistic-reset-all</listitem>
  3459. <listitem>statistic-remove-all</listitem>
  3460. </itemizedlist>
  3461. as described here <xref linkend="command-stats"/>.
  3462. </para>
  3463. </section>
  3464. <section id="dhcp4-std">
  3465. <title>Supported DHCP Standards</title>
  3466. <para>The following standards are currently supported:</para>
  3467. <itemizedlist>
  3468. <listitem>
  3469. <simpara><emphasis>Dynamic Host Configuration Protocol</emphasis>,
  3470. <ulink url="http://tools.ietf.org/html/rfc2131">RFC 2131</ulink>:
  3471. Supported messages are DHCPDISCOVER (1), DHCPOFFER (2),
  3472. DHCPREQUEST (3), DHCPRELEASE (7), DHCPINFORM (8), DHCPACK (5), and
  3473. DHCPNAK(6).</simpara>
  3474. </listitem>
  3475. <listitem>
  3476. <simpara><emphasis>DHCP Options and BOOTP Vendor Extensions</emphasis>,
  3477. <ulink url="http://tools.ietf.org/html/rfc2132">RFC 2132</ulink>:
  3478. Supported options are: PAD (0),
  3479. END(255), Message Type(53), DHCP Server Identifier (54),
  3480. Domain Name (15), DNS Servers (6), IP Address Lease Time
  3481. (51), Subnet mask (1), and Routers (3).</simpara>
  3482. </listitem>
  3483. <listitem>
  3484. <simpara><emphasis>DHCP Relay Agent Information Option</emphasis>,
  3485. <ulink url="http://tools.ietf.org/html/rfc3046">RFC 3046</ulink>:
  3486. Relay Agent Information option is supported.</simpara>
  3487. </listitem>
  3488. <listitem>
  3489. <simpara><emphasis>Vendor-Identifying Vendor Options for
  3490. Dynamic Host Configuration Protocol version 4</emphasis>,
  3491. <ulink url="http://tools.ietf.org/html/rfc3925">RFC 3925</ulink>:
  3492. Vendor-Identifying Vendor Class and Vendor-Identifying Vendor-Specific
  3493. Information options are supported.</simpara>
  3494. </listitem>
  3495. <listitem>
  3496. <simpara><emphasis>Client Identifier Option in DHCP Server Replies</emphasis>,
  3497. <ulink url="http://tools.ietf.org/html/rfc6842">RFC 6842</ulink>:
  3498. Server by default sends back client-id option. That capability may be
  3499. disabled. See <xref linkend="dhcp4-echo-client-id"/> for details.
  3500. </simpara>
  3501. </listitem>
  3502. </itemizedlist>
  3503. </section>
  3504. <section>
  3505. <title>User context in IPv4 pools</title>
  3506. <para>
  3507. Kea allows loading hook libraries that sometimes could benefit from
  3508. additional parameters. If such a parameter is specific to the whole
  3509. library, it is typically defined as a parameter for the hook library.
  3510. However, sometimes there is a need to specify parameters that are
  3511. different for each pool.
  3512. </para>
  3513. <para>
  3514. Let's consider an imaginary case of devices that have color LED
  3515. lights. Depending on their location, they should glow red, blue or
  3516. green. It would be easy to write a hook library that would send
  3517. specific values as maybe vendor option. However, the server has to
  3518. have some way to specify that value for each pool. This need is
  3519. addressed by user contexts. In essence, any user data can specified
  3520. in the user context as long as it is a valid JSON map. For example,
  3521. the forementioned case of LED devices could be configured in the
  3522. following way:
  3523. <screen>
  3524. "Dhcp4": {
  3525. "subnet4": [
  3526. {
  3527. "subnet": "192.0.2.0/24",
  3528. "pools": [ { "pool": "192.0.2.10 - 192.0.2.20" } ],
  3529. <userinput>"user-context": { "colour": "red" }</userinput>
  3530. },
  3531. ...
  3532. ],
  3533. ...
  3534. }</screen>
  3535. </para>
  3536. <para>
  3537. It should be noted that Kea will not use that information, but will
  3538. simply store and make it available to hook libraries. It is up to the
  3539. hook library to extract that information and make use of it.</para>
  3540. <para>
  3541. Currently only pools allow definition of user contexts, but this
  3542. concept is expected to be enhanced to other structures in the future.
  3543. For more background information, see <xref linkend="user-context"/>
  3544. </para>
  3545. </section>
  3546. <section id="dhcp4-limit">
  3547. <title>DHCPv4 Server Limitations</title>
  3548. <para>These are the current limitations of the DHCPv4 server
  3549. software. Most of them are reflections of the current stage of
  3550. development and should be treated as <quote>not implemented
  3551. yet</quote>, rather than actual limitations. However, some of them
  3552. are implications of the design choices made. Those are clearly
  3553. marked as such.</para>
  3554. <itemizedlist>
  3555. <listitem>
  3556. <simpara>
  3557. BOOTP (<ulink url="http://tools.ietf.org/html/rfc951">RFC 951</ulink>)
  3558. is not supported. This is a design choice: BOOTP support is not planned.
  3559. </simpara>
  3560. </listitem>
  3561. <listitem>
  3562. <simpara>On Linux and BSD system families the DHCP messages are sent
  3563. and received over the raw sockets (using LPF and BPF) and all packet
  3564. headers (including data link layer, IP and UDP headers) are created and
  3565. parsed by Kea, rather than the system kernel. Currently, Kea can
  3566. only parse the data link layer headers with a format adhering to
  3567. IEEE 802.3 standard and assumes this data link layer header format
  3568. for all interfaces. Hence, Kea will fail to work on interfaces
  3569. which use different data link layer header formats (e.g. Infiniband).
  3570. </simpara>
  3571. </listitem>
  3572. <listitem>
  3573. <simpara>The DHCPv4 server does not verify that
  3574. assigned address is unused. According to <ulink url="http://tools.ietf.org/html/rfc2131">RFC 2131</ulink>, the
  3575. allocating server should verify that address is not used by
  3576. sending ICMP echo request.</simpara>
  3577. </listitem>
  3578. </itemizedlist>
  3579. </section>
  3580. <!--
  3581. <section id="dhcp4-srv-examples">
  3582. <title>Kea DHCPv4 server examples</title>
  3583. <para>
  3584. This section provides easy to use example. Each example can be read
  3585. separately. It is not intended to be read sequentially as there will
  3586. be many repetitions between examples. They are expected to serve as
  3587. easy to use copy-paste solutions to many common deployments.
  3588. </para>
  3589. @todo: add simple configuration for direct clients
  3590. @todo: add configuration for relayed clients
  3591. @todo: add client classification example
  3592. </section> -->
  3593. </chapter>