hooks.xml 99 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563
  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. <para>
  444. In addition to logging lease activity driven by DHCPv4 client traffic, it also
  445. logs entries for the following lease management control channel commands:
  446. lease4-add, lease4-update, and lease4-del. Each entry is a single string
  447. with no embedded end-of-line markers and they will typically have the following
  448. forms:
  449. </para>
  450. <para>
  451. <command>lease4-add:</command>
  452. <screen>
  453. Administrator added a lease of address: *address* to a device with hardware address: *device-id*
  454. </screen>
  455. Dependent on the arguments of the add command, it may also include the
  456. client-id and duration.
  457. </para>
  458. <para>
  459. Example:
  460. <screen>
  461. Administrator added a lease of address: 192.0.2.202 to a device with hardware address: 1a:1b:1c:1d:1e:1f for 1 days 0 hrs 0 mins 0 secs
  462. </screen>
  463. </para>
  464. <para>
  465. <command>lease4-update:</command>
  466. <screen>
  467. Administrator updated information on the lease of address: *address* to a device with hardware address: *device-id*
  468. </screen>
  469. Dependent on the arguments of the update command, it may also include the
  470. client-id and lease duration.
  471. </para>
  472. <para>
  473. Example:
  474. <screen>
  475. Administrator updated information on the lease of address: 192.0.2.202 to a device with hardware address: 1a:1b:1c:1d:1e:1f, client-id: 1234567890
  476. </screen>
  477. </para>
  478. <para>
  479. <command>lease4-del:</command>
  480. Deletes have two forms, one by address and one by identifier and identifier type:
  481. <screen>
  482. Administrator deleted the lease for address: *address*
  483. </screen>
  484. or
  485. <screen>
  486. Administrator deleted a lease for a device identified by: *identifier-type* of *identifier*
  487. </screen>
  488. Currently only a type of @b hw-address (hardware address) is supported.
  489. </para>
  490. <para>
  491. Examples:
  492. <screen>
  493. Administrator deleted the lease for address: 192.0.2.202
  494. Administrator deleted a lease for a device identified by: hw-address of 1a:1b:1c:1d:1e:1f
  495. </screen>
  496. </para>
  497. </section>
  498. <section>
  499. <title>DHCPv6 Log Entries</title>
  500. <para>
  501. For DHCPv6 the library creates entries based on lease management
  502. actions intercepted by the lease6_select (for new leases), lease6_renew
  503. (for renewed leases) and lease6_rebind (for rebound leases).
  504. </para>
  505. <para>
  506. An entry is a single string with no embedded end-of-line markers
  507. and has the following sections:
  508. <screen>
  509. address duration device-id {relay-info}*
  510. </screen>
  511. </para>
  512. <para>
  513. Where:
  514. <itemizedlist>
  515. <listitem><para>
  516. address - the leased IPv6 address or prefix given out and whether
  517. it was assigned or renewed.
  518. </para></listitem>
  519. <listitem><para>
  520. duration - the lease lifetime expressed in days (if present),
  521. hours, minutes and seconds. A lease lifetime of 0xFFFFFFFF will be
  522. denoted with the text "infinite duration".
  523. </para></listitem>
  524. <listitem><para>
  525. device-id - the client's DUID and hardware address (if present).
  526. </para></listitem>
  527. <listitem><para>
  528. relay-info - for relayed packets the content of relay agent
  529. messages, remote-id (code 37), subscriber-id (code 38) and
  530. interface-id (code 18) options if present. Note that
  531. interface-id option, if present, identifies the whole interface the
  532. relay agent received the message on. This typically translates to a
  533. single link in your network, but it depends on your specific network
  534. topology. Nevertheless, this is useful information to better scope
  535. down the location of the device, so it is being recorded, if present.
  536. </para></listitem>
  537. </itemizedlist>
  538. </para>
  539. <para>
  540. For instance (line breaks added for readability, they would not
  541. be present in the log file).
  542. <screen>
  543. Address:2001:db8:1:: has been assigned for 0 hrs 11 mins 53 secs to a device with
  544. DUID: 17:34:e2:ff:09:92:54 and hardware address: hwtype=1 08:00:2b:02:3f:4e
  545. (from Raw Socket) connected via relay at address: fe80::abcd for client on
  546. link address: 3001::1, hop count: 1, identified by remote-id:
  547. 01:02:03:04:0a:0b:0c:0d:0e:0f and subscriber-id: 1a:2b:3c:4d:5e:6f
  548. </screen>
  549. </para>
  550. <para>
  551. In addition to logging lease activity driven by DHCPv6 client traffic, it also
  552. logs entries for the following lease management control channel commands:
  553. lease6-add, lease6-update, and lease6-del. Each entry is a single string
  554. with no embedded end-of-line markers and they will typically have the following
  555. forms:
  556. </para>
  557. <para>
  558. <command>lease6-add:</command>
  559. <screen>
  560. Administrator added a lease of address: *address* to a device with DUID: *DUID*
  561. </screen>
  562. Dependent on the arguments of the add command, it may also include the hardware address and duration.
  563. </para>
  564. <para>
  565. Example:
  566. <screen>
  567. Administrator added a lease of address: 2001:db8::3 to a device with DUID: 1a:1b:1c:1d:1e:1f:20:21:22:23:24 for 1 days 0 hrs 0 mins 0 secs
  568. </screen>
  569. </para>
  570. <para>
  571. <command>lease6-update:</command>
  572. <screen>
  573. Administrator updated information on the lease of address: *address* to a device with DUID: *DUID*
  574. </screen>
  575. Dependent on the arguments of the update command, it may also include the hardware address and lease duration.
  576. </para>
  577. <para>
  578. Example:
  579. <screen>
  580. Administrator updated information on the lease of address: 2001:db8::3 to a device with DUID: 1a:1b:1c:1d:1e:1f:20:21:22:23:24, hardware address: 1a:1b:1c:1d:1e:1f
  581. </screen>
  582. </para>
  583. <para>
  584. <command>lease6-del:</command>
  585. Deletes have two forms, one by address and one by identifier and identifier type:
  586. <screen>
  587. Administrator deleted the lease for address: *address*
  588. </screen>
  589. or
  590. <screen>
  591. Administrator deleted a lease for a device identified by: *identifier-type* of *identifier*
  592. </screen>
  593. Currently only a type of DUID is supported.
  594. </para>
  595. <para>
  596. Examples:
  597. <screen>
  598. Administrator deleted the lease for address: 2001:db8::3
  599. Administrator deleted a lease for a device identified by: duid of 1a:1b:1c:1d:1e:1f:20:21:22:23:24
  600. </screen>
  601. </para>
  602. </section>
  603. <section id="forensic-log-configuration">
  604. <title>Configuring the Forensic Log Hooks</title>
  605. <para>
  606. To use this functionality the hook library must be included in the
  607. configuration of the desired DHCP server modules. The legal_log
  608. library is installed alongside the Kea libraries in
  609. <filename>[kea-install-dir]/lib</filename> where
  610. <filename>kea-install-dir</filename> is determined by the
  611. &quot;--prefix&quot; option of the configure script. It defaults to
  612. <filename>/usr/local</filename>. Assuming the
  613. default value then, configuring kea-dhcp4 to load the legal_log
  614. library could be done with the following Kea4 configuration:
  615. <screen>
  616. "Dhcp4": { <userinput>
  617. "hooks-libraries": [
  618. {
  619. "library": "/usr/local/lib/libdhcp_legal_log.so",
  620. "parameters": {
  621. "path": "/var/kea/var",
  622. "base-name": "kea-forensic4"
  623. }
  624. },
  625. ...
  626. ] </userinput>
  627. }
  628. </screen>
  629. </para>
  630. <para>
  631. To configure it for kea-dhcp6, the commands are simply as shown below:
  632. <screen>
  633. "Dhcp6": { <userinput>
  634. "hooks-libraries": [
  635. {
  636. "library": "/usr/local/lib/libdhcp_legal_log.so",
  637. "parameters": {
  638. "path": "/var/kea/var",
  639. "base-name": "kea-forensic6"
  640. }
  641. },
  642. ...
  643. ] </userinput>
  644. }
  645. </screen>
  646. </para>
  647. <para>
  648. Two Hook Library parameters are supported:
  649. <itemizedlist>
  650. <listitem><para>
  651. path - the directory in which the forensic file(s) will be written. The
  652. default value is
  653. <filename>[prefix]/kea/var</filename>. The directory must exist.
  654. </para></listitem>
  655. <listitem><para>
  656. base-name - an arbitrary value which is used in conjunction with
  657. the current system date to form the current forensic file name. It defaults
  658. to <filename>kea-legal</filename>.
  659. </para></listitem>
  660. </itemizedlist>
  661. </para>
  662. </section>
  663. </section>
  664. <section id="flex-id">
  665. <title>flex_id: Flexible Identifiers for Host Reservations</title>
  666. <para>
  667. This section describes a hook application dedicated to generate
  668. flexible identifiers for host reservation. Kea software provides a way
  669. to handle host reservations that include addresses, prefixes, options,
  670. client classes and other features. The reservation can be based on
  671. hardware address, DUID, circuit-id or client-id in DHCPv4 and using
  672. hardware address or DUID in DHCPv6. However, there are sometimes
  673. scenarios where the reservation is more complex, e.g. uses other
  674. options that mentioned above, uses part of specific options or perhaps
  675. even a combination of several options and fields to uniquely identify
  676. a client. Those scenarios are addressed by the Flexible Identifiers
  677. hook application.</para>
  678. <para>Currently this library is only available to ISC customers with a
  679. support contract.</para>
  680. <para>The library allows for defining an expression, using notation
  681. initially used for client classification only. See <xref
  682. linkend="classification-using-expressions" /> for detailed description
  683. of the syntax available. One notable difference is that for client
  684. classification the expression currently has to evaluate to either true
  685. or false, while the flexible identifier expression is expected to
  686. evaluate to a string that will be used as identifier. It is a valid case
  687. for the expression to evaluate to empty string (e.g. in cases where a
  688. client does not sent specific options). This expression is then
  689. evaluated for each incoming packet. This evaluation generates an
  690. identifier that is used to identify the client. In particular, there may
  691. be host reservations that are tied to specific values of the flexible
  692. identifier.</para>
  693. <para>
  694. The library can be loaded in similar way as other hook libraries. It
  695. takes a mandatory parameter identifier-expression and optional
  696. boolean parameter replace-client-id:
  697. <screen>
  698. "Dhcp6": { <userinput>
  699. "hooks-libraries": [
  700. {
  701. "library": "/path/libdhcp_flex_id.so",
  702. "parameters": {
  703. "identifier-expression": "<userinput>expression</userinput>",
  704. "replace-client-id": "<userinput>false</userinput>"
  705. }
  706. },
  707. ...
  708. ] </userinput>
  709. }
  710. </screen>
  711. </para>
  712. <para>
  713. The flexible identifier library supports both DHCPv4 and DHCPv6.
  714. </para>
  715. <para>
  716. EXAMPLE: Let's consider a case of an IPv6 network that has an
  717. independent interface for each of the connected customers. Customers
  718. are able to plug in whatever device they want, so any type of
  719. identifier (e.g. a client-id) is unreliable. Therefore the operator
  720. may decide to use an option inserted by a relay agent to differentiate
  721. between clients. In this particular deployment, the operator verified
  722. that the interface-id is unique for each customer facing
  723. interface. Therefore it is suitable for usage as reservation. However,
  724. only the first 6 bytes of the interface-id are interesting, because
  725. remaining bytes are either randomly changed or not unique between
  726. devices. Therefore the customer decided to use first 6 bytes of the
  727. interface-id option inserted by the relay agent. After adding "flex-id"
  728. host-reservation-identifiers goal can be achieved by using the
  729. following configuration:
  730. <screen>
  731. "Dhcp6": {
  732. "subnet6": [{ ..., // subnet definition starts here
  733. "reservations": [
  734. <userinput>"flex-id": "'port1234'"</userinput>, // value of the first 8 bytes of the interface-id
  735. "ip-addresses": [ "2001:db8::1" ]
  736. ],
  737. }], // end of subnet definitions
  738. "host-reservation-identifiers": ["duid", "flex-id"], // add "flex-id" to reservation identifiers
  739. "hooks-libraries": [
  740. {
  741. "library": "/path/libdhcp_flex_id.so",
  742. "parameters": {
  743. "identifier-expression": "<userinput>substring(relay6[0].option[18].hex,0,8)</userinput>"
  744. }
  745. },
  746. ...
  747. ]
  748. }
  749. </screen>
  750. </para>
  751. <para>
  752. NOTE: Care should be taken when adjusting the expression. If the
  753. expression changes, then all the flex-id values may change, possibly
  754. rendering all reservations based on flex-id unusable until they're
  755. manually updated. Therefore it is strongly recommended to start with
  756. the expression and a handful reservations, adjust the expression as
  757. needed and only after it was confirmed the expression does exactly
  758. what is expected out of it go forward with host reservations on any
  759. broader scale.
  760. </para>
  761. <para>
  762. flex-id values in host reservations can be specified in two
  763. ways. First, they can be expressed as hex string, e.g. bar string
  764. can be represented as 626174. Alternatively, it can be expressed
  765. as quoted value (using double and single quotes), e.g. "'bar'".
  766. The former is more convenient for printable characters, while hex
  767. string values are more convenient for non-printable characters.
  768. </para>
  769. <screen>
  770. "Dhcp6": {
  771. "subnet6": [{ ..., // subnet definition starts here
  772. "reservations": [
  773. <userinput>"flex-id": "01:02:03:04:05:06"</userinput>, // value of the first 8 bytes of the interface-id
  774. "ip-addresses": [ "2001:db8::1" ]
  775. ],
  776. }], // end of subnet definitions
  777. "host-reservation-identifiers": ["duid", "flex-id"], // add "flex-id" to reservation identifiers
  778. "hooks-libraries": [
  779. {
  780. "library": "/path/libdhcp_flex_id.so",
  781. "parameters": {
  782. "identifier-expression": "<userinput>vendor[4491].option[1026].hex</userinput>"
  783. }
  784. },
  785. ...
  786. ]
  787. }
  788. </screen>
  789. <para>
  790. When "replace-client-id" is set to false (which is the default setting),
  791. the flex-id hook library uses evaluated flexible identifier solely for
  792. identifying host reservations, i.e. searching for reservations within a
  793. database. This is a functional equivalent of other identifiers,
  794. similar to hardware address or circuit-id. However,
  795. this mode of operation has an implication that if a client device is
  796. replaced, it may cause a conflict between an existing lease (allocated
  797. for old device) and the new lease being allocated for the new device. The
  798. conflict arises because the same flexible identifier is computed for the
  799. replaced device and the server will try to allocate the same lease. The
  800. mismatch between client identifiers sent by new device and old device causes
  801. the server to refuse this new allocation until the old lease expires.
  802. A manifestation of this problem is dependant on specific expression
  803. used as flexible identifier and is likely to appear if you only use options
  804. and other parameters that are identifying where the device is
  805. connected (e.g. circuit-id), rather than the device identification
  806. itself (e.g. MAC address).
  807. </para>
  808. <para>
  809. The flex-id library offers a way to overcome the problem with lease conflicts
  810. by dynamically replacing client identifier (or DUID in DHCPv6 case) with a
  811. value derived from flexible identifier. The server processes the client's
  812. query as if flexible identifier was sent in the client identifier (or DUID)
  813. option. This guarantees that returning client (for which the same flexible
  814. identifier is evaluated) will be assigned the same lease despite the client
  815. identifier and/or MAC address change.
  816. </para>
  817. <para>
  818. The following is a stub configuration that enables this behavior:
  819. <screen>
  820. "Dhcp4": { <userinput>
  821. "hooks-libraries": [
  822. {
  823. "library": "/path/libdhcp_flex_id.so",
  824. "parameters": {
  825. "identifier-expression": "<userinput>expression</userinput>",
  826. "replace-client-id": "<userinput>true</userinput>"
  827. }
  828. },
  829. ...
  830. ] </userinput>
  831. }
  832. </screen>
  833. </para>
  834. <para>
  835. In the DHCPv4 case, the value derived from the flexible identifier is formed
  836. by prepending 1 byte with a value of zero to flexible identifier. In the IPv6
  837. case, it is formed by prepanding two zero bytes before the flexible identifier.
  838. </para>
  839. <para>
  840. Note that for this mechanism to take effect, the DHCPv4 server must be configured
  841. to respect the client identifier option value during lease allocation, i.e.
  842. "match-client-id" must be set to true. See
  843. <xref linkend="dhcp4-match-client-id"/> for details. No additional settings
  844. are required for DHCPv6.
  845. </para>
  846. <para>
  847. If "replace-client-id" option is set to true, the value of "echo-client-id"
  848. parameter (that governs whether to send back a client-id option or
  849. not) is ignored.
  850. </para>
  851. <para>
  852. The <xref linkend="lease-cmds"/> section describes commands used to retrieve,
  853. update and delete leases using various identifiers, e.g. "hw-address",
  854. "client-id". The lease_cmds library doesn't natively support querying for
  855. leases by flexible identifier. However, when "replace-client-id" is set to
  856. true, it makes it possible to query for leases using a value derived from
  857. the flexible identifier. In the DHCPv4 case, the query will look similar to this:
  858. <screen>
  859. {
  860. "command": "lease4-get",
  861. "arguments": {
  862. "identifier-type": "client-id",
  863. "identifier": "00:<userinput>54:64:45:66</userinput>",
  864. "subnet-id": 44
  865. }
  866. }
  867. </screen>
  868. where hexadecimal value of "54:64:45:66" is a flexible identifier computed
  869. for the client.
  870. </para>
  871. <para>
  872. In the DHCPv6 case, the corresponding query will look similar to this:
  873. <screen>
  874. {
  875. "command": "lease6-get",
  876. "arguments": {
  877. "identifier-type": "duid",
  878. "identifier": "00:00:<userinput>54:64:45:66</userinput>",
  879. "subnet-id": 10
  880. }
  881. }</screen>
  882. </para>
  883. </section>
  884. <section id="host-cmds">
  885. <title>host_cmds: Host Commands</title>
  886. <para>
  887. This section describes a hook application that offers a number of new
  888. commands used to query and manipulate host reservations. Kea provides
  889. a way to store host reservations in a database. In many larger
  890. deployments it is useful to be able to manage that information while
  891. the server is running. This library provides management commands for
  892. adding, querying and deleting host reservations in a safe way without
  893. restarting the server. In particular, it validates the parameters, so
  894. an attempt to insert incorrect data e.g. add a host with conflicting
  895. identifier in the same subnet will be rejected. Those commands are
  896. exposed via command channel (JSON over unix sockets) and Control Agent
  897. (JSON over RESTful interface). Additional commands and capabilities
  898. related to host reservations will be added in the future.
  899. </para>
  900. <para>Currently this library is only available to ISC customers with a
  901. support contract.</para>
  902. <para>
  903. Currently three commands are supported: reservation-add (which adds
  904. new host reservation), reservation-get (which returns existing
  905. reservation if specified criteria are matched) and reservation-del
  906. (which attempts to delete a reservation matching specified
  907. criteria). To use commands that change the reservation information
  908. (currently these are reservation-add and reservation-del, but this
  909. rule applies to other commands that may be implemented in the future),
  910. hosts database must be specified (see hosts-database description in
  911. <xref linkend="hosts-database-configuration4"/> and <xref
  912. linkend="hosts-database-configuration6"/>) and it must not operate in
  913. read-only mode. If the hosts-database is not specified or is running
  914. in read-only mode, the host_cmds library will load, but any attempts
  915. to use reservation-add or reservation-del will fail.
  916. </para>
  917. <para>
  918. Additional host reservation commands are planned in the future. For
  919. a description of envisaged commands, see
  920. <ulink url="http://kea.isc.org/wiki/ControlAPIRequirements">Control API
  921. Requirements </ulink> document.</para>
  922. <para>
  923. All commands are using JSON syntax. They can be issued either using
  924. control channel (see <xref linkend="ctrl-channel"/>) or via Control
  925. Agent (see <xref linkend="kea-ctrl-agent"/>).
  926. </para>
  927. <para>
  928. The library can be loaded in similar way as other hook libraries. It
  929. does not take any parameters. It supports both DHCPv4 and DHCPv6
  930. servers.
  931. <screen>
  932. "Dhcp6": { <userinput>
  933. "hooks-libraries": [
  934. {
  935. "library": "/path/libdhcp_host_cmds.so"
  936. }
  937. ...
  938. ] </userinput>
  939. }
  940. </screen>
  941. </para>
  942. <section>
  943. <title>reservation-add command</title>
  944. <para>
  945. <command>reservation-add</command> allows for the insertion of a new host. It
  946. takes a set of arguments that vary depending on the nature of the host
  947. reservation. Any parameters allowed in the configuration file that
  948. pertain to host reservation are permitted here. For details regarding
  949. IPv4 reservations, see <xref linkend="host-reservation-v4"/> and <xref
  950. linkend="host-reservation-v6"/>. There is one notable addition. A
  951. <command>subnet-id</command> must be specified. This parameter is
  952. mandatory, because reservations specified in the configuration file
  953. are always defined within a subnet, so the subnet they belong to is
  954. clear. This is not the case with reservation-add, therefore the
  955. subnet-id must be specified explicitly. An example command can be as
  956. simple as:
  957. <screen>{
  958. "command": "reservation-add",
  959. "arguments": {
  960. <userinput>"reservation": {
  961. "subnet-id": 1,
  962. "hw-address": "1a:1b:1c:1d:1e:1f",
  963. "ip-address": "192.0.2.202"
  964. }</userinput>
  965. }
  966. }</screen> but can also take many more parameters, for example:
  967. <screen>
  968. {
  969. "command": "reservation-add",
  970. "arguments": {
  971. <userinput>"reservation":
  972. {
  973. "subnet-id":1,
  974. "client-id": "01:0a:0b:0c:0d:0e:0f",
  975. "ip-address": "192.0.2.205",
  976. "next-server": "192.0.2.1",
  977. "server-hostname": "hal9000",
  978. "boot-file-name": "/dev/null",
  979. "option-data": [
  980. {
  981. "name": "domain-name-servers",
  982. "data": "10.1.1.202,10.1.1.203"
  983. }
  984. ],
  985. "client-classes": [ "special_snowflake", "office" ]
  986. }</userinput>
  987. }
  988. }</screen>
  989. Here is an example of complex IPv6 reservation:
  990. <screen>
  991. {
  992. "command": "reservation-add",
  993. "arguments": {
  994. <userinput>"reservation":
  995. {
  996. "subnet-id":1,
  997. "duid": "01:02:03:04:05:06:07:08:09:0A",
  998. "ip-addresses": [ "2001:db8:1:cafe::1" ],
  999. "prefixes": [ "2001:db8:2:abcd::/64" ],
  1000. "hostname": "foo.example.com",
  1001. "option-data": [
  1002. {
  1003. "name": "vendor-opts",
  1004. "data": "4491"
  1005. },
  1006. {
  1007. "name": "tftp-servers",
  1008. "space": "vendor-4491",
  1009. "data": "3000:1::234"
  1010. }
  1011. ]
  1012. }</userinput>
  1013. }
  1014. }</screen>
  1015. </para>
  1016. <para>
  1017. The command returns a status that indicates either a success (result
  1018. 0) or a failure (result 1). Failed command always includes text
  1019. parameter that explains the cause of failure. Example results:
  1020. <screen>{ "result": 0, "text": "Host added." }</screen> Example failure:
  1021. <screen>{ "result": 1, "text": "Mandatory 'subnet-id' parameter missing." }</screen>
  1022. </para>
  1023. <para>
  1024. As <command>reservation-add</command> is expected to store the host,
  1025. hosts-database parameter must be specified in your configuration and
  1026. the database must not run in read-only mode. In the future versions
  1027. it will be possible to modify the reservations read from a
  1028. configuration file. Please contact ISC if you are interested in this
  1029. functionality.
  1030. </para>
  1031. </section>
  1032. <section>
  1033. <title>reservation-get command</title>
  1034. <para><command>reservation-get</command> can be used to query the host
  1035. database and retrieve existing reservations. There are two types of
  1036. parameters this command supports: (subnet-id, address) or (subnet-id,
  1037. identifier-type, identifier). The first type of query is used when the
  1038. address (either IPv4 or IPv6) is known, but the details of the
  1039. reservation aren't. One common use case of this type of query is to
  1040. find out whether a given address is reserved or not. The second query
  1041. uses identifiers. For maximum flexibility, Kea stores the host
  1042. identifying information as a pair of values: type and the actual
  1043. identifier. Currently supported identifiers are "hw-address", "duid",
  1044. "circuit-id", "client-id" and "flex-id", but additional types may be
  1045. added in the future. If any new identifier types are defined in the
  1046. future, reservation-get command will support them
  1047. automatically.</para>
  1048. <para>
  1049. An example command for getting a host reservation by (subnet-id,
  1050. address) pair looks as follows:
  1051. <screen>
  1052. {
  1053. "command": "reservation-get",
  1054. "arguments": {
  1055. "subnet-id": 1,
  1056. "ip-address": "192.0.2.202"
  1057. }
  1058. }</screen>
  1059. An example query by (subnet-id, identifier-type, identifier) looks as follows:
  1060. <screen>
  1061. {
  1062. "command": "reservation-get",
  1063. "arguments":
  1064. "subnet-id": 4,
  1065. "identifier-type": "hw-address",
  1066. "identifier": "01:02:03:04:05:06"
  1067. }
  1068. }</screen>
  1069. </para>
  1070. <para><command>reservation-get</command> typically returns result 0
  1071. when the query was conducted properly. In particular, 0 is returned
  1072. when the host was not found. If the query was successful a number
  1073. of host parameters will be returned. An example of a query that
  1074. did not find the host looks as follows:
  1075. <screen>{ "result": 0, "text": "Host not found." }</screen>
  1076. An example result returned when the host was found:
  1077. <screen>{
  1078. "arguments": {
  1079. "boot-file-name": "bootfile.efi",
  1080. "client-classes": [
  1081. ],
  1082. "hostname": "somehost.example.org",
  1083. "hw-address": "01:02:03:04:05:06",
  1084. "ip-address": "192.0.2.100",
  1085. "next-server": "192.0.0.2",
  1086. "option-data": [
  1087. ],
  1088. "server-hostname": "server-hostname.example.org"
  1089. },
  1090. "result": 0,
  1091. "text": "Host found."
  1092. }</screen>
  1093. An example result returned when the query was malformed:<screen>
  1094. { "result": 1, "text": "No 'ip-address' provided and 'identifier-type'
  1095. is either missing or not a string." }</screen>
  1096. </para>
  1097. </section>
  1098. <section>
  1099. <title>reservation-del command</title>
  1100. <para><command>reservation-del</command> can be used to delete a
  1101. reservation from the host database. There are two types of parameters
  1102. this command supports: (subnet-id, address) or (subnet-id,
  1103. identifier-type, identifier). The first type of query is used when the
  1104. address (either IPv4 or IPv6) is known, but the details of the
  1105. reservation aren't. One common use case of this type of query is to
  1106. remove a reservation (e.g. you want a specific address to no longer be
  1107. reserved). The second query uses identifiers. For maximum flexibility,
  1108. Kea stores the host identifying information as a pair of values: type
  1109. and the actual identifier. Currently supported identifiers are
  1110. "hw-address", "duid", "circuit-id", "client-id" and "flex-id", but
  1111. additional types may be added in the future. If any new identifier
  1112. types are defined in the future, reservation-get command will support
  1113. them automatically.</para>
  1114. <para>
  1115. An example command for deleting a host reservation by (subnet-id,
  1116. address) pair looks as follows:
  1117. <screen>
  1118. {
  1119. "command": "reservation-del",
  1120. "arguments": {
  1121. "subnet-id": 1,
  1122. "ip-address": "192.0.2.202"
  1123. }
  1124. }</screen>
  1125. An example deletion by (subnet-id, identifier-type, identifier) looks as follows:
  1126. <screen>
  1127. {
  1128. "command": "reservation-del",
  1129. "arguments":
  1130. "subnet-id": 4,
  1131. "identifier-type": "hw-address",
  1132. "identifier": "01:02:03:04:05:06"
  1133. }
  1134. }</screen>
  1135. </para>
  1136. <para>
  1137. <command>reservation-del</command> returns result 0 when the host
  1138. deletion was successful or 1 if it was not. A descriptive text is
  1139. provided in case of error. Example results look as follows:
  1140. <screen>
  1141. {
  1142. "result": 1,
  1143. "text": "Host not deleted (not found)."
  1144. }</screen>
  1145. <screen>
  1146. {
  1147. "result": 0,
  1148. "text": "Host deleted."
  1149. }</screen>
  1150. <screen>
  1151. {
  1152. "result": 1,
  1153. "text": "Unable to delete a host because there is no hosts-database
  1154. configured."
  1155. }</screen>
  1156. </para>
  1157. </section>
  1158. </section>
  1159. <!-- ================================================================= -->
  1160. <!-- === lease_cmds ================================================== -->
  1161. <!-- ================================================================= -->
  1162. <section id="lease-cmds">
  1163. <title>lease_cmds: Lease Commands</title>
  1164. <para>
  1165. This section describes the hook library that offers a number of new
  1166. commands used to manage leases. Kea provides a way to store lease
  1167. information in several backends (memfile, MySQL, PostgreSQL and
  1168. Cassandra). This library provides a unified interface that can
  1169. manipulate leases in an unified, safe way. In particular, it allows
  1170. things previously impossible: manipulate leases in memfile while Kea
  1171. is running, sanity check changes, check lease existence and remove all
  1172. leases belonging to specific subnet. It can also catch more obscure
  1173. errors, like adding a lease with subnet-id that does not exist in the
  1174. configuration or configuring a lease to use an address that is outside
  1175. of the subnet to which it is supposed to belong.
  1176. </para>
  1177. <para>There are many use cases when an administrative command may be
  1178. useful: during migration between servers (possibly even between
  1179. different vendors), when a certain network is being retired, when a
  1180. device has been disconnected and the sysadmin knows for sure that it
  1181. will not be coming back. The "get" queries may be useful for automating
  1182. certain management and monitoring tasks. They can also act as
  1183. preparatory steps for lease updates and removals.</para>
  1184. <para>
  1185. This library provides the following commands:
  1186. <itemizedlist>
  1187. <listitem>
  1188. <para><command>lease4-add</command> - adds new IPv4 lease;</para>
  1189. </listitem>
  1190. <listitem>
  1191. <para><command>lease6-add</command> - adds new IPv6 lease;</para>
  1192. </listitem>
  1193. <listitem>
  1194. <para><command>lease4-get</command> - checks if an IPv4 lease with
  1195. the specified parameters exists and returns it if it does;</para>
  1196. </listitem>
  1197. <listitem>
  1198. <para><command>lease6-get</command> - checks if an IPv6 lease with
  1199. the specified parameters exists and returns it if it does;</para>
  1200. </listitem>
  1201. <listitem>
  1202. <para><command>lease4-del</command> - attempts to delete an IPv4
  1203. lease with the specified parameters;</para>
  1204. </listitem>
  1205. <listitem>
  1206. <para><command>lease6-del</command> - attempts to delete an IPv6
  1207. lease with the specified parameters;</para>
  1208. </listitem>
  1209. <listitem>
  1210. <para><command>lease4-update</command> - updates an IPv4 lease;</para>
  1211. </listitem>
  1212. <listitem>
  1213. <para><command>lease6-update</command> - updates an IPv6 lease;</para>
  1214. </listitem>
  1215. <listitem>
  1216. <para><command>lease4-wipe</command> - removes all leases from a
  1217. specific IPv4 subnet;</para>
  1218. </listitem>
  1219. <listitem>
  1220. <para><command>lease6-wipe</command> - removes all leases from a
  1221. specific IPv6 subnet;</para>
  1222. </listitem>
  1223. </itemizedlist>
  1224. </para>
  1225. <para>Lease commands library is part of the open source code and is
  1226. available to every Kea user.</para>
  1227. <para>
  1228. All commands are using JSON syntax. They can be issued either using
  1229. control channel (see <xref linkend="ctrl-channel"/>) or via Control
  1230. Agent (see <xref linkend="kea-ctrl-agent"/>).
  1231. </para>
  1232. <para>
  1233. The library can be loaded in the same way as other hook libraries. It
  1234. does not take any parameters. It supports both DHCPv4 and DHCPv6
  1235. servers.
  1236. <screen>
  1237. "Dhcp6": { <userinput>
  1238. "hooks-libraries": [
  1239. {
  1240. "library": "/path/libdhcp_lease_cmds.so"
  1241. }
  1242. ...
  1243. ] </userinput>
  1244. }
  1245. </screen>
  1246. </para>
  1247. <section>
  1248. <title>lease4-add, lease6-add commands</title>
  1249. <para>
  1250. <command>lease4-add</command> and <command>lease6-add</command>
  1251. commands allow for the creation of a new lease. Typically Kea creates a lease
  1252. on its own, when it first sees a new device. However, sometimes it may
  1253. be convenient to create the lease administratively. The
  1254. <command>lease4-add</command> command requires at least three
  1255. parameters: an IPv4 address, a subnet-id and an identifier: hardware
  1256. (MAC) address. The simplest successful call might look as follows:
  1257. <screen>
  1258. {
  1259. "command": "lease4-add",
  1260. "arguments": {
  1261. "subnet-id": 44,
  1262. "ip-address": "192.0.2.202",
  1263. "hw-address": "1a:1b:1c:1d:1e:1f"
  1264. }
  1265. }
  1266. </screen>
  1267. </para>
  1268. <para><command>lease6-add</command> command requires four
  1269. parameters: an IPv6 address, a subnet-id, and IAID value
  1270. (identity association identifier, a value sent by clients) and
  1271. a DUID:
  1272. <screen>
  1273. {
  1274. "command": "lease6-add",
  1275. "arguments": {
  1276. "subnet-id": 66,
  1277. "ip-address": "2001:db8::3",
  1278. "duid": "1a:1b:1c:1d:1e:1f:20:21:22:23:24",
  1279. "iaid": 1234
  1280. }
  1281. }</screen>
  1282. <command>lease6-add</command> can be also used to add leases for IPv6
  1283. prefixes. In this case there are two parameters that must be
  1284. specified: type (set to value of &quot;IA_PD&quot;) and a prefix
  1285. length. The actual prefix is set using ip-address field. For example,
  1286. to configure a lease for prefix 2001:db8:abcd::/48, the following
  1287. command can be used:
  1288. <screen>
  1289. {
  1290. "command": "lease6-add",
  1291. "arguments": {
  1292. "subnet-id": 66,
  1293. "type": "IA_PD",
  1294. "ip-address": "2001:db8:abcd::",
  1295. "prefix-len": 48,
  1296. "duid": "1a:1b:1c:1d:1e:1f:20:21:22:23:24",
  1297. "iaid": 1234
  1298. }
  1299. }</screen>
  1300. The commands can take a number of additional optional parameters:
  1301. <itemizedlist>
  1302. <listitem>
  1303. <para><command>valid-lft</command> - specifies the lifetime of the
  1304. lease, expressed in seconds. If not specified, the value
  1305. configured in the subnet related to specified subnet-id is
  1306. used.</para>
  1307. </listitem>
  1308. <listitem>
  1309. <para><command>expire</command> - timestamp of the lease
  1310. expiration time, expressed in unix format (seconds since 1 Jan
  1311. 1970). If not specified, the default value is now + valid
  1312. lifetime.</para>
  1313. </listitem>
  1314. <listitem>
  1315. <para><command>fqdn-fwd</command> - specifies whether the lease
  1316. should be marked as if forward DNS update was conducted. Note this
  1317. only affects the lease parameter and the actual DNS update will
  1318. not be conducted at the lease insertion time. If configured, a DNS
  1319. update to remove the A or AAAA records will be conducted when the
  1320. lease is removed due to expiration or being released by a
  1321. client. If not specified, the default value is false. Hostname
  1322. parameter must be specified in fqdn-fwd is set to true.</para>
  1323. </listitem>
  1324. <listitem>
  1325. <para><command>fqdn-rev</command> - specifies whether the lease
  1326. should be marked as if reverse DNS update was conducted. Note this
  1327. only affects the lease parameter and the actual DNS update will
  1328. not be conducted at the lease insertion time. If configured, a DNS
  1329. update to remove the PTR record will be conducted when the lease
  1330. is removed due to expiration or being released by a client. If not
  1331. specified, the default value is false. Hostname parameter must be
  1332. specified in fqdn-fwd is set to true.</para>
  1333. </listitem>
  1334. <listitem>
  1335. <para><command>hostname</command> - specifies the hostname to be
  1336. associated with this lease. Its value must be non-empty if either
  1337. fqdn-fwd or fwdn-rev are set to true. If not specified, the
  1338. default value is an empty string.</para>
  1339. </listitem>
  1340. <listitem>
  1341. <para><command>hw-address</command> - hardware (MAC) address can
  1342. be optionally specified for IPv6 lease. It is mandatory parameter
  1343. for IPv4 lease.</para>
  1344. </listitem>
  1345. <listitem>
  1346. <para><command>client-id</command> - client identifier is an
  1347. optional parameter that can be specified for IPv4 lease.</para>
  1348. </listitem>
  1349. <listitem>
  1350. <para><command>preferred-lft</command> - Preferred lifetime is an
  1351. optional parameter for IPv6 leases. If not specified, the value
  1352. configured for the subnet corresponding to the specified subnet-id
  1353. is used. This parameter is not used in IPv4.</para>
  1354. </listitem>
  1355. </itemizedlist>
  1356. </para>
  1357. <para>Here's an example of more complex lease addition:
  1358. <screen>
  1359. {
  1360. "command": "lease6-add",
  1361. "arguments": {
  1362. "subnet-id": 66,
  1363. "ip-address": "2001:db8::3",
  1364. "duid": "01:02:03:04:05:06:07:08",
  1365. "iaid": 1234,
  1366. "hw-address": "1a:1b:1c:1d:1e:1f",
  1367. "preferred-lft": 500,
  1368. "valid-lft": 1000,
  1369. "expire": 12345678,
  1370. "fqdn-fwd": true,
  1371. "fqdn-rev": true,
  1372. "hostname": "urania.example.org"
  1373. }
  1374. }
  1375. </screen>
  1376. </para>
  1377. <para>
  1378. The command returns a status that indicates either a success (result
  1379. 0) or a failure (result 1). Failed command always includes text
  1380. parameter that explains the cause of failure. Example results:
  1381. <screen>{ "result": 0, "text": "Lease added." }</screen> Example failure:
  1382. <screen>{ "result": 1, "text": "missing parameter 'ip-address' (&lt;string&gt;:3:19)" }</screen>
  1383. </para>
  1384. <section>
  1385. <title>lease4-get, lease6-get commands</title>
  1386. <para><command>lease4-get</command> or <command>lease6-get</command>
  1387. can be used to query the lease database and retrieve existing
  1388. leases. There are two types of parameters the
  1389. <command>lease4-get</command> supports: (address) or (subnet-id,
  1390. identifier-type, identifier). There are two types for
  1391. <command>lease6-get</command>: (address,type) or (subnet-id,
  1392. identifier-type, identifier, IAID, type). The first type of query is
  1393. used when the address (either IPv4 or IPv6) is known, but the details
  1394. of the lease aren't. One common use case of this type of query is to
  1395. find out whether a given address is being used or not. The second
  1396. query uses identifiers. Currently supported identifiers for leases are:
  1397. "hw-address" (IPv4 only), "client-id" (IPv4 only) and "duid" (IPv6 only).
  1398. </para>
  1399. <para>
  1400. An example <command>lease4-get</command> command for getting a lease
  1401. by an IPv4 address looks as follows:
  1402. <screen>
  1403. {
  1404. "command": "lease4-get",
  1405. "arguments": {
  1406. "ip-address": "192.0.2.1"
  1407. }
  1408. }
  1409. </screen>
  1410. </para>
  1411. <para>An example of the <command>lease6-get</command> query
  1412. looks as follows:
  1413. <screen>
  1414. {
  1415. "command": "lease6-get",
  1416. "arguments": {
  1417. "ip-address": "2001:db8:1234:ab::",
  1418. "type": "IA_PD"
  1419. }
  1420. }</screen>
  1421. </para>
  1422. <para>An example query by "hw-address" for IPv4 lease looks
  1423. as follows:
  1424. <screen>
  1425. {
  1426. "command": "lease4-get",
  1427. "arguments": {
  1428. "identifier-type": "hw-address",
  1429. "identifier": "08:08:08:08:08:08",
  1430. "subnet-id": 44
  1431. }
  1432. }</screen>
  1433. </para>
  1434. <para>An example query by "client-id" for IPv4 lease looks
  1435. as follows:
  1436. <screen>
  1437. {
  1438. "command": "lease4-get",
  1439. "arguments": {
  1440. "identifier-type": "client-id",
  1441. "identifier": "01:01:02:03:04:05:06",
  1442. "subnet-id": 44
  1443. }
  1444. }</screen>
  1445. </para>
  1446. <para>An example query by (subnet-id, identifier-type,
  1447. identifier, iaid, type) for IPv6 lease looks as follows:
  1448. <screen>
  1449. {
  1450. "command": "lease4-get",
  1451. "arguments": {
  1452. "identifier-type": "duid",
  1453. "identifier": "08:08:08:08:08:08",
  1454. "iaid": 1234567,
  1455. "type": "IA_NA",
  1456. "subnet-id": 44
  1457. }
  1458. }</screen>
  1459. The type is an optional parameter. Supported values are: IA_NA
  1460. (non-temporary address) and IA_PD (IPv6 prefix) are supported.
  1461. If not specified, IA_NA is assumed.
  1462. </para>
  1463. <para><command>leaseX-get</command> returns a result that indicates a
  1464. result of the operation and lease details, if found. It has one of the
  1465. following values: 0 (success), 1 (error) or 2 (empty). The empty
  1466. result means that a query has been completed properly, but the object
  1467. (a lease in this case) has not been found. The lease parameters, if
  1468. found, are returned as arguments.
  1469. </para>
  1470. <para>
  1471. An example result returned when the host was found:
  1472. <screen>{
  1473. "arguments": {
  1474. "client-id": "42:42:42:42:42:42:42:42",
  1475. "cltt": 12345678,
  1476. "fqdn-fwd": false,
  1477. "fqdn-rev": true,
  1478. "hostname": "myhost.example.com.",
  1479. "hw-address": "08:08:08:08:08:08",
  1480. "ip-address": "192.0.2.1",
  1481. "state": 0,
  1482. "subnet-id": 44,
  1483. "valid-lft": 3600
  1484. },
  1485. "result": 0,
  1486. "text": "IPv4 lease found."
  1487. }</screen>
  1488. </para>
  1489. </section>
  1490. <section>
  1491. <title>lease4-del, lease6-del commands</title>
  1492. <para><command>leaseX-del</command> can be used to delete a lease from
  1493. the lease database. There are two types of parameters this command
  1494. supports, similar to leaseX-get commands: (address) for both v4 and
  1495. v6, (subnet-id, identifier-type, identifier) for v4 and (subnet-id,
  1496. identifier-type, identifier, type, IAID) for v6. The first type of
  1497. query is used when the address (either IPv4 or IPv6) is known, but the
  1498. details of the lease are not. One common use case of this type of query
  1499. is to remove a lease (e.g. you want a specific address to no longer be
  1500. used, no matter who may use it). The second query uses
  1501. identifiers. For maximum flexibility, this interface uses identifiers
  1502. as a pair of values: type and the actual identifier. Currently
  1503. supported identifiers are "hw-address" (IPv4 only), "client-id"
  1504. (IPv4 only) and "duid" (IPv6 only), but additional types may be added
  1505. in the future. </para>
  1506. <para>
  1507. An example command for deleting a host reservation by address looks
  1508. as follows:
  1509. <screen>
  1510. {
  1511. "command": "lease4-del",
  1512. "arguments": {
  1513. "ip-address": "192.0.2.202"
  1514. }
  1515. }</screen>
  1516. An example IPv4 lease deletion by "hw-address" looks as follows:
  1517. <screen>{
  1518. "command": "lease4-del",
  1519. "arguments": {
  1520. "identifier": "08:08:08:08:08:08",
  1521. "identifier-type": "hw-address",
  1522. "subnet-id": 44
  1523. }
  1524. }</screen>
  1525. </para>
  1526. <para><command>leaseX-del</command> returns a result that
  1527. indicates a outcome of the operation. It has one of the
  1528. following values: 0 (success), 1 (error) or 3 (empty). The
  1529. empty result means that a query has been completed properly,
  1530. but the object (a lease in this case) has not been found.
  1531. </para>
  1532. </section>
  1533. <section>
  1534. <title>lease4-update, lease6-update commands</title>
  1535. <para><command>lease4-update</command> and
  1536. <command>lease6-update</command> commands can be used to update
  1537. existing leases. Since all lease database backends are indexed by IP
  1538. addresses, it is not possible to update an address. All other fields
  1539. may be updated. If an address needs to be changed, please use
  1540. <command>leaseX-del</command> followed by
  1541. <command>leaseX-add</command> commands.</para>
  1542. <para>To use <command>leaseX-update</command> the lease must
  1543. be present in the lease database. If the lease is not there,
  1544. an error will be returned. Please use
  1545. <command>leaseX-add</command> to add new leases. You may
  1546. check if a lease is present using
  1547. <command>leaseX-get</command>, if needed.</para>
  1548. <para>
  1549. An example command updating IPv4 lease looks as follows:
  1550. <screen>{
  1551. "command": "lease4-update",
  1552. "arguments": {
  1553. "ip-address": "192.0.2.1",
  1554. "hostname": "newhostname.example.org",
  1555. "hw-address": "1a:1b:1c:1d:1e:1f",
  1556. "subnet-id": 44
  1557. }
  1558. }</screen>
  1559. </para>
  1560. <para>
  1561. An example command updating IPv6 lease looks as follows:
  1562. <screen>{
  1563. "command": "lease6-update",
  1564. "arguments": {
  1565. "ip-address": "2001:db8::1",
  1566. "duid": "88:88:88:88:88:88:88:88",
  1567. "iaid": 7654321,
  1568. "hostname": "newhostname.example.org",
  1569. "subnet-id": 66
  1570. }
  1571. }</screen>
  1572. </para>
  1573. </section>
  1574. <section>
  1575. <title>lease4-wipe, lease6-wipe commands</title>
  1576. <para><command>lease4-wipe</command> and
  1577. <command>lease6-wipe</command> are designed to remove all
  1578. leases associated with a given subnet. This administrative
  1579. task is expected to be used when existing subnet is being
  1580. retired. Note that the leases are not properly expired,
  1581. there are no DNS updates conducted, no log messages and
  1582. hooks are not called for leases being removed.</para>
  1583. <para>An example of <command>lease4-wipe</command> looks as follows:
  1584. <screen>{
  1585. "command": "lease4-wipe",
  1586. "arguments": {
  1587. "subnet-id": 44
  1588. }
  1589. }</screen>
  1590. </para>
  1591. <para>An example of <command>lease6-wipe</command> looks as follows:
  1592. <screen>{
  1593. "command": "lease6-wipe",
  1594. "arguments": {
  1595. "subnet-id": 66
  1596. }
  1597. }</screen>
  1598. </para>
  1599. <para>The commands return a textual description of the
  1600. number of leases removed and 0 (success) status code if any
  1601. leases were removed and 2 (empty) if there were no
  1602. leases. Status code 1 (error) may be returned in case the
  1603. parameters are incorrect or some other exception is
  1604. encountered.</para>
  1605. <para>Note: not all backends support this command.</para>
  1606. </section>
  1607. </section>
  1608. </section>
  1609. <section id="subnet-cmds">
  1610. <title>subnet_cmds: Subnet Commands</title>
  1611. <para>
  1612. This section describes a hook application that offers a number of new
  1613. commands used to query and manipulate subnet and shared network
  1614. configurations in Kea. This application is very useful in deployments
  1615. with a large number of subnets being managed by the DHCP servers and
  1616. when the subnets are frequently updated. The commands offer
  1617. lightweight approach for manipulating subnets without a need to fully
  1618. reconfigure the server and without affecting existing servers'
  1619. configurations. An ability to manage shared networks (listing,
  1620. retrieving details, adding new ones, removing existing ones, adding
  1621. subnets to and removing from shared networks) is also provided.
  1622. </para>
  1623. <para>Currently this library is only available to ISC customers with a
  1624. support contract.</para>
  1625. <para>The following commands are currently supported:
  1626. <itemizedlist mark='bullet'>
  1627. <listitem>
  1628. <simpara><command>subnet4-list/subnet6-list</command>: lists all configured subnets
  1629. </simpara>
  1630. </listitem>
  1631. <listitem>
  1632. <simpara>
  1633. <command>subnet4-get/subnet6-get</command>: retrieves detailed information about a specified subnet
  1634. </simpara>
  1635. </listitem>
  1636. <listitem>
  1637. <simpara>
  1638. <command>subnet4-add/subnet6-add</command>: adds new subnet into server's configuration
  1639. </simpara>
  1640. </listitem>
  1641. <listitem>
  1642. <simpara>
  1643. <command>subnet4-del/subnet6-del</command>: removes a subnet from the server's configuration
  1644. </simpara>
  1645. </listitem>
  1646. <listitem>
  1647. <simpara>
  1648. <command>network4-list/network6-list</command>: lists all configured
  1649. shared networks
  1650. </simpara>
  1651. </listitem>
  1652. <listitem>
  1653. <simpara>
  1654. <command>network4-get/network6-get</command>: retrieves detailed
  1655. information about specified shared network
  1656. </simpara>
  1657. </listitem>
  1658. <listitem>
  1659. <simpara>
  1660. <command>network4-add/network6-add</command>: adds a new shared
  1661. network to the server's configuration
  1662. </simpara>
  1663. </listitem>
  1664. <listitem>
  1665. <simpara>
  1666. <command>network4-del/network6-del</command>: removes a shared
  1667. network from the server's configuration
  1668. </simpara>
  1669. </listitem>
  1670. <listitem>
  1671. <simpara>
  1672. <command>network4-subnet-add/network6-subnet-add</command>: adds
  1673. existing subnet to existing shared network
  1674. </simpara>
  1675. </listitem>
  1676. <listitem>
  1677. <simpara>
  1678. <command>network4-subnet-del/network6-subnet-del</command>: removes
  1679. a subnet from existing shared network and demotes it to a plain
  1680. subnet.
  1681. </simpara>
  1682. </listitem>
  1683. </itemizedlist>
  1684. </para>
  1685. <section>
  1686. <title>subnet4-list command</title>
  1687. <para>
  1688. This command is used to list all currently configured subnets. The
  1689. subnets are returned in a brief form, i.e. a subnet identifier
  1690. and subnet prefix is included for each subnet. In order to retrieve
  1691. the detailed information about the subnet the
  1692. <command>subnet4-get</command> should be used.
  1693. </para>
  1694. <para>
  1695. This command has the simple structure:
  1696. <screen>
  1697. {
  1698. "command": "subnet4-list"
  1699. }
  1700. </screen>
  1701. </para>
  1702. <para>
  1703. The list of subnets returned as a result of this command is returned
  1704. in the following format:
  1705. <screen>
  1706. {
  1707. "result": 0,
  1708. "text": "2 IPv4 subnets found",
  1709. "arguments": {
  1710. "subnets": [
  1711. {
  1712. "id": 10,
  1713. "subnet": "10.0.0.0/8"
  1714. },
  1715. {
  1716. "id": 100,
  1717. "subnet": "192.0.2.0/24"
  1718. }
  1719. ]
  1720. }
  1721. </screen>
  1722. </para>
  1723. <para>
  1724. If no IPv4 subnets are found, an error code is returned along with
  1725. the error description.
  1726. </para>
  1727. </section>
  1728. <section>
  1729. <title>subnet6-list command</title>
  1730. <para>
  1731. This command is used to list all currently configured subnets. The
  1732. subnets are returned in a brief form, i.e. a subnet identifier
  1733. and subnet prefix is included for each subnet. In order to retrieve
  1734. the detailed information about the subnet the
  1735. <command>subnet6-get</command> should be used.
  1736. </para>
  1737. <para>
  1738. This command has the simple structure:
  1739. <screen>
  1740. {
  1741. "command": "subnet6-list"
  1742. }
  1743. </screen>
  1744. </para>
  1745. <para>
  1746. The list of subnets returned as a result of this command is returned
  1747. in the following format:
  1748. <screen>
  1749. {
  1750. "result": 0,
  1751. "text": "2 IPv6 subnets found",
  1752. "arguments": {
  1753. "subnets": [
  1754. {
  1755. "id": 11,
  1756. "subnet": "2001:db8:1::/64"
  1757. },
  1758. {
  1759. "id": 233,
  1760. "subnet": "3000::/16"
  1761. }
  1762. ]
  1763. }
  1764. </screen>
  1765. </para>
  1766. <para>
  1767. If no IPv6 subnets are found, an error code is returned along with
  1768. the error description.
  1769. </para>
  1770. </section>
  1771. <section>
  1772. <title>subnet4-get command</title>
  1773. <para>This command is used to retrieve detailed information about the
  1774. specified subnet. This command usually follows the
  1775. <command>subnet4-list</command>, which is used to discover available
  1776. subnets with their respective subnet identifiers and prefixes. Any of
  1777. those parameters can be then used in <command>subnet4-get</command>
  1778. to fetch subnet information:
  1779. <screen>
  1780. {
  1781. "command": "subnet4-get",
  1782. "arguments": {
  1783. "id": 10
  1784. }
  1785. }</screen>
  1786. or
  1787. <screen>
  1788. {
  1789. "command": "subnet4-get",
  1790. "arguments": {
  1791. "subnet": "10.0.0.0/8"
  1792. }
  1793. }
  1794. </screen>
  1795. </para>
  1796. <para>
  1797. If the subnet exists the response will be similar to this:
  1798. <screen>
  1799. {
  1800. "result": 0,
  1801. "text": "Info about IPv4 subnet 10.0.0.0/8 (id 10) returned",
  1802. "arguments": {
  1803. "subnets": [
  1804. {
  1805. "subnet": "10.0.0.0/8",
  1806. "id": 1,
  1807. "option-data": [
  1808. ....
  1809. ]
  1810. ...
  1811. }
  1812. ]
  1813. }
  1814. }
  1815. </screen>
  1816. </para>
  1817. </section>
  1818. <section>
  1819. <title>subnet6-get command</title>
  1820. <para>This command is used to retrieve detailed information about the
  1821. specified subnet. This command usually follows the
  1822. <command>subnet6-list</command>, which is used to discover available
  1823. subnets with their respective subnet identifiers and prefixes. Any of
  1824. those parameters can be then used in <command>subnet6-get</command>
  1825. to fetch subnet information:
  1826. <screen>
  1827. {
  1828. "command": "subnet6-get",
  1829. "arguments": {
  1830. "id": 11
  1831. }
  1832. }
  1833. </screen>
  1834. or
  1835. <screen>
  1836. {
  1837. "command": "subnet6-get",
  1838. "arguments": {
  1839. "subnet": "2001:db8:1::/64"
  1840. }
  1841. }</screen>
  1842. If the subnet exists the response will be similar to this:
  1843. <screen>
  1844. {
  1845. "result": 0,
  1846. "text": "Info about IPv6 subnet 2001:db8:1::/64 (id 11) returned",
  1847. "arguments": {
  1848. "subnets": [
  1849. {
  1850. "subnet": "2001:db8:1::/64",
  1851. "id": 1,
  1852. "option-data": [
  1853. ...
  1854. ]
  1855. ....
  1856. }
  1857. ]
  1858. }
  1859. }
  1860. </screen>
  1861. </para>
  1862. </section>
  1863. <section>
  1864. <title>subnet4-add</title>
  1865. <para>
  1866. This command is used to create and add new subnet to the existing
  1867. server configuration. This operation has no impact on other
  1868. subnets. The subnet identifier must be specified and must be
  1869. unique among all subnets. If the identifier or a subnet prefix is
  1870. not unique an error is reported and the subnet is not added.
  1871. </para>
  1872. <para>
  1873. The subnet information within this command has the same structure
  1874. as the subnet information in the server configuration file with the
  1875. exception that static host reservations must not be specified
  1876. within <command>subnet4-add</command>. The commands described in
  1877. <xref linkend="host-cmds"/> should be used to add, remove and
  1878. modify static reservations.
  1879. <screen>
  1880. {
  1881. "command": "subnet4-add",
  1882. "arguments": {
  1883. "subnets": [ {
  1884. "id": 123,
  1885. "subnet": "10.20.30.0/24",
  1886. ...
  1887. } ]
  1888. }
  1889. }
  1890. </screen>
  1891. </para>
  1892. <para>
  1893. The response to this command has the following structure:
  1894. <screen>
  1895. {
  1896. "result": 0,
  1897. "text": "IPv4 subnet added",
  1898. "arguments": {
  1899. "subnets": [
  1900. {
  1901. "id": 123,
  1902. "subnet": "10.20.30.0/24"
  1903. }
  1904. ]
  1905. }
  1906. }
  1907. </screen>
  1908. </para>
  1909. </section>
  1910. <section>
  1911. <title>subnet6-add</title>
  1912. <para>
  1913. This command is used to create and add new subnet to the existing
  1914. server configuration. This operation has no impact on other
  1915. subnets. The subnet identifier must be specified and must be
  1916. unique among all subnets. If the identifier or a subnet prefix is
  1917. not unique an error is reported and the subnet is not added.
  1918. </para>
  1919. <para>
  1920. The subnet information within this command has the same structure
  1921. as the subnet information in the server configuration file with the
  1922. exception that static host reservations must not be specified
  1923. within <command>subnet6-add</command>. The commands described in
  1924. <xref linkend="host-cmds"/> should be used to add, remove and
  1925. modify static reservations.
  1926. <screen>
  1927. {
  1928. "command": "subnet6-add",
  1929. "arguments": {
  1930. "subnet6": [ {
  1931. "id": 234,
  1932. "subnet": "2001:db8:1::/64",
  1933. ...
  1934. } ]
  1935. }
  1936. }
  1937. </screen>
  1938. </para>
  1939. <para>
  1940. The response to this command has the following structure:
  1941. <screen>
  1942. {
  1943. "result": 0,
  1944. "text": "IPv6 subnet added",
  1945. "arguments": {
  1946. "subnet6": [
  1947. {
  1948. "id": 234,
  1949. "subnet": "2001:db8:1::/64"
  1950. }
  1951. ]
  1952. }
  1953. }
  1954. </screen>
  1955. </para>
  1956. <para>
  1957. It is recommended, but not mandatory to specify subnet
  1958. id. If not specified, Kea will try to assign the next
  1959. subnet-id value. This automatic ID value generator is
  1960. simple. It returns a previously automatically assigned value
  1961. increased by 1. This works well, unless you manually create
  1962. a subnet with a value bigger than previously used. For
  1963. example, if you call subnet4-add five times, each without
  1964. id, Kea will assign IDs: 1,2,3,4 and 5 and it will work just
  1965. fine. However, if you try to call subnet4-add five times,
  1966. with the first subnet having subnet-id of value 3 and
  1967. remaining ones having no subnet-id, it will fail. The first
  1968. command (with explicit value) will use subnet-id 3, the
  1969. second command will create a subnet with id of 1, the third
  1970. will use value of 2 and finally the fourth will have the
  1971. subnet-id value auto-generated as 3. However, since there is
  1972. already a subnet with that id, it will fail.
  1973. </para>
  1974. <para>
  1975. The general recommendation is to either: never use explicit
  1976. values (so the auto-generated values will always work) or
  1977. always use explicit values (so the auto-generation is never
  1978. used). You can mix those two approaches only if you
  1979. understand how the internal automatic subnet-id generation works.
  1980. </para>
  1981. </section>
  1982. <section>
  1983. <title>subnet4-del command</title>
  1984. <para>
  1985. This command is used to remove a subnet from the server's configuration.
  1986. This command has no effect on other configured subnets but removing
  1987. a subnet has certain implications which the server's administrator
  1988. should be aware of.
  1989. </para>
  1990. <para>
  1991. In most cases the server has assigned some leases to the clients
  1992. belonging to the subnet. The server may also be configured with
  1993. static host reservations which are associated with this subnet.
  1994. The current implementation of the <command>subnet4-del</command>
  1995. removes neither the leases nor host reservations associated with
  1996. a subnet. This is the safest approach because the server doesn't
  1997. loose track of leases assigned to the clients from this subnet.
  1998. However, removal of the subnet may still cause configuration
  1999. errors and conflicts. For example: after removal of the subnet,
  2000. the server administrator may add a new subnet with the ID used
  2001. previously for the removed subnet. This means that the existing
  2002. leases and static reservations will be in conflict with this
  2003. new subnet. Thus, we recommend that this command is used with extreme
  2004. caution.
  2005. </para>
  2006. <para>
  2007. This command can also be used to completely delete an IPv4 subnet that
  2008. is part of a shared network. If you want to simply remove the subnet
  2009. from a shared network and keep the subnet configuration, use
  2010. <command>network4-subnet-del</command> command instead.
  2011. </para>
  2012. <para>The command has the following structure:
  2013. <screen>
  2014. {
  2015. "command": "subnet4-del",
  2016. "arguments": {
  2017. "id": 123
  2018. }
  2019. }
  2020. </screen>
  2021. </para>
  2022. <para>
  2023. The example successful response may look like this:
  2024. <screen>
  2025. {
  2026. "result": 0,
  2027. "text": "IPv4 subnet 192.0.2.0/24 (id 123) deleted",
  2028. "arguments": {
  2029. "subnets": [
  2030. {
  2031. "id": 123,
  2032. "subnet": "192.0.2.0/24"
  2033. }
  2034. ]
  2035. }
  2036. }
  2037. </screen>
  2038. </para>
  2039. </section>
  2040. <section>
  2041. <title>subnet6-del command</title>
  2042. <para>
  2043. This command is used to remove a subnet from the server's configuration.
  2044. This command has no effect on other configured subnets but removing
  2045. a subnet has certain implications which the server's administrator
  2046. should be aware of.
  2047. </para>
  2048. <para>
  2049. In most cases the server has assigned some leases to the clients
  2050. belonging to the subnet. The server may also be configured with
  2051. static host reservations which are associated with this subnet.
  2052. The current implementation of the <command>subnet6-del</command>
  2053. removes neither the leases nor host reservations associated with
  2054. a subnet. This is the safest approach because the server doesn't
  2055. loose track of leases assigned to the clients from this subnet.
  2056. However, removal of the subnet may still cause configuration
  2057. errors and conflicts. For example: after removal of the subnet,
  2058. the server administrator may add a new subnet with the ID used
  2059. previously for the removed subnet. This means that the existing
  2060. leases and static reservations will be in conflict with this
  2061. new subnet. Thus, we recommend that this command is used with extreme
  2062. caution.
  2063. </para>
  2064. <para>
  2065. This command can also be used to completely delete an IPv6 subnet that
  2066. is part of a shared network. If you want to simply remove the subnet
  2067. from a shared network and keep the subnet configuration, use
  2068. <command>network6-subnet-del</command> command instead.
  2069. </para>
  2070. <para>The command has the following structure:
  2071. <screen>
  2072. {
  2073. "command": "subnet6-del",
  2074. "arguments": {
  2075. "id": 234
  2076. }
  2077. }
  2078. </screen>
  2079. </para>
  2080. <para>
  2081. The example successful response may look like this:
  2082. <screen>
  2083. {
  2084. "result": 0,
  2085. "text": "IPv6 subnet 2001:db8:1::/64 (id 234) deleted",
  2086. "subnets": [
  2087. {
  2088. "id": 234,
  2089. "subnet": "2001:db8:1::/64"
  2090. }
  2091. ]
  2092. }
  2093. </screen>
  2094. </para>
  2095. </section>
  2096. <section>
  2097. <title>network4-list, network6-list commands</title>
  2098. <para>
  2099. These commands are used to retrieve full list of currently configured
  2100. shared networks. The list contains only very basic information about
  2101. each shared network. If more details are needed, please use
  2102. <command>network4-get</command> or <command>network6-get</command> to
  2103. retrieve all information available. This command does not require any
  2104. parameters and its invocation is very simple:
  2105. <screen>
  2106. {
  2107. "command": "network4-list"
  2108. }
  2109. </screen>
  2110. An example response for <command>network4-list</command> looks as follows:
  2111. <screen>
  2112. {
  2113. "arguments": {
  2114. "shared-networks": [
  2115. { "name": "floor1" },
  2116. { "name": "office" }
  2117. ]
  2118. },
  2119. "result": 0,
  2120. "text": "2 IPv4 network(s) found"
  2121. }</screen>
  2122. <command>network6-list</command> follows exactly the same syntax for
  2123. both the query and the response.
  2124. </para>
  2125. </section>
  2126. <section>
  2127. <title>network4-get, network6-get commands</title>
  2128. <para>
  2129. These commands are used to retrieve detailed information
  2130. about shared networks, including subnets currently
  2131. being part of a given network. Both commands take one
  2132. mandatory parameter <command>name</command>, which specify
  2133. the name of shared network. An example command to retrieve
  2134. details about IPv4 shared network with a name "floor13"
  2135. looks as follows:
  2136. <screen>
  2137. {
  2138. "command": "network4-get",
  2139. "arguments": {
  2140. "name": "floor13"
  2141. }
  2142. }</screen>
  2143. An example response could look as follows:
  2144. <screen>
  2145. {
  2146. "result": 0,
  2147. "text": "Info about IPv4 shared network 'floor13' returned",
  2148. "arguments": {
  2149. "shared-networks": [
  2150. {
  2151. "match-client-id": true,
  2152. "name": "floor13",
  2153. "option-data": [ ],
  2154. "rebind-timer": 90,
  2155. "relay": {
  2156. "ip-address": "0.0.0.0"
  2157. },
  2158. "renew-timer": 60,
  2159. "reservation-mode": "all",
  2160. "subnet4": [
  2161. {
  2162. "subnet": "192.0.2.0/24",
  2163. "id": 5,
  2164. // many other subnet specific details here
  2165. },
  2166. {
  2167. "id": 6,
  2168. "subnet": "192.0.3.0/31",
  2169. // many other subnet specific details here
  2170. }
  2171. ],
  2172. "valid-lifetime": 120
  2173. }
  2174. ]
  2175. }
  2176. }
  2177. </screen>
  2178. Note that actual response contains many additional fields that are
  2179. omitted here for clarity. The response format is exactly the same as
  2180. used in <command>config-get</command>, just is limited to returning
  2181. shared networks information.
  2182. </para>
  2183. </section>
  2184. <section>
  2185. <title>network4-add, network6-add commands</title>
  2186. <para>
  2187. These commands are used to add a new shared network. New
  2188. network has to have unique name. This command requires one parameter
  2189. <command>shared-networks</command>, which is a list and
  2190. should contain exactly one entry that defines the
  2191. network. The only mandatory element for a network is its
  2192. name. Although it does not make operational sense, it is
  2193. allowed to add an empty shared network that does not have
  2194. any subnets in it. That is allowed for testing purposes, but
  2195. having empty networks (or with only one subnet) is
  2196. discouraged in production environments. For details regarding
  2197. syntax, see <xref linkend="shared-network4"/> and <xref
  2198. linkend="shared-network6"/>.
  2199. </para>
  2200. <note><para>As opposed to parameter inheritance during full
  2201. new configuration processing, this command does not fully handle
  2202. parameter inheritance and any missing parameters will be
  2203. filled with default values, rather than inherited from
  2204. global scope.</para></note>
  2205. <para>
  2206. An example that showcases how to add a new IPv4 shared network looks
  2207. as follows:
  2208. <screen>
  2209. {
  2210. "command": "network4-add",
  2211. "arguments": {
  2212. "shared-networks": [ {
  2213. "name": "floor13",
  2214. "subnet4": [
  2215. {
  2216. "id": 100,
  2217. "pools": [ { "pool": "192.0.2.2-192.0.2.99" } ],
  2218. "subnet": "192.0.2.0/24",
  2219. "option-data": [
  2220. {
  2221. "name": "routers",
  2222. "data": "192.0.2.1"
  2223. }
  2224. ]
  2225. },
  2226. {
  2227. "id": 101,
  2228. "pools": [ { "pool": "192.0.3.2-192.0.3.99" } ],
  2229. "subnet": "192.0.3.0/24",
  2230. "option-data": [
  2231. {
  2232. "name": "routers",
  2233. "data": "192.0.3.1"
  2234. }
  2235. ]
  2236. } ]
  2237. } ]
  2238. }
  2239. }
  2240. </screen>
  2241. Assuming there was no shared network with a name floor13 and no subnets with id
  2242. 100 and 101 previously configured, the command will be successful and will
  2243. return the following response:
  2244. <screen>
  2245. {
  2246. "arguments": {
  2247. "shared-networks": [ { "name": "floor13" } ]
  2248. },
  2249. "result": 0,
  2250. "text": "A new IPv4 shared network 'floor13' added"
  2251. }
  2252. </screen>
  2253. The <command>network6-add</command> uses the same syntax for both the query and
  2254. the response. However, there are some parameters that are IPv4-only
  2255. (e.g. match-client-id) and some are IPv6-only (e.g. interface-id). The same
  2256. applies to subnets within the network.
  2257. </para>
  2258. </section>
  2259. <section>
  2260. <title>network4-del, network6-del commands</title>
  2261. <para>
  2262. These commands are used to delete existing shared networks. Each
  2263. subnet within the network being removed will be demoted to a plain
  2264. subnet. If you want to completely remove the subnets, please use
  2265. <command>subnet4-del</command> or <command>subnet6-del</command>
  2266. commands. Both commands take exactly one parameter 'name' that
  2267. specifies the name of the network to be removed. An example invocation
  2268. of <command>network4-del</command> command looks as follows:
  2269. <screen>
  2270. {
  2271. "command": "network4-del",
  2272. "arguments": {
  2273. "name": "floor13"
  2274. }
  2275. }
  2276. </screen>
  2277. Assuming there was such a network configured, the response will look similar to
  2278. the following:
  2279. <screen>
  2280. {
  2281. "arguments": {
  2282. "shared-networks": [
  2283. {
  2284. "name": "floor1"
  2285. }
  2286. ]
  2287. },
  2288. "result": 0,
  2289. "text": "IPv4 shared network 'floor13' deleted"
  2290. }</screen>
  2291. The <command>network6-del</command> command uses exactly the same syntax for
  2292. both the command and the response.
  2293. </para>
  2294. </section>
  2295. <section>
  2296. <title>network4-subnet-add, network6-subnet-add commands</title>
  2297. <para>
  2298. These commands are used to add existing subnets to existing shared
  2299. networks. There are several ways to add new shared network. System
  2300. administrator can add the whole shared network at once, either by
  2301. editing a configuration file or by calling
  2302. <command>network4-add</command> or <command>network6-add</command>
  2303. commands with desired subnets in it. This approach works better for completely
  2304. new shared subnets. However, there may be cases when an existing
  2305. subnet is running out of addresses and needs to be extended with
  2306. additional address space. In other words another subnet has to be
  2307. added on top of it. For this scenario, a system administrator can use
  2308. <command>network4-add</command> or <command>network6-add</command> and
  2309. then add existing subnet to this newly created shared network using
  2310. <command>network4-subnet-add</command> or
  2311. <command>network6-subnet-add</command>.
  2312. </para>
  2313. <para>
  2314. The <command>network4-subnet-add</command> and
  2315. <command>network6-subnet-add</command> commands take two parameters:
  2316. <command>id</command>, which is an integer and specifies subnet-id of existing subnet to
  2317. be added to a shared network; and <command>name</command>, which
  2318. specifies name of the shared network the subnet will be added to. The
  2319. subnet must not belong to any existing network. In case you want to
  2320. reassign a subnet from one shared network to another, please use
  2321. <command>network4-subnet-del</command> or
  2322. <command>network6-subnet-del</command> commands first.
  2323. </para>
  2324. <para>
  2325. An example invocation of <command>network4-subnet-add</command>
  2326. command looks as follows:
  2327. <screen>
  2328. {
  2329. "command": "network4-subnet-add",
  2330. "arguments": {
  2331. "name": "floor13",
  2332. "id": 5
  2333. }
  2334. }</screen>
  2335. Assuming there is a network named 'floor13', there is a subnet with subnet-id 5
  2336. and it is not a part of existing network, the command will return a response
  2337. similar to the following:
  2338. <screen>
  2339. {
  2340. "result": 0,
  2341. "text": "IPv4 subnet 10.0.0.0/8 (id 5) is now part of shared network 'floor1'"
  2342. }</screen>
  2343. The <command>network6-subnet-add</command> command uses exactly the same syntax for
  2344. both the command and the response.
  2345. </para>
  2346. <note><para>As opposed to parameter inheritance during full
  2347. new configuration processing or when adding a new shared network with
  2348. new subnets, this command does not fully handle
  2349. parameter inheritance and any missing parameters will be
  2350. filled with default values, rather than inherited from
  2351. global scope or from the shared network.</para></note>
  2352. </section>
  2353. <section>
  2354. <title>network4-subnet-del, network6-subnet-del commands</title>
  2355. <para>
  2356. These commands are used to remove a subnet that is part of existing shared
  2357. network and demote it to a plain, stand-alone subnet. If you want to
  2358. remove a subnet completely, use <command>subnet4-del</command> or
  2359. <command>subnet6-del</command> commands instead.
  2360. The <command>network4-subnet-del</command> and
  2361. <command>network6-subnet-del</command> commands take two parameters:
  2362. <command>id</command>, which is an integer and specifies subnet-id of
  2363. existing subnet to be removed from a shared network; and
  2364. <command>name</command>, which specifies name of the shared network
  2365. the subnet will be removed from.
  2366. </para>
  2367. <para>An example invocation of the
  2368. <command>network4-subnet-del</command> command looks as follows:
  2369. <screen>
  2370. {
  2371. "command": "network4-subnet-del",
  2372. "arguments": {
  2373. "name": "floor13",
  2374. "id": 5
  2375. }
  2376. }</screen>
  2377. Assuming there was a subnet with subnet-id equal to 5 that was part of a shared
  2378. network named 'floor13', the response would look similar to the following:
  2379. <screen>
  2380. {
  2381. "result": 0,
  2382. "text": "IPv4 subnet 10.0.0.0/8 (id 5) is now removed from shared network 'floor13'"
  2383. }</screen>
  2384. The <command>network6-subnet-del</command> command uses exactly the same syntax for
  2385. both the command and the response.
  2386. </para>
  2387. </section>
  2388. </section>
  2389. </section> <!-- end of subnet commands -->
  2390. <section id="user-context">
  2391. <title>User contexts</title>
  2392. <para>Hook libraries can have their own configuration parameters. That is
  2393. convenient if the parameter applies to the whole library. However,
  2394. sometimes it is very useful if certain configuration entities are extended
  2395. with additional configuration data. This is where the concept of user
  2396. contexts comes in. A sysadmin can define an arbitrary set of data and
  2397. attach it to Kea structures, as long as the data is specified as JSON map.
  2398. In particular, it is possible to define fields that are integers, strings,
  2399. boolean, lists and maps. It is possible to define nested structures of
  2400. arbitrary complexity. Kea does not use that data on its own, simply stores
  2401. and makes it available for the hook libraries.
  2402. </para>
  2403. <para>
  2404. Another use case for user contexts may be storing comments and other
  2405. information that will be retained by Kea. Regular comments are discarded
  2406. when configuration is loaded, but user contexts are retained. This is
  2407. useful if you want your comments to survive config-set, config-get
  2408. operations for example.
  2409. </para>
  2410. <para>
  2411. As of Kea 1.3, the structures that allow user contexts are pools of all
  2412. types (addresses and prefixes) and subnets. These are supported in both
  2413. DHCPv4 and DHCPv6. It is expected that other structures will be extended
  2414. in the future to provide the user context capability.
  2415. </para>
  2416. </section>
  2417. </chapter> <!-- hooks-libraries -->