hooks.xml 77 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988
  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="hooks-libraries">
  7. <title>Hooks Libraries</title>
  8. <section id="hooks-libraries-introduction">
  9. <title>Introduction</title>
  10. <para>
  11. Although Kea offers a lot of flexibility, there may be cases where
  12. its behavior needs customization. To accommodate this possibility,
  13. Kea includes the idea of "Hooks". This feature lets Kea load one
  14. or more dynamically-linked libraries (known as "hooks libraries")
  15. and, at various points in its processing ("hook points"), call
  16. functions in them. Those functions perform whatever custom
  17. processing is required.
  18. </para>
  19. <para>
  20. Hooks libraries are attached to individual Kea processes, not to
  21. Kea as a whole. This means (for example) that it is possible
  22. to associate one set of libraries with the DHCP4 server and a
  23. different set to the DHCP6 server.
  24. </para>
  25. <para>
  26. Another point to note is that it is possible for a process to
  27. load multiple libraries. When processing reaches a hook point,
  28. Kea calls the hooks library functions attached to it. If multiple
  29. libraries have attached a function to a given hook point, Kea calls
  30. all of them, in the order in which the libraries are specified in
  31. the configuration file. The order may be important: consult the
  32. documentation of the libraries to see if this is the case.
  33. </para>
  34. <para>
  35. The next section describes how to configure hooks libraries. If you
  36. are interested in writing your own hooks library, information can be
  37. found in the <ulink url="https://jenkins.isc.org/job/Fedora20_32_doxygen_doc/doxygen/">Kea
  38. Developer's Guide</ulink>.
  39. </para>
  40. </section> <!-- end Introduction -->
  41. <section>
  42. <title>Configuring Hooks Libraries</title>
  43. <para>
  44. The hooks libraries for a given process are configured using the
  45. <command>hooks-libraries</command> keyword in the
  46. configuration for that process. (Note that
  47. the word "hooks" is plural). The value of the keyword
  48. is an array of map structures, each structure corresponding to a hooks
  49. library. For example, to set up two hooks libraries for the DHCPv4
  50. server, the configuration would be:
  51. <screen>
  52. <userinput>"Dhcp4": {
  53. :
  54. "hooks-libraries": [
  55. {
  56. "library": "/opt/charging.so"
  57. },
  58. {
  59. "library": "/opt/local/notification.so",
  60. "parameters": {
  61. "mail": "spam@example.com",
  62. "floor": 13,
  63. "debug": false,
  64. "users": [ "alice", "bob", "charlie" ],
  65. "languages": {
  66. "french": "bonjour",
  67. "klingon": "yl'el"
  68. }
  69. }
  70. }
  71. ]
  72. :
  73. }</userinput>
  74. </screen>
  75. </para>
  76. <note><para>
  77. This is a change to the syntax used in Kea 0.9.2 and earlier, where
  78. hooks-libraries was a list of strings, each string being the name of
  79. a library. The change was made in Kea 1.0 to facilitate the
  80. specification of library-specific parameters, a capability
  81. available in Kea 1.1.0 onwards.
  82. </para></note>
  83. <note>
  84. <para>
  85. The library reloading behavior has changed in Kea 1.1. Libraries are
  86. reloaded, even if their list hasn't changed. Kea does that, because
  87. the parameters specified for the library (or the files those
  88. parameters point to) may have changed.
  89. </para>
  90. </note>
  91. <para>
  92. Libraries may have additional parameters. Those are not mandatory in the
  93. sense that there may be libraries that don't require them. However, for
  94. specific library there is often specific requirement for specify certain
  95. set of parameters. Please consult the documentation for your library
  96. for details. In the example above, the first library has no parameters.
  97. The second library has five parameters, specifying mail (string
  98. parameter), floor (integer parameter), debug (boolean parameter) and
  99. even lists (list of strings) and maps (containing strings). Nested
  100. parameters could be used if the library supports it. This topic is
  101. explained in detail in the Hooks Developer's Guide in the "Configuring
  102. Hooks Libraries" section.
  103. </para>
  104. <para>
  105. Notes:
  106. <itemizedlist mark='bullet'>
  107. <listitem><para>
  108. The full path to each library should be given.
  109. </para></listitem>
  110. <listitem><para>
  111. As noted above, order may be important - consult the documentation for
  112. each library.
  113. </para></listitem>
  114. <listitem><para>
  115. An empty list has the same effect as omitting the
  116. <command>hooks-libraries</command> configuration element all together.
  117. </para>
  118. <note><para>
  119. There is one case where this is not true: if Kea
  120. is running with a configuration that contains a
  121. <command>hooks-libraries</command> item, and that item is
  122. removed and the configuration reloaded, the removal will be
  123. ignored and the libraries remain loaded. As a workaround,
  124. instead of removing the <command>hooks-libraries</command>
  125. item, change it to an empty list. This will be fixed in a
  126. future version of Kea.
  127. </para></note>
  128. </listitem>
  129. </itemizedlist>
  130. </para>
  131. <para>
  132. At the present time, only the kea-dhcp4 and kea-dhcp6 processes support
  133. hooks libraries.
  134. </para>
  135. </section>
  136. <section>
  137. <title>Available Hooks Libraries</title>
  138. <para>
  139. As described above, the hooks functionality provides a way to customize
  140. a Kea server without modifying the core code. ISC has chosen to take
  141. advantage of this feature to provide functions that may only be useful
  142. to a subset of Kea users. To this end ISC has created some hooks
  143. libraries; these discussed in the following sections.
  144. </para>
  145. <note><para>
  146. Some of these libraries will be available with the base code while others
  147. will be shared with organizations supporting development of Kea
  148. , possibly as a 'benefit' or 'thank you' for helping to sustain
  149. the larger Kea project. If you would like to get access to those
  150. libraries, please consider taking out a support contract: this includes
  151. professional support, advance security notifications, input into our
  152. roadmap planning, and many other benefits, while helping
  153. making Kea sustainable in the long term.
  154. </para></note>
  155. <para>Currently the following libraries are available or planned from ISC:
  156. <table frame="all" id="hook-libs">
  157. <title>List of available hooks libraries</title>
  158. <tgroup cols='3'>
  159. <colspec colname='name' />
  160. <colspec colname='avail' />
  161. <colspec colname='description' />
  162. <thead>
  163. <row>
  164. <entry>Name</entry>
  165. <entry>Availability</entry>
  166. <entry>Since</entry>
  167. <entry>Description</entry>
  168. </row>
  169. </thead>
  170. <tbody>
  171. <row>
  172. <entry>user_chk</entry>
  173. <entry>Kea sources</entry>
  174. <entry>Kea 0.8</entry>
  175. <entry>Reads known users list from a file. Unknown users
  176. will be assigned a
  177. lease from the last subnet defined in the configuration file,
  178. e.g. to redirect them a captive portal. This demonstrates how an
  179. external source of information can be used to influence the Kea
  180. allocation engine. This hook is part of the Kea source code and is
  181. available in the src/hooks/dhcp/user_chk directory.</entry>
  182. </row>
  183. <row>
  184. <entry>Forensic Logging</entry>
  185. <entry>Support customers</entry>
  186. <entry>Kea 1.1.0</entry>
  187. <entry>This library provides hooks that record a detailed log of
  188. lease assignments and renewals into a set of log files. In many
  189. legal jurisdictions companies, especially ISPs, must record
  190. information about the addresses they have leased to DHCP
  191. clients. This library is designed to help with that
  192. requirement. If the information that it records is sufficient it
  193. may be used directly. If your jurisdiction requires that you save
  194. a different set of information, you may use it as a template or
  195. example and create your own custom logging hooks.</entry>
  196. </row>
  197. <row>
  198. <entry>Flexible Identifier</entry>
  199. <entry>Support customers</entry>
  200. <entry>Kea 1.2.0</entry>
  201. <entry>Kea software provides a way to handle host reservations
  202. that include addresses, prefixes, options, client classes and
  203. other features. The reservation can be based on hardware address,
  204. DUID, circuit-id or client-id in DHCPv4 and using hardware address
  205. or DUID in DHCPv6. However, there are sometimes scenarios where the
  206. reservation is more complex, e.g. uses other options that
  207. mentioned above, uses part of specific options or perhaps even a
  208. combination of several options and fields to uniquely identify a
  209. client. Those scenarios are addressed by the Flexible Identifiers
  210. hook application. It allows defining an expression, similar to
  211. the one used in client classification,
  212. e.g. substring(relay6[0].option[37],0,6). Each incoming packet is
  213. evaluated against that expression and its value is then searched
  214. in the reservations database.
  215. </entry>
  216. </row>
  217. <row>
  218. <entry>Host Commands</entry>
  219. <entry>Support customers</entry>
  220. <entry>Kea 1.2.0</entry>
  221. <entry>Kea provides a way to store host reservations in a
  222. database. In many larger deployments it is useful to be able to
  223. manage that information while the server is running. This library
  224. provides management commands for adding, querying and deleting
  225. host reservations in a safe way without restarting the server.
  226. In particular, it validates the parameters, so an attempt to
  227. insert incorrect data, e.g. add a host with conflicting identifier
  228. in the same subnet will be rejected. Those commands are
  229. exposed via command channel (JSON over unix sockets) and Control
  230. Agent (JSON over RESTful interface). Additional commands and
  231. capabilities related to host reservations will be added in the
  232. future.</entry>
  233. </row>
  234. <row>
  235. <entry>Subnet Commands</entry>
  236. <entry>Support customers</entry>
  237. <entry>Kea 1.3.0</entry>
  238. <entry>In deployments in which subnet configuration needs to
  239. be frequently updated, it is a hard requirement that such updates be
  240. performed without the need for a full DHCP server reconfiguration
  241. or restart. This hooks library allows for incremental changes
  242. to the subnet configuration such as: adding a subnet, removing
  243. a subnet. It also allows for listing all available subnets and
  244. fetching detailed information about a selected subnet. The
  245. commands exposed by this library do not affect other subnets
  246. or configuration parameters currently used by the server.
  247. </entry>
  248. </row>
  249. </tbody>
  250. </tgroup>
  251. </table>
  252. </para>
  253. <para>
  254. ISC hopes to see more hooks libraries become available as time
  255. progresses, both developed internally and externally. Since
  256. this list may evolve dynamically, we decided to keep it on a
  257. wiki page, available at this link: <ulink
  258. url="http://kea.isc.org/wiki/Hooks">http://kea.isc.org/wiki/Hooks</ulink>.
  259. If you are a developer or are aware of any hooks libraries not
  260. listed there, please send a note to the kea-users or kea-dev
  261. mailing lists and someone will update it.
  262. </para>
  263. <section>
  264. <title>user_chk: Checking User Access</title>
  265. <para>
  266. The user_chk library is the first hooks library published by ISC. It
  267. attempts to serve several purposes:
  268. <itemizedlist>
  269. <listitem>
  270. <para>To assign "new" or "unregistered" users to a
  271. restricted subnet, while "known" or "registered" users are assigned
  272. to unrestricted subnets.</para>
  273. </listitem>
  274. <listitem>
  275. <para>To allow DHCP response options or vendor option
  276. values to be customized based upon user identity. </para>
  277. </listitem>
  278. <listitem>
  279. <para>To provide a real time record of the user registration
  280. activity which can be sampled by an external consumer.</para>
  281. </listitem>
  282. <listitem>
  283. <para> To serve as a demonstration of various capabilities
  284. possible using the hooks interface.</para>
  285. </listitem>
  286. </itemizedlist>
  287. </para>
  288. <para>
  289. Once loaded, the library allows segregating incoming requests into
  290. known and unknown clients. For known clients, the packets are
  291. processed mostly as usual, except it is possible to override certain
  292. options being sent. That can be done on a per host basis. Clients
  293. that are not on the known hosts list will be treated as unknown and
  294. will be assigned to the last subnet defined in the configuration file.
  295. </para>
  296. <para>
  297. As an example of use, this behavior may be used to put unknown users into a
  298. separate subnet that leads to a walled garden, where they can only
  299. access a registration portal. Once they fill in necessary data, their
  300. details are added to the known clients file and they get a proper
  301. address after their device is restarted.
  302. </para>
  303. <note><para>This library was developed several years before the host
  304. reservation mechanism has become available. Currently host reservation is
  305. much more
  306. powerful and flexible, but nevertheless the user_chk capability to consult
  307. and external source of information about clients and alter Kea's
  308. behavior is useful and remains of educational value.
  309. </para></note>
  310. <para>
  311. The library reads the /tmp/user_chk_registry.txt file while being
  312. loaded and each time an incoming packet is processed. The file is expected
  313. to have each line contain a self-contained JSON snippet which must
  314. have the following two entries:
  315. <itemizedlist>
  316. <listitem><para><command>type</command>, whose value
  317. is "HW_ADDR" for IPv4 users or "DUID" for IPv6
  318. users</para></listitem>
  319. <listitem><para><command>id</command>, whose value is
  320. either the hardware address or the DUID from the request
  321. formatted as a string of hex digits, with or without
  322. ":" delimiters.</para></listitem>
  323. </itemizedlist>
  324. and may have the zero or more of the following entries:
  325. <itemizedlist>
  326. <listitem><para><command>bootfile</command> whose value
  327. is the pathname of the desired file</para></listitem>
  328. <listitem><para><command>tftp_server</command> whose
  329. value is the hostname or IP address of the desired
  330. server</para></listitem>
  331. </itemizedlist>
  332. A sample user registry file is shown below:
  333. <screen>{ "type" : "HW_ADDR", "id" : "0c:0e:0a:01:ff:04", "bootfile" : "/tmp/v4bootfile" }
  334. { "type" : "HW_ADDR", "id" : "0c:0e:0a:01:ff:06", "tftp_server" : "tftp.v4.example.com" }
  335. { "type" : "DUID", "id" : "00:01:00:01:19:ef:e6:3b:00:0c:01:02:03:04", "bootfile" : "/tmp/v6bootfile" }
  336. { "type" : "DUID", "id" : "00:01:00:01:19:ef:e6:3b:00:0c:01:02:03:06", "tftp_server" : "tftp.v6.example.com" }</screen>
  337. </para>
  338. <para>As with any other hooks libraries provided by ISC, internals of the
  339. user_chk code are well documented. You can take a look at the <ulink
  340. url="https://jenkins.isc.org/job/Fedora20_32_doxygen_doc/doxygen/d8/db2/libdhcp_user_chk.html">Kea Developer's Guide section dedicated to the user_chk library</ulink>
  341. that discusses how the code works internally. That, together with
  342. our general entries in <ulink
  343. url="https://jenkins.isc.org/job/Fedora20_32_doxygen_doc/doxygen/">Hooks
  344. Framework section</ulink> should give you some pointers how to extend
  345. this library and perhaps even write your own from scratch.</para>
  346. </section>
  347. <section>
  348. <title>legal_log: Forensic Logging Hooks</title>
  349. <para>
  350. This section describes the forensic log hooks library. This library
  351. provides hooks that record a detailed log of lease assignments
  352. and renewals into a set of log files. Currently this library
  353. is only available to ISC customers with a support contract.
  354. </para>
  355. <para>
  356. In many legal jurisdictions companies, especially ISPs, must record
  357. information about the addresses they have leased to DHCP clients.
  358. This library is designed to help with that requirement. If the
  359. information that it records is sufficient it may be used directly.
  360. If your jurisdiction requires that you save a different set of
  361. information you may use it as a template or example and create your
  362. own custom logging hooks.
  363. </para>
  364. <para>
  365. This logging is done as a set of hooks to allow it to be customized
  366. to any particular need. Modifying a hooks library is easier and
  367. safer than updating the core code. In addition by using the hooks
  368. features those users who don't need to log this information can
  369. leave it out and avoid any performance penalties.
  370. </para>
  371. <section>
  372. <title>Log File Naming</title>
  373. <para>
  374. The names for the log files have the following form:
  375. </para>
  376. <screen>
  377. path/base-name.CCYYMMDD.txt
  378. </screen>
  379. <para>
  380. The &quot;path&quot; and &quot;base-name&quot; are supplied in the
  381. configuration as described below see
  382. <xref linkend="forensic-log-configuration"/>. The next part of the name is
  383. the date the log file was started, with four digits for year, two digits
  384. for month and two digits for day. The file is rotated on a daily basis.
  385. </para>
  386. <note><para>
  387. When running Kea servers for both DHCPv4 and DHCPv6 the log names must
  388. be distinct. See the examples in <xref linkend="forensic-log-configuration"/>.
  389. </para></note>
  390. </section>
  391. <section>
  392. <title>DHCPv4 Log Entries</title>
  393. <para>
  394. For DHCPv4 the library creates entries based on DHCPREQUEST messages
  395. and corresponding DHCPv4 leases intercepted by lease4_select
  396. (for new leases) and lease4_renew (for renewed leases) hooks.
  397. </para>
  398. <para>
  399. An entry is a single string with no embedded end-of-line markers
  400. and has the following sections:
  401. <screen>
  402. address duration device-id {client-info} {relay-info}
  403. </screen>
  404. </para>
  405. <para>
  406. Where:
  407. <itemizedlist>
  408. <listitem><para>
  409. address - the leased IPv4 address given out and whether it was
  410. assigned or renewed.
  411. </para></listitem>
  412. <listitem><para>
  413. duration - the lease lifetime expressed in days (if present),
  414. hours, minutes and seconds. A lease lifetime of 0xFFFFFFFF will be
  415. denoted with the text &quot;infinite duration&quot;.
  416. </para></listitem>
  417. <listitem><para>
  418. device-id - the client's hardware address shown as numerical type
  419. and hex digit string.
  420. </para></listitem>
  421. <listitem><para>
  422. client-info - the DHCP client id option (61) if present, shown as
  423. a hex string.
  424. </para></listitem>
  425. <listitem><para>
  426. relay-info - for relayed packets the giaddr and the RAI circuit-id,
  427. remote-id and subscriber-id options (option 82 sub
  428. options: 1, 2 and 6) if present.
  429. The circuit id and remote id are presented as hex strings
  430. </para></listitem>
  431. </itemizedlist>
  432. </para>
  433. <para>
  434. For instance (line breaks added for readability, they would not
  435. be present in the log file).
  436. <screen>
  437. Address: 192.2.1.100 has been renewed for 1 hrs 52 min 15 secs to a device with
  438. hardware address: hwtype=1 08:00:2b:02:3f:4e, client-id: 17:34:e2:ff:09:92:54
  439. connected via relay at address: 192.2.16.33, identified by circuit-id:
  440. 68:6f:77:64:79 and remote-id: 87:f6:79:77:ef
  441. </screen>
  442. </para>
  443. </section>
  444. <section>
  445. <title>DHCPv6 Log Entries</title>
  446. <para>
  447. For DHCPv6 the library creates entries based on lease management
  448. actions intercepted by the lease6_select (for new leases), lease6_renew
  449. (for renewed leases) and lease6_rebind (for rebound leases).
  450. </para>
  451. <para>
  452. An entry is a single string with no embedded end-of-line markers
  453. and has the following sections:
  454. <screen>
  455. address duration device-id {relay-info}*
  456. </screen>
  457. </para>
  458. <para>
  459. Where:
  460. <itemizedlist>
  461. <listitem><para>
  462. address - the leased IPv6 address or prefix given out and whether
  463. it was assigned or renewed.
  464. </para></listitem>
  465. <listitem><para>
  466. duration - the lease lifetime expressed in days (if present),
  467. hours, minutes and seconds. A lease lifetime of 0xFFFFFFFF will be
  468. denoted with the text "infinite duration".
  469. </para></listitem>
  470. <listitem><para>
  471. device-id - the client's DUID and hardware address (if present).
  472. </para></listitem>
  473. <listitem><para>
  474. relay-info - for relayed packets the content of relay agent
  475. messages, remote-id (code 37), subscriber-id (code 38) and
  476. interface-id (code 18) options if present. Note that
  477. interface-id option, if present, identifies the whole interface the
  478. relay agent received the message on. This typically translates to a
  479. single link in your network, but it depends on your specific network
  480. topology. Nevertheless, this is useful information to better scope
  481. down the location of the device, so it is being recorded, if present.
  482. </para></listitem>
  483. </itemizedlist>
  484. </para>
  485. <para>
  486. For instance (line breaks added for readability, they would not
  487. be present in the log file).
  488. <screen>
  489. Address:2001:db8:1:: has been assigned for 0 hrs 11 mins 53 secs to a device with
  490. DUID: 17:34:e2:ff:09:92:54 and hardware address: hwtype=1 08:00:2b:02:3f:4e
  491. (from Raw Socket) connected via relay at address: fe80::abcd for client on
  492. link address: 3001::1, hop count: 1, identified by remote-id:
  493. 01:02:03:04:0a:0b:0c:0d:0e:0f and subscriber-id: 1a:2b:3c:4d:5e:6f
  494. </screen>
  495. </para>
  496. </section>
  497. <section id="forensic-log-configuration">
  498. <title>Configuring the Forensic Log Hooks</title>
  499. <para>
  500. To use this functionality the hook library must be included in the
  501. configuration of the desired DHCP server modules. The legal_log
  502. library is installed alongside the Kea libraries in
  503. <filename>[kea-install-dir]/lib</filename> where
  504. <filename>kea-install-dir</filename> is determined by the
  505. &quot;--prefix&quot; option of the configure script. It defaults to
  506. <filename>/usr/local</filename>. Assuming the
  507. default value then, configuring kea-dhcp4 to load the legal_log
  508. library could be done with the following Kea4 configuration:
  509. <screen>
  510. "Dhcp4": { <userinput>
  511. "hooks-libraries": [
  512. {
  513. "library": "/usr/local/lib/libdhcp_legal_log.so",
  514. "parameters": {
  515. "path": "/var/kea/var",
  516. "base-name": "kea-forensic4"
  517. }
  518. },
  519. ...
  520. ] </userinput>
  521. }
  522. </screen>
  523. </para>
  524. <para>
  525. To configure it for kea-dhcp6, the commands are simply as shown below:
  526. <screen>
  527. "Dhcp6": { <userinput>
  528. "hooks-libraries": [
  529. {
  530. "library": "/usr/local/lib/libdhcp_legal_log.so",
  531. "parameters": {
  532. "path": "/var/kea/var",
  533. "base-name": "kea-forensic6"
  534. }
  535. },
  536. ...
  537. ] </userinput>
  538. }
  539. </screen>
  540. </para>
  541. <para>
  542. Two Hook Library parameters are supported:
  543. <itemizedlist>
  544. <listitem><para>
  545. path - the directory in which the forensic file(s) will be written. The
  546. default value is
  547. <filename>[prefix]/kea/var</filename>. The directory must exist.
  548. </para></listitem>
  549. <listitem><para>
  550. base-name - an arbitrary value which is used in conjunction with
  551. the current system date to form the current forensic file name. It defaults
  552. to <filename>kea-legal</filename>.
  553. </para></listitem>
  554. </itemizedlist>
  555. </para>
  556. </section>
  557. </section>
  558. <section id="flex-id">
  559. <title>flex_id: Flexible Identifiers for Host Reservations</title>
  560. <para>
  561. This section describes a hook application dedicated to generate
  562. flexible identifiers for host reservation. Kea software provides a way
  563. to handle host reservations that include addresses, prefixes, options,
  564. client classes and other features. The reservation can be based on
  565. hardware address, DUID, circuit-id or client-id in DHCPv4 and using
  566. hardware address or DUID in DHCPv6. However, there are sometimes
  567. scenario where the reservation is more complex, e.g. uses other
  568. options that mentioned above, uses part of specific options or perhaps
  569. even a combination of several options and fields to uniquely identify
  570. a client. Those scenarios are addressed by the Flexible Identifiers
  571. hook application.</para>
  572. <para>Currently this library is only available to ISC customers with a
  573. support contract.</para>
  574. <para>The library allows for defining an expression, using notation
  575. initially used for client classification only. See <xref
  576. linkend="classification-using-expressions" /> for detailed description
  577. of the syntax available. One notable difference is that for client
  578. classification the expression currently has to evaluate to either true
  579. or false, while the flexible identifier expression is expected to
  580. evaluate to a string that will be used as identifier. It is a valid case
  581. for the expression to evaluate to empty string (e.g. in cases where a
  582. client does not sent specific options). This expression is then
  583. evaluated for each incoming packet. This evaluation generates an
  584. identifier that is used to identify the client. In particular, there may
  585. be host reservations that are tied to specific values of the flexible
  586. identifier.</para>
  587. <para>
  588. The library can be loaded in similar way as other hook libraries. It
  589. takes one mandatory parameter identifier-expression:
  590. <screen>
  591. "Dhcp6": { <userinput>
  592. "hooks-libraries": [
  593. {
  594. "library": "/path/libdhcp_flex_id.so",
  595. "parameters": {
  596. "identifier-expression": "<userinput>expression</userinput>"
  597. }
  598. },
  599. ...
  600. ] </userinput>
  601. }
  602. </screen>
  603. </para>
  604. <para>
  605. The flexible identifier library supports both DHCPv4 and DHCPv6.
  606. </para>
  607. <para>
  608. EXAMPLE: Let's consider a case of an IPv6 network that has an
  609. independent interface for each of the connected customers. Customers
  610. are able to plug in whatever device they want, so any type of
  611. identifier (e.g. a client-id) is unreliable. Therefore the operator
  612. may decide to use an option inserted by a relay agent to differentiate
  613. between clients. In this particular deployment, the operator verified
  614. that the interface-id is unique for each customer facing
  615. interface. Therefore it is suitable for usage as reservation. However,
  616. only the first 6 bytes of the interface-id are interesting, because
  617. remaining bytes are either randomly changed or not unique between
  618. devices. Therefore the customer decided to use first 6 bytes of the
  619. interface-id option inserted by the relay agent. After adding "flex-id"
  620. host-reservation-identifiers goal can be achieved by using the
  621. following configuration:
  622. <screen>
  623. "Dhcp6": {
  624. "subnet6": [{ ..., // subnet definition starts here
  625. "reservations": [
  626. <userinput>"flex-id": "'port1234'"</userinput>, // value of the first 8 bytes of the interface-id
  627. "ip-addresses": [ "2001:db8::1" ]
  628. ],
  629. }], // end of subnet definitions
  630. "host-reservation-identifiers": ["duid", "flex-id"], // add "flex-id" to reservation identifiers
  631. "hooks-libraries": [
  632. {
  633. "library": "/path/libdhcp_flex_id.so",
  634. "parameters": {
  635. "identifier-expression": "<userinput>substring(relay6[0].option[18].hex,0,8)</userinput>"
  636. }
  637. },
  638. ...
  639. ]
  640. }
  641. </screen>
  642. </para>
  643. <para>
  644. NOTE: Care should be taken when adjusting the expression. If the
  645. expression changes, then all the flex-id values may change, possibly
  646. rendering all reservations based on flex-id unusable until they're
  647. manually updated. Therefore it is strongly recommended to start with
  648. the expression and a handful reservations, adjust the expression as
  649. needed and only after it was confirmed the expression does exactly
  650. what is expected out of it go forward with host reservations on any
  651. broader scale.
  652. </para>
  653. <para>
  654. flex-id values in host reservations can be specified in two
  655. ways. First, they can be expressed as hex string, e.g. bar string
  656. can be represented as 626174. Alternatively, it can be expressed
  657. as quoted value (using double and single quotes), e.g. "'bar'".
  658. The former is more convenient for printable characters, while hex
  659. string values are more convenient for non-printable characters.
  660. </para>
  661. <screen>
  662. "Dhcp6": {
  663. "subnet6": [{ ..., // subnet definition starts here
  664. "reservations": [
  665. <userinput>"flex-id": "01:02:03:04:05:06"</userinput>, // value of the first 8 bytes of the interface-id
  666. "ip-addresses": [ "2001:db8::1" ]
  667. ],
  668. }], // end of subnet definitions
  669. "host-reservation-identifiers": ["duid", "flex-id"], // add "flex-id" to reservation identifiers
  670. "hooks-libraries": [
  671. {
  672. "library": "/path/libdhcp_flex_id.so",
  673. "parameters": {
  674. "identifier-expression": "<userinput>vendor[4491].option[1026].hex</userinput>"
  675. }
  676. },
  677. ...
  678. ]
  679. }
  680. </screen>
  681. </section>
  682. <section id="host-cmds">
  683. <title>host_cmds: Host Commands</title>
  684. <para>
  685. This section describes a hook application that offers a number of new
  686. commands used to query and manipulate host reservations. Kea provides
  687. a way to store host reservations in a database. In many larger
  688. deployments it is useful to be able to manage that information while
  689. the server is running. This library provides management commands for
  690. adding, querying and deleting host reservations in a safe way without
  691. restarting the server. In particular, it validates the parameters, so
  692. an attempt to insert incorrect data e.g. add a host with conflicting
  693. identifier in the same subnet will be rejected. Those commands are
  694. exposed via command channel (JSON over unix sockets) and Control Agent
  695. (JSON over RESTful interface). Additional commands and capabilities
  696. related to host reservations will be added in the future.
  697. </para>
  698. <para>Currently this library is only available to ISC customers with a
  699. support contract.</para>
  700. <para>
  701. Currently three commands are supported: reservation-add (which adds
  702. new host reservation), reservation-get (which returns existing
  703. reservation if specified criteria are matched) and reservation-del
  704. (which attempts to delete a reservation matching specified
  705. criteria). To use commands that change the reservation information
  706. (currently these are reservation-add and reservation-del, but this
  707. rule applies to other commands that may be implemented in the future),
  708. hosts database must be specified (see hosts-database description in
  709. <xref linkend="hosts-database-configuration4"/> and <xref
  710. linkend="hosts-database-configuration6"/>) and it must not operate in
  711. read-only mode. If the hosts-database is not specified or is running
  712. in read-only mode, the host_cmds library will load, but any attempts
  713. to use reservation-add or reservation-del will fail.
  714. </para>
  715. <para>
  716. Additional host reservation commands are planned in the future. For
  717. a description of envisaged commands, see
  718. <ulink url="http://kea.isc.org/wiki/ControlAPIRequirements">Control API
  719. Requirements </ulink> document.</para>
  720. <para>
  721. All commands are using JSON syntax. They can be issued either using
  722. control channel (see <xref linkend="ctrl-channel"/>) or via Control
  723. Agent (see <xref linkend="kea-ctrl-agent"/>).
  724. </para>
  725. <para>
  726. The library can be loaded in similar way as other hook libraries. It
  727. does not take any parameters. It supports both DHCPv4 and DHCPv6
  728. servers.
  729. <screen>
  730. "Dhcp6": { <userinput>
  731. "hooks-libraries": [
  732. {
  733. "library": "/path/libdhcp_host_cmds.so"
  734. }
  735. ...
  736. ] </userinput>
  737. }
  738. </screen>
  739. </para>
  740. <section>
  741. <title>reservation-add command</title>
  742. <para>
  743. <command>reservation-add</command> allows insertion of a new host. It
  744. takes a set of arguments that vary depending on the nature of the host
  745. reservation. Any parameters allowed in the configuration file that
  746. pertain to host reservation are permitted here. For details regarding
  747. IPv4 reservations, see <xref linkend="host-reservation-v4"/> and <xref
  748. linkend="host-reservation-v6"/>. There is one notable addition. A
  749. <command>subnet-id</command> must be specified. This parameter is
  750. mandatory, because reservations specified in the configuration file
  751. are always defined within a subnet, so the subnet they belong to is
  752. clear. This is not the case with reservation-add, therefore the
  753. subnet-id must be specified explicitly. An example command can be as
  754. simple as:
  755. <screen>{
  756. "command": "reservation-add",
  757. "arguments": {
  758. <userinput>"reservation": {
  759. "subnet-id": 1,
  760. "hw-address": "1a:1b:1c:1d:1e:1f",
  761. "ip-address": "192.0.2.202"
  762. }</userinput>
  763. }
  764. }</screen> but can also take many more parameters, for example:
  765. <screen>
  766. {
  767. "command": "reservation-add",
  768. "arguments": {
  769. <userinput>"reservation":
  770. {
  771. "subnet-id":1,
  772. "client-id": "01:0a:0b:0c:0d:0e:0f",
  773. "ip-address": "192.0.2.205",
  774. "next-server": "192.0.2.1",
  775. "server-hostname": "hal9000",
  776. "boot-file-name": "/dev/null",
  777. "option-data": [
  778. {
  779. "name": "domain-name-servers",
  780. "data": "10.1.1.202,10.1.1.203"
  781. }
  782. ],
  783. "client-classes": [ "special_snowflake", "office" ]
  784. }</userinput>
  785. }
  786. }</screen>
  787. Here is an example of complex IPv6 reservation:
  788. <screen>
  789. {
  790. "command": "reservation-add",
  791. "arguments": {
  792. <userinput>"reservation":
  793. {
  794. "subnet-id":1,
  795. "duid": "01:02:03:04:05:06:07:08:09:0A",
  796. "ip-addresses": [ "2001:db8:1:cafe::1" ],
  797. "prefixes": [ "2001:db8:2:abcd::/64" ],
  798. "hostname": "foo.example.com",
  799. "option-data": [
  800. {
  801. "name": "vendor-opts",
  802. "data": "4491"
  803. },
  804. {
  805. "name": "tftp-servers",
  806. "space": "vendor-4491",
  807. "data": "3000:1::234"
  808. }
  809. ]
  810. }</userinput>
  811. }
  812. }</screen>
  813. </para>
  814. <para>
  815. The command returns a status that indicates either a success (result
  816. 0) or a failure (result 1). Failed command always includes text
  817. parameter that explains the cause of failure. Example results:
  818. <screen>{ "result": 0, "text": "Host added." }</screen> Example failure:
  819. <screen>{ "result": 1, "text": "Mandatory 'subnet-id' parameter missing." }</screen>
  820. </para>
  821. <para>
  822. As <command>reservation-add</command> is expected to store the host,
  823. hosts-database parameter must be specified in your configuration and
  824. the database must not run in read-only mode. In the future versions
  825. it will be possible to modify the reservations read from a
  826. configuration file. Please contact ISC if you are interested in this
  827. functionality.
  828. </para>
  829. </section>
  830. <section>
  831. <title>reservation-get command</title>
  832. <para><command>reservation-get</command> can be used to query the host
  833. database and retrieve existing reservations. There are two types of
  834. parameters this command supports: (subnet-id, address) or (subnet-id,
  835. identifier-type, identifier). The first type of query is used when the
  836. address (either IPv4 or IPv6) is known, but the details of the
  837. reservation aren't. One common use case of this type of query is to
  838. find out whether a given address is reserved or not. The second query
  839. uses identifiers. For maximum flexibility, Kea stores the host
  840. identifying information as a pair of values: type and the actual
  841. identifier. Currently supported identifiers are "hw-address", "duid",
  842. "circuit-id", "client-id" and "flex-id", but additional types may be
  843. added in the future. If any new identifier types are defined in the
  844. future, reservation-get command will support them
  845. automatically.</para>
  846. <para>
  847. An example command for getting a host reservation by (subnet-id,
  848. address) pair looks as follows:
  849. <screen>
  850. {
  851. "command": "reservation-get",
  852. "arguments": {
  853. "subnet-id": 1,
  854. "ip-address": "192.0.2.202"
  855. }
  856. }</screen>
  857. An example query by (subnet-id, identifier-type, identifier) looks as follows:
  858. <screen>
  859. {
  860. "command": "reservation-get",
  861. "arguments":
  862. "subnet-id": 4,
  863. "identifier-type": "hw-address",
  864. "identifier": "01:02:03:04:05:06"
  865. }
  866. }</screen>
  867. </para>
  868. <para><command>reservation-get</command> typically returns result 0
  869. when the query was conducted properly. In particular, 0 is returned
  870. when the host was not found. If the query was successful a number
  871. of host parameters will be returned. An example of a query that
  872. did not find the host looks as follows:
  873. <screen>{ "result": 0, "text": "Host not found." }</screen>
  874. An example result returned when the host was found:
  875. <screen>{
  876. "arguments": {
  877. "boot-file-name": "bootfile.efi",
  878. "client-classes": [
  879. ],
  880. "hostname": "somehost.example.org",
  881. "hw-address": "01:02:03:04:05:06",
  882. "ip-address": "192.0.2.100",
  883. "next-server": "192.0.0.2",
  884. "option-data": [
  885. ],
  886. "server-hostname": "server-hostname.example.org"
  887. },
  888. "result": 0,
  889. "text": "Host found."
  890. }</screen>
  891. An example result returned when the query was malformed:<screen>
  892. { "result": 1, "text": "No 'ip-address' provided and 'identifier-type'
  893. is either missing or not a string." }</screen>
  894. </para>
  895. </section>
  896. <section>
  897. <title>reservation-del command</title>
  898. <para><command>reservation-del</command> can be used to delete a
  899. reservation from the host database. There are two types of parameters
  900. this command supports: (subnet-id, address) or (subnet-id,
  901. identifier-type, identifier). The first type of query is used when the
  902. address (either IPv4 or IPv6) is known, but the details of the
  903. reservation aren't. One common use case of this type of query is to
  904. remove a reservation (e.g. you want a specific address to no longer be
  905. reserved). The second query uses identifiers. For maximum flexibility,
  906. Kea stores the host identifying information as a pair of values: type
  907. and the actual identifier. Currently supported identifiers are
  908. "hw-address", "duid", "circuit-id", "client-id" and "flex-id", but
  909. additional types may be added in the future. If any new identifier
  910. types are defined in the future, reservation-get command will support
  911. them automatically.</para>
  912. <para>
  913. An example command for deleting a host reservation by (subnet-id,
  914. address) pair looks as follows:
  915. <screen>
  916. {
  917. "command": "reservation-del",
  918. "arguments": {
  919. "subnet-id": 1,
  920. "ip-address": "192.0.2.202"
  921. }
  922. }</screen>
  923. An example deletion by (subnet-id, identifier-type, identifier) looks as follows:
  924. <screen>
  925. {
  926. "command": "reservation-del",
  927. "arguments":
  928. "subnet-id": 4,
  929. "identifier-type": "hw-address",
  930. "identifier": "01:02:03:04:05:06"
  931. }
  932. }</screen>
  933. </para>
  934. <para>
  935. <command>reservation-del</command> returns result 0 when the host
  936. deletion was successful or 1 if it was not. A descriptive text is
  937. provided in case of error. Example results look as follows:
  938. <screen>
  939. {
  940. "result": 1,
  941. "text": "Host not deleted (not found)."
  942. }</screen>
  943. <screen>
  944. {
  945. "result": 0,
  946. "text": "Host deleted."
  947. }</screen>
  948. <screen>
  949. {
  950. "result": 1,
  951. "text": "Unable to delete a host because there is no hosts-database
  952. configured."
  953. }</screen>
  954. </para>
  955. </section>
  956. </section>
  957. <!-- ================================================================= -->
  958. <!-- === lease_cmds ================================================== -->
  959. <!-- ================================================================= -->
  960. <section id="lease-cmds">
  961. <title>lease_cmds: Lease Commands</title>
  962. <para>
  963. This section describes the hook library that offers a number of new
  964. commands used to manage leases. Kea provides a way to store lease
  965. information in several backends (memfile, MySQL, PostgreSQL and
  966. Cassandra). This library provides a unified interface that can
  967. manipulate leases in an unified, safe way. In particular, it allows
  968. things previously impossible: manipulate leases in memfile while Kea
  969. is running, sanity check changes, check lease existence and remove all
  970. leases belonging to specific subnet. It can also catch more obscure
  971. errors, like adding a lease with subnet-id that does not exist in the
  972. configuration or configuring a lease to use an address that is outside
  973. of the subnet to which it is supposed to belong.
  974. </para>
  975. <para>There are many use cases when an administrative command may be
  976. useful: during migration between servers (possibly even between
  977. different vendors), when a certain network is being retired, when a
  978. device has been disconnected and the sysadmin knows for sure that it
  979. will not be coming back. The "get" queries may be useful for automating
  980. certain management and monitoring tasks. They can also act as
  981. preparatory steps for lease updates and removals.</para>
  982. <para>
  983. This library provides the following commands:
  984. <itemizedlist>
  985. <listitem>
  986. <para><command>lease4-add</command> - adds new IPv4 lease;</para>
  987. </listitem>
  988. <listitem>
  989. <para><command>lease6-add</command> - adds new IPv6 lease;</para>
  990. </listitem>
  991. <listitem>
  992. <para><command>lease4-get</command> - checks if an IPv4 lease with
  993. the specified parameters exists and returns it if it does;</para>
  994. </listitem>
  995. <listitem>
  996. <para><command>lease6-get</command> - checks if an IPv6 lease with
  997. the specified parameters exists and returns it if it does;</para>
  998. </listitem>
  999. <listitem>
  1000. <para><command>lease4-del</command> - attempts to delete an IPv4
  1001. lease with the specified parameters;</para>
  1002. </listitem>
  1003. <listitem>
  1004. <para><command>lease6-del</command> - attempts to delete an IPv6
  1005. lease with the specified parameters;</para>
  1006. </listitem>
  1007. <listitem>
  1008. <para><command>lease4-update</command> - updates an IPv4 lease;</para>
  1009. </listitem>
  1010. <listitem>
  1011. <para><command>lease6-update</command> - updates an IPv6 lease;</para>
  1012. </listitem>
  1013. <listitem>
  1014. <para><command>lease4-wipe</command> - removes all leases from a
  1015. specific IPv4 subnet;</para>
  1016. </listitem>
  1017. <listitem>
  1018. <para><command>lease6-wipe</command> - removes all leases from a
  1019. specific IPv6 subnet;</para>
  1020. </listitem>
  1021. </itemizedlist>
  1022. </para>
  1023. <para>Lease commands library is part of the open source code and is
  1024. available to every Kea user.</para>
  1025. <para>
  1026. All commands are using JSON syntax. They can be issued either using
  1027. control channel (see <xref linkend="ctrl-channel"/>) or via Control
  1028. Agent (see <xref linkend="kea-ctrl-agent"/>).
  1029. </para>
  1030. <para>
  1031. The library can be loaded in the same way as other hook libraries. It
  1032. does not take any parameters. It supports both DHCPv4 and DHCPv6
  1033. servers.
  1034. <screen>
  1035. "Dhcp6": { <userinput>
  1036. "hooks-libraries": [
  1037. {
  1038. "library": "/path/libdhcp_lease_cmds.so"
  1039. }
  1040. ...
  1041. ] </userinput>
  1042. }
  1043. </screen>
  1044. </para>
  1045. <section>
  1046. <title>lease4-add, lease6-add commands</title>
  1047. <para>
  1048. <command>lease4-add</command> and <command>lease6-add</command>
  1049. commands allow creation of a new lease. Typically Kea creates a lease
  1050. on its own, when it first sees a new device. However, sometimes it may
  1051. be convenient to create the lease administratively. The
  1052. <command>lease4-add</command> command requires at least three
  1053. parameters: an IPv4 address, a subnet-id and an identifier: hardware
  1054. (MAC) address. The simplest successful call might look as follows:
  1055. <screen>
  1056. {
  1057. "command": "lease4-add",
  1058. "arguments": {
  1059. "subnet-id": 44,
  1060. "ip-address": "192.0.2.202",
  1061. "hw-address": "1a:1b:1c:1d:1e:1f"
  1062. }
  1063. }
  1064. </screen>
  1065. </para>
  1066. <para><command>lease6-add</command> command requires four
  1067. paramaters: an IPv6 address, a subnet-id, and IAID value
  1068. (identity association identifier, a value sent by clients) and
  1069. a DUID:
  1070. <screen>
  1071. {
  1072. "command": "lease6-add",
  1073. "arguments": {
  1074. "subnet-id": 66,
  1075. "ip-address": "2001:db8::3",
  1076. "duid": "1a:1b:1c:1d:1e:1f:20:21:22:23:24",
  1077. "iaid": 1234
  1078. }
  1079. }</screen>
  1080. <command>lease6-add</command> can be also used to add leases for IPv6
  1081. prefixes. In this case there are two parameters that must be
  1082. specified: type (set to value of &quot;IA_PD&quot;) and a prefix
  1083. length. The actual prefix is set using ip-address field. For example,
  1084. to configure a lease for prefix 2001:db8:abcd::/48, the following
  1085. command can be used:
  1086. <screen>
  1087. {
  1088. "command": "lease6-add",
  1089. "arguments": {
  1090. "subnet-id": 66,
  1091. "type": "IA_PD",
  1092. "ip-address": "2001:db8:abcd::",
  1093. "prefix-len": 48,
  1094. "duid": "1a:1b:1c:1d:1e:1f:20:21:22:23:24",
  1095. "iaid": 1234
  1096. }
  1097. }</screen>
  1098. The commands can take a number of additional optional parameters:
  1099. <itemizedlist>
  1100. <listitem>
  1101. <para><command>valid-lft</command> - specifies the lifetime of the
  1102. lease, expressed in seconds. If not specified, the value
  1103. configured in the subnet related to specified subnet-id is
  1104. used.</para>
  1105. </listitem>
  1106. <listitem>
  1107. <para><command>expire</command> - timestamp of the lease
  1108. expiration time, expressed in unix format (seconds since 1 Jan
  1109. 1970). If not specified, the default value is now + valid
  1110. lifetime.</para>
  1111. </listitem>
  1112. <listitem>
  1113. <para><command>fqdn-fwd</command> - specifies whether the lease
  1114. should be marked as if forward DNS update was conducted. Note this
  1115. only affects the lease parameter and the actual DNS update will
  1116. not be conducted at the lease insertion time. If configured, a DNS
  1117. update to remove the A or AAAA records will be conducted when the
  1118. lease is removed due to expiration or being released by a
  1119. client. If not specifed, the default value is false. Hostname
  1120. parameter must be specified in fqdn-fwd is set to true.</para>
  1121. </listitem>
  1122. <listitem>
  1123. <para><command>fqdn-rev</command> - specifies whether the lease
  1124. should be marked as if reverse DNS update was conducted. Note this
  1125. only affects the lease parameter and the actual DNS update will
  1126. not be conducted at the lease insertion time. If configured, a DNS
  1127. update to remove the PTR record will be conducted when the lease
  1128. is removed due to expiration or being released by a client. If not
  1129. specifed, the default value is false. Hostname parameter must be
  1130. specified in fqdn-fwd is set to true.</para>
  1131. </listitem>
  1132. <listitem>
  1133. <para><command>hostname</command> - specifies the hostname to be
  1134. associated with this lease. Its value must be non-empty if either
  1135. fqdn-fwd or fwdn-rev are set to true. If not specified, the
  1136. default value is an empty string.</para>
  1137. </listitem>
  1138. <listitem>
  1139. <para><command>hw-address</command> - hardware (MAC) address can
  1140. be optionally specified for IPv6 lease. It is mandatory parameter
  1141. for IPv4 lease.</para>
  1142. </listitem>
  1143. <listitem>
  1144. <para><command>client-id</command> - client identifier is an
  1145. optional parameter that can be specified for IPv4 lease.</para>
  1146. </listitem>
  1147. <listitem>
  1148. <para><command>preferred-lft</command> - Preferred lifetime is an
  1149. optional parameter for IPv6 leases. If not specified, the value
  1150. configured for the subnet corresponding to the specified subnet-id
  1151. is used. This parameter is not used in IPv4.</para>
  1152. </listitem>
  1153. </itemizedlist>
  1154. </para>
  1155. <para>Here's an example of more complex lease addition:
  1156. <screen>
  1157. {
  1158. "command": "lease6-add",
  1159. "arguments": {
  1160. "subnet-id": 66,
  1161. "ip-address": "2001:db8::3",
  1162. "duid": "01:02:03:04:05:06:07:08",
  1163. "iaid": 1234,
  1164. "hw-address": "1a:1b:1c:1d:1e:1f",
  1165. "preferred-lft": 500,
  1166. "valid-lft": 1000,
  1167. "expire": 12345678,
  1168. "fqdn-fwd": true,
  1169. "fqdn-rev": true,
  1170. "hostname": "urania.example.org"
  1171. }
  1172. }
  1173. </screen>
  1174. </para>
  1175. <para>
  1176. The command returns a status that indicates either a success (result
  1177. 0) or a failure (result 1). Failed command always includes text
  1178. parameter that explains the cause of failure. Example results:
  1179. <screen>{ "result": 0, "text": "Lease added." }</screen> Example failure:
  1180. <screen>{ "result": 1, "text": "missing parameter 'ip-address' (&lt;string&gt;:3:19)" }</screen>
  1181. </para>
  1182. <section>
  1183. <title>lease4-get, lease6-get commands</title>
  1184. <para><command>lease4-get</command> or <command>lease6-get</command>
  1185. can be used to query the lease database and retrieve existing
  1186. leases. There are two types of parameters the
  1187. <command>lease4-get</command> supports: (address) or (subnet-id,
  1188. identifier-type, identifier). There are two types for
  1189. <command>lease6-get</command>: (address,type) or (subnet-id,
  1190. identifier-type, identifier, IAID, type). The first type of query is
  1191. used when the address (either IPv4 or IPv6) is known, but the details
  1192. of the lease aren't. One common use case of this type of query is to
  1193. find out whether a given address is being used or not. The second
  1194. query uses identifiers. For maximum flexibility, Kea stores the host
  1195. identifying information as a pair of values: type and the actual
  1196. identifier. Currently supported identifiers are "hw-address", "duid",
  1197. "circuit-id", "client-id" and "flex-id", but additional types may be
  1198. added in the future. If any new identifier types are defined in the
  1199. future, reservation-get command will support them
  1200. automatically.</para>
  1201. <para>
  1202. An example <command>lease4-get</command> command for getting a lease
  1203. by an IPv4 address looks as follows:
  1204. <screen>
  1205. {
  1206. "command": "lease4-get",
  1207. "arguments": {
  1208. "ip-address": "192.0.2.1"
  1209. }
  1210. }
  1211. </screen>
  1212. </para>
  1213. <para>An example of the <command>lease6-get</command> query
  1214. looks as follows:
  1215. <screen>
  1216. {
  1217. "command": "lease6-get",
  1218. "arguments": {
  1219. "ip-address": "2001:db8:1234:ab::",
  1220. "type": "IA_PD"
  1221. }
  1222. }</screen>
  1223. </para>
  1224. <para>An example query by (subnet-id, identifier-type,
  1225. identifier) for IPv4 lease looks as follows:
  1226. <screen>
  1227. {
  1228. "command": "lease4-get",
  1229. "arguments": {
  1230. "identifier-type": "hw-address",
  1231. "identifier": "08:08:08:08:08:08",
  1232. "subnet-id": 44
  1233. }
  1234. }</screen>
  1235. </para>
  1236. <para>An example query by (subnet-id, identifier-type,
  1237. identifier, iaid, type) for IPv6 lease looks as follows:
  1238. <screen>
  1239. {
  1240. "command": "lease4-get",
  1241. "arguments": {
  1242. "identifier-type": "duid",
  1243. "identifier": "08:08:08:08:08:08",
  1244. "iaid": 1234567,
  1245. "type": "IA_NA",
  1246. "subnet-id": 44
  1247. }
  1248. }</screen>
  1249. The type is an optional parameter. Supported values are: IA_NA
  1250. (non-temporary address) and IA_PD (IPv6 prefix) are supported.
  1251. If not specified, IA_NA is assumed.
  1252. </para>
  1253. <para><command>leaseX-get</command> returns a result that indicates a
  1254. result of the operation and lease details, if found. It has one of the
  1255. following values: 0 (success), 1 (error) or 2 (empty). The empty
  1256. result means that a query has been completed properly, but the object
  1257. (a lease in this case) has not been found. The lease parameters, if
  1258. found, are returned as arguments.
  1259. </para>
  1260. <para>
  1261. An example result returned when the host was found:
  1262. <screen>{
  1263. "arguments": {
  1264. "client-id": "42:42:42:42:42:42:42:42",
  1265. "cltt": 12345678,
  1266. "fqdn-fwd": false,
  1267. "fqdn-rev": true,
  1268. "hostname": "myhost.example.com.",
  1269. "hw-address": "08:08:08:08:08:08",
  1270. "ip-address": "192.0.2.1",
  1271. "state": 0,
  1272. "subnet-id": 44,
  1273. "valid-lft": 3600
  1274. },
  1275. "result": 0,
  1276. "text": "IPv4 lease found."
  1277. }</screen>
  1278. </para>
  1279. </section>
  1280. <section>
  1281. <title>lease4-del, lease6-del commands</title>
  1282. <para><command>leaseX-del</command> can be used to delete a lease from
  1283. the lease database. There are two types of parameters this command
  1284. supports, similar to leaseX-get commands: (address) for both v4 and
  1285. v6, (subnet-id, identifier-type, identifier) for v4 and (subnet-id,
  1286. identifier-type, identifier, type, IAID) for v6. The first type of
  1287. query is used when the address (either IPv4 or IPv6) is known, but the
  1288. details of the lease are not. One common use case of this type of query
  1289. is to remove a lease (e.g. you want a specific address to no longer be
  1290. used, no matter who may use it). The second query uses
  1291. identifiers. For maximum flexibility, this interface uses identifiers
  1292. as a pair of values: type and the actual identifier. Currently
  1293. supported identifiers are "hw-address" and "duid", but additional
  1294. types may be added in the future. </para>
  1295. <para>
  1296. An example command for deleting a host reservation by address looks
  1297. as follows:
  1298. <screen>
  1299. {
  1300. "command": "lease4-del",
  1301. "arguments": {
  1302. "ip-address": "192.0.2.202"
  1303. }
  1304. }</screen>
  1305. An example IPv4 lease deletion by (subnet-id, identifier-type, identifier) looks
  1306. as follows:
  1307. <screen>{
  1308. "command": "lease4-del",
  1309. "arguments": {
  1310. "identifier": "08:08:08:08:08:08",
  1311. "identifier-type": "hw-address",
  1312. "subnet-id": 44
  1313. }
  1314. }</screen>
  1315. </para>
  1316. <para><command>leaseX-get</command> returns a result that
  1317. indicates a outcome of the operation. It has one of the
  1318. following values: 0 (success), 1 (error) or 2 (empty). The
  1319. empty result means that a query has been completed properly,
  1320. but the object (a lease in this case) has not been found.
  1321. </para>
  1322. </section>
  1323. <section>
  1324. <title>lease4-update, lease6-update commands</title>
  1325. <para><command>lease4-update</command> and
  1326. <command>lease6-update</command> commands can be used to update
  1327. existing leases. Since all lease database backends are indexed by IP
  1328. addresses, it is not possible to update an address. All other fields
  1329. may be updated. If an address needs to be changed, please use
  1330. <command>leaseX-del</command> followed by
  1331. <command>leaseX-add</command> commands.</para>
  1332. <para>To use <command>leaseX-update</command> the lease must
  1333. be present in the lease database. If the lease is not there,
  1334. an error will be returned. Please use
  1335. <command>leaseX-add</command> to add new leases. You may
  1336. check if a lease is present using
  1337. <command>leaseX-get</command>, if needed.</para>
  1338. <para>
  1339. An example command updating IPv6 lease looks as follows:
  1340. <screen>{
  1341. "command": "lease4-update",
  1342. "arguments": {
  1343. "ip-address": "192.0.2.1",
  1344. "hostname": "newhostname.example.org",
  1345. "hw-address": "1a:1b:1c:1d:1e:1f",
  1346. "subnet-id": 44
  1347. }
  1348. }</screen>
  1349. </para>
  1350. <para>
  1351. An example command updating IPv6 lease looks as follows:
  1352. <screen>{
  1353. "command": "lease6-update",
  1354. "arguments": {
  1355. "ip-address": "2001:db8::1",
  1356. "duid": "88:88:88:88:88:88:88:88",
  1357. "iaid": 7654321,
  1358. "hostname": "newhostname.example.org",
  1359. "subnet-id": 66
  1360. }
  1361. }</screen>
  1362. </para>
  1363. </section>
  1364. <section>
  1365. <title>lease4-wipe, lease6-wipe commands</title>
  1366. <para><command>lease4-wipe</command> and
  1367. <command>lease6-wipe</command> are designed to remove all
  1368. leases associated with a given subnet. This administrative
  1369. task is expected to be used when existing subnet is being
  1370. retired. Note that the leases are not properly expired,
  1371. there are no DNS updates conducted, no log messages and
  1372. hooks are not called for leases being removed.</para>
  1373. <para>An example of <command>lease4-wipe</command> looks as follows:
  1374. <screen>{
  1375. "command": "lease4-wipe",
  1376. "arguments": {
  1377. "subnet-id": 44
  1378. }
  1379. }</screen>
  1380. </para>
  1381. <para>An example of <command>lease6-wipe</command> looks as follows:
  1382. <screen>{
  1383. "command": "lease6-wipe",
  1384. "arguments": {
  1385. "subnet-id": 66
  1386. }
  1387. }</screen>
  1388. </para>
  1389. <para>The commands return a textual description of the
  1390. number of leases removed and 0 (success) status code if any
  1391. leases were removed and 2 (empty) if there were no
  1392. leases. Status code 1 (error) may be returned in case the
  1393. parameeters are incorrect or some other exception is
  1394. encountered.</para>
  1395. <para>Note: not all backends support this command.</para>
  1396. </section>
  1397. </section>
  1398. </section>
  1399. <section id="subnet-cmds">
  1400. <title>subnet_cmds: Subnet Commands</title>
  1401. <para>
  1402. This section describes a hook application that offers a number of new
  1403. commands used to query and manipulate subnet configurations in Kea.
  1404. This application is very useful in deployments with a large number of
  1405. subnets being managed by the DHCP servers and when the subnets are
  1406. frequently updated. The commands offer lightweight approach for
  1407. manipulating subnets without a need to fully reconfigure the server
  1408. and without affecting existing servers' configurations.
  1409. </para>
  1410. <para>Currently this library is only available to ISC customers with a
  1411. support contract.</para>
  1412. <para>The following commands are currently supported:
  1413. <itemizedlist mark='bullet'>
  1414. <listitem>
  1415. <simpara><command>subnet4-list/subnet6-list</command>: lists all configured subnets
  1416. </simpara>
  1417. </listitem>
  1418. <listitem>
  1419. <simpara>
  1420. <command>subnet4-get/subnet6-get</command>: retrieves detailed information about a selected subnet
  1421. </simpara>
  1422. </listitem>
  1423. <listitem>
  1424. <simpara>
  1425. <command>subnet4-add/subnet6-add</command>: adds new subnet into server's configuration
  1426. </simpara>
  1427. </listitem>
  1428. <listitem>
  1429. <simpara>
  1430. <command>subnet4-del/subnet6-del</command>: removes a subnet from the server's configuration
  1431. </simpara>
  1432. </listitem>
  1433. </itemizedlist>
  1434. </para>
  1435. <section>
  1436. <title>subnet4-list command</title>
  1437. <para>
  1438. This command is used to list all currently configured subnets. The
  1439. subnets are returned in a brief form, i.e. a subnet identifier
  1440. and subnet prefix is included for each subnet. In order to retrieve
  1441. the detailed information about the subnet the
  1442. <command>subnet4-get</command> should be used.
  1443. </para>
  1444. <para>
  1445. This command has the simple structure:
  1446. <screen>
  1447. {
  1448. "command": "subnet4-list"
  1449. }
  1450. </screen>
  1451. </para>
  1452. <para>
  1453. The list of subnets returned as a result of this command is returned
  1454. in the following format:
  1455. <screen>
  1456. {
  1457. "result": 0,
  1458. "text": "2 IPv4 subnets found",
  1459. "arguments": {
  1460. "subnets": [
  1461. {
  1462. "id": 10,
  1463. "subnet": "10.0.0.0/8"
  1464. },
  1465. {
  1466. "id": 100,
  1467. "subnet": "192.0.2.0/24"
  1468. }
  1469. ]
  1470. }
  1471. </screen>
  1472. </para>
  1473. <para>
  1474. If no IPv4 subnets are found, an error code is returned along with
  1475. the error description.
  1476. </para>
  1477. </section>
  1478. <section>
  1479. <title>subnet6-list command</title>
  1480. <para>
  1481. This command is used to list all currently configured subnets. The
  1482. subnets are returned in a brief form, i.e. a subnet identifier
  1483. and subnet prefix is included for each subnet. In order to retrieve
  1484. the detailed information about the subnet the
  1485. <command>subnet6-get</command> should be used.
  1486. </para>
  1487. <para>
  1488. This command has the simple structure:
  1489. <screen>
  1490. {
  1491. "command": "subnet6-list"
  1492. }
  1493. </screen>
  1494. </para>
  1495. <para>
  1496. The list of subnets returned as a result of this command is returned
  1497. in the following format:
  1498. <screen>
  1499. {
  1500. "result": 0,
  1501. "text": "2 IPv6 subnets found",
  1502. "arguments": {
  1503. "subnets": [
  1504. {
  1505. "id": 11,
  1506. "subnet": "2001:db8:1::/64"
  1507. },
  1508. {
  1509. "id": 233,
  1510. "subnet": "3000::/16"
  1511. }
  1512. ]
  1513. }
  1514. </screen>
  1515. </para>
  1516. <para>
  1517. If no IPv6 subnets are found, an error code is returned along with
  1518. the error description.
  1519. </para>
  1520. </section>
  1521. <section>
  1522. <title>subnet4-get command</title>
  1523. <para>This command is used to retrieve detailed information about the
  1524. specified subnet. This command usually follows the
  1525. <command>subnet4-list</command>, which is used to discover available
  1526. subnets with their respective subnet identifiers and prefixes. Any of
  1527. those parameters can be then used in <command>subnet4-get</command>
  1528. to fetch subnet information:
  1529. <screen>
  1530. {
  1531. "command": "subnet4-get",
  1532. "arguments": {
  1533. "id": 10
  1534. }
  1535. }</screen>
  1536. or
  1537. <screen>
  1538. {
  1539. "command": "subnet4-get",
  1540. "arguments": {
  1541. "subnet": "10.0.0.0/8"
  1542. }
  1543. }
  1544. </screen>
  1545. </para>
  1546. <para>
  1547. If the subnet exists the response will be similar to this:
  1548. <screen>
  1549. {
  1550. "result": 0,
  1551. "text": "Info about IPv4 subnet 10.0.0.0/8 (id 10) returned",
  1552. "arguments": {
  1553. "subnets": [
  1554. {
  1555. "subnet": "10.0.0.0/8",
  1556. "id": 1,
  1557. "option-data": [
  1558. ....
  1559. ]
  1560. ...
  1561. }
  1562. ]
  1563. }
  1564. }
  1565. </screen>
  1566. </para>
  1567. </section>
  1568. <section>
  1569. <title>subnet6-get command</title>
  1570. <para>This command is used to retrieve detailed information about the
  1571. specified subnet. This command usually follows the
  1572. <command>subnet6-list</command>, which is used to discover available
  1573. subnets with their respective subnet identifiers and prefixes. Any of
  1574. those parameters can be then used in <command>subnet6-get</command>
  1575. to fetch subnet information:
  1576. <screen>
  1577. {
  1578. "command": "subnet6-get",
  1579. "arguments": {
  1580. "id": 11
  1581. }
  1582. }
  1583. </screen>
  1584. or
  1585. <screen>
  1586. {
  1587. "command": "subnet6-get",
  1588. "arguments": {
  1589. "subnet": "2001:db8:1::/64"
  1590. }
  1591. }</screen>
  1592. If the subnet exists the response will be similar to this:
  1593. <screen>
  1594. {
  1595. "result": 0,
  1596. "text": "Info about IPv6 subnet 2001:db8:1::/64 (id 11) returned",
  1597. "arguments": {
  1598. "subnets": [
  1599. {
  1600. "subnet": "2001:db8:1::/64",
  1601. "id": 1,
  1602. "option-data": [
  1603. ...
  1604. ]
  1605. ....
  1606. }
  1607. ]
  1608. }
  1609. }
  1610. </screen>
  1611. </para>
  1612. </section>
  1613. <section>
  1614. <title>subnet4-add</title>
  1615. <para>
  1616. This command is used to create and add new subnet to the existing
  1617. server configuration. This operation has no impact on other
  1618. subnets. The subnet identifier must be specified and must be
  1619. unique among all subnets. If the identifier or a subnet prefix is
  1620. not unique an error is reported and the subnet is not added.
  1621. </para>
  1622. <para>
  1623. The subnet information within this command has the same structure
  1624. as the subnet information in the server configuration file with the
  1625. exception that static host reservations must not be specified
  1626. within <command>subnet4-add</command>. The commands described in
  1627. <xref linkend="host-cmds"/> should be used to add, remove and
  1628. modify static reservations.
  1629. <screen>
  1630. {
  1631. "command": "subnet4-add",
  1632. "arguments": {
  1633. "subnets": [ {
  1634. "id": 123,
  1635. "subnet": "10.20.30.0/24",
  1636. ...
  1637. } ]
  1638. }
  1639. }
  1640. </screen>
  1641. </para>
  1642. <para>
  1643. The response to this command has the following structure:
  1644. <screen>
  1645. {
  1646. "result": 0,
  1647. "text": "IPv4 subnet added",
  1648. "arguments": {
  1649. "subnets": [
  1650. {
  1651. "id": 123,
  1652. "subnet": "10.20.30.0/24"
  1653. }
  1654. ]
  1655. }
  1656. }
  1657. </screen>
  1658. </para>
  1659. </section>
  1660. <section>
  1661. <title>subnet6-add</title>
  1662. <para>
  1663. This command is used to create and add new subnet to the existing
  1664. server configuration. This operation has no impact on other
  1665. subnets. The subnet identifier must be specified and must be
  1666. unique among all subnets. If the identifier or a subnet prefix is
  1667. not unique an error is reported and the subnet is not added.
  1668. </para>
  1669. <para>
  1670. The subnet information within this command has the same structure
  1671. as the subnet information in the server configuration file with the
  1672. exception that static host reservations must not be specified
  1673. within <command>subnet6-add</command>. The commands described in
  1674. <xref linkend="host-cmds"/> should be used to add, remove and
  1675. modify static reservations.
  1676. <screen>
  1677. {
  1678. "command": "subnet6-add",
  1679. "arguments": {
  1680. "subnet6": [ {
  1681. "id": 234,
  1682. "subnet": "2001:db8:1::/64",
  1683. ...
  1684. } ]
  1685. }
  1686. }
  1687. </screen>
  1688. </para>
  1689. <para>
  1690. The response to this command has the following structure:
  1691. <screen>
  1692. {
  1693. "result": 0,
  1694. "text": "IPv6 subnet added",
  1695. "arguments": {
  1696. "subnet6": [
  1697. {
  1698. "id": 234,
  1699. "subnet": "2001:db8:1::/64"
  1700. }
  1701. ]
  1702. }
  1703. }
  1704. </screen>
  1705. </para>
  1706. <para>
  1707. It is recommended, but not mandatory to specify subnet
  1708. id. If not specified, Kea will try to assign the next
  1709. subnet-id value. This automatic ID value generator is
  1710. simple. It returns a previously automatically assigned value
  1711. increased by 1. This works well, unless you manually create
  1712. a subnet with a value bigger than previously used. For
  1713. example, if you call subnet4-add five times, each without
  1714. id, Kea will assign IDs: 1,2,3,4 and 5 and it will work just
  1715. fine. However, if you try to call subnet4-add five times,
  1716. with the first subnet having subnet-id of value 3 and
  1717. remaining ones having no subnet-id, it will fail. The first
  1718. command (with explicit value) will use subnet-id 3, the
  1719. second command will create a subnet with id of 1, the third
  1720. will use value of 2 and finally the fourth will have the
  1721. subnet-id value auto-generated as 3. However, since there is
  1722. already a subnet with that id, it will fail.
  1723. </para>
  1724. <para>
  1725. The general recommendation is to either: never use explicit
  1726. values (so the auto-generated values will always work) or
  1727. always use explicit values (so the auto-generation is never
  1728. used). You can mix those two approaches only if you
  1729. understand how the internal automatic subnet-id generation works.
  1730. </para>
  1731. </section>
  1732. <section>
  1733. <title>subnet4-del command</title>
  1734. <para>
  1735. This command is used to remove a subnet from the server's configuration.
  1736. This command has no effect on other configured subnets but removing
  1737. a subnet has certain implications which the server's administrator
  1738. should be aware of.
  1739. </para>
  1740. <para>
  1741. In most cases the server has assigned some leases to the clients
  1742. belonging to the subnet. The server may also be configured with
  1743. static host reservations which are associated with this subnet.
  1744. The current implementation of the <command>subnet4-del</command>
  1745. removes neither the leases nor host reservations associated with
  1746. a subnet. This is the safest approach because the server doesn't
  1747. loose track of leases assigned to the clients from this subnet.
  1748. However, removal of the subnet may still cause configuration
  1749. errors and conflicts. For example: after removal of the subnet,
  1750. the server administrator may add a new subnet with the ID used
  1751. previously for the removed subnet. This means that the existing
  1752. leases and static reservations will be in conflict with this
  1753. new subnet. Thus, we recommend that this command is used with extreme
  1754. caution.
  1755. </para>
  1756. <para>The command has the following structure:
  1757. <screen>
  1758. {
  1759. "command": "subnet4-del",
  1760. "arguments": {
  1761. "id": 123
  1762. }
  1763. }
  1764. </screen>
  1765. </para>
  1766. <para>
  1767. The example successful response may look like this:
  1768. <screen>
  1769. {
  1770. "result": 0,
  1771. "text": "IPv4 subnet 192.0.2.0/24 (id 123) deleted",
  1772. "arguments": {
  1773. "subnets": [
  1774. {
  1775. "id": 123,
  1776. "subnet": "192.0.2.0/24"
  1777. }
  1778. ]
  1779. }
  1780. }
  1781. </screen>
  1782. </para>
  1783. </section>
  1784. <section>
  1785. <title>subnet6-del command</title>
  1786. <para>
  1787. This command is used to remove a subnet from the server's configuration.
  1788. This command has no effect on other configured subnets but removing
  1789. a subnet has certain implications which the server's administrator
  1790. should be aware of.
  1791. </para>
  1792. <para>
  1793. In most cases the server has assigned some leases to the clients
  1794. belonging to the subnet. The server may also be configured with
  1795. static host reservations which are associated with this subnet.
  1796. The current implementation of the <command>subnet6-del</command>
  1797. removes neither the leases nor host reservations associated with
  1798. a subnet. This is the safest approach because the server doesn't
  1799. loose track of leases assigned to the clients from this subnet.
  1800. However, removal of the subnet may still cause configuration
  1801. errors and conflicts. For example: after removal of the subnet,
  1802. the server administrator may add a new subnet with the ID used
  1803. previously for the removed subnet. This means that the existing
  1804. leases and static reservations will be in conflict with this
  1805. new subnet. Thus, we recommend that this command is used with extreme
  1806. caution.
  1807. </para>
  1808. <para>The command has the following structure:
  1809. <screen>
  1810. {
  1811. "command": "subnet6-del",
  1812. "arguments": {
  1813. "id": 234
  1814. }
  1815. }
  1816. </screen>
  1817. </para>
  1818. <para>
  1819. The example successful response may look like this:
  1820. <screen>
  1821. {
  1822. "result": 0,
  1823. "text": "IPv6 subnet 2001:db8:1::/64 (id 234) deleted",
  1824. "subnets": [
  1825. {
  1826. "id": 234,
  1827. "subnet": "2001:db8:1::/64"
  1828. }
  1829. ]
  1830. }
  1831. </screen>
  1832. </para>
  1833. </section>
  1834. </section>
  1835. </section> <!-- end of subnet commands -->
  1836. <section id="user-context">
  1837. <title>User contexts</title>
  1838. <para>Hook libraries can have their own configuration parameters. That is
  1839. convenient if the parameter applies to the whole library. However,
  1840. sometimes it is very useful if certain configuration entities are extended
  1841. with additional configuration data. This is where the concept of user
  1842. contexts comes in. A sysadmin can define an arbitrary set of data and
  1843. attach it to Kea structures, as long as the data is specified as JSON map.
  1844. In particular, it is possible to define fields that are integers, strings,
  1845. boolean, lists and maps. It is possible to define nested structures of
  1846. arbitrary complexity. Kea does not use that data on its own, simply stores
  1847. and makes it available for the hook libraries.
  1848. </para>
  1849. <para>
  1850. Another use case for user contexts may be storing comments and other
  1851. information that will be retained by Kea. Regular comments are discarded
  1852. when configuration is loaded, but user contexts are retained. This is
  1853. useful if you want your comments to survive config-set, config-get
  1854. operations for example.
  1855. </para>
  1856. <para>
  1857. As of Kea 1.3, the structures that allow user contexts are pools of all
  1858. types (addresses and prefixes) and subnets. These are supported in both
  1859. DHCPv4 and DHCPv6. It is expected that other structures will be extended
  1860. in the future to provide the user context capability.
  1861. </para>
  1862. </section>
  1863. </chapter> <!-- hooks-libraries -->