dhcp4-srv.xml 177 KB

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