1 .\" Copyright (c) 2006-2009 Roy Marples
2 .\" All rights reserved
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .Nd an RFC 2131 compliant DHCP client
33 .Op Fl bdgknpqwABDEGKLTV
34 .Op Fl c , -script Ar script
35 .Op Fl e , -env Ar value
36 .Op Fl f , -config Ar file
37 .Op Fl h , -hostname Ar hostname
38 .Op Fl i , -vendorclassid Ar vendorclassid
39 .Op Fl l , -leasetime Ar seconds
40 .Op Fl m , -metric Ar metric
41 .Op Fl o , -option Ar option
42 .Op Fl r , -request Ar address
43 .Op Fl s , -inform Ar address Ns Op Ar /cidr
44 .Op Fl t , -timeout Ar seconds
45 .Op Fl u , -userclass Ar class
46 .Op Fl v , -vendor Ar code , Ar value
47 .Op Fl y , -reboot Ar seconds
48 .Op Fl z , -allowinterfaces Ar pattern
49 .Op Fl C , -nohook Ar hook
50 .Op Fl F , -fqdn Ar FQDN
51 .Op Fl I , -clientid Ar clientid
52 .Op Fl O , -nooption Ar option
53 .Op Fl Q , -require Ar option
54 .Op Fl S , -static Ar value
55 .Op Fl W , -whitelist Ar address Ns Op Ar /cidr
56 .Op Fl X , -blacklist Ar address Ns Op Ar /cidr
57 .Op Fl Z , -denyinterfaces Ar pattern
68 is an implementation of the DHCP client specified in
71 gets the host information
73 IP address, routes, etc
75 from a DHCP server and configures the network
78 machine on which it is running.
80 then runs the configuration script which writes DNS information to
82 if available, otherwise directly to
83 .Pa /etc/resolv.conf .
84 If the hostname is currently blank, (null) or localhost, or
86 is YES or TRUE or 1 then
88 sets the hostname to the one supplied by the DHCP server.
90 then daemonises and waits for the lease renewal time to lapse.
91 It will then attempt to renew its lease and reconfigure if the new lease
95 is also an implementation of the BOOTP client specified in
97 .Ss Local Link configuration
100 failed to obtain a lease, it probes for a valid IPv4LL address
102 aka ZeroConf, aka APIPA
104 Once obtained it restarts the process of looking for a DHCP server to get a
109 nearly always succeeds and returns an exit code of 0.
110 In the rare case it fails, it normally means that there is a reverse ARP proxy
111 installed which always defeats IPv4LL probing.
112 To disable this behaviour, you can use the
115 .Ss Multiple interfaces
116 If a list of interfaces are given on the command line, then
118 only works with those interfaces, otherwise
120 discovers available Ethernet interfaces.
121 If any interface reports a working carrier then
123 will try and obtain a lease before forking to the background,
124 otherwise it will fork right away.
125 This behaviour can be modified with the
131 If a single interface is given then
133 only works for that interface and runs as a separate instance.
136 option is enabled in this instance to maintain compatability with older
139 Interfaces are preferred by carrier, DHCP lease/IPv4LL and then lowest metric.
140 For systems that support route metrics, each route will be tagged with the
143 changes the routes to use the interface with the same route and the lowest
145 See options below for controlling which interfaces we allow and deny through
147 .Ss Hooking into DHCP events
151 or the script specified by the
154 This script runs each script found in
157 The default installation supplies the scripts
163 You can disable each script by using the
167 .Xr dhcpcd-run-hooks 8
168 for details on how these scripts work.
170 currently ignores the exit code of the script.
172 You can fine-tune the behaviour of
174 with the following options:
175 .Bl -tag -width indent
176 .It Fl b , -background
177 Background immediately.
178 This is useful for startup scripts which don't disable link messages for
180 .It Fl c , -script Ar script
183 instead of the default
186 Echo debug messages to the stderr and syslog.
187 .It Fl e , -env Ar value
190 to the environment for use in
191 .Xr dhcpcd-run-hooks 8 .
192 For example, you can force the hostname hook to always set the hostname with
194 .Va force_hostname=YES .
195 .It Fl g , -reconfigure
197 will re-apply IP address, routing and run
198 .Xr dhcpcd-run-hooks 8
200 This is useful so that a 3rd party such as PPP or VPN can change the routing
201 table and / or DNS, etc and then instruct
203 to put things back afterwards.
205 does not read a new configuration when this happens - you should rebind if you
206 need that functionality.
207 .It Fl f , -config Ar file
208 Specify a config to load instead of
209 .Pa @SYSCONFDIR@/dhcpcd.conf .
211 always processes the config file before any command line options.
212 .It Fl h , -hostname Ar hostname
215 to the DHCP server so it can be registered in DNS.
218 is an empty string then the current system hostname is sent.
221 is a FQDN (ie, contains a .) then it will be encoded as such.
222 .It Fl i , -vendorclassid Ar vendorclassid
225 field sent. The default is
227 If not set then none is sent.
229 This causes an existing
231 process running on the
233 to release its lease, de-configure the
237 then waits until this process has exited.
238 .It Fl l , -leasetime Ar seconds
239 Request a specific lease time in
243 does not request any lease time and leaves it in the hands of the
245 .It Fl m , -metric Ar metric
246 Metrics are used to prefer an interface over another one, lowest wins.
248 will supply a default metic of 200 +
249 .Xr if_nametoindex 3 .
250 An extra 100 will be added for wireless interfaces.
251 .It Fl o , -option Ar option
259 process running on the
263 will not re-configure itself or use any other command line arguments.
265 will timeout the rebind after 30 seconds at which point the lease will be
268 will enter the discovery state to obtain a new lease.
271 option to change this.
274 is not running, then it starts up as normal.
275 This option used to be renew, but rebind is more accurate as we need to
276 broadcast the request instead of unicasting.
277 .It Fl p , -persistent
279 normally de-configures the
281 and configuration when it exits.
282 Sometimes, this isn't desirable if, for example, you have root mounted over
284 You can use this option to stop this from happening.
285 .It Fl r , -request Op Ar address
287 normally sends a DHCP DISCOVER to find servers to offer an address.
289 then requests the address used.
290 You can use this option to skip the DISCOVER phase and just request the
292 The downside is if you request an
294 the DHCP server does not know about or the DHCP server is not
295 authorative, it will remain silent.
296 In this situation, we go back to the init state and DISCOVER again.
299 is given then the first address currently assigned to the
302 .It Fl s , -inform Op Ar address Ns Op Ar /cidr
305 as above, but sends a DHCP INFORM instead of a REQUEST.
306 This does not get a lease as such, just notifies the DHCP server of the
309 You should also include the optional
311 network number in case the address is not already configured on the interface.
313 remains running and pretends it has an infinite lease.
315 will not de-configure the interface when it exits.
318 fails to contact a DHCP server then it returns a failure instead of falling
320 .It Fl t , -timeout Ar seconds
323 instead of the default 30.
328 to wait forever to get a lease.
329 .It Fl u , -userclass Ar class
330 Tags the DHCP message with the userclass
332 DHCP servers use this to give members of the class DHCP options other than the
333 default, without having to know things like hardware address or hostname.
334 .It Fl v , -vendor Ar code , Ns Ar value
335 Add an enscapulated vendor option.
337 should be between 1 and 254 inclusive.
338 To add a raw vendor string, omit
343 Set the vendor option 01 with an IP address.
344 .D1 dhcpcd \-v 01,192.168.0.2 eth0
345 Set the vendor option 02 with a hex code.
346 .D1 dhcpcd \-v 02,01:02:03:04:05 eth0
347 Set the vendor option 03 with an IP address as a string.
348 .D1 dhcpcd \-v 03,\e"192.168.0.2\e" eth0
349 Set un-encapulated vendor option to hello world.
350 .D1 dhcpcd \-v ,"hello world" eth0
352 Wait for an address to be assigned before forking to the background.
354 This will signal an existing
356 process running on the
362 then waits until this process has exited.
363 .It Fl y , -reboot Ar seconds
366 seconds before moving to the discover phase if we have an old lease to use.
367 The default is 10 seconds.
368 A setting of 0 seconds causes
370 to skip the reboot phase and go straight into discover.
375 This requires persistent storage and not all DHCP servers work with it so it
376 is not enabled by default.
378 generates the DUID and stores it in
379 .Pa @SYSCONFDIR@/dhcpcd.duid .
380 This file should not be copied to other hosts.
381 .It Fl E , -lastlease
384 cannot obtain a lease, then try to use the last lease acquired for the
388 option is not given then the lease is used if it hasn't expired.
389 .It Fl F , -fqdn Ar fqdn
390 Requests that the DHCP server updates DNS using FQDN instead of just a
394 are disable, none, ptr and both.
396 itself never does any DNS updates.
398 encodes the FQDN hostname as specified in
400 .It Fl I , -clientid Ar clientid
403 If the string is of the format 01:02:03 then it is encoded as hex.
404 For interfaces whose hardware address is longer than 8 bytes, or if the
406 is an empty string then
410 of the hardware family and the hardware address.
412 .Ss Restricting behaviour
414 will try to do as much as it can by default.
415 However, there are sometimes situations where you don't want the things to be
416 configured exactly how the the DHCP server wants.
417 Here are some options that deal with turning these bits off.
418 .Bl -tag -width indent
422 on the command line, only warnings and errors will be displayed.
423 The messages are still logged though.
424 .It Fl z , -allowinterfaces Ar pattern
425 When discovering interfaces, the interface name must match
427 which is a space or comma separated list of patterns passed to
429 If the same interface is matched in
430 .Fl Z , -denyinterfaces
431 then it is still denied.
433 Don't request or claim the address by ARP.
434 This also disables IPv4LL.
435 .It Fl B , -nobackground
436 Don't run in the background when we acquire a lease.
437 This is mainly useful for running under the control of another process, such
438 as a debugger or a network manager.
439 .It Fl C , -nohook Ar script
440 Don't run this hook script.
441 Matches full name, or prefixed with 2 numbers optionally ending with
446 from touching your DNS or MTU settings you would do:-
447 .D1 dhcpcd -C resolv.conf -C mtu eth0
448 .It Fl G , -nogateway
449 Don't set any default routes.
451 Don't receive link messages for carrier status.
452 You should only have to use this with buggy device drivers or running
454 through a network manager.
456 Don't use IPv4LL (aka APIPA, aka Bonjour, aka ZeroConf).
457 .It Fl O , -nooption Ar option
458 Don't request the specified option.
459 If no option given, then don't request any options other than those to
460 configure the interface and routing.
461 .It Fl Q , -require Ar option
464 to be present in all DHCP messages, otherwise the message is ignored.
467 only responds to DHCP servers and not BOOTP servers, you can
469 .Ar dhcp_message_type .
470 .It Fl S, -static Ar value
477 will not attempt to obtain a lease and just use the value for the address with
478 an infinite lease time.
480 Here is an example which configures a static address, routes and dns.
481 .D1 dhcpcd -S ip_address=192.168.0.10/24 \e
482 .D1 -S routers=192.168.0.1 \e
483 .D1 -S domain_name_servers=192.168.0.1 \e
486 On receipt of DHCP messages just call
488 with the reason of TEST which echos the DHCP variables found in the message
490 The interface configuration isn't touched and neither are any configuration
492 To test INFORM the interface needs to be configured with the desired address
496 Display a list of option codes and the associated variable for use in
497 .Xr dhcpcd-run-hooks 8 .
498 Variables are prefixed with new_ and old_ unless the option number is -.
499 Variables without an option are part of the DHCP message and cannot be
501 .It Fl W, -whitelist Ar address Ns Op /cidr
502 Only accept packets from
503 .Ar address Ns Op /cidr .
508 .It Fl X, -blacklist Ar address Ns Op Ar /cidr
509 Ignore all packets from
510 .Ar address Ns Op Ar /cidr .
511 .It Fl Z , -denyinterfaces Ar pattern
512 When discovering interfaces, the interface name must not match
514 which is a space or comma separated list of patterns passed to
517 .Sh 3RDPARTY LINK MANAGEMENT
518 Some interfaces require configuration by 3rd parties, such as PPP or VPN.
519 When an interface configuration in
521 is marked as STATIC or INFORM without an address then
523 will monitor the interface until an address is added or removed from it and
525 For point to point interfaces (like PPP), a default route to its
526 destination is automatically added to the configuration.
527 If the point to point interface if configured for INFORM, then
529 unicasts INFORM to the destination, otherwise it defaults to STATIC.
532 requires a Berkley Packet Filter, or BPF device on BSD based systems and a
533 Linux Socket Filter, or LPF device on Linux based systems.
536 .It Pa @SYSCONFDIR@/dhcpcd.conf
537 Configuration file for dhcpcd.
538 If you always use the same options, put them here.
539 .It Pa @SYSCONFDIR@/dhcpcd.duid
540 Text file that holds the DUID used to identify the host.
542 Bourne shell script that is run to configure or de-configure an interface.
544 A directory containing bourne shell scripts that are run by the above script.
545 Each script can be disabled by using the
547 option described above.
548 .It Pa @DBDIR@/dhcpcd\- Ns Ar interface Ns .lease
549 The actual DHCP message send by the server. We use this when reading the last
550 lease and use the files mtime as when it was issued.
551 .It Pa /var/run/dhcpcd.pid
554 running on all interfaces.
555 .It Pa /var/run/dhcpcd\- Ns Ar interface Ns .pid
563 .Xr dhcpcd-run-hooks 8 ,
566 .Xr if_nametoindex 3 ,
569 RFC 951, RFC 1534, RFC 2131, RFC 2132, RFC 2855, RFC 3004, RFC 3361, RFC 3396,
570 RFC 3397, RFC 3442, RFC 3927, RFC 4361, RFC 4390, RFC 4702.
572 .An Roy Marples Aq roy@marples.name
574 Please report them to http://roy.marples.name/projects/dhcpcd