1dhcpd(8) System Manager's Manual dhcpd(8)
2
3
4
6 dhcpd - Dynamic Host Configuration Protocol Server
7
9 dhcpd [ -p port ] [ -f ] [ -d ] [ -q ] [ -t | -T ] [ -4 | -6 ] [ -4o6
10 port ] [ -s server ] [ -cf config-file ] [ -lf lease-file ] [ -pf pid-
11 file ] [ --no-pid ] [ -user user ] [ -group group ] [ -chroot dir ] [
12 -tf trace-output-file ] [ -play trace-playback-file ] [ if0 [ ...ifN ]
13 ]
14
15 dhcpd --version
16
18 The Internet Systems Consortium DHCP Server, dhcpd, implements the Dy‐
19 namic Host Configuration Protocol (DHCP) and the Internet Bootstrap
20 Protocol (BOOTP). DHCP allows hosts on a TCP/IP network to request and
21 be assigned IP addresses, and also to discover information about the
22 network to which they are attached. BOOTP provides similar functional‐
23 ity, with certain restrictions.
24
26 The DHCP protocol allows a host which is unknown to the network admin‐
27 istrator to be automatically assigned a new IP address out of a pool of
28 IP addresses for its network. In order for this to work, the network
29 administrator allocates address pools in each subnet and enters them
30 into the dhcpd.conf(5) file.
31
32 There are two versions of the DHCP protocol DHCPv4 and DHCPv6. At
33 startup the server may be started for one or the other via the -4 or
34 -6 arguments.
35
36 On startup, dhcpd reads the dhcpd.conf file and stores a list of avail‐
37 able addresses on each subnet in memory. When a client requests an ad‐
38 dress using the DHCP protocol, dhcpd allocates an address for it. Each
39 client is assigned a lease, which expires after an amount of time cho‐
40 sen by the administrator (by default, one day). Before leases expire,
41 the clients to which leases are assigned are expected to renew them in
42 order to continue to use the addresses. Once a lease has expired, the
43 client to which that lease was assigned is no longer permitted to use
44 the leased IP address.
45
46 In order to keep track of leases across system reboots and server
47 restarts, dhcpd keeps a list of leases it has assigned in the
48 dhcpd.leases(5) file. Before dhcpd grants a lease to a host, it
49 records the lease in this file and makes sure that the contents of the
50 file are flushed to disk. This ensures that even in the event of a
51 system crash, dhcpd will not forget about a lease that it has assigned.
52 On startup, after reading the dhcpd.conf file, dhcpd reads the
53 dhcpd.leases file to refresh its memory about what leases have been as‐
54 signed.
55
56 New leases are appended to the end of the dhcpd.leases file. In order
57 to prevent the file from becoming arbitrarily large, from time to time
58 dhcpd creates a new dhcpd.leases file from its in-core lease database.
59 Once this file has been written to disk, the old file is renamed
60 dhcpd.leases~, and the new file is renamed dhcpd.leases. If the system
61 crashes in the middle of this process, whichever dhcpd.leases file re‐
62 mains will contain all the lease information, so there is no need for a
63 special crash recovery process.
64
65 BOOTP support is also provided by this server. Unlike DHCP, the BOOTP
66 protocol does not provide a protocol for recovering dynamically-as‐
67 signed addresses once they are no longer needed. It is still possible
68 to dynamically assign addresses to BOOTP clients, but some administra‐
69 tive process for reclaiming addresses is required. By default, leases
70 are granted to BOOTP clients in perpetuity, although the network admin‐
71 istrator may set an earlier cutoff date or a shorter lease length for
72 BOOTP leases if that makes sense.
73
74 BOOTP clients may also be served in the old standard way, which is to
75 simply provide a declaration in the dhcpd.conf file for each BOOTP
76 client, permanently assigning an address to each client.
77
78 Whenever changes are made to the dhcpd.conf file, dhcpd must be
79 restarted. To restart dhcpd, send a SIGTERM (signal 15) to the process
80 ID contained in /var/run/dhcpd.pid, and then re-invoke dhcpd. Because
81 the DHCP server database is not as lightweight as a BOOTP database,
82 dhcpd does not automatically restart itself when it sees a change to
83 the dhcpd.conf file.
84
85 Note: We get a lot of complaints about this. We realize that it would
86 be nice if one could send a SIGHUP to the server and have it reload the
87 database. This is not technically impossible, but it would require a
88 great deal of work, our resources are extremely limited, and they can
89 be better spent elsewhere. So please don't complain about this on the
90 mailing list unless you're prepared to fund a project to implement this
91 feature, or prepared to do it yourself.
92
94 The names of the network interfaces on which dhcpd should listen for
95 broadcasts may be specified on the command line. This should be done
96 on systems where dhcpd is unable to identify non-broadcast interfaces,
97 but should not be required on other systems. If no interface names are
98 specified on the command line dhcpd will identify all network inter‐
99 faces which are up, eliminating non-broadcast interfaces if possible,
100 and listen for DHCP broadcasts on each interface.
101
103 -4 Run as a DHCP server. This is the default and cannot be combined
104 with -6.
105
106 -6 Run as a DHCPv6 server. This cannot be combined with -4.
107
108 -4o6 port
109 Participate in the DHCPv4 over DHCPv6 protocol specified by RFC
110 7341. This associates a DHCPv4 and a DHCPv6 server to allow the
111 v4 server to receive v4 requests that were encapsulated in a v6
112 packet. Communication between the two servers is done on a pair
113 of UDP sockets bound to ::1 port and port + 1. Both servers must
114 be launched using the same port argument.
115
116 -p port
117 The UDP port number on which dhcpd should listen. If unspeci‐
118 fied dhcpd uses the default port of 67. This is mostly useful
119 for debugging purposes.
120
121 -s address
122 Specify an address or host name to which dhcpd should send
123 replies rather than the broadcast address (255.255.255.255).
124 This option is only supported in IPv4.
125
126 -f Force dhcpd to run as a foreground process instead of as a dae‐
127 mon in the background. This is useful when running dhcpd under
128 a debugger, or when running it out of inittab on System V sys‐
129 tems.
130
131 -d Send log messages to the standard error descriptor. This can be
132 useful for debugging, and also at sites where a complete log of
133 all dhcp activity must be kept but syslogd is not reliable or
134 otherwise cannot be used. Normally, dhcpd will log all output
135 using the syslog(3) function with the log facility set to
136 LOG_DAEMON. Note that -d implies -f (the daemon will not fork
137 itself into the background).
138
139 -q Be quiet at startup. This suppresses the printing of the entire
140 copyright message during startup. This might be desirable when
141 starting dhcpd from a system startup script (e.g., /etc/rc).
142
143 -t Test the configuration file. The server tests the configuration
144 file for correct syntax, but will not attempt to perform any
145 network operations. This can be used to test a new configura‐
146 tion file automatically before installing it.
147
148 -T Test the lease file. The server tests the lease file for cor‐
149 rect syntax, but will not attempt to perform any network opera‐
150 tions. In addition to reading the lease file it will also write
151 the leases to a temporary lease file. The current lease file
152 will not be modified and the temporary lease file will be re‐
153 moved upon completion of the test. This can be used to test a
154 new lease file automatically before installing it.
155
156 -user user
157 Setuid to user after completing privileged operations, such as
158 creating sockets that listen on privileged ports. This also
159 causes the lease file to be owned by user. This option is only
160 available if the code was compiled with the PARANOIA patch
161 (./configure --enable-paranoia).
162
163 -group group
164 Setgid to group after completing privileged operations, such as
165 creating sockets that listen on privileged ports. This also
166 causes the lease file to use group. This option is only avail‐
167 able if the code was compiled with the PARANOIA patch (./config‐
168 ure --enable-paranoia).
169
170 -chroot dir
171 Chroot to directory. This may occur before or after reading the
172 configuration files depending on whether the code was compiled
173 with the EARLY_CHROOT option enabled (./configure --enable-
174 early-chroot). This option is only available if the code was
175 compiled with the PARANOIA patch (./configure --enable-para‐
176 noia).
177
178 -tf tracefile
179 Specify a file into which the entire startup state of the server
180 and all the transactions it processes are logged. This can be
181 useful in submitting bug reports - if you are getting a core
182 dump every so often, you can start the server with the -tf op‐
183 tion and then, when the server dumps core, the trace file will
184 contain all the transactions that led up to it dumping core, so
185 that the problem can be easily debugged with -play.
186
187 -play playfile
188 Specify a file from which the entire startup state of the server
189 and all the transactions it processed are read. The -play op‐
190 tion must be specified with an alternate lease file, using the
191 -lf switch, so that the DHCP server doesn't wipe out your exist‐
192 ing lease file with its test data. The DHCP server will refuse
193 to operate in playback mode unless you specify an alternate
194 lease file.
195
196 --version
197 Print version number and exit.
198
199 Modifying default file locations: The following options can be used to
200 modify the locations dhcpd uses for its files. Because of the impor‐
201 tance of using the same lease database at all times when running dhcpd
202 in production, these options should be used only for testing lease
203 files or database files in a non-production environment.
204
205 -cf config-file
206 Path to alternate configuration file.
207
208 -lf lease-file
209 Path to alternate lease file.
210
211 -pf pid-file
212 Path to alternate pid file.
213
214 --no-pid
215 Option to disable writing pid files. By default the program
216 will write a pid file. If the program is invoked with this op‐
217 tion it will not check for an existing server process.
218
220 During operations the server may use multiple UDP and TCP ports to pro‐
221 vide different functions. Which ports are opened depends on both the
222 way you compiled your code and the configuration you supply. The fol‐
223 lowing should provide you an idea of what ports may be in use.
224
225 Normally a DHCPv4 server will open a raw UDP socket to receive and send
226 most DHCPv4 packets. It also opens a fallback UDP socket for use in
227 sending unicast packets. Normally these will both use the well known
228 port number for BOOTPS.
229
230 For each DHCPv4 failover peer you list in the configuration file there
231 will be a TCP socket listening for connections on the ports specified
232 in the configuration file. When the peer connects there will be an‐
233 other socket for the established connection. For the established con‐
234 nection the side (primary or secondary) opening the connection will use
235 a random port.
236
237 For DHCPv6 the server opens a UDP socket on the well known
238 dhcpv6-server port.
239
240 The server opens an icmp socket for doing ping requests to check if ad‐
241 dresses are in use.
242
243 If you have included an omapi-port statement in your configuration file
244 then the server will open a TCP socket on that port to listen for OMPAI
245 connections. When something connects another port will be used for the
246 established connection.
247
248 When DDNS is enabled at compile time (see includes/site.h) the server
249 will open both a v4 and a v6 UDP socket on random ports, unless DDNS
250 updates are globally disabled by setting ddns-update-style to none in
251 the configuration file.
252
254 The syntax of the dhcpd.conf(5) file is discussed separately. This
255 section should be used as an overview of the configuration process, and
256 the dhcpd.conf(5) documentation should be consulted for detailed refer‐
257 ence information.
258
260 dhcpd needs to know the subnet numbers and netmasks of all subnets for
261 which it will be providing service. In addition, in order to dynami‐
262 cally allocate addresses, it must be assigned one or more ranges of ad‐
263 dresses on each subnet which it can in turn assign to client hosts as
264 they boot. Thus, a very simple configuration providing DHCP support
265 might look like this:
266
267 subnet 239.252.197.0 netmask 255.255.255.0 {
268 range 239.252.197.10 239.252.197.250;
269 }
270
271 Multiple address ranges may be specified like this:
272
273 subnet 239.252.197.0 netmask 255.255.255.0 {
274 range 239.252.197.10 239.252.197.107;
275 range 239.252.197.113 239.252.197.250;
276 }
277
278 If a subnet will only be provided with BOOTP service and no dynamic ad‐
279 dress assignment, the range clause can be left out entirely, but the
280 subnet statement must appear.
281
283 DHCP leases can be assigned almost any length from zero seconds to in‐
284 finity. What lease length makes sense for any given subnet, or for any
285 given installation, will vary depending on the kinds of hosts being
286 served.
287
288 For example, in an office environment where systems are added from time
289 to time and removed from time to time, but move relatively infre‐
290 quently, it might make sense to allow lease times of a month or more.
291 In a final test environment on a manufacturing floor, it may make more
292 sense to assign a maximum lease length of 30 minutes - enough time to
293 go through a simple test procedure on a network appliance before pack‐
294 aging it up for delivery.
295
296 It is possible to specify two lease lengths: the default length that
297 will be assigned if a client doesn't ask for any particular lease
298 length, and a maximum lease length. These are specified as clauses to
299 the subnet command:
300
301 subnet 239.252.197.0 netmask 255.255.255.0 {
302 range 239.252.197.10 239.252.197.107;
303 default-lease-time 600;
304 max-lease-time 7200;
305 }
306
307 This particular subnet declaration specifies a default lease time of
308 600 seconds (ten minutes), and a maximum lease time of 7200 seconds
309 (two hours). Other common values would be 86400 (one day), 604800 (one
310 week) and 2592000 (30 days).
311
312 Each subnet need not have the same lease—in the case of an office envi‐
313 ronment and a manufacturing environment served by the same DHCP server,
314 it might make sense to have widely disparate values for default and
315 maximum lease times on each subnet.
316
318 Each BOOTP client must be explicitly declared in the dhcpd.conf file.
319 A very basic client declaration will specify the client network inter‐
320 face's hardware address and the IP address to assign to that client.
321 If the client needs to be able to load a boot file from the server,
322 that file's name must be specified. A simple bootp client declaration
323 might look like this:
324
325 host haagen {
326 hardware ethernet 08:00:2b:4c:59:23;
327 fixed-address 239.252.197.9;
328 filename "/tftpboot/haagen.boot";
329 }
330
332 DHCP (and also BOOTP with Vendor Extensions) provide a mechanism
333 whereby the server can provide the client with information about how to
334 configure its network interface (e.g., subnet mask), and also how the
335 client can access various network services (e.g., DNS, IP routers, and
336 so on).
337
338 These options can be specified on a per-subnet basis, and, for BOOTP
339 clients, also on a per-client basis. In the event that a BOOTP client
340 declaration specifies options that are also specified in its subnet
341 declaration, the options specified in the client declaration take
342 precedence. A reasonably complete DHCP configuration might look some‐
343 thing like this:
344
345 subnet 239.252.197.0 netmask 255.255.255.0 {
346 range 239.252.197.10 239.252.197.250;
347 default-lease-time 600;
348 max-lease-time 7200;
349 option subnet-mask 255.255.255.0;
350 option broadcast-address 239.252.197.255;
351 option routers 239.252.197.1;
352 option domain-name-servers 239.252.197.2, 239.252.197.3;
353 option domain-name "isc.org";
354 }
355
356 A bootp host on that subnet that needs to be in a different domain and
357 use a different name server might be declared as follows:
358
359 host haagen {
360 hardware ethernet 08:00:2b:4c:59:23;
361 fixed-address 239.252.197.9;
362 filename "/tftpboot/haagen.boot";
363 option domain-name-servers 192.5.5.1;
364 option domain-name "example.com";
365 }
366
367 A more complete description of the dhcpd.conf file syntax is provided
368 in dhcpd.conf(5).
369
371 The DHCP server provides the capability to modify some of its configu‐
372 ration while it is running, without stopping it, modifying its database
373 files, and restarting it. This capability is currently provided using
374 OMAPI - an API for manipulating remote objects. OMAPI clients connect
375 to the server using TCP/IP, authenticate, and can then examine the
376 server's current status and make changes to it.
377
378 Rather than implementing the underlying OMAPI protocol directly, user
379 programs should use the dhcpctl API or OMAPI itself. Dhcpctl is a
380 wrapper that handles some of the housekeeping chores that OMAPI does
381 not do automatically. Dhcpctl and OMAPI are documented in dhcpctl(3)
382 and omapi(3).
383
384 OMAPI exports objects, which can then be examined and modified. The
385 DHCP server exports the following objects: lease, host, failover-state
386 and group. Each object has a number of methods that are provided:
387 lookup, create, and destroy. In addition, it is possible to look at
388 attributes that are stored on objects, and in some cases to modify
389 those attributes.
390
392 Leases can't currently be created or destroyed, but they can be looked
393 up to examine and modify their state.
394
395 Leases have the following attributes:
396
397 state integer lookup, examine
398 1 = free
399 2 = active
400 3 = expired
401 4 = released
402 5 = abandoned
403 6 = reset
404 7 = backup
405 8 = reserved
406 9 = bootp
407
408 ip-address data lookup, examine
409 The IP address of the lease.
410
411 dhcp-client-identifier data lookup, examine, update
412 The client identifier that the client used when it acquired the
413 lease. Not all clients send client identifiers, so this may be
414 empty.
415
416 client-hostname data examine, update
417 The value the client sent in the host-name option.
418
419 host handle examine
420 the host declaration associated with this lease, if any.
421
422 subnet handle examine
423 the subnet object associated with this lease (the subnet object is
424 not currently supported).
425
426 pool handle examine
427 the pool object associated with this lease (the pool object is not
428 currently supported).
429
430 billing-class handle examine
431 the handle to the class to which this lease is currently billed,
432 if any (the class object is not currently supported).
433
434 hardware-address data examine, update
435 the hardware address (chaddr) field sent by the client when it ac‐
436 quired its lease.
437
438 hardware-type integer examine, update
439 the type of the network interface that the client reported when it
440 acquired its lease.
441
442 ends time examine
443 the time when the lease's current state ends, as understood by the
444 client.
445
446 tstp time examine
447 the time when the lease's current state ends, as understood by the
448 server.
449 tsfp time examine
450 the adjusted time when the lease's current state ends, as under‐
451 stood by the failover peer (if there is no failover peer, this
452 value is undefined). Generally this value is only adjusted for
453 expired, released, or reset leases while the server is operating
454 in partner-down state, and otherwise is simply the value supplied
455 by the peer.
456 atsfp time examine
457 the actual tsfp value sent from the peer. This value is forgotten
458 when a lease binding state change is made, to facilitate retrans‐
459 mission logic.
460
461 cltt time examine
462 The time of the last transaction with the client on this lease.
463
465 Hosts can be created, destroyed, looked up, examined and modified. If
466 a host declaration is created or deleted using OMAPI, that information
467 will be recorded in the dhcpd.leases file. It is permissible to delete
468 host declarations that are declared in the dhcpd.conf file.
469
470 Hosts have the following attributes:
471
472 name data lookup, examine, modify
473 the name of the host declaration. This name must be unique among
474 all host declarations.
475
476 group handle examine, modify
477 the named group associated with the host declaration, if there is
478 one.
479
480 hardware-address data lookup, examine, modify
481 the link-layer address that will be used to match the client, if
482 any. Only valid if hardware-type is also present.
483
484 hardware-type integer lookup, examine, modify
485 the type of the network interface that will be used to match the
486 client, if any. Only valid if hardware-address is also present.
487
488 dhcp-client-identifier data lookup, examine, modify
489 the dhcp-client-identifier option that will be used to match the
490 client, if any.
491
492 ip-address data examine, modify
493 a fixed IP address which is reserved for a DHCP client that
494 matches this host declaration. The IP address will only be as‐
495 signed to the client if it is valid for the network segment to
496 which the client is connected.
497
498 statements data modify
499 a list of statements in the format of the dhcpd.conf file that
500 will be executed whenever a message from the client is being pro‐
501 cessed.
502
503 known integer examine, modify
504 if nonzero, indicates that a client matching this host declaration
505 will be treated as known in pool permit lists. If zero, the
506 client will not be treated as known.
507
509 Named groups can be created, destroyed, looked up, examined and modi‐
510 fied. If a group declaration is created or deleted using OMAPI, that
511 information will be recorded in the dhcpd.leases file. It is permissi‐
512 ble to delete group declarations that are declared in the dhcpd.conf
513 file.
514
515 Named groups currently can only be associated with hosts - this allows
516 one set of statements to be efficiently attached to more than one host
517 declaration.
518
519 Groups have the following attributes:
520
521 name data
522 the name of the group. All groups that are created using OMAPI
523 must have names, and the names must be unique among all groups.
524
525 statements data
526 a list of statements in the format of the dhcpd.conf file that
527 will be executed whenever a message from a client whose host dec‐
528 laration references this group is processed.
529
531 The control object allows you to shut the server down. If the server
532 is doing failover with another peer, it will make a clean transition
533 into the shutdown state and notify its peer, so that the peer can go
534 into partner down, and then record the "recover" state in the lease
535 file so that when the server is restarted, it will automatically resyn‐
536 chronize with its peer.
537
538 On shutdown the server will also attempt to cleanly shut down all OMAPI
539 connections. If these connections do not go down cleanly after five
540 seconds, they are shut down preemptively. It can take as much as 25
541 seconds from the beginning of the shutdown process to the time that the
542 server actually exits.
543
544 To shut the server down, open its control object and set the state at‐
545 tribute to 2.
546
548 The failover-state object is the object that tracks the state of the
549 failover protocol as it is being managed for a given failover peer.
550 The failover object has the following attributes (please see dhcpd.conf
551 [1m(5) for explanations about what these attributes mean):
552
553 name data examine
554 Indicates the name of the failover peer relationship, as described
555 in the server's dhcpd.conf file.
556
557 partner-address data examine
558 Indicates the failover partner's IP address.
559
560 local-address data examine
561 Indicates the IP address that is being used by the DHCP server for
562 this failover pair.
563
564 partner-port data examine
565 Indicates the TCP port on which the failover partner is listening
566 for failover protocol connections.
567
568 local-port data examine
569 Indicates the TCP port on which the DHCP server is listening for
570 failover protocol connections for this failover pair.
571
572 max-outstanding-updates integer examine
573 Indicates the number of updates that can be outstanding and unac‐
574 knowledged at any given time, in this failover relationship.
575
576 mclt integer examine
577 Indicates the maximum client lead time in this failover relation‐
578 ship.
579
580 load-balance-max-secs integer examine
581 Indicates the maximum value for the secs field in a client request
582 before load balancing is bypassed.
583
584 load-balance-hba data examine
585 Indicates the load balancing hash bucket array for this failover
586 relationship.
587
588 local-state integer examine, modify
589 Indicates the present state of the DHCP server in this failover
590 relationship. Possible values for state are:
591
592 1 - startup
593 2 - normal
594 3 - communications interrupted
595 4 - partner down
596 5 - potential conflict
597 6 - recover
598 7 - paused
599 8 - shutdown
600 9 - recover done
601 10 - resolution interrupted
602 11 - conflict done
603 254 - recover wait
604
605 (Note that some of the above values have changed since DHCP
606 3.0.x.)
607
608 In general it is not a good idea to make changes to this state.
609 However, in the case that the failover partner is known to be
610 down, it can be useful to set the DHCP server's failover state to
611 partner down. At this point the DHCP server will take over ser‐
612 vice of the failover partner's leases as soon as possible, and
613 will give out normal leases, not leases that are restricted by
614 MCLT. If you do put the DHCP server into the partner-down when
615 the other DHCP server is not in the partner-down state, but is not
616 reachable, IP address assignment conflicts are possible, even
617 likely. Once a server has been put into partner-down mode, its
618 failover partner must not be brought back online until communica‐
619 tion is possible between the two servers.
620
621 partner-state integer examine
622 Indicates the present state of the failover partner.
623
624 local-stos integer examine
625 Indicates the time at which the DHCP server entered its present
626 state in this failover relationship.
627
628 partner-stos integer examine
629 Indicates the time at which the failover partner entered its
630 present state.
631
632 hierarchy integer examine
633 Indicates whether the DHCP server is primary (0) or secondary (1)
634 in this failover relationship.
635
636 last-packet-sent integer examine
637 Indicates the time at which the most recent failover packet was
638 sent by this DHCP server to its failover partner.
639
640 last-timestamp-received integer examine
641 Indicates the timestamp that was on the failover message most re‐
642 cently received from the failover partner.
643
644 skew integer examine
645 Indicates the skew between the failover partner's clock and this
646 DHCP server's clock
647
648 max-response-delay integer examine
649 Indicates the time in seconds after which, if no message is re‐
650 ceived from the failover partner, the partner is assumed to be out
651 of communication.
652
653 cur-unacked-updates integer examine
654 Indicates the number of update messages that have been received
655 from the failover partner but not yet processed.
656
658 /etc/dhcp/dhcpd.conf, /var/lib/dhcpd/dhcpd.leases, /var/run/dhcpd.pid,
659 /var/lib/dhcpd/dhcpd.leases~.
660
662 dhclient(8), dhcrelay(8), dhcpd.conf(5), dhcpd.leases(5)
663
665 dhcpd(8) was originally written by Ted Lemon under a contract with
666 Vixie Labs. Funding for this project was provided by Internet Systems
667 Consortium. Version 3 of the DHCP server was funded by Nominum, Inc.
668 Information about Internet Systems Consortium is available at
669 https://www.isc.org/.
670
671
672
673 dhcpd(8)