dhcp4-srv.xml 165 KB

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