xref: /openbsd-src/usr.sbin/dhcpd/dhcpd.8 (revision a28daedfc357b214be5c701aa8ba8adb29a7f1c2)
1.\"	$OpenBSD: dhcpd.8,v 1.16 2008/05/07 12:19:20 beck 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: May 7 2008 $
40.Dt DHCPD 8
41.Os
42.Sh NAME
43.Nm dhcpd
44.Nd Dynamic Host Configuration Protocol 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 Y Ar synctarget
55.Op Fl y Ar synclisten
56.Op Ar if0 Op Ar ... ifN
57.Ek
58.Sh DESCRIPTION
59The Internet Software Consortium DHCP Server,
60.Nm dhcpd ,
61implements the Dynamic Host Configuration Protocol (DHCP) and the
62Internet Bootstrap Protocol (BOOTP).
63DHCP allows hosts on a TCP/IP network to request and be assigned IP addresses,
64and also to discover information about the network to which they are attached.
65BOOTP provides similar functionality, with certain restrictions.
66.Pp
67The DHCP protocol allows a host which is unknown to the network
68administrator to be automatically assigned a new IP address out of a
69pool of IP addresses for its network.
70In order for this to work, the network administrator allocates address pools
71in each subnet and enters them into the
72.Xr dhcpd.conf 5
73file.
74.Pp
75On startup,
76.Nm
77reads the
78.Pa dhcpd.conf
79file and stores a list of available addresses on each subnet in memory.
80When a client requests an address using the DHCP protocol,
81.Nm
82allocates an address for it.
83Each client is assigned a lease, which expires after an amount of time
84chosen by the administrator (by default, one day).
85When a leased IP address is assigned to a new hardware address,
86.Nm
87may delete the leased IP from certain
88.Xr pf 4
89tables.
90Before leases expire, the clients to which leases are assigned are expected
91to renew them in order to continue to use the addresses.
92Once a lease has expired, the client to which that lease was assigned is no
93longer permitted to use the leased IP address.
94.Pp
95In order to keep track of leases across system reboots and server restarts,
96.Nm
97keeps a list of leases it has assigned in the
98.Xr dhcpd.leases 5
99file.
100Before
101.Nm
102grants a lease to a host, it records the lease in this file and makes sure
103that the contents of the file are flushed to disk.
104This ensures that even in the event of a system crash,
105.Nm
106will not forget about a lease that it has assigned.
107On startup, after reading the
108.Pa dhcpd.conf
109file,
110.Nm
111reads the
112.Pa dhcpd.leases
113file to refresh its memory about what leases have been assigned.
114.Pp
115BOOTP support is also provided by this server.
116Unlike DHCP, the BOOTP protocol does not provide a protocol for recovering
117dynamically-assigned addresses once they are no longer needed.
118It is still possible to dynamically assign addresses to BOOTP clients, but
119some administrative process for reclaiming addresses is required.
120By default, leases are granted to BOOTP clients in perpetuity, although
121the network administrator may set an earlier cutoff date or a shorter
122lease length for BOOTP leases if that makes sense.
123.Pp
124BOOTP clients may also be served in the old standard way, which is
125simply to provide a declaration in the
126.Pa dhcpd.conf
127file for each BOOTP client, permanently assigning an address to each client.
128.Pp
129Whenever changes are made to the
130.Pa dhcpd.conf
131file,
132.Nm
133must be restarted.
134Because the DHCP server database is not as lightweight as a BOOTP database,
135.Nm
136does not automatically restart itself when it sees a change to the
137.Pa dhcpd.conf
138file.
139.Pp
140DHCP traffic always bypasses IPsec.
141Otherwise there could be situations when a server has an IPsec SA for the
142client and sends replies over that,
143which a newly booted client would not be able to grasp.
144.Sh COMMAND LINE
145The names of the network interfaces on which
146.Nm
147should listen for broadcasts may be specified on the command line.
148This should be done on systems where
149.Nm
150is unable to identify non-broadcast interfaces,
151but should not be required on other systems.
152If no interface names are specified on the command line,
153.Nm
154will identify all network interfaces which are up, eliminating non-broadcast
155interfaces if possible, and listen for DHCP broadcasts on each interface.
156.Pp
157The options are as follows:
158.Bl -tag -width Ds
159.It Fl A Ar abandoned_ip_table
160When an address is abandoned for some reason, add it to the
161.Xr pf 4
162table named
163.Ar abandoned_ip_table .
164This can be used to defend against machines "camping" on an address
165without obtaining a lease.
166When an address is properly leased,
167.Nm
168will remove the address from this table.
169.It Fl C Ar changed_ip_table
170When an address is leased to a different hardware address, delete it from the
171.Xr pf 4
172table named
173.Ar changed_ip_table .
174This feature complements the overload table in a stateful
175.Xr pf 4
176rule.
177If a host appears to be misbehaving, it can be quarantined by using the
178overload feature.
179When the address is leased to a different machine,
180.Nm
181can remove the address from the overload table, thus allowing a well-behaved
182machine to reuse the address.
183.It Fl c Ar config-file
184Use an alternate configuration file,
185.Ar config-file .
186Because of the importance of using the same lease database at all times when
187running
188.Nm
189in production, this option should be used
190.Em only
191for testing database files in a non-production environment.
192.It Fl d
193Force
194.Nm
195to log to
196.Ar stderr .
197This can be useful for debugging, and also at sites where a complete log of
198all dhcp activity must be kept, but
199.Xr syslogd 8
200is not reliable or otherwise cannot be used.
201Normally,
202.Nm
203will log all output using the
204.Xr syslog 3
205function with the log facility set to
206.Dv LOG_DAEMON .
207.It Fl f
208Run
209.Nm
210as a foreground process, rather than allowing it to run as a daemon in the
211background.
212This is useful when running
213.Nm
214under a debugger, or when running it out of inittab on System V systems.
215.It Fl L Ar leased_ip_table
216When an address is leased
217.Nm
218will insert it into the
219.Xr pf 4
220table named
221.Ar leased_ip_table .
222Addresses are removed from the table when the lease expires.
223Combined with the table of abandoned addresses, this can help enforce a
224requirement to use DHCP on a network, or can place DHCP users in a different
225class of service.
226Users are cautioned against placing much trust in Ethernet or IP addresses;
227.Xr ifconfig 8
228can be used to trivially change the interface's address, and on a busy DHCP
229network, IP addresses will likely be quickly recycled.
230.It Fl l Ar lease-file
231Use an alternate lease file,
232.Ar lease-file .
233Because of the importance of using the same lease database at all times when
234running
235.Nm
236in production, this option should be used
237.Em only
238for testing lease files in a non-production environment.
239.It Fl n
240Only test configuration, do not run
241.Nm .
242.It Fl Y Ar synctarget
243Add target
244.Ar synctarget
245to receive synchronisation messages.
246.Ar synctarget
247can be either an IPv4 address for unicast messages
248or a network interface name followed optionally by a colon and a numeric TTL
249value for multicast messages to the group 224.0.1.240.
250If the multicast TTL is not specified, a default value of 1 is used.
251This option can be specified multiple times.
252See also
253.Sx SYNCHRONISATION
254below.
255.It Fl y Ar synclisten
256Listen on
257.Ar synclisten
258for incoming synchronisation messages.
259The format for
260.Ar synclisten
261is the same as for
262.Ar synctarget ,
263above.
264This option can be specified only once.
265See also
266.Sx SYNCHRONISATION
267below.
268.El
269.Sh CONFIGURATION
270The syntax of the
271.Xr dhcpd.conf 5
272file is discussed separately.
273This section should be used as an overview of the configuration process,
274and the
275.Xr dhcpd.conf 5
276documentation should be consulted for detailed reference information.
277.Bl -tag -width 3n
278.It Subnets
279.Nm
280needs to know the subnet numbers and netmasks of all subnets for
281which it will be providing service.
282In addition, in order to dynamically allocate addresses, it must be assigned
283one or more ranges of addresses on each subnet which it can in turn assign
284to client hosts as they boot.
285Thus, a very simple configuration providing DHCP support might look like this:
286.Bd -literal -offset indent
287subnet 239.252.197.0 netmask 255.255.255.0 {
288  range 239.252.197.10 239.252.197.250;
289}
290.Ed
291.Pp
292Multiple address ranges may be specified like this:
293.Bd -literal -offset indent
294subnet 239.252.197.0 netmask 255.255.255.0 {
295  range 239.252.197.10 239.252.197.107;
296  range 239.252.197.113 239.252.197.250;
297}
298.Ed
299.Pp
300If a subnet will only be provided with BOOTP service and no dynamic
301address assignment, the range clause can be left out entirely, but the
302subnet statement must appear.
303.It Lease Lengths
304DHCP leases can be assigned almost any length from zero seconds to infinity.
305What lease length makes sense for any given subnet, or for any given
306installation, will vary depending on the kinds of hosts being served.
307.Pp
308For example, in an office environment where systems are added from
309time to time and removed from time to time, but move relatively
310infrequently, it might make sense to allow lease times of a month of more.
311In a final test environment on a manufacturing floor, it may make more sense
312to assign a maximum lease length of 30 minutes \- enough time to go through a
313simple test procedure on a network appliance before packaging it up for
314delivery.
315.Pp
316It is possible to specify two lease lengths: the default length that
317will be assigned if a client doesn't ask for any particular lease
318length, and a maximum lease length.
319These are specified as clauses to the subnet command:
320.Bd -literal -offset indent
321subnet 239.252.197.0 netmask 255.255.255.0 {
322  range 239.252.197.10 239.252.197.107;
323  default-lease-time 600;
324  max-lease-time 7200;
325}
326.Ed
327.Pp
328This particular subnet declaration specifies a default lease time of
329600 seconds (ten minutes), and a maximum lease time of 7200 seconds
330(two hours).
331Other common values would be 86400 (one day), 604800 (one week)
332and 2592000 (30 days).
333.Pp
334Each subnet need not have the same lease \- in the case of an office
335environment and a manufacturing environment served by the same DHCP
336server, it might make sense to have widely disparate values for
337default and maximum lease times on each subnet.
338.It BOOTP Support
339Each BOOTP client must be explicitly declared in the
340.Xr dhcpd.conf 5
341file.
342A very basic client declaration will specify the client network interface's
343hardware address and the IP address to assign to that client.
344If the client needs to be able to load a boot file from the server,
345that file's name must be specified.
346A simple BOOTP client declaration might look like this:
347.Bd -literal -offset indent
348host haagen {
349  hardware ethernet 08:00:2b:4c:59:23;
350  fixed-address 239.252.197.9;
351  filename "haagen.boot";
352}
353.Ed
354.It Options
355DHCP (and also BOOTP with Vendor Extensions) provides a mechanism
356whereby the server can provide the client with information about how
357to configure its network interface (e.g., subnet mask), and also how
358the client can access various network services (e.g., DNS, IP routers,
359and so on).
360.Pp
361These options can be specified on a per-subnet basis, and, for BOOTP
362clients, also on a per-client basis.
363In the event that a BOOTP client declaration specifies options that are
364also specified in its subnet declaration, the options specified in the
365client declaration take precedence.
366A reasonably complete DHCP configuration might look something like this:
367.Bd -literal -offset indent
368subnet 239.252.197.0 netmask 255.255.255.0 {
369  range 239.252.197.10 239.252.197.250;
370  default-lease-time 600;
371  max-lease-time 7200;
372  option subnet-mask 255.255.255.0;
373  option broadcast-address 239.252.197.255;
374  option routers 239.252.197.1;
375  option domain-name-servers 239.252.197.2, 239.252.197.3;
376  option domain-name "isc.org";
377}
378.Ed
379.Pp
380A BOOTP host on that subnet that needs to be in a different domain and
381use a different name server might be declared as follows:
382.Bd -literal -offset indent
383host haagen {
384  hardware ethernet 08:00:2b:4c:59:23;
385  fixed-address 239.252.197.9;
386  filename "haagen.boot";
387  option domain-name-servers 192.5.5.1;
388  option domain-name "vix.com";
389}
390.Ed
391.El
392.Pp
393A more complete description of the
394.Pa dhcpd.conf
395file syntax is provided in
396.Xr dhcpd.conf 5 .
397.Sh SYNCHRONISATION
398.Nm
399supports realtime synchronisation of the lease allocations to
400a number of
401.Nm
402daemons running on multiple machines,
403using the
404.Fl Y
405and
406.Fl y
407options.
408.Pp
409The following example will accept incoming multicast and unicast
410synchronisation messages, and send outgoing multicast messages through
411the network interface
412.Ar em0 :
413.Bd -literal -offset indent
414# /usr/sbin/dhcpd -y em0 -Y em0
415.Ed
416.Pp
417The second example will increase the multicast TTL to a value of 2,
418add the unicast targets
419.Ar foo.somewhere.org
420and
421.Ar bar.somewhere.org ,
422and accept incoming unicast messages sent to
423.Ar example.somewhere.org
424only.
425.Bd -literal -offset indent
426# /usr/sbin/dhcpd -y example.somewhere.org -Y em0:2 \e
427	-Y foo.somewhere.org -Y bar.somewhere.org
428.Ed
429.Pp
430If the file
431.Pa /var/db/dhcpd.key
432exists,
433.Nm
434will calculate the message-digest fingerprint (checksum) for the file
435and use it as a shared key to authenticate the synchronisation messages.
436The file itself can contain any data.
437For example, to create a secure random key:
438.Bd -literal -offset indent
439# dd if=/dev/arandom of=/var/db/dhcpd.key bs=2048 count=1
440.Ed
441.Pp
442The file needs to be copied to all hosts
443sending or receiving synchronisation messages.
444.Pp
445All hosts using synchronisation must use the same configuration in the
446.Pa /etc/dhcpd.conf
447file.
448.Sh FILES
449.Bl -tag -width "/var/db/dhcpd.leases~  " -compact
450.It /etc/dhcpd.conf
451DHCPD configuration file.
452.It /var/db/dhcpd.leases
453DHCPD lease file.
454.El
455.Sh SEE ALSO
456.Xr pf 4 ,
457.Xr dhcpd.conf 5 ,
458.Xr dhcpd.leases 5 ,
459.Xr dhclient 8 ,
460.Xr dhcp 8 ,
461.Xr dhcrelay 8 ,
462.Xr pxeboot 8
463.Sh AUTHORS
464.An -nosplit
465.Nm
466was written by
467.An Ted Lemon Aq mellon@vix.com
468under a contract with Vixie Labs.
469.Pp
470The current implementation was reworked by
471.An Henning Brauer Aq henning@openbsd.org .
472.Sh BUGS
473We realize that it would be nice if one could send a
474.Dv SIGHUP
475to the server and have it reload the database.
476This is not technically impossible, but it would require a great deal of work,
477our resources are extremely limited, and they can be better spent elsewhere.
478So please don't complain about this on the mailing list unless you're prepared
479to fund a project to implement this feature, or prepared to do it yourself.
480