dhcp4-srv.xml 163 KB

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