dhcp4-srv.xml 86 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
  4. <!ENTITY mdash "&#x2014;" >
  5. ]>
  6. <chapter id="dhcp4">
  7. <title>The DHCPv4 Server</title>
  8. <section id="dhcp4-start-stop">
  9. <title>Starting and Stopping the DHCPv4 Server</title>
  10. <!-- @todo Rewrite this section once #3422 is done -->
  11. <para>
  12. It is recommended that the Kea DHCPv4 server be started and stopped
  13. using <command>keactrl</command> (described in <xref linkend="keactrl"/>).
  14. However, it is also possible to run the server directly: it accepts
  15. the following command-line switches:
  16. </para>
  17. <itemizedlist>
  18. <listitem>
  19. <simpara>
  20. <command>-c <replaceable>file</replaceable></command> -
  21. specifies the configuration file. This is the only mandatory
  22. switch.</simpara>
  23. </listitem>
  24. <listitem>
  25. <simpara>
  26. <command>-d</command> - specifies whether the server
  27. logging should be switched to debug/verbose mode. In verbose mode,
  28. the logging severity and debuglevel specified in a configuration
  29. file are ignored and "debug" severity and the maximum debuglevel
  30. (99) are assumed. The flag is convenient, for temporarily
  31. switching the server into maximum verbosity, e.g. when
  32. debugging.</simpara>
  33. </listitem>
  34. <listitem>
  35. <simpara>
  36. <command>-p <replaceable>port</replaceable></command> -
  37. specifies UDP port the server will listen on. This is only
  38. useful during testing, as the DHCPv4 server listening on
  39. ports other than default DHCPv4 ports will not be able to
  40. handle regular DHCPv4 queries.</simpara>
  41. </listitem>
  42. <listitem>
  43. <simpara>
  44. <command>-v</command> - prints out Kea version and exits.
  45. </simpara>
  46. </listitem>
  47. <listitem>
  48. <simpara>
  49. <command>-V</command> - prints out Kea extended version with
  50. additional parameters and exits.
  51. </simpara>
  52. </listitem>
  53. </itemizedlist>
  54. <para>
  55. When running in a console, the server can be shut down by
  56. pressing ctrl-c. It detects the key combination and shuts
  57. down gracefully.
  58. </para>
  59. <para>
  60. On start-up, the server will detect available network interfaces
  61. and will attempt to open UDP sockets on all interfaces
  62. mentioned in the configuration file.
  63. </para>
  64. <para>
  65. Since the DHCPv4 server opens privileged ports, it requires root
  66. access. Make sure you run this daemon as root.
  67. </para>
  68. </section>
  69. <section id="dhcp4-configuration">
  70. <title>DHCPv4 Server Configuration</title>
  71. <section>
  72. <title>Introduction</title>
  73. <para>
  74. This section explains how to configure the DHCPv4 server using the
  75. Kea configuration backend. (Kea configuration using any other
  76. backends is outside of scope of this document.) Before DHCPv4
  77. is started, its configuration file has to be created. The
  78. basic configuration looks as follows:
  79. <screen>
  80. {
  81. # DHCPv4 configuration starts in this line
  82. "Dhcp4": {
  83. # First we set up global values
  84. "interfaces": [ "eth0" ],
  85. "valid-lifetime": 4000,
  86. "renew-timer": 1000,
  87. "rebind-timer": 2000,
  88. # Next we specify the type of lease database
  89. "lease-database": {
  90. "type": "memfile",
  91. "persist": true,
  92. "name": "/var/kea/dhcp4.leases"
  93. },
  94. # Finally, we list the subnets from which we will be leasing addresses.
  95. "subnet4": [
  96. {
  97. "subnet": "192.0.2.0/24",
  98. "pools": [
  99. { "pool": "192.0.2.1 - 192.0.2.200" }
  100. ]
  101. }
  102. ]
  103. # DHCPv4 configuration ends with this line
  104. }
  105. } </screen>
  106. </para>
  107. <para>The following paragraphs provide a brief overview of the parameters in
  108. the above example and
  109. their format. Subsequent sections of this chapter go into much greater detail
  110. for these and other parameters.</para>
  111. <para>The lines starting with a hash (#) are comments and are ignored by
  112. the server; they do not impact its
  113. operation in any way.</para>
  114. <para>The configuration starts in the first line with the initial
  115. opening curly bracket (or brace). Each configuration consists of
  116. one or more objects. In this specific example, we have only one
  117. object called Dhcp4. This is a simplified configuration, as usually
  118. there will be additional objects, like <command>Logging</command> or
  119. <command>DhcpDns</command>, but we omit them now for clarity. The Dhcp4
  120. configuration starts with the <command>"Dhcp4": {</command> line
  121. and ends with the corresponding closing brace (in the above example,
  122. the brace after the last comment). Everything defined between those
  123. lines is considered to be the Dhcp4 configuration.</para>
  124. <para>In general case, the order in which those parameters appear does not
  125. matter. There are two caveats here though. The first one is to remember that
  126. the configuration file must be a well formed JSON. That means that parameters
  127. for any given scope must be separate by a comma and there must not be a comma
  128. after the last parameter. When reordering configuration file, keep in mind that
  129. moving a parameter to or from the last position in a given scope may require
  130. moving the comma as well. The second caveat is that it is uncommon &mdash; although
  131. legal JSON &mdash; to
  132. repeat the same parameter multiple times. If that appears, the last occurrence of a
  133. given parameter in a given scope is used while all previous instances are
  134. ignored. This is unlikely to cause any confusion as there are no real life
  135. reasons to keep multiple copies of the same parameter in your configuration
  136. file.</para>
  137. <para>Moving onto the DHCPv4 configuration elements,
  138. the line defining <command>interfaces</command> parameter specifies a list
  139. of network interfaces on which the server should listen.
  140. Lists are opened and closed with square brackets, with elements
  141. separated by commas. Had we wanted to listen on two interfaces, the line could
  142. look like this:
  143. <screen>
  144. "interfaces": [ "eth0", "eth1" ],
  145. </screen>
  146. As "<command>interfaces</command>" is not the last parameter in the configuration,
  147. a trailing comma is required.</para>
  148. <para>A number of other parameters
  149. follow. <command>valid-lifetime</command> defines how long the addresses (leases) given out by the
  150. server are valid. If nothing changes, client that got the address is allowed to
  151. use it for 4000 seconds. (Note that integer numbers are specified as is,
  152. without any quotes around them.) <command>renew-timer</command> and
  153. <command>rebind-timer</command> are values that
  154. define T1 and T2 timers that govern when the client will begin renewal and
  155. rebind procedures. Note that <command>renew-timer</command> and
  156. <command>rebind-timer</command> are optional. If they are not specified the
  157. client will select values for T1 and T2 timers according to the
  158. <ulink url="http://tools.ietf.org/html/rfc2131">RFC 2131</ulink>.</para>
  159. <para>The next couple lines define the lease database, the place where the server
  160. stores its lease information. This particular example tells the server to use
  161. <command>memfile</command>, which is the simplest (and fastest) database
  162. backend. It uses in-memory database and stores leases on disk in a CSV
  163. file. This is a very simple configuration. Usually, lease database configuration
  164. is more extensive and contains additional parameters. Note that
  165. <command>lease-database</command>
  166. is an object and opens up a new scope, using an opening brace.
  167. Its parameters (just one in this example -- <command>type</command>)
  168. follow. Had there been more than one, they would be separated by commas. This
  169. scope is closed with a closing brace. As more parameters follow, a trailing
  170. comma is present.</para>
  171. <para>Finally, we need to define a list of IPv4 subnets. This is the
  172. most important DHCPv4 configuration structure as the server uses that
  173. information to process clients' requests. It defines all subnets that
  174. the server is expected to receive DHCP requests from. The subnets are
  175. specified with the <command>subnet4</command> parameter. It is a list,
  176. so it starts and ends with square brackets. Each subnet definition in
  177. the list has several attributes associated with it, so is a structure
  178. and is opened and closed with braces. At minimum, a subnet definition
  179. has to have at least two parameters: <command>subnet</command> (that
  180. defines the whole subnet) and <command>pools</command> (which is a list of
  181. dynamically allocated pools that are governed by the DHCP server).</para>
  182. <para>The example contains a single subnet. Had more than one been defined,
  183. additional elements
  184. in the <command>subnet4</command> parameter would be specified and
  185. separated by commas. For example, to define three subnets, the following
  186. syntax would be used:
  187. <screen>
  188. "subnet4": [
  189. {
  190. "pools": [ { "pool": "192.0.2.1 - 192.0.2.200" } ],
  191. "subnet": "192.0.2.0/24"
  192. },
  193. {
  194. "pools": [ { "pool": "192.0.3.100 - 192.0.3.200" } ],
  195. "subnet": "192.0.3.0/24"
  196. },
  197. {
  198. "pools": [ { "pool": "192.0.4.1 - 192.0.4.254" } ],
  199. "subnet": "192.0.4.0/24"
  200. }
  201. ]
  202. </screen>
  203. </para>
  204. <para>After all parameters are specified, we have two contexts open:
  205. global and Dhcp4, hence we need two closing curly brackets to close them.
  206. In a real life configuration file there most likely would be additional
  207. components defined such as Logging or DhcpDdns, so the closing brace would
  208. be followed by a comma and another object definition.</para>
  209. <para>Kea 0.9 does not have configuration syntax validation
  210. implemented yet. Such a feature is planned for the near future. For
  211. the time being, it is convenient to use on-line JSON validators and/or
  212. viewers to check whether the syntax is correct. One example of such a
  213. JSON validator is available at <ulink
  214. url="http://jsonviewer.stack.hu/"/>.
  215. </para>
  216. </section>
  217. <section>
  218. <title>Lease Storage</title>
  219. <para>All leases issued by the server are stored in the lease database.
  220. Currently there are three database backends available:
  221. memfile (which is the default backend), MySQL and PostgreSQL.</para>
  222. <section>
  223. <title>Memfile - Basic Storage for Leases</title>
  224. <para>The server is able to store lease data in different repositories. Larger
  225. deployments may elect to store leases in a database. <xref
  226. linkend="database-configuration4"/> describes this option. In typical
  227. smaller deployments though, the server will use a CSV file rather than a database to
  228. store lease information. As well as requiring less administration, an
  229. advantage of using a file for storage is that it
  230. eliminates a dependency on third-party database software.</para>
  231. <para>The configuration of the file backend (Memfile) is controlled through
  232. the Dhcp4/lease-database parameters. <!-- @todo: we don't have default
  233. parameters. Let's comment this out When default parameters are used, the
  234. Memfile backend will write leases to a disk in the
  235. [kea-install-dir]/var/kea/kea-leases4.csv. -->
  236. The following configuration sets the name of the lease file to
  237. <filename>/tmp/kea-leases4.csv</filename>:
  238. <screen>
  239. "Dhcp4": {
  240. "lease-database": {
  241. <userinput>"type": "memfile"</userinput>,
  242. <userinput>"persist": true</userinput>,
  243. <userinput>"name": "/tmp/kea-leases4.csv"</userinput>
  244. }
  245. ...
  246. }
  247. </screen>
  248. </para>
  249. <para>The "persist" parameter controls whether the leases are written to disk.
  250. It is strongly recommended that this parameter is set to
  251. <command>true</command> at all times during the normal operation of the
  252. server. (Not writing leases to disk will mean that if a server is restarted
  253. (e.g. after a power failure), it will not know what addresses have been
  254. assigned. As a result, it may hand out addresses to new clients that are
  255. already in use.)</para>
  256. </section>
  257. <section id="database-configuration4">
  258. <title>Database Configuration</title>
  259. <note>
  260. <para>Database access information must be configured for the DHCPv4 server,
  261. even if it has already been configured for the DHCPv6 server. The servers
  262. store their information independently, so each server can use a separate
  263. database or both servers can use the same database.</para>
  264. </note>
  265. <para>Database configuration is controlled through the Dhcp4/lease-database
  266. parameters. The type of the database must be set to "mysql" or "postgresql",
  267. e.g.
  268. <screen>
  269. "Dhcp4": { "lease-database": { <userinput>"type": "mysql"</userinput>, ... }, ... }
  270. </screen>
  271. Next, the name of the database is to hold the leases must be set: this is the
  272. name used when the lease database was created (see <xref linkend="dhcp-mysql-database-create"/>
  273. or <xref linkend="dhcp-pgsql-database-create"/>).
  274. <screen>
  275. "Dhcp4": { "lease-database": { <userinput>"name": "<replaceable>database-name</replaceable>" </userinput>, ... }, ... }
  276. </screen>
  277. If the database is located on a different system to the DHCPv4 server, the
  278. database host name must also be specified (although it should be noted that this
  279. configuration may have a severe impact on server performance):
  280. <screen>
  281. "Dhcp4": { "lease-database": { <userinput>"host": <replaceable>remote-host-name</replaceable>"</userinput>, ... }, ... }
  282. </screen>
  283. The usual state of affairs will be to have the database on the same machine as
  284. the DHCPv4 server. In this case, set the value to the empty string:
  285. <screen>
  286. "Dhcp4": { "lease-database": { <userinput>"host" : ""</userinput>, ... }, ... }
  287. </screen>
  288. </para>
  289. <para>Finally, the credentials of the account under which the server will
  290. access the database should be set:
  291. <screen>
  292. "Dhcp4": { "lease-database": { <userinput>"user": "<replaceable>user-name</replaceable>"</userinput>,
  293. <userinput>"password" "<replaceable>password</replaceable>"</userinput>,
  294. ... },
  295. ... }
  296. </screen>
  297. If there is no password to the account, set the password to the empty string
  298. "". (This is also the default.)</para>
  299. </section>
  300. </section>
  301. <section id="dhcp4-interface-selection">
  302. <title>Interface selection</title>
  303. <para>The DHCPv4 server has to be configured to listen on specific network
  304. interfaces. The simplest network interface configuration tells the server to
  305. listen on all available interfaces:
  306. <screen>
  307. "Dhcp4": { <userinput>"interfaces": ["*"]</userinput>, ... }</screen>
  308. The asterisk plays the role of a wildcard and means "listen on all interfaces".
  309. However, it is usually a good idea to explicitly specify interface names:
  310. <screen>
  311. "Dhcp4": { <userinput>"interfaces": [ "eth1", "eth3" ]</userinput>, ... }</screen>
  312. </para>
  313. <para>It is possible to use wildcard interface name (asterisk) concurrently
  314. with explicit interface names:
  315. <screen>
  316. "Dhcp4": { <userinput>"interfaces": [ "eth1", "eth3", "*" ]</userinput>, ... }</screen>
  317. It is anticipated that this will form of usage only be used where it is desired to
  318. temporarily override a list of interface names and listen on all interfaces.
  319. </para>
  320. </section>
  321. <section id="ipv4-subnet-id">
  322. <title>IPv4 Subnet Identifier</title>
  323. <para>
  324. The subnet identifier is a unique number associated with a particular subnet.
  325. In principle, it is used to associate clients' leases with respective subnets.
  326. When a subnet identifier is not specified for a subnet being configured, it will
  327. be automatically assigned by the configuration mechanism. The identifiers
  328. are assigned from 1 and are monotonically increased for each subsequent
  329. subnet: 1, 2, 3 ....
  330. </para>
  331. <para>
  332. If there are multiple subnets configured with auto-generated identifiers and
  333. one of them is removed, the subnet identifiers may be renumbered. For example:
  334. if there are four subnets and third is removed the last subnet will be assigned
  335. identifier that the third subnet had before removal. As a result, the leases
  336. stored in the lease database for subnet 3 are now associated with
  337. subnet 4, something that may have unexpected consequences. It is planned
  338. to implement the mechanism to preserve auto-generated subnet ids in a
  339. future version of Kea. However, the only remedy for this issue
  340. at present is to
  341. manually specify a unique identifier for each subnet.
  342. </para>
  343. <para>
  344. The following configuration will assign the arbitrary subnet
  345. identifier to the newly configured subnet:
  346. <screen>
  347. "Dhcp4": {
  348. "subnet4": [
  349. "subnet": "192.0.2.0/24",
  350. <userinput>"id": 1024</userinput>,
  351. ...
  352. ]
  353. }
  354. </screen>
  355. This identifier will not change for this subnet unless the "id" parameter is
  356. removed or set to 0. The value of 0 forces auto-generation of the subnet
  357. identifier.
  358. </para>
  359. <!-- @todo: describe whether database needs to be updated after changing
  360. id -->
  361. </section>
  362. <section id="dhcp4-address-config">
  363. <title>Configuration of IPv4 Address Pools</title>
  364. <para>
  365. The essential role of DHCPv4 server is address assignment. The server has to
  366. be configured with at least one subnet and one pool of dynamic addresses to
  367. be managed. For example, assume that the server is connected to a network
  368. segment that uses the 192.0.2.0/24 prefix. The Administrator of that network
  369. has decided that addresses from range 192.0.2.10 to 192.0.2.20 are going to
  370. be managed by the Dhcp4 server. Such a configuration can be achieved in the
  371. following way:
  372. <screen>
  373. "Dhcp4": {
  374. <userinput>"subnet4": [
  375. "subnet": "192.0.2.0/24",
  376. "pools": [
  377. {
  378. "pool": "192.0.2.10 - 192.0.2.20"
  379. }
  380. ]</userinput>,
  381. ...
  382. ]
  383. }</screen>
  384. Note that subnet is defined as a simple string, but the 'pools' parameter is
  385. actually a list of pools: for this reason, the pool definition is enclosed
  386. in square brackets, even though only one range of addresses is
  387. specified in this example.</para>
  388. <para>Each <command>pool</command> is a structure that contains the parameters
  389. th describe a single pool. Currently there is only one parameter,
  390. <command>pool</command>, which gives the range of addresses
  391. in the pool. Additional parameters will be added in future
  392. releases of Kea.</para>
  393. <para>It is possible to define more than one pool in a subnet: continuing
  394. the previous example, further assume that 192.0.2.64/26 should be also be
  395. managed by the server. It could be written as 192.0.2.64 to
  396. 192.0.2.127. Alternatively, it can be expressed more simply as
  397. 192.0.2.64/26. Both formats are supported by Dhcp4 and can be mixed in the
  398. pool list. For example, one could define the following pools:
  399. <screen>
  400. "Dhcp4": {
  401. "subnet4": [
  402. <userinput>"pools": [
  403. { "pool": "192.0.2.10-192.0.2.20" },
  404. { "pool": "192.0.2.64/26" }
  405. ]</userinput>,
  406. ...
  407. ],
  408. ...
  409. }
  410. </screen>
  411. The number of pools is not limited, but for performance reasons it is recommended to
  412. use as few as possible. White space in pool definitions is ignored, so
  413. spaces before and after hyphen are optional. They can be used to improve readability.
  414. </para>
  415. <para>
  416. The server may be configured to serve more than one subnet:
  417. <screen>
  418. "Dhcp4": {
  419. "subnet4": [
  420. {
  421. "subnet": "192.0.2.0/24",
  422. "pools": [ { "pool": "192.0.2.1 - 192.0.2.200" } ],
  423. ...
  424. },
  425. {
  426. "subnet": "192.0.3.0/24",
  427. "pools": [ { "pool": "192.0.3.100 - 192.0.3.200" } ],
  428. ...
  429. },
  430. {
  431. "subnet": "192.0.4.0/24",
  432. "pools": [ { "pool": "192.0.4.1 - 192.0.4.254" } ],
  433. ...
  434. }
  435. ]
  436. }
  437. </screen>
  438. </para>
  439. <para>
  440. When configuring a DHCPv4 server using prefix/length notation, please pay
  441. attention to the boundary values. When specifying that the server should use
  442. a given pool, it will be able to allocate also first (typically network
  443. address) and the last (typically broadcast address) address from that pool.
  444. In the aforementioned example of pool 192.0.3.0/24, both 192.0.3.0 and
  445. 192.0.3.255 addresses may be assigned as well. This may be invalid in some
  446. network configurations. If you want to avoid this, please use the "min-max" notation.
  447. </para>
  448. </section>
  449. <section id="dhcp4-std-options">
  450. <title>Standard DHCPv4 options</title>
  451. <para>
  452. One of the major features of the DHCPv4 server is to provide configuration
  453. options to clients. Although there are several options that require
  454. special behavior, most options are sent by the server only if the client
  455. explicitly requested them. The following example shows how to
  456. configure the addresses of DNS servers, which is one of the most frequently used
  457. options. Options specified in this way are considered global and apply
  458. to all configured subnets.
  459. <screen>
  460. "Dhcp4": {
  461. "option-data": [
  462. {
  463. <userinput>"name": "domain-name-servers",
  464. "code": 6,
  465. "space": "dhcp4",
  466. "csv-format": true,
  467. "data": "192.0.2.1, 192.0.2.2"</userinput>
  468. },
  469. ...
  470. ]
  471. }
  472. </screen>
  473. </para>
  474. <para>
  475. The <command>name</command> parameter specifies the
  476. option name. For a complete list of currently supported names,
  477. see <xref linkend="dhcp4-std-options-list"/> below.
  478. The <command>code</command> parameter specifies the option code, which must match one of the
  479. values from that list. The next line specifies option space, which must always
  480. be set to "dhcp4" as these are standard DHCPv4 options. For
  481. other option spaces, including custom option spaces, see <xref
  482. linkend="dhcp4-option-spaces"/>. The next line specifies the format in
  483. which the data will be entered: use of CSV (comma
  484. separated values) is recommended. The sixth line gives the actual value to
  485. be sent to clients. Data is specified as a normal text, with
  486. values separated by commas if more than one value is
  487. allowed.
  488. </para>
  489. <para>
  490. Options can also be configured as hexadecimal values. If
  491. <command>csv-format</command> is
  492. set to false, option data must be specified as a hexadecimal string. The
  493. following commands configure the domain-name-servers option for all
  494. subnets with the following addresses: 192.0.3.1 and 192.0.3.2.
  495. Note that <command>csv-format</command> is set to false.
  496. <screen>
  497. "Dhcp4": {
  498. "option-data": [
  499. {
  500. <userinput>"name": "domain-name-servers",
  501. "code": 6,
  502. "space": "dhcp4",
  503. "csv-format": false,
  504. "data": "C0 00 03 01 C0 00 03 02"</userinput>
  505. },
  506. ...
  507. ],
  508. ...
  509. }</screen>
  510. </para>
  511. <para>
  512. Most of the parameters in the "option-data" structure are optional and
  513. can be omitted in some circumstances as discussed in the
  514. <xref linkend="dhcp4-option-data-defaults"/>.
  515. </para>
  516. <para>
  517. It is possible to specify or override options on a per-subnet basis. If
  518. clients connected to most of your subnets are expected to get the
  519. same values of a given option, you should use global options: you
  520. can then override specific values for a small number of subnets.
  521. On the other hand, if you use different values in each subnet,
  522. it does not make sense to specify global option values
  523. (Dhcp4/option-data), rather you should set only subnet-specific values
  524. (Dhcp4/subnet[X]/option-data[Y]).
  525. </para>
  526. <para>
  527. The following commands override the global
  528. DNS servers option for a particular subnet, setting a single DNS
  529. server with address 192.0.2.3.
  530. <screen>
  531. "Dhcp4": {
  532. "subnet4": [
  533. {
  534. <userinput>"option-data": [
  535. {
  536. "name": "domain-name-servers",
  537. "code": 6,
  538. "space": "dhcp4",
  539. "csv-format": true,
  540. "data": "192.0.2.3"
  541. },
  542. ...
  543. ]</userinput>,
  544. ...
  545. },
  546. ...
  547. ],
  548. ...
  549. }
  550. </screen>
  551. </para>
  552. <para>
  553. The currently supported standard DHCPv4 options are
  554. listed in <xref linkend="dhcp4-std-options-list"/>
  555. and <xref linkend="dhcp4-std-options-list-part2"/>.
  556. The "Name" and "Code"
  557. are the values that should be used as a name in the option-data
  558. structures. "Type" designates the format of the data: the meanings of
  559. the various types is given in <xref linkend="dhcp-types"/>.
  560. </para>
  561. <para>
  562. Some options are designated as arrays, which means that more than one
  563. value is allowed in such an option. For example the option time-servers
  564. allows the specification of more than one IPv4 address, so allowing
  565. clients to obtain the addresses of multiple NTP servers.
  566. </para>
  567. <!-- @todo: describe record types -->
  568. <para>
  569. The <xref linkend="dhcp4-custom-options"/> describes the configuration
  570. syntax to create custom option definitions (formats). It is generally not
  571. allowed to create custom definitions for standard options, even if the
  572. definition being created matches the actual option format defined in the
  573. RFCs. There is an exception from this rule for standard options for which
  574. Kea does not provide a definition yet. In order to use such options,
  575. a server administrator must create a definition as described in
  576. <xref linkend="dhcp4-custom-options"/> in the 'dhcp4' option space. This
  577. definition should match the option format described in the relevant
  578. RFC but configuration mechanism would allow any option format as it has
  579. no means to validate it at the moment.
  580. </para>
  581. <para>
  582. <table frame="all" id="dhcp4-std-options-list">
  583. <title>List of standard DHCPv4 options</title>
  584. <tgroup cols='4'>
  585. <colspec colname='name'/>
  586. <colspec colname='code' align='center'/>
  587. <colspec colname='type' align='center'/>
  588. <colspec colname='array' align='center'/>
  589. <thead>
  590. <row>
  591. <entry>Name</entry>
  592. <entry>Code</entry>
  593. <entry>Type</entry>
  594. <entry>Array?</entry>
  595. </row>
  596. </thead>
  597. <tbody>
  598. <row><entry>subnet-mask</entry><entry>1</entry><entry>ipv4-address</entry><entry>false</entry></row>
  599. <row><entry>time-offset</entry><entry>2</entry><entry>int32</entry><entry>false</entry></row>
  600. <row><entry>routers</entry><entry>3</entry><entry>ipv4-address</entry><entry>true</entry></row>
  601. <row><entry>time-servers</entry><entry>4</entry><entry>ipv4-address</entry><entry>true</entry></row>
  602. <row><entry>name-servers</entry><entry>5</entry><entry>ipv4-address</entry><entry>false</entry></row>
  603. <row><entry>domain-name-servers</entry><entry>6</entry><entry>ipv4-address</entry><entry>true</entry></row>
  604. <row><entry>log-servers</entry><entry>7</entry><entry>ipv4-address</entry><entry>true</entry></row>
  605. <row><entry>cookie-servers</entry><entry>8</entry><entry>ipv4-address</entry><entry>true</entry></row>
  606. <row><entry>lpr-servers</entry><entry>9</entry><entry>ipv4-address</entry><entry>true</entry></row>
  607. <row><entry>impress-servers</entry><entry>10</entry><entry>ipv4-address</entry><entry>true</entry></row>
  608. <row><entry>resource-location-servers</entry><entry>11</entry><entry>ipv4-address</entry><entry>true</entry></row>
  609. <row><entry>host-name</entry><entry>12</entry><entry>string</entry><entry>false</entry></row>
  610. <row><entry>boot-size</entry><entry>13</entry><entry>uint16</entry><entry>false</entry></row>
  611. <row><entry>merit-dump</entry><entry>14</entry><entry>string</entry><entry>false</entry></row>
  612. <row><entry>domain-name</entry><entry>15</entry><entry>fqdn</entry><entry>false</entry></row>
  613. <row><entry>swap-server</entry><entry>16</entry><entry>ipv4-address</entry><entry>false</entry></row>
  614. <row><entry>root-path</entry><entry>17</entry><entry>string</entry><entry>false</entry></row>
  615. <row><entry>extensions-path</entry><entry>18</entry><entry>string</entry><entry>false</entry></row>
  616. <row><entry>ip-forwarding</entry><entry>19</entry><entry>boolean</entry><entry>false</entry></row>
  617. <row><entry>non-local-source-routing</entry><entry>20</entry><entry>boolean</entry><entry>false</entry></row>
  618. <row><entry>policy-filter</entry><entry>21</entry><entry>ipv4-address</entry><entry>true</entry></row>
  619. <row><entry>max-dgram-reassembly</entry><entry>22</entry><entry>uint16</entry><entry>false</entry></row>
  620. <row><entry>default-ip-ttl</entry><entry>23</entry><entry>uint8</entry><entry>false</entry></row>
  621. <row><entry>path-mtu-aging-timeout</entry><entry>24</entry><entry>uint32</entry><entry>false</entry></row>
  622. <row><entry>path-mtu-plateau-table</entry><entry>25</entry><entry>uint16</entry><entry>true</entry></row>
  623. <row><entry>interface-mtu</entry><entry>26</entry><entry>uint16</entry><entry>false</entry></row>
  624. <row><entry>all-subnets-local</entry><entry>27</entry><entry>boolean</entry><entry>false</entry></row>
  625. <row><entry>broadcast-address</entry><entry>28</entry><entry>ipv4-address</entry><entry>false</entry></row>
  626. <row><entry>perform-mask-discovery</entry><entry>29</entry><entry>boolean</entry><entry>false</entry></row>
  627. <row><entry>mask-supplier</entry><entry>30</entry><entry>boolean</entry><entry>false</entry></row>
  628. <row><entry>router-discovery</entry><entry>31</entry><entry>boolean</entry><entry>false</entry></row>
  629. <row><entry>router-solicitation-address</entry><entry>32</entry><entry>ipv4-address</entry><entry>false</entry></row>
  630. <row><entry>static-routes</entry><entry>33</entry><entry>ipv4-address</entry><entry>true</entry></row>
  631. <row><entry>trailer-encapsulation</entry><entry>34</entry><entry>boolean</entry><entry>false</entry></row>
  632. <row><entry>arp-cache-timeout</entry><entry>35</entry><entry>uint32</entry><entry>false</entry></row>
  633. <row><entry>ieee802-3-encapsulation</entry><entry>36</entry><entry>boolean</entry><entry>false</entry></row>
  634. <row><entry>default-tcp-ttl</entry><entry>37</entry><entry>uint8</entry><entry>false</entry></row>
  635. <row><entry>tcp-keepalive-interval</entry><entry>38</entry><entry>uint32</entry><entry>false</entry></row>
  636. <row><entry>tcp-keepalive-garbage</entry><entry>39</entry><entry>boolean</entry><entry>false</entry></row>
  637. </tbody>
  638. </tgroup>
  639. </table>
  640. </para>
  641. <para>
  642. <table frame="all" id="dhcp4-std-options-list-part2">
  643. <title>List of standard DHCPv4 options (continued)</title>
  644. <tgroup cols='4'>
  645. <colspec colname='name'/>
  646. <colspec colname='code'/>
  647. <colspec colname='type'/>
  648. <colspec colname='array'/>
  649. <thead>
  650. <row>
  651. <entry>Name</entry>
  652. <entry>Code</entry>
  653. <entry>Type</entry>
  654. <entry>Array?</entry>
  655. </row>
  656. </thead>
  657. <tbody>
  658. <row><entry>nis-domain</entry><entry>40</entry><entry>string</entry><entry>false</entry></row>
  659. <row><entry>nis-servers</entry><entry>41</entry><entry>ipv4-address</entry><entry>true</entry></row>
  660. <row><entry>ntp-servers</entry><entry>42</entry><entry>ipv4-address</entry><entry>true</entry></row>
  661. <row><entry>vendor-encapsulated-options</entry><entry>43</entry><entry>empty</entry><entry>false</entry></row>
  662. <row><entry>netbios-name-servers</entry><entry>44</entry><entry>ipv4-address</entry><entry>true</entry></row>
  663. <row><entry>netbios-dd-server</entry><entry>45</entry><entry>ipv4-address</entry><entry>true</entry></row>
  664. <row><entry>netbios-node-type</entry><entry>46</entry><entry>uint8</entry><entry>false</entry></row>
  665. <row><entry>netbios-scope</entry><entry>47</entry><entry>string</entry><entry>false</entry></row>
  666. <row><entry>font-servers</entry><entry>48</entry><entry>ipv4-address</entry><entry>true</entry></row>
  667. <row><entry>x-display-manager</entry><entry>49</entry><entry>ipv4-address</entry><entry>true</entry></row>
  668. <row><entry>dhcp-requested-address</entry><entry>50</entry><entry>ipv4-address</entry><entry>false</entry></row>
  669. <!-- Lease time should not be configured by a user.
  670. <row><entry>dhcp-lease-time</entry><entry>51</entry><entry>uint32</entry><entry>false</entry></row>
  671. -->
  672. <row><entry>dhcp-option-overload</entry><entry>52</entry><entry>uint8</entry><entry>false</entry></row>
  673. <!-- Message Type, Server Identifier and Parameter Request List should not be configured by a user.
  674. <row><entry>dhcp-message-type</entry><entry>53</entry><entry>uint8</entry><entry>false</entry></row>
  675. <row><entry>dhcp-server-identifier</entry><entry>54</entry><entry>ipv4-address</entry><entry>false</entry></row>
  676. <row><entry>dhcp-parameter-request-list</entry><entry>55</entry><entry>uint8</entry><entry>true</entry></row>
  677. -->
  678. <row><entry>dhcp-message</entry><entry>56</entry><entry>string</entry><entry>false</entry></row>
  679. <row><entry>dhcp-max-message-size</entry><entry>57</entry><entry>uint16</entry><entry>false</entry></row>
  680. <!-- Renewal and rebinding time should not be configured by a user.
  681. <row><entry>dhcp-renewal-time</entry><entry>58</entry><entry>uint32</entry><entry>false</entry></row>
  682. <row><entry>dhcp-rebinding-time</entry><entry>59</entry><entry>uint32</entry><entry>false</entry></row>
  683. -->
  684. <row><entry>vendor-class-identifier</entry><entry>60</entry><entry>binary</entry><entry>false</entry></row>
  685. <!-- Client identifier should not be configured by a user.
  686. <row><entry>dhcp-client-identifier</entry><entry>61</entry><entry>binary</entry><entry>false</entry></row>
  687. -->
  688. <row><entry>nwip-domain-name</entry><entry>62</entry><entry>string</entry><entry>false</entry></row>
  689. <row><entry>nwip-suboptions</entry><entry>63</entry><entry>binary</entry><entry>false</entry></row>
  690. <row><entry>tftp-server-name</entry><entry>66</entry><entry>string</entry><entry>false</entry></row>
  691. <row><entry>boot-file-name</entry><entry>67</entry><entry>string</entry><entry>false</entry></row>
  692. <row><entry>user-class</entry><entry>77</entry><entry>binary</entry><entry>false</entry></row>
  693. <row><entry>fqdn</entry><entry>81</entry><entry>record</entry><entry>false</entry></row>
  694. <row><entry>dhcp-agent-options</entry><entry>82</entry><entry>empty</entry><entry>false</entry></row>
  695. <row><entry>authenticate</entry><entry>90</entry><entry>binary</entry><entry>false</entry></row>
  696. <row><entry>client-last-transaction-time</entry><entry>91</entry><entry>uint32</entry><entry>false</entry></row>
  697. <row><entry>associated-ip</entry><entry>92</entry><entry>ipv4-address</entry><entry>true</entry></row>
  698. <row><entry>subnet-selection</entry><entry>118</entry><entry>ipv4-address</entry><entry>false</entry></row>
  699. <row><entry>domain-search</entry><entry>119</entry><entry>binary</entry><entry>false</entry></row>
  700. <row><entry>vivco-suboptions</entry><entry>124</entry><entry>binary</entry><entry>false</entry></row>
  701. <row><entry>vivso-suboptions</entry><entry>125</entry><entry>binary</entry><entry>false</entry></row>
  702. </tbody>
  703. </tgroup>
  704. </table>
  705. </para>
  706. <para>
  707. <table frame="all" id="dhcp-types">
  708. <title>List of standard DHCP option types</title>
  709. <tgroup cols='2'>
  710. <colspec colname='name'/>
  711. <colspec colname='meaning'/>
  712. <thead>
  713. <row><entry>Name</entry><entry>Meaning</entry></row>
  714. </thead>
  715. <tbody>
  716. <row><entry>binary</entry><entry>An arbitrary string of bytes, specified as a set of hexadecimal digits.</entry></row>
  717. <row><entry>boolean</entry><entry>Boolean value with allowed values true or false</entry></row>
  718. <row><entry>empty</entry><entry>No value, data is carried in suboptions</entry></row>
  719. <row><entry>fqdn</entry><entry>Fully qualified domain name (e.g. www.example.com)</entry></row>
  720. <row><entry>ipv4-address</entry><entry>IPv4 address in the usual dotted-decimal notation (e.g. 192.0.2.1)</entry></row>
  721. <row><entry>ipv6-address</entry><entry>IPv6 address in the usual colon notation (e.g. 2001:db8::1)</entry></row>
  722. <row><entry>record</entry><entry>Structured data that may comprise any types (except "record" and "empty")</entry></row>
  723. <row><entry>string</entry><entry>Any text</entry></row>
  724. <row><entry>uint8</entry><entry>8 bit unsigned integer with allowed values 0 to 255</entry></row>
  725. <row><entry>uint16</entry><entry>16 bit unsigned integer with allowed values 0 to 65535</entry></row>
  726. <row><entry>uint32</entry><entry>32 bit unsigned integer with allowed values 0 to 4294967295</entry></row>
  727. </tbody>
  728. </tgroup>
  729. </table>
  730. </para>
  731. </section>
  732. <section id="dhcp4-custom-options">
  733. <title>Custom DHCPv4 options</title>
  734. <para>Kea supports custom (non-standard) DHCPv4 options. Assume
  735. that we want to define a new DHCPv4 option called "foo" which
  736. will have code 222 and will convey a single unsigned 32 bit
  737. integer value. We can define such an option by using the
  738. following entry in the configuration file:
  739. <screen>
  740. "Dhcp4": {
  741. "option-def": [
  742. {
  743. <userinput>"name": "foo",
  744. "code": 222,
  745. "type": "uint32",
  746. "array": false,
  747. "record-types": "",
  748. "space": "dhcp4",
  749. "encapsulate": ""</userinput>
  750. }, ...
  751. ],
  752. ...
  753. }
  754. </screen>
  755. The <command>false</command> value of the <command>array</command>
  756. parameter determines that the option does NOT comprise an array of
  757. "uint32" values but rather a single value. Two other parameters have been
  758. left blank: <command>record-types</command> and
  759. <command>encapsulate</command>. The former specifies the comma separated
  760. list of option data fields if the option comprises a record of data
  761. fields. This should be non-empty if the <command>type</command> is set to
  762. "record". Otherwise it must be left blank. The latter parameter specifies
  763. the name of the option space being encapsulated by the particular
  764. option. If the particular option does not encapsulate any option space it
  765. should be left blank. Note that the above set of comments define the
  766. format of the new option and do not set its values.
  767. </para>
  768. <note>
  769. <para>
  770. In the current release the default values are not propagated to the
  771. parser when the new configuration is being set. Therefore, all
  772. parameters must be specified at all times, even if their values are
  773. left blank.
  774. </para>
  775. </note>
  776. <para>Once the new option format is defined, its value is set
  777. in the same way as for a standard option. For example the following
  778. commands set a global value that applies to all subnets.
  779. <screen>
  780. "Dhcp4": {
  781. "option-data": [
  782. {
  783. <userinput>name "foo",
  784. "code": 222,
  785. "space": "dhcp4",
  786. "csv-format": true,
  787. "data": "12345"</userinput>
  788. }, ...
  789. ],
  790. ...
  791. }
  792. </screen>
  793. </para>
  794. <para>New options can take more complex forms than simple use of
  795. primitives (uint8, string, ipv4-address etc): it is possible to
  796. define an option comprising a number of existing primitives.
  797. Assume we want to define a new option that will consist of
  798. an IPv4 address, followed by unsigned 16 bit integer, followed by
  799. a boolean value, followed by a text string. Such an option could
  800. be defined in the following way:
  801. <screen>
  802. "Dhcp4": {
  803. "option-def": [
  804. {
  805. <userinput>"name": "bar",
  806. "code": 223,
  807. "space": "dhcp4",
  808. "type": "record",
  809. "array": false,
  810. "record-types": "ipv4-address, uint16, boolean, string",
  811. "encapsulate": ""</userinput>
  812. }, ...
  813. ],
  814. ...
  815. }
  816. </screen>
  817. The <command>type</command> is set to "record" to indicate that the option contains
  818. multiple values of different types. These types are given as a comma-separated
  819. list in the <command>record-types</command> field and should be those listed in <xref linkend="dhcp-types"/>.
  820. </para>
  821. <para>
  822. The values of the option are set as follows:
  823. <screen>
  824. "Dhcp4": {
  825. "option-data": [
  826. {
  827. <userinput>"name": "bar",
  828. "space": "dhcp4",
  829. "code": 223,
  830. "csv-format": true,
  831. "data": "192.0.2.100, 123, true, Hello World"</userinput>
  832. }
  833. ],
  834. ...
  835. }</screen>
  836. <command>csv-format</command> is set <command>true</command> to indicate
  837. that the <command>data</command> field comprises a command-separated list
  838. of values. The values in the <command>data</command> must correspond to
  839. the types set in the <command>record-types</command> field of the option
  840. definition.
  841. </para>
  842. <note>
  843. <para>In general case, boolean values are specified as <command>true</command> or
  844. <command>false</command>, without quotes. Some specific boolean parameters may
  845. accept also <command>"true"</command>, <command>"false"</command>,
  846. <command>0</command>, <command>1</command>, <command>"0"</command> and
  847. <command>"1"</command>. Future Kea versions will accept all those values
  848. for all boolean parameters.</para>
  849. </note>
  850. </section>
  851. <section id="dhcp4-vendor-opts">
  852. <title>DHCPv4 Vendor Specific Options</title>
  853. <para>
  854. Currently there are three option spaces defined: "dhcp4" (used by the DHCPv4 daemon)
  855. and "dhcp6" (for the DHCPv6 daemon); there is also "vendor-encapsulated-options-space",
  856. which is empty by default, but options
  857. can be defined in it. Those options are called vendor-specific
  858. information options. The following examples show how to define
  859. an option "foo" with code 1 that consists of an IPv4 address, an
  860. unsigned 16 bit integer and a string. The "foo" option is conveyed
  861. in a vendor specific information option.
  862. </para>
  863. <para>
  864. The first step is to define the format of the option:
  865. <screen>
  866. "Dhcp4": {
  867. "option-def": [
  868. {
  869. <userinput>"name": "foo",
  870. "code": 1,
  871. "space": "vendor-encapsulated-options-space",
  872. "type": "record",
  873. "array": false,
  874. "record-types": "ipv4-address, uint16, string",
  875. "encapsulates": ""</userinput>
  876. }
  877. ],
  878. ...
  879. }</screen>
  880. (Note that the option space is set to "vendor-encapsulated-options-space".)
  881. Once the option format is defined, the next step is to define actual values
  882. for that option:
  883. <screen>
  884. "Dhcp4": {
  885. "option-data": [
  886. {
  887. <userinput>"name": "foo"
  888. "space": "vendor-encapsulated-options-space",
  889. "code": 1,
  890. "csv-format": true,
  891. "data": "192.0.2.3, 123, Hello World"</userinput>
  892. }
  893. ],
  894. ...
  895. }</screen>
  896. We also set up a dummy value for "vendor-encapsulated-options", the option that conveys our sub-option "foo".
  897. This is required else the option will not be included in messages sent to the client.
  898. <screen>
  899. "Dhcp4": {
  900. "option-data": [
  901. {
  902. <userinput>"name": "vendor-encapsulated-options"
  903. "space": "dhcp4",
  904. "code": 43,
  905. "csv-format": false,
  906. "data": ""</userinput>
  907. }
  908. ],
  909. ...
  910. }</screen>
  911. </para>
  912. <note>
  913. <para>
  914. With this version of Kea, the "vendor-encapsulated-options" option
  915. must be specified in the configuration although it has no configurable
  916. parameters. If it is not specified, the server will assume that it is
  917. not configured and will not send it to a client. In the future there
  918. will be no need to include this option in the configuration.
  919. </para>
  920. </note>
  921. </section>
  922. <section id="dhcp4-option-spaces">
  923. <title>Nested DHCPv4 Options (Custom Option Spaces)</title>
  924. <para>It is sometimes useful to define completely new option
  925. space. This is the case when user creates new option in the
  926. standard option space ("dhcp4 or "dhcp6") and wants this option
  927. to convey sub-options. Since they are in a separate space,
  928. sub-option codes will have a separate numbering scheme and may
  929. overlap with the codes of standard options.
  930. </para>
  931. <para>Note that creation of a new option space when defining
  932. sub-options for a standard option is not required, because it is
  933. created by default if the standard option is meant to convey any
  934. sub-options (see <xref linkend="dhcp4-vendor-opts"/>).
  935. </para>
  936. <para>
  937. Assume that we want to have a DHCPv4 option called "container" with
  938. code 222 that conveys two sub-options with codes 1 and 2.
  939. First we need to define the new sub-options:
  940. <screen>
  941. "Dhcp4": {
  942. "option-def": [
  943. {
  944. <userinput>"name": "subopt1",
  945. "code": 1,
  946. "space": "isc",
  947. "type": "ipv4-address".
  948. "record-types": "",
  949. "array": false,
  950. "encapsulate ""
  951. },
  952. {
  953. "name": "subopt2",
  954. "code": 2,
  955. "space": "isc",
  956. "type": "string",
  957. "record-types": "",
  958. "array": false
  959. "encapsulate": ""</userinput>
  960. }
  961. ],
  962. ...
  963. }</screen>
  964. Note that we have defined the options to belong to a new option space
  965. (in this case, "isc").
  966. </para>
  967. <para>
  968. The next step is to define a regular DHCPv4 option with our desired
  969. code and specify that it should include options from the new option space:
  970. <screen>
  971. "Dhcp4": {
  972. "option-def": [
  973. ...,
  974. {
  975. <userinput>"name": "container",
  976. "code": 222,
  977. "space": "dhcp4",
  978. "type": "empty",
  979. "array": false,
  980. "record-types": "",
  981. "encapsulate": "isc"</userinput>
  982. }
  983. ],
  984. ...
  985. }</screen>
  986. The name of the option space in which the sub-options are defined
  987. is set in the "encapsulate" field. The "type" field is set to "empty"
  988. to indicate that this option does not carry any data other than
  989. sub-options.
  990. </para>
  991. <para>
  992. Finally, we can set values for the new options:
  993. <screen>
  994. "Dhcp4": {
  995. "option-data": [
  996. {
  997. <userinput>"name": "subopt1",
  998. "space": "isc",
  999. "code": 1,
  1000. "csv-format": true,
  1001. "data": "192.0.2.3"</userinput>
  1002. },
  1003. }
  1004. <userinput>"name": "subopt2",
  1005. "space": "isc",
  1006. "code": 2,
  1007. "csv-format": true,
  1008. "data": "Hello world"</userinput>
  1009. },
  1010. {
  1011. <userinput>"name": "container",
  1012. "space": "dhcp4",
  1013. "code": 222,
  1014. "csv-format": true,
  1015. "data": ""</userinput>
  1016. }
  1017. ],
  1018. ...
  1019. }
  1020. </screen>
  1021. Even though the "container" option does not carry any data except
  1022. sub-options, the "data" field must be explicitly set to an empty value.
  1023. This is required because in the current version of Kea, the
  1024. default configuration values are not propagated to the configuration parsers:
  1025. if the "data" is not set the parser will assume that this
  1026. parameter is not specified and an error will be reported.
  1027. </para>
  1028. <para>Note that it is possible to create an option which carries some data
  1029. in addition to the sub-options defined in the encapsulated option space. For example,
  1030. if the "container" option from the previous example was required to carry an uint16
  1031. value as well as the sub-options, the "type" value would have to be set to "uint16" in
  1032. the option definition. (Such an option would then have the following
  1033. data structure: DHCP header, uint16 value, sub-options.) The value specified
  1034. with the "data" parameter &mdash; which should be a valid integer enclosed in quotes,
  1035. e.g. "123" &mdash; would then be assigned to the uint16 field in the "container" option.
  1036. </para>
  1037. </section>
  1038. <section id="dhcp4-option-data-defaults">
  1039. <title>Unspecified parameters for DHCPv4 option configuration</title>
  1040. <para>In many cases it is not required to specify all parameters for
  1041. an option configuration and the default values may be used. However, it is
  1042. important to understand the implications of not specifing some of them
  1043. as it may result in configuration errors. The list below explains
  1044. the behavior of the server when a particular parameter is not explicitly
  1045. specified:
  1046. <itemizedlist>
  1047. <listitem>
  1048. <simpara><command>name</command> - the server requires an option name or
  1049. option code to identify an option. If this parameter is unspecified, the
  1050. option code must be specified.
  1051. </simpara>
  1052. </listitem>
  1053. <listitem>
  1054. <simpara><command>code</command> - the server requires an option name or
  1055. option code to identify an option. This parameter may be left unspecified if
  1056. the <command>name</command> parameter is specified. However, this also
  1057. requires that the particular option has its definition (it is either a
  1058. standard option or an administrator created a definition for the option
  1059. using an 'option-def' structure), as the option definition associates an
  1060. option with a particular name. It is possible to configure an option
  1061. for which there is no definition (unspecified option format).
  1062. Configuration of such options requires the use of option code.
  1063. </simpara>
  1064. </listitem>
  1065. <listitem>
  1066. <simpara><command>space</command> - if the option space is unspecified it
  1067. will default to 'dhcp4' which is an option space holding DHCPv4 standard
  1068. options.
  1069. </simpara>
  1070. </listitem>
  1071. <listitem>
  1072. <simpara><command>data</command> - if the option data is unspecified it
  1073. defaults to an empty value. The empty value is mostly used for the
  1074. options which have no payload (boolean options), but it is legal to specify
  1075. empty values for some options which carry variable length data and which
  1076. spec allows for the length of 0. For such options, the data parameter
  1077. may be omitted in the configuration.</simpara>
  1078. </listitem>
  1079. <listitem>
  1080. <simpara><command>csv-format</command> - if this value is not specified
  1081. and the definition for the particular option exists, the server will assume
  1082. that the option data is specified as a list of comma separated values to be
  1083. assigned to individual fields of the DHCP option. If the definition
  1084. does not exist for this option, the server will assume that the data
  1085. parameter contains the option payload in the binary format (represented
  1086. as a string of hexadecimal digits). Note that not specifying this
  1087. parameter doesn't imply that it defaults to a fixed value, but
  1088. the configuration data interpretation also depends on the presence
  1089. of the option definition. An administrator must be aware if the
  1090. definition for the particular option exists when this parameter
  1091. is not specified. It is generally recommended to not specify this
  1092. parameter only for the options for which the definition exists, e.g.
  1093. standard options. Setting <command>csv-format</command> to an explicit
  1094. value will cause the server to strictly check the format of the option
  1095. data specified.
  1096. </simpara>
  1097. </listitem>
  1098. </itemizedlist>
  1099. </para>
  1100. </section>
  1101. <section id="dhcp4-stateless-configuration">
  1102. <title>Stateless Configuration of DHCPv4 clients</title>
  1103. <para>The DHCPv4 server supports the stateless client configuration whereby the
  1104. client has an IP address configured (e.g. using manual configuration) and only
  1105. contacts the server to obtain other configuration parameters, e.g. DNS servers' addresses.
  1106. In order to obtain the stateless configuration parameters the client sends the
  1107. DHCPINFORM message to the server with the "ciaddr" set to the address that the
  1108. client is currently using. The server unicasts the DHCPACK message to the
  1109. client that includes the stateless configuration ("yiaddr" not set).
  1110. </para>
  1111. <para>The server will respond to the DHCPINFORM when the client is associated
  1112. with the particular subnet defined in the server's configuration. The example
  1113. subnet configuration will look like this:
  1114. <screen>
  1115. "Dhcp4": {
  1116. "subnet4": [
  1117. {
  1118. "subnet": "192.0.2.0/24"
  1119. "option-data": [ {"
  1120. "name": "domain-name-servers",
  1121. "code": 6,
  1122. "data": "192.0.2.200,192.0.2.201",
  1123. "csv-format": true,
  1124. "space": "dhcp4"
  1125. } ]
  1126. }
  1127. ]
  1128. }</screen>
  1129. </para>
  1130. <para>This subnet specifies the single option which will be included in
  1131. the DHCPACK message to the client in response to DHCPINFORM. Note that
  1132. the subnet definition does not require the address pool configuration
  1133. if it will be used solely for the stateless configuration.
  1134. </para>
  1135. <para>This server will associate the subnet with the client if one of
  1136. the following conditions is met:
  1137. <itemizedlist>
  1138. <listitem>
  1139. <simpara>The DHCPINFORM is relayed and the giaddr matches the
  1140. configured subnet.</simpara>
  1141. </listitem>
  1142. <listitem>
  1143. <simpara>The DHCPINFORM is unicast from the client and the ciaddr
  1144. matches the configured subnet.</simpara>
  1145. </listitem>
  1146. <listitem>
  1147. <simpara>The DHCPINFORM is unicast from the client, the ciaddr is
  1148. not set but the source address of the IP packet matches the
  1149. configured subnet.</simpara>
  1150. </listitem>
  1151. <listitem>
  1152. <simpara>The DHCPINFORM is not relayed and the IP address on the
  1153. interface on which the message is received matches the configured
  1154. subnet.</simpara>
  1155. </listitem>
  1156. </itemizedlist>
  1157. </para>
  1158. </section>
  1159. <section id="dhcp4-client-classifier">
  1160. <title>Client Classification in DHCPv4</title>
  1161. <note>
  1162. <para>
  1163. The DHCPv4 server has been extended to support limited client classification.
  1164. Although the current capability is modest, it is expected to be expanded
  1165. in the future. However, it is envisaged that the majority of client classification
  1166. extensions will be using hooks extensions.
  1167. </para>
  1168. </note>
  1169. <para>In certain cases it is useful to differentiate between different
  1170. types of clients and treat them differently. The process of doing
  1171. classification is conducted in two steps. The first step is to assess
  1172. incoming packet and assign it to zero or more classes. This classification
  1173. is currently simple, but is expected to grow in capability soon. Currently
  1174. the server checks whether incoming packet has vendor class identifier
  1175. option (60). If it has, content of that option is prepended with
  1176. &quot;VENDOR_CLASS_&quot; then is interpreted as a class. For example,
  1177. modern cable modems will send this option with value &quot;docsis3.0&quot;
  1178. and as a result the packet will belong to class &quot;VENDOR_CLASS_docsis3.0&quot;.
  1179. </para>
  1180. <para>It is envisaged that the client classification will be used for changing the
  1181. behavior of almost any part of the DHCP message processing, including assigning
  1182. leases from different pools, assigning different option (or different values of
  1183. the same options) etc. For now, there are only two mechanisms that are taking
  1184. advantage of client classification: specific processing for cable modems and
  1185. subnet selection.</para>
  1186. <para>
  1187. For clients that belong to the VENDOR_CLASS_docsis3.0 class, the siaddr
  1188. field is set to the value of next-server (if specified in a subnet). If
  1189. there is boot-file-name option specified, its value is also set in the
  1190. file field in the DHCPv4 packet. For eRouter1.0 class, the siaddr is
  1191. always set to 0.0.0.0. That capability is expected to be moved to
  1192. external hook library that will be dedicated to cable modems.
  1193. </para>
  1194. <para>
  1195. Kea can be instructed to limit access to given subnets based on class information.
  1196. This is particularly useful for cases where two types of devices share the
  1197. same link and are expected to be served from two different subnets. The
  1198. primary use case for such a scenario is cable networks. There are two
  1199. classes of devices: the cable modem itself, which should be handled a lease
  1200. from subnet A and all other devices behind the modem that should get a lease
  1201. from subnet B. That segregation is essential to prevent overly curious
  1202. users from playing with their cable modems. For details on how to set up
  1203. class restrictions on subnets, see <xref linkend="dhcp4-subnet-class"/>.
  1204. </para>
  1205. <section id="dhcp4-subnet-class">
  1206. <title>Limiting Access to IPv4 Subnet to Certain Classes</title>
  1207. <para>
  1208. In certain cases it beneficial to restrict access to certain subnets
  1209. only to clients that belong to a given subnet. For details on client
  1210. classes, see <xref linkend="dhcp4-client-classifier"/>. This is an
  1211. extension of a previous example from <xref linkend="dhcp4-address-config"/>.
  1212. Let's assume that the server is connected to a network segment that uses
  1213. the 192.0.2.0/24 prefix. The Administrator of that network has decided
  1214. that addresses from range 192.0.2.10 to 192.0.2.20 are going to be
  1215. managed by the Dhcp4 server. Only clients belonging to client class
  1216. VENDOR_CLASS_docsis3.0 are allowed to use this subnet. Such a
  1217. configuration can be achieved in the following way:
  1218. <screen>
  1219. "Dhcp4": {
  1220. "subnet4": [
  1221. {
  1222. <userinput>"subnet": "192.0.2.0/24",
  1223. "pools": [ { "pool": "192.0.2.10 - 192.0.2.20" } ],
  1224. "client-class": "VENDOR_CLASS_docsis3.0"</userinput>
  1225. }
  1226. ],
  1227. ...
  1228. }</screen>
  1229. </para>
  1230. <para>
  1231. Care should be taken with client classification as it is easy to prevent
  1232. clients that do not meet class criteria to be denied any service altogether.
  1233. </para>
  1234. </section>
  1235. </section>
  1236. <section id="dhcp4-ddns-config">
  1237. <title>Configuring DHCPv4 for DDNS</title>
  1238. <para>
  1239. As mentioned earlier, kea-dhcp4 can be configured to generate requests to the
  1240. DHCP-DDNS server to update DNS entries. These requests are known as
  1241. NameChangeRequests or NCRs. Each NCR contains the following information:
  1242. <orderedlist>
  1243. <listitem><para>
  1244. Whether it is a request to add (update) or remove DNS entries
  1245. </para></listitem>
  1246. <listitem><para>
  1247. Whether the change requests forward DNS updates (A records), reverse
  1248. DNS updates (PTR records), or both.
  1249. </para></listitem>
  1250. <listitem><para>
  1251. The FQDN, lease address, and DHCID
  1252. </para></listitem>
  1253. </orderedlist>
  1254. The parameters for controlling the generation of NCRs for submission to the
  1255. DHCP-DDNS server
  1256. are contained in the <command>dhcp-ddns</command> section of the kea-dhcp4 server
  1257. configuration. The default values for this section are as follows:
  1258. <screen>
  1259. "Dhcp4": {
  1260. "dhcp-ddns": {
  1261. <userinput>"enable-updates": true,
  1262. "server-ip": "127.0.0.1",
  1263. "server-port": 53001,
  1264. "sender-ip": "",
  1265. "sender-port": 0,
  1266. "max-queue-size": 1024,
  1267. "ncr-protocol": "UDP",
  1268. "ncr-format": "JSON",
  1269. "override-no-update": false,
  1270. "override-client-update": false,
  1271. "replace-client-name": false,
  1272. "generated-prefix": "myhost",
  1273. "qualifying-suffix": "example.com"</userinput>
  1274. },
  1275. ...
  1276. }
  1277. </screen>
  1278. </para>
  1279. <section id="dhcpv4-d2-io-config">
  1280. <title>DHCP-DDNS Server Connectivity</title>
  1281. <para>
  1282. In order for NCRs to reach the DHCP-DDNS server, kea-dhcp4 must be able
  1283. to communicate with it. kea-dhcp4 uses the following configuration
  1284. parameters to control how it communications with DHCP-DDNS:
  1285. <itemizedlist>
  1286. <listitem><simpara>
  1287. <command>enable-updates</command> - determines whether or not kea-dhcp4 will
  1288. generate NCRs. By default, this value is false hence DDNS updates are
  1289. disabled. To enable DDNS updates set this value to true:
  1290. </simpara></listitem>
  1291. <listitem><simpara>
  1292. <command>server-ip</command> - IP address on which DHCP-DDNS listens for requests. The default is
  1293. the local loopback interface at address 127.0.0.1. You may specify
  1294. either an IPv4 or IPv6 address.
  1295. </simpara></listitem>
  1296. <listitem><simpara>
  1297. <command>server-port</command> - port on which DHCP-DDNS listens for requests. The default value
  1298. is 53001.
  1299. </simpara></listitem>
  1300. <listitem><simpara>
  1301. <command>sender-ip</command> - IP address which kea-dhcp4 should use to send requests to the DHCP-DDNS server.
  1302. The default value is blank which instructs kea-dhcp4 to select a suitable
  1303. address.
  1304. </simpara></listitem>
  1305. <listitem><simpara>
  1306. <command>sender-port</command> - port which kea-dhcp4 should use to send requests to the DHCP-DDNS server. The
  1307. default value of 0 instructs kea-dhcp4 to select suitable port.
  1308. </simpara></listitem>
  1309. <listitem><simpara>
  1310. <command>max-queue-size</command> - maximum number of requests allowed to queue waiting to
  1311. be sent to the DHCP-DDNS server. This value guards against requests accumulating
  1312. uncontrollably if they are being generated faster than they can be
  1313. delivered. If the number of requests queued for transmission reaches
  1314. this value, DDNS updating will be turned off until the queue backlog has
  1315. been sufficiently reduced. The intention is allow the kea-dhcp4 server to
  1316. continue lease operations without running the risk that its memory usage
  1317. grows without limit. The default value is 1024.
  1318. </simpara></listitem>
  1319. <listitem><simpara>
  1320. <command>ncr-format</command> - socket protocol use when sending requests to the DHCP-DDNS server. Currently
  1321. only UDP is supported. TCP may be available in an upcoming release.
  1322. </simpara></listitem>
  1323. <listitem><simpara>
  1324. <command>ncr-protocol</command> - packet format to use when sending requests to the DHCP-DDNS server.
  1325. Currently only JSON format is supported. Other formats may be available
  1326. in future releases.
  1327. </simpara></listitem>
  1328. </itemizedlist>
  1329. By default, the DHCP-DDNS server is assumed to running on the same machine as kea-dhcp4, and
  1330. all of the default values mentioned above should be sufficient.
  1331. If, however, the DHCP-DDNS server has been configured to listen on a different address or
  1332. port, these values must altered accordingly. For example, if the DHCP-DDNS server has been
  1333. configured to listen on 192.168.1.10 port 900, the following configuration
  1334. would be required:
  1335. <screen>
  1336. "Dhcp4": {
  1337. "dhcp-ddns": {
  1338. <userinput>"server-ip": "192.168.1.10",
  1339. "server-port": 900</userinput>,
  1340. ...
  1341. },
  1342. ...
  1343. }
  1344. </screen>
  1345. </para>
  1346. </section>
  1347. <section id="dhcpv4-d2-rules-config">
  1348. <title>When Does the kea-dhcp4 Server Generate DDNS Requests?</title>
  1349. <para>kea-dhcp4 follows the behavior prescribed for DHCP servers in
  1350. <ulink url="http://tools.ietf.org/html/rfc4702">RFC 4702</ulink>.
  1351. It is important to keep in mind that kea-dhcp4 provides the initial decision
  1352. making of when and what to update and forwards that information to the DHCP-DDNS server in
  1353. the form of NCRs. Carrying out the actual DNS updates and dealing with
  1354. such things as conflict resolution are within the purview of the DHCP-DDNS server itself (<xref linkend="dhcp-ddns-server"/>).
  1355. This section describes when kea-dhcp4 will generate NCRs and the
  1356. configuration parameters that can be used to influence this decision.
  1357. It assumes that the "enable-updates" parameter is true.
  1358. </para>
  1359. <para>
  1360. In general, kea-dhcp4 will generate DDNS update requests when:
  1361. <orderedlist>
  1362. <listitem><para>
  1363. A new lease is granted in response to a DHCP REQUEST
  1364. </para></listitem>
  1365. <listitem><para>
  1366. An existing lease is renewed but the FQDN associated with it has
  1367. changed.
  1368. </para></listitem>
  1369. <listitem><para>
  1370. An existing lease is released in response to a DHCP RELEASE
  1371. </para></listitem>
  1372. </orderedlist>
  1373. In the second case, lease renewal, two DDNS requests will be issued: one
  1374. request to remove entries for the previous FQDN and a second request to
  1375. add entries for the new FQDN. In the last case, a lease release, a
  1376. single DDNS request to remove its entries will be made. The decision
  1377. making involved when granting a new lease (the first case) is more
  1378. involved and is discussed next.
  1379. </para>
  1380. <para>
  1381. When a new lease is granted, kea-dhcp4 will generate a DDNS
  1382. update request if the DHCP REQUEST contains either the FQDN option
  1383. (code 81) or the Host Name option (code 12). If both are present,
  1384. the server will use the FQDN option. By default kea-dhcp4
  1385. will respect the FQDN N and S flags specified by the client as shown
  1386. in the following table:
  1387. </para>
  1388. <table id="fqdn-flag-table">
  1389. <title>Default FQDN Flag Behavior</title>
  1390. <tgroup cols='4' align='left'>
  1391. <colspec colname='cflags'/>
  1392. <colspec colname='meaning'/>
  1393. <colspec colname='response'/>
  1394. <colspec colname='sflags'/>
  1395. <thead>
  1396. <row>
  1397. <entry>Client Flags:N-S</entry>
  1398. <entry>Client Intent</entry>
  1399. <entry>Server Response</entry>
  1400. <entry>Server Flags:N-S-O</entry>
  1401. </row>
  1402. </thead>
  1403. <tbody>
  1404. <row>
  1405. <entry>0-0</entry>
  1406. <entry>
  1407. Client wants to do forward updates, server should do reverse updates
  1408. </entry>
  1409. <entry>Server generates reverse-only request</entry>
  1410. <entry>1-0-0</entry>
  1411. </row>
  1412. <row>
  1413. <entry>0-1</entry>
  1414. <entry>Server should do both forward and reverse updates</entry>
  1415. <entry>Server generates request to update both directions</entry>
  1416. <entry>0-1-0</entry>
  1417. </row>
  1418. <row>
  1419. <entry>1-0</entry>
  1420. <entry>Client wants no updates done</entry>
  1421. <entry>Server does not generate a request</entry>
  1422. <entry>1-0-0</entry>
  1423. </row>
  1424. </tbody>
  1425. </tgroup>
  1426. </table>
  1427. <para>
  1428. The first row in the table above represents "client delegation". Here
  1429. the DHCP client states that it intends to do the forward DNS updates and
  1430. the server should do the reverse updates. By default, kea-dhcp4 will honor
  1431. the client's wishes and generate a DDNS request to the DHCP-DDNS server to update only
  1432. reverse DNS data. The parameter <command>override-client-update</command> can be used
  1433. to instruct the server to override client delegation requests. When
  1434. this parameter is true, kea-dhcp4 will disregard requests for client
  1435. delegation and generate a DDNS request to update both forward and
  1436. reverse DNS data. In this case, the N-S-O flags in the server's
  1437. response to the client will be 0-1-1 respectively.
  1438. </para>
  1439. <para>
  1440. (Note that the flag combination N=1, S=1 is prohibited according to
  1441. <ulink utl="http://tools.ietf.org/html/rfc4702">RFC 4702</ulink>. If such a combination is received from the client, the packet
  1442. will be dropped by kea-dhcp4.)
  1443. </para>
  1444. <para>
  1445. To override client delegation, set the following values in your configuration
  1446. file:
  1447. </para>
  1448. <screen>
  1449. "Dhcp4": {
  1450. "dhcp-ddns": {
  1451. <userinput>"override-client-update": true</userinput>,
  1452. ...
  1453. },
  1454. ...
  1455. }
  1456. </screen>
  1457. <para>
  1458. The third row in the table above describes the case in which the client
  1459. requests that no DNS updates be done. The parameter, <command>override-no-update</command>,
  1460. can be used to instruct the server to disregard the client's wishes. When
  1461. this parameter is true, kea-dhcp4 will generate DDNS update request to the DHCP-DDNS server
  1462. even if the client requests that no updates be done. The N-S-O flags in the
  1463. server's response to the client will be 0-1-1.
  1464. </para>
  1465. <para>
  1466. To override client delegation, the following values should be set in your configuration:
  1467. </para>
  1468. <screen>
  1469. "Dhcp4": {
  1470. "dhcp-ddns": {
  1471. <userinput>"override-no-update": true</userinput>,
  1472. ...
  1473. },
  1474. ...
  1475. }
  1476. </screen>
  1477. <para>
  1478. kea-dhcp4 will always generate DDNS update requests if the client request
  1479. only contains the Host Name option. In addition it will include an FQDN
  1480. option in the response to the client with the FQDN N-S-O flags set to
  1481. 0-1-0 respectively. The domain name portion of the FQDN option will be
  1482. the name submitted to D2 in the DDNS update request.
  1483. </para>
  1484. </section>
  1485. <section id="dhcpv4-fqdn-name-generation">
  1486. <title>kea-dhcp4 name generation for DDNS update requests</title>
  1487. <para>Each NameChangeRequest must of course include the fully qualified domain
  1488. name whose DNS entries are to be affected. kea-dhcp4 can be configured to
  1489. supply a portion or all of that name based upon what it receives from
  1490. the client in the DHCP REQUEST.</para>
  1491. <para>
  1492. The rules for determining the FQDN option are as follows:
  1493. <orderedlist>
  1494. <listitem><para>
  1495. If configured to do, so ignore the REQUEST contents and generate a
  1496. FQDN using a configurable prefix and suffix.
  1497. </para></listitem>
  1498. <listitem><para>
  1499. If the REQUEST contains the client FQDN option, the candidate
  1500. name is taken from there, otherwise it is taken from the Host Name option.
  1501. The candidate name may then be modified:
  1502. <orderedlist>
  1503. <listitem><para>
  1504. If the candidate name is a fully qualified domain name, use it.
  1505. </para></listitem>
  1506. <listitem><para>
  1507. If the candidate name is a partial (i.e. unqualified) name then
  1508. add a configurable suffix to the name and use the result as the FQDN.
  1509. </para></listitem>
  1510. <listitem><para>
  1511. If the candidate name is a empty, generate a FQDN using a
  1512. configurable prefix and suffix.
  1513. </para></listitem>
  1514. </orderedlist>
  1515. </para></listitem>
  1516. </orderedlist>
  1517. To instruct kea-dhcp4 to always generate the FQDN for a client, set the
  1518. parameter <command>replace-client-name</command> to true as follows:
  1519. </para>
  1520. <screen>
  1521. "Dhcp4": {
  1522. "dhcp-ddns": {
  1523. <userinput>"replace-client-name": true</userinput>,
  1524. ...
  1525. },
  1526. ...
  1527. }
  1528. </screen>
  1529. <para>
  1530. The prefix used in the generation of a FQDN is specified by the
  1531. <command>generated-prefix</command> parameter. The default value is "myhost". To alter
  1532. its value simply set it to the desired string:
  1533. </para>
  1534. <screen>
  1535. "Dhcp4": {
  1536. "dhcp-ddns": {
  1537. <userinput>"generated-prefix": "another.host"</userinput>,
  1538. ...
  1539. },
  1540. ...
  1541. }
  1542. </screen>
  1543. <para>
  1544. The suffix used when generating a FQDN or when qualifying a partial name
  1545. is specified by the <command>qualifying-suffix</command> parameter. There
  1546. is no default value. To set its value simply set it to the desired string:
  1547. </para>
  1548. <screen>
  1549. "Dhcp4": {
  1550. "dhcp-ddns": {
  1551. <userinput>"qualifying-suffix": "foo.example.org"</userinput>,
  1552. ...
  1553. },
  1554. ...
  1555. }
  1556. </screen>
  1557. </section>
  1558. <para>
  1559. When generating a name, kea-dhcp4 will construct name of the format:
  1560. </para>
  1561. <para>
  1562. [generated-prefix]-[address-text].[qualifying-suffix].
  1563. </para>
  1564. <para>
  1565. where address-text is simply the lease IP address converted to a
  1566. hyphenated string. For example, if lease address is 172.16.1.10 and
  1567. assuming default values for <command>generated-prefix</command> and <command>qualifying-suffix</command>, the
  1568. generated FQDN would be:
  1569. </para>
  1570. <para>
  1571. myhost-172-16-1-10.example.com.
  1572. </para>
  1573. </section>
  1574. <section id="dhcp4-next-server">
  1575. <title>Next Server (siaddr)</title>
  1576. <para>In some cases, clients want to obtain configuration from the TFTP server.
  1577. Although there is a dedicated option for it, some devices may use siaddr field
  1578. in the DHCPv4 packet for that purpose. That specific field can be configured
  1579. using <command>next-server</command> directive. It is possible to define it in global scope or
  1580. for a given subnet only. If both are defined, subnet value takes precedence.
  1581. The value in subnet can be set to 0.0.0.0, which means that <command>next-server</command> should
  1582. not be sent. It may also be set to empty string, which means the same as if
  1583. it was not defined at all, i.e. use the global value.
  1584. </para>
  1585. <screen>
  1586. "Dhcp4": {
  1587. <userinput>"next-server": "192.0.2.123"</userinput>,
  1588. ...,
  1589. "subnet4": {
  1590. [
  1591. <userinput>"next-server": "192.0.2.234"</userinput>,
  1592. ...
  1593. ]
  1594. }
  1595. }
  1596. </screen>
  1597. </section>
  1598. <section id="dhcp4-echo-client-id">
  1599. <title>Echoing Client-ID (RFC 6842)</title>
  1600. <para>The original DHCPv4 specification
  1601. (<ulink url="http://tools.ietf.org/html/rfc2131">RFC 2131</ulink>)
  1602. states that the DHCPv4
  1603. server must not send back client-id options when responding to
  1604. clients. However, in some cases that confused clients that did
  1605. not have MAC address or client-id; see
  1606. <ulink url="http://tools.ietf.org/html/rfc6842">RFC 6842</ulink>.
  1607. for details. That
  1608. behavior has changed with the publication of
  1609. <ulink url="http://tools.ietf.org/html/rfc6842">RFC 6842</ulink>.
  1610. which updated
  1611. <ulink url="http://tools.ietf.org/html/rfc2131">RFC 2131</ulink>.
  1612. That update now states that the server must
  1613. send client-id if client sent it. That is the default behaviour
  1614. that Kea offers. However, in some cases older devices that do
  1615. not support
  1616. <ulink url="http://tools.ietf.org/html/rfc6842">RFC 6842</ulink>.
  1617. may refuse to accept responses that include
  1618. client-id option. To enable backward compatibility, an optional
  1619. configuration parameter has been introduced. To configure it,
  1620. use the following configuration statement:</para>
  1621. <screen>
  1622. "Dhcp4": {
  1623. <userinput>"echo-client-id": false</userinput>,
  1624. ...
  1625. }
  1626. </screen>
  1627. </section>
  1628. </section> <!-- end of configuring kea-dhcp4 server section with many subsections -->
  1629. <section id="dhcp4-serverid">
  1630. <title>Server Identifier in DHCPv4</title>
  1631. <para>
  1632. The DHCPv4 protocol uses a "server identifier" to allow clients
  1633. to discriminate between several servers present on the same link: this
  1634. value is an IPv4 address of the server. The server chooses the IPv4 address
  1635. of the interface on which the message from the client (or relay) has been
  1636. received. A single server instance will use multiple server identifiers
  1637. if it is receiving queries on multiple interfaces.
  1638. </para>
  1639. <para>
  1640. Currently there is no mechanism to override the default server identifiers
  1641. by an administrator. In the future, the configuration mechanism will be used
  1642. to specify the custom server identifier.
  1643. </para>
  1644. </section>
  1645. <section id="dhcp4-subnet-selection">
  1646. <title>How the DHCPv4 Server Selects a Subnet for the Client</title>
  1647. <para>
  1648. The DHCPv4 server differentiates between the directly connected clients,
  1649. clients trying to renew leases and clients sending their messages through
  1650. relays. For the directly connected clients the server will check the
  1651. configuration of the interface on which the message has been received, and
  1652. if the server configuration doesn't match any configured subnet the
  1653. message is discarded.</para>
  1654. <para>Assuming that the server's interface is configured with the
  1655. IPv4 address 192.0.2.3, the server will only process messages received through
  1656. this interface from a directly connected client if there is a subnet
  1657. configured to which this IPv4 address belongs, e.g. 192.0.2.0/24.
  1658. The server will use this subnet to assign IPv4 address for the client.
  1659. </para>
  1660. <para>
  1661. The rule above does not apply when the client unicasts its message, i.e.
  1662. is trying to renew its lease. Such message is accepted through any
  1663. interface. The renewing client sets ciaddr to the currently used IPv4
  1664. address. The server uses this address to select the subnet for the client
  1665. (in particular, to extend the lease using this address).
  1666. </para>
  1667. <para>
  1668. If the message is relayed it is accepted through any interface. The giaddr
  1669. set by the relay agent is used to select the subnet for the client.
  1670. </para>
  1671. <para>
  1672. It is also possible to specify a relay IPv4 address for a given subnet. It
  1673. can be used to match incoming packets into a subnet in uncommon configurations,
  1674. e.g. shared subnets. See <xref linkend="dhcp4-relay-override"/> for details.
  1675. </para>
  1676. <note>
  1677. <para>The subnet selection mechanism described in this section is based
  1678. on the assumption that client classification is not used. The classification
  1679. mechanism alters the way in which subnet is selected for the client,
  1680. depending on the classes that the client belongs to.</para>
  1681. </note>
  1682. <section id="dhcp4-relay-override">
  1683. <title>Using a Specific Relay Agent for a Subnet</title>
  1684. <para>
  1685. The relay has to have an interface connected to the link on which
  1686. the clients are being configured. Typically the relay has an IPv4
  1687. address configured on that interface that belongs to the subnet that
  1688. the server will assign addresses from. In such typical case, the
  1689. server is able to use IPv4 address inserted by the relay (in the giaddr
  1690. field of the DHCPv4 packet) to select the appropriate subnet.
  1691. </para>
  1692. <para>
  1693. However, that is not always the case. In certain uncommon &mdash;
  1694. valid &mdash; deployments, the relay address may not match the subnet. This
  1695. usually means that there is more than one subnet allocated for a given
  1696. link. The two most common examples where this is the case are long lasting
  1697. network renumbering (where both old and new address space is still being
  1698. used) and a cable network. In a cable network both cable modems and the
  1699. devices behind them are physically connected to the same link, yet
  1700. they use distinct addressing. In such case, the DHCPv4 server needs
  1701. additional information (the IPv4 address of the relay) to properly select
  1702. an appropriate subnet.
  1703. </para>
  1704. <para>
  1705. The following example assumes that there is a subnet 192.0.2.0/24
  1706. that is accessible via relay that uses 10.0.0.1 as its IPv4 address.
  1707. The server will be able to select this subnet for any incoming packets
  1708. that came from a relay that has an address in 192.0.2.0/24 subnet.
  1709. It will also select that subnet for a relay with address 10.0.0.1.
  1710. <screen>
  1711. "Dhcp4": {
  1712. "subnet4": [
  1713. {
  1714. "subnet": "192.0.2.0/24",
  1715. "pools": [ { "pool": "192.0.2.10 - 192.0.2.20" } ],
  1716. <userinput>"relay": {
  1717. "ip-address": "10.0.0.1"
  1718. }</userinput>,
  1719. ...
  1720. }
  1721. ],
  1722. ...
  1723. }
  1724. </screen>
  1725. </para>
  1726. </section>
  1727. <section id="dhcp4-srv-example-client-class-relay">
  1728. <title>Segregating IPv4 Clients in a Cable Network</title>
  1729. <para>
  1730. In certain cases, it is useful to mix relay address information,
  1731. introduced in <xref linkend="dhcp4-relay-override"/> with client
  1732. classification, explained in <xref linkend="dhcp4-subnet-class"/>.
  1733. One specific example is cable network, where typically modems
  1734. get addresses from a different subnet than all devices connected
  1735. behind them.
  1736. </para>
  1737. <para>
  1738. Let's assume that there is one CMTS (Cable Modem Termination System)
  1739. with one CM MAC (a physical link that modems are connected to).
  1740. We want the modems to get addresses from the 10.1.1.0/24 subnet, while
  1741. everything connected behind modems should get addresses from another
  1742. subnet (192.0.2.0/24). The CMTS that acts as a relay uses address
  1743. 10.1.1.1. The following configuration can serve that configuration:
  1744. <screen>
  1745. "Dhcp4": {
  1746. "subnet4": [
  1747. {
  1748. "subnet": "10.1.1.0/24",
  1749. "pools": [ { "pool": "10.1.1.2 - 10.1.1.20" } ],
  1750. <userinput>"client-class" "docsis3.0",
  1751. "relay": {
  1752. "ip-address": "10.1.1.1"
  1753. }</userinput>
  1754. },
  1755. {
  1756. "subnet": "192.0.2.0/24",
  1757. "pools": [ { "pool": "192.0.2.10 - 192.0.2.20" } ],
  1758. <userinput>"relay": {
  1759. "ip-address": "10.1.1.1"
  1760. }</userinput>
  1761. }
  1762. ],
  1763. ...
  1764. }
  1765. </screen>
  1766. </para>
  1767. </section>
  1768. </section>
  1769. <section id="dhcp4-std">
  1770. <title>Supported DHCP Standards</title>
  1771. <para>The following standards are currently supported:</para>
  1772. <itemizedlist>
  1773. <listitem>
  1774. <simpara><emphasis>Dynamic Host Configuration Protocol</emphasis>,
  1775. <ulink url="http://tools.ietf.org/html/rfc2131">RFC 2131</ulink>:
  1776. Supported messages are DISCOVER (1), OFFER (2),
  1777. REQUEST (3), RELEASE (7), INFORM (8), ACK (5), and NAK(6).</simpara>
  1778. </listitem>
  1779. <listitem>
  1780. <simpara><emphasis>DHCP Options and BOOTP Vendor Extensions</emphasis>,
  1781. <ulink url="http://tools.ietf.org/html/rfc2132">RFC 2132</ulink>:
  1782. Supported options are: PAD (0),
  1783. END(255), Message Type(53), DHCP Server Identifier (54),
  1784. Domain Name (15), DNS Servers (6), IP Address Lease Time
  1785. (51), Subnet mask (1), and Routers (3).</simpara>
  1786. </listitem>
  1787. <listitem>
  1788. <simpara><emphasis>DHCP Relay Agent Information Option</emphasis>,
  1789. <ulink url="http://tools.ietf.org/html/rfc3046">RFC 3046</ulink>:
  1790. Relay Agent Information option is supported.</simpara>
  1791. </listitem>
  1792. <listitem>
  1793. <simpara><emphasis>Vendor-Identifying Vendor Options for
  1794. Dynamic Host Configuration Protocol version 4</emphasis>,
  1795. <ulink url="http://tools.ietf.org/html/rfc3925">RFC 3925</ulink>:
  1796. Vendor-Identifying Vendor Class and Vendor-Identifying Vendor-Specific
  1797. Information options are supported.</simpara>
  1798. </listitem>
  1799. <listitem>
  1800. <simpara><emphasis>Client Identifier Option in DHCP Server Replies</emphasis>,
  1801. <ulink url="http://tools.ietf.org/html/rfc6842">RFC 6842</ulink>:
  1802. Server by default sends back client-id option. That capability may be
  1803. disabled. See <xref linkend="dhcp4-echo-client-id"/> for details.
  1804. </simpara>
  1805. </listitem>
  1806. </itemizedlist>
  1807. </section>
  1808. <section id="dhcp4-limit">
  1809. <title>DHCPv4 Server Limitations</title>
  1810. <para>These are the current limitations of the DHCPv4 server
  1811. software. Most of them are reflections of the current stage of
  1812. development and should be treated as <quote>not implemented
  1813. yet</quote>, rather than actual limitations. However, some of them
  1814. are implications of the design choices made. Those are clearly
  1815. marked as such.</para>
  1816. <itemizedlist>
  1817. <listitem> <!-- see tickets #3234, #3281 -->
  1818. <simpara>
  1819. Removal of a subnet during server reconfiguration may cause renumbering
  1820. of auto-generated subnet identifiers, as described in section
  1821. <xref linkend="ipv4-subnet-id"/>.
  1822. </simpara>
  1823. </listitem>
  1824. <listitem>
  1825. <simpara>Host reservation (static addresses) is not supported yet.</simpara>
  1826. </listitem>
  1827. <listitem>
  1828. <simpara>Full featured client classification is not supported yet.</simpara>
  1829. </listitem>
  1830. <listitem>
  1831. <simpara>
  1832. BOOTP (<ulink url="http://tools.ietf.org/html/rfc951">RFC 951</ulink>)
  1833. is not supported. This is a design choice. BOOTP support is not planned.
  1834. </simpara>
  1835. </listitem>
  1836. <listitem>
  1837. <simpara>On Linux and BSD system families the DHCP messages are sent
  1838. and received over the raw sockets (using LPF and BPF) and all packet
  1839. headers (including data link layer, IP and UDP headers) are created and
  1840. parsed by Kea, rather than the system kernel. Currently, Kea can
  1841. only parse the data link layer headers with a format adhering to
  1842. IEEE 802.3 standard and assumes this data link layer header format
  1843. for all interfaces. Hence, Kea will fail to work on interfaces
  1844. which use different data link layer header formats (e.g. Infiniband).
  1845. </simpara>
  1846. </listitem>
  1847. <listitem>
  1848. <simpara>The DHCPv4 server does not verify that
  1849. assigned address is unused. According to <ulink url="http://tools.ietf.org/html/rfc2131">RFC 2131</ulink>, the
  1850. allocating server should verify that address is not used by
  1851. sending ICMP echo request.</simpara>
  1852. </listitem>
  1853. <listitem>
  1854. <simpara>Address duplication report (DECLINE) is not supported yet.</simpara>
  1855. </listitem>
  1856. <listitem>
  1857. <simpara>
  1858. The server doesn't act upon expired leases. In particular,
  1859. when a lease expires, the server doesn't request the removal
  1860. of the DNS records associated with it. Expired leases can be
  1861. recycled.
  1862. </simpara>
  1863. </listitem>
  1864. </itemizedlist>
  1865. </section>
  1866. <!--
  1867. <section id="dhcp4-srv-examples">
  1868. <title>Kea DHCPv4 server examples</title>
  1869. <para>
  1870. This section provides easy to use example. Each example can be read
  1871. separately. It is not intended to be read sequentially as there will
  1872. be many repetitions between examples. They are expected to serve as
  1873. easy to use copy-paste solutions to many common deployments.
  1874. </para>
  1875. @todo: add simple configuration for direct clients
  1876. @todo: add configuration for relayed clients
  1877. @todo: add client classification example
  1878. </section> -->
  1879. </chapter>