xref: /openbsd-src/usr.sbin/dhcpd/dhcpd.8 (revision f2da64fbbbf1b03f09f390ab01267c93dfd77c4c)
1.\"	$OpenBSD: dhcpd.8,v 1.27 2015/03/13 19:58:41 jmc Exp $
2.\"
3.\" Copyright (c) 1995, 1996 The Internet Software Consortium.
4.\" All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\"
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\" 3. Neither the name of The Internet Software Consortium nor the names
16.\"    of its contributors may be used to endorse or promote products derived
17.\"    from this software without specific prior written permission.
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
20.\" CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
21.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23.\" DISCLAIMED.  IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
24.\" CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
27.\" USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28.\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
30.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31.\" SUCH DAMAGE.
32.\"
33.\" This software has been written for the Internet Software Consortium
34.\" by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
35.\" Enterprises.  To learn more about the Internet Software Consortium,
36.\" see ``http://www.isc.org/''.  To learn more about Vixie
37.\" Enterprises, see ``http://www.vix.com''.
38.\"
39.Dd $Mdocdate: March 13 2015 $
40.Dt DHCPD 8
41.Os
42.Sh NAME
43.Nm dhcpd
44.Nd Dynamic Host Configuration Protocol (DHCP) server
45.Sh SYNOPSIS
46.Nm dhcpd
47.Bk -words
48.Op Fl dfn
49.Op Fl A Ar abandoned_ip_table
50.Op Fl C Ar changed_ip_table
51.Op Fl c Ar config-file
52.Op Fl L Ar leased_ip_table
53.Op Fl l Ar lease-file
54.Op Fl u Ns Op Ar bind_address
55.Op Fl Y Ar synctarget
56.Op Fl y Ar synclisten
57.Op Ar if0 Op Ar ... ifN
58.Ek
59.Sh DESCRIPTION
60The Internet Software Consortium DHCP Server,
61.Nm dhcpd ,
62implements the Dynamic Host Configuration Protocol (DHCP) and the
63Internet Bootstrap Protocol (BOOTP).
64DHCP allows hosts on a TCP/IP network to request and be assigned IP addresses,
65and also to discover information about the network to which they are attached.
66BOOTP provides similar functionality, with certain restrictions.
67.Pp
68The DHCP protocol allows a host which is unknown to the network
69administrator to be automatically assigned a new IP address out of a
70pool of IP addresses for its network.
71In order for this to work, the network administrator allocates address pools
72in each subnet and enters them into the
73.Xr dhcpd.conf 5
74file.
75.Pp
76On startup,
77.Nm
78reads the
79.Pa dhcpd.conf
80file and stores a list of available addresses on each subnet in memory.
81When a client requests an address using the DHCP protocol,
82.Nm
83allocates an address for it.
84Each client is assigned a lease, which expires after an amount of time
85chosen by the administrator (by default, one day).
86When a leased IP address is assigned to a new hardware address,
87.Nm
88may delete the leased IP from certain
89.Xr pf 4
90tables.
91Before leases expire, the clients to which leases are assigned are expected
92to renew them in order to continue to use the addresses.
93Once a lease has expired, the client to which that lease was assigned is no
94longer permitted to use the leased IP address.
95.Pp
96In order to keep track of leases across system reboots and server restarts,
97.Nm
98keeps a list of leases it has assigned in the
99.Xr dhcpd.leases 5
100file.
101Before
102.Nm
103grants a lease to a host, it records the lease in this file and makes sure
104that the contents of the file are flushed to disk.
105This ensures that even in the event of a system crash,
106.Nm
107will not forget about a lease that it has assigned.
108On startup, after reading the
109.Pa dhcpd.conf
110file,
111.Nm
112reads the
113.Pa dhcpd.leases
114file to refresh its memory about what leases have been assigned.
115.Pp
116BOOTP support is also provided by this server.
117Unlike DHCP, the BOOTP protocol does not provide a protocol for recovering
118dynamically-assigned addresses once they are no longer needed.
119It is still possible to dynamically assign addresses to BOOTP clients, but
120some administrative process for reclaiming addresses is required.
121By default, leases are granted to BOOTP clients in perpetuity, although
122the network administrator may set an earlier cutoff date or a shorter
123lease length for BOOTP leases if that makes sense.
124.Pp
125BOOTP clients may also be served in the old standard way, which is
126simply to provide a declaration in the
127.Pa dhcpd.conf
128file for each BOOTP client, permanently assigning an address to each client.
129.Pp
130Whenever changes are made to the
131.Pa dhcpd.conf
132file,
133.Nm
134must be restarted.
135Because the DHCP server database is not as lightweight as a BOOTP database,
136.Nm
137does not automatically restart itself when it sees a change to the
138.Pa dhcpd.conf
139file.
140.Pp
141DHCP traffic always bypasses IPsec.
142Otherwise there could be situations when a server has an IPsec SA for the
143client and sends replies over that,
144which a newly booted client would not be able to grasp.
145.Sh COMMAND LINE
146The names of the network interfaces on which
147.Nm
148should listen for broadcasts may be specified on the command line.
149This should be done on systems where
150.Nm
151is unable to identify non-broadcast interfaces,
152but should not be required on other systems.
153If no interface names are specified on the command line,
154and the
155.Fl u
156option is not given,
157.Nm
158will identify all network interfaces which are up, eliminating non-broadcast
159interfaces if possible, and listen for DHCP broadcasts on each interface.
160.Pp
161The options are as follows:
162.Bl -tag -width Ds
163.It Fl A Ar abandoned_ip_table
164When an address is abandoned for some reason, add it to the
165.Xr pf 4
166table named
167.Ar abandoned_ip_table .
168This can be used to defend against machines "camping" on an address
169without obtaining a lease.
170When an address is properly leased,
171.Nm
172will remove the address from this table.
173.It Fl C Ar changed_ip_table
174When an address is leased to a different hardware address, delete it from the
175.Xr pf 4
176table named
177.Ar changed_ip_table .
178This feature complements the overload table in a stateful
179.Xr pf 4
180rule.
181If a host appears to be misbehaving, it can be quarantined by using the
182overload feature.
183When the address is leased to a different machine,
184.Nm
185can remove the address from the overload table, thus allowing a well-behaved
186machine to reuse the address.
187.It Fl c Ar config-file
188Use an alternate configuration file,
189.Ar config-file .
190Because of the importance of using the same lease database at all times when
191running
192.Nm
193in production, this option should be used
194.Em only
195for testing database files in a non-production environment.
196.It Fl d
197Force
198.Nm
199to log to
200.Ar stderr .
201This can be useful for debugging, and also at sites where a complete log of
202all dhcp activity must be kept, but
203.Xr syslogd 8
204is not reliable or otherwise cannot be used.
205Normally,
206.Nm
207will log all output using the
208.Xr syslog 3
209function with the log facility set to
210.Dv LOG_DAEMON .
211.It Fl f
212Run
213.Nm
214as a foreground process, rather than allowing it to run as a daemon in the
215background.
216This is useful when running
217.Nm
218under a debugger, or when running it out of inittab on System V systems.
219.It Fl L Ar leased_ip_table
220When an address is leased
221.Nm
222will insert it into the
223.Xr pf 4
224table named
225.Ar leased_ip_table .
226Addresses are removed from the table when the lease expires.
227Combined with the table of abandoned addresses, this can help enforce a
228requirement to use DHCP on a network, or can place DHCP users in a different
229class of service.
230Users are cautioned against placing much trust in Ethernet or IP addresses;
231.Xr ifconfig 8
232can be used to trivially change the interface's address, and on a busy DHCP
233network, IP addresses will likely be quickly recycled.
234.It Fl l Ar lease-file
235Use an alternate lease file,
236.Ar lease-file .
237Because of the importance of using the same lease database at all times when
238running
239.Nm
240in production, this option should be used
241.Em only
242for testing lease files in a non-production environment.
243.It Fl n
244Only test configuration, do not run
245.Nm .
246.It Fl u Ns Op Ar bind_address
247Use a UDP socket instead of BPF for receiving and sending packets.
248Only
249.Dv DHCPINFORM
250messages can be handled on this socket;
251other messages are discarded.
252With this option,
253.Nm
254can answer
255.Dv DHCPINFORM
256from clients on non Ethernet interfaces
257such as
258.Xr tun 4
259or
260.Xr pppx 4 .
261If
262.Ar bind_address
263is specified,
264.Nm
265will bind to that address; otherwise
266the limited broadcast address (255.255.255.255) is used as the default.
267.It Fl Y Ar synctarget
268Add target
269.Ar synctarget
270to receive synchronisation messages.
271.Ar synctarget
272can be either an IPv4 address for unicast messages
273or a network interface name followed optionally by a colon and a numeric TTL
274value for multicast messages to the group 224.0.1.240.
275If the multicast TTL is not specified, a default value of 1 is used.
276This option can be specified multiple times.
277See also
278.Sx SYNCHRONISATION
279below.
280.It Fl y Ar synclisten
281Listen on
282.Ar synclisten
283for incoming synchronisation messages.
284The format for
285.Ar synclisten
286is the same as for
287.Ar synctarget ,
288above.
289This option can be specified only once.
290See also
291.Sx SYNCHRONISATION
292below.
293.El
294.Sh CONFIGURATION
295The syntax of the
296.Xr dhcpd.conf 5
297file is discussed separately.
298This section should be used as an overview of the configuration process,
299and the
300.Xr dhcpd.conf 5
301documentation should be consulted for detailed reference information.
302.Bl -tag -width 3n
303.It Subnets
304.Nm
305needs to know the subnet numbers and netmasks of all subnets for
306which it will be providing service.
307In addition, in order to dynamically allocate addresses, it must be assigned
308one or more ranges of addresses on each subnet which it can in turn assign
309to client hosts as they boot.
310Thus, a very simple configuration providing DHCP support might look like this:
311.Bd -literal -offset indent
312subnet 239.252.197.0 netmask 255.255.255.0 {
313  range 239.252.197.10 239.252.197.250;
314}
315.Ed
316.Pp
317Multiple address ranges may be specified like this:
318.Bd -literal -offset indent
319subnet 239.252.197.0 netmask 255.255.255.0 {
320  range 239.252.197.10 239.252.197.107;
321  range 239.252.197.113 239.252.197.250;
322}
323.Ed
324.Pp
325If a subnet will only be provided with BOOTP service and no dynamic
326address assignment, the range clause can be left out entirely, but the
327subnet statement must appear.
328.It Lease Lengths
329DHCP leases can be assigned almost any length from zero seconds to infinity.
330What lease length makes sense for any given subnet, or for any given
331installation, will vary depending on the kinds of hosts being served.
332.Pp
333For example, in an office environment where systems are added from
334time to time and removed from time to time, but move relatively
335infrequently, it might make sense to allow lease times of a month or more.
336In a final test environment on a manufacturing floor, it may make more sense
337to assign a maximum lease length of 30 minutes \- enough time to go through a
338simple test procedure on a network appliance before packaging it up for
339delivery.
340.Pp
341It is possible to specify two lease lengths: the default length that
342will be assigned if a client doesn't ask for any particular lease
343length, and a maximum lease length.
344These are specified as clauses to the subnet command:
345.Bd -literal -offset indent
346subnet 239.252.197.0 netmask 255.255.255.0 {
347  range 239.252.197.10 239.252.197.107;
348  default-lease-time 600;
349  max-lease-time 7200;
350}
351.Ed
352.Pp
353This particular subnet declaration specifies a default lease time of
354600 seconds (ten minutes), and a maximum lease time of 7200 seconds
355(two hours).
356Other common values would be 86400 (one day), 604800 (one week)
357and 2592000 (30 days).
358.Pp
359Each subnet need not have the same lease \- in the case of an office
360environment and a manufacturing environment served by the same DHCP
361server, it might make sense to have widely disparate values for
362default and maximum lease times on each subnet.
363.It BOOTP Support
364Each BOOTP client must be explicitly declared in the
365.Xr dhcpd.conf 5
366file.
367A very basic client declaration will specify the client network interface's
368hardware address and the IP address to assign to that client.
369If the client needs to be able to load a boot file from the server,
370that file's name must be specified.
371A simple BOOTP client declaration might look like this:
372.Bd -literal -offset indent
373host haagen {
374  hardware ethernet 08:00:2b:4c:59:23;
375  fixed-address 239.252.197.9;
376  filename "haagen.boot";
377}
378.Ed
379.It Options
380DHCP (and also BOOTP with Vendor Extensions) provides a mechanism
381whereby the server can provide the client with information about how
382to configure its network interface (e.g., subnet mask), and also how
383the client can access various network services (e.g., DNS, IP routers,
384and so on).
385.Pp
386These options can be specified on a per-subnet basis and, for BOOTP
387clients, also on a per-client basis.
388In the event that a BOOTP client declaration specifies options that are
389also specified in its subnet declaration, the options specified in the
390client declaration take precedence.
391A reasonably complete DHCP configuration might look something like this:
392.Bd -literal -offset indent
393subnet 239.252.197.0 netmask 255.255.255.0 {
394  range 239.252.197.10 239.252.197.250;
395  default-lease-time 600;
396  max-lease-time 7200;
397  option subnet-mask 255.255.255.0;
398  option broadcast-address 239.252.197.255;
399  option routers 239.252.197.1;
400  option domain-name-servers 239.252.197.2, 239.252.197.3;
401  option domain-name "isc.org";
402}
403.Ed
404.Pp
405A BOOTP host on that subnet that needs to be in a different domain and
406use a different name server might be declared as follows:
407.Bd -literal -offset indent
408host haagen {
409  hardware ethernet 08:00:2b:4c:59:23;
410  fixed-address 239.252.197.9;
411  filename "haagen.boot";
412  option domain-name-servers 192.5.5.1;
413  option domain-name "vix.com";
414}
415.Ed
416.El
417.Pp
418A more complete description of the
419.Pa dhcpd.conf
420file syntax is provided in
421.Xr dhcpd.conf 5 .
422.Sh SYNCHRONISATION
423.Nm
424supports realtime synchronisation of the lease allocations to
425a number of
426.Nm
427daemons running on multiple machines,
428using the
429.Fl Y
430and
431.Fl y
432options.
433.Pp
434The following example will accept incoming multicast and unicast
435synchronisation messages, and send outgoing multicast messages through
436the network interface
437.Ar em0 :
438.Bd -literal -offset indent
439# /usr/sbin/dhcpd -y em0 -Y em0
440.Ed
441.Pp
442The second example will increase the multicast TTL to a value of 2,
443add the unicast targets
444.Ar foo.somewhere.org
445and
446.Ar bar.somewhere.org ,
447and accept incoming unicast messages sent to
448.Ar example.somewhere.org
449only.
450.Bd -literal -offset indent
451# /usr/sbin/dhcpd -y example.somewhere.org -Y em0:2 \e
452	-Y foo.somewhere.org -Y bar.somewhere.org
453.Ed
454.Pp
455If the file
456.Pa /var/db/dhcpd.key
457exists,
458.Nm
459will calculate the message-digest fingerprint (checksum) for the file
460and use it as a shared key to authenticate the synchronisation messages.
461The file itself can contain any data.
462For example, to create a secure random key:
463.Bd -literal -offset indent
464# dd if=/dev/random of=/var/db/dhcpd.key bs=2048 count=1
465.Ed
466.Pp
467The file needs to be copied to all hosts
468sending or receiving synchronisation messages.
469.Pp
470All hosts using synchronisation must use the same configuration in the
471.Pa /etc/dhcpd.conf
472file.
473.Sh FILES
474.Bl -tag -width "/var/db/dhcpd.leases~  " -compact
475.It Pa /etc/dhcpd.conf
476DHCPD configuration file.
477.It Pa /var/db/dhcpd.leases
478DHCPD lease file.
479.El
480.Sh SEE ALSO
481.Xr pf 4 ,
482.Xr dhcpd.conf 5 ,
483.Xr dhcpd.leases 5 ,
484.Xr dhclient 8 ,
485.Xr dhcrelay 8 ,
486.Xr pxeboot 8
487.Sh STANDARDS
488.Rs
489.%A R. Droms
490.%D October 1993
491.%R RFC 1534
492.%T Interoperation Between DHCP and BOOTP
493.Re
494.Pp
495.Rs
496.%A R. Droms
497.%D March 1997
498.%R RFC 2131
499.%T Dynamic Host Configuration Protocol
500.Re
501.Pp
502.Rs
503.%A S. Alexander
504.%A R. Droms
505.%D March 1997
506.%R RFC 2132
507.%T DHCP Options and BOOTP Vendor Extensions
508.Re
509.Pp
510.Rs
511.%A T. Lemon
512.%A S. Cheshire
513.%D November 2002
514.%R RFC 3396
515.%T Encoding Long Options in the Dynamic Host Configuration Protocol (DHCPv4)
516.Re
517.Pp
518.Rs
519.%A T. Lemon
520.%A S. Cheshire
521.%A B. Volz
522.%D December 2002
523.%R RFC 3442
524.%T The Classless Static Route Option for Dynamic Host Configuration Protocol (DHCP) version 4
525.Re
526.Sh AUTHORS
527.An -nosplit
528.Nm
529was written by
530.An Ted Lemon Aq Mt mellon@vix.com
531under a contract with Vixie Labs.
532.Pp
533The current implementation was reworked by
534.An Henning Brauer Aq Mt henning@openbsd.org .
535.Sh BUGS
536We realize that it would be nice if one could send a
537.Dv SIGHUP
538to the server and have it reload the database.
539This is not technically impossible, but it would require a great deal of work,
540our resources are extremely limited, and they can be better spent elsewhere.
541So please don't complain about this on the mailing list unless you're prepared
542to fund a project to implement this feature, or prepared to do it yourself.
543