1DHCPCD(8) BSD System Manager's Manual DHCPCD(8)
2
4 dhcpcd — a DHCP client
5
7 dhcpcd [-146ABbDdEGgHJKLMNPpqTV] [-C, --nohook hook]
8 [-c, --script script] [-e, --env value] [-F, --fqdn FQDN]
9 [-f, --config file] [-h, --hostname hostname]
10 [-I, --clientid clientid] [-i, --vendorclassid vendorclassid]
11 [-j, --logfile logfile] [-l, --leasetime seconds]
12 [-m, --metric metric] [-O, --nooption option]
13 [-o, --option option] [-Q, --require option]
14 [-r, --request address] [-S, --static value]
15 [-s, --inform address[/cidr[/broadcast_address]]] [--inform6]
16 [-t, --timeout seconds] [-u, --userclass class]
17 [-v, --vendor code, value] [-W, --whitelist address[/cidr]] [-w]
18 [--waitip=[4 | 6]] [-y, --reboot seconds]
19 [-X, --blacklist address[/cidr]] [-Z, --denyinterfaces pattern]
20 [-z, --allowinterfaces pattern] [--inactive] [--configure]
21 [--noconfigure] [interface] [...]
22 dhcpcd -n, --rebind [interface]
23 dhcpcd -k, --release [interface]
24 dhcpcd -U, --dumplease [interface]
25 dhcpcd --version
26 dhcpcd -x, --exit [interface]
27
29 dhcpcd is an implementation of the DHCP client specified in RFC 2131.
30 dhcpcd gets the host information (IP address, routes, etc) from a DHCP
31 server and configures the network interface of the machine on which it is
32 running. dhcpcd then runs the configuration script which writes DNS in‐
33 formation to resolvconf(8), if available, otherwise directly to
34 /etc/resolv.conf. If the hostname is currently blank, (null) or local‐
35 host, or force_hostname is YES or TRUE or 1 then dhcpcd sets the hostname
36 to the one supplied by the DHCP server. dhcpcd then daemonises and waits
37 for the lease renewal time to lapse. It will then attempt to renew its
38 lease and reconfigure if the new lease changes when the lease begins to
39 expire or the DHCP server sends a message to renew early.
40
41 If any interface reports a working carrier then dhcpcd will try to obtain
42 a lease before forking to the background, otherwise it will fork right
43 away. This behaviour can be modified with the -b, --background and -w,
44 --waitip options.
45
46 dhcpcd is also an implementation of the BOOTP client specified in RFC
47 951.
48
49 dhcpcd is also an implementation of the IPv6 Router Solicitor as speci‐
50 fied in RFC 4861 and RFC 6106.
51
52 dhcpcd is also an implementation of the IPv6 Privacy Extensions to Auto‐
53 Conf as specified in RFC 4941. This feature needs to be enabled in the
54 kernel and dhcpcd will start using it.
55
56 dhcpcd is also an implementation of the DHCPv6 client as specified in RFC
57 3315. By default, dhcpcd only starts DHCPv6 when instructed to do so by
58 an IPV6 Router Advertisement. If no Identity Association is configured,
59 then a Non-temporary Address is requested.
60
61 Local Link configuration
62 If dhcpcd failed to obtain a lease, it probes for a valid IPv4LL address
63 (aka ZeroConf, aka APIPA). Once obtained it restarts the process of
64 looking for a DHCP server to get a proper address.
65
66 When using IPv4LL, dhcpcd nearly always succeeds and returns an exit code
67 of 0. In the rare case it fails, it normally means that there is a re‐
68 verse ARP proxy installed which always defeats IPv4LL probing. To dis‐
69 able this behaviour, you can use the -L, --noipv4ll option.
70
71 Multiple interfaces
72 If a list of interfaces are given on the command line, then dhcpcd only
73 works with those interfaces, otherwise dhcpcd discovers available Ether‐
74 net interfaces that can be configured. When dhcpcd not limited to one
75 interface on the command line, it is running in Master mode. The
76 dhcpcd-ui project expects dhcpcd to be running this way.
77
78 If a single interface is given then dhcpcd only works for that interface
79 and runs as a separate instance to other dhcpcd processes. -w, --waitip
80 option is enabled in this instance to maintain compatibility with older
81 versions. Using a single interface also affects the -k, -N, -n and -x
82 options, where the same interface will need to be specified, as a lack of
83 an interface will imply Master mode which this is not. To force starting
84 in Master mode with only one interface, the -M, --master option can be
85 used.
86
87 Interfaces are preferred by carrier, DHCP lease/IPv4LL and then lowest
88 metric. For systems that support route metrics, each route will be
89 tagged with the metric, otherwise dhcpcd changes the routes to use the
90 interface with the same route and the lowest metric. See options below
91 for controlling which interfaces we allow and deny through the use of
92 patterns.
93
94 Non-ethernet interfaces and some virtual ethernet interfaces such as TAP
95 and bridge are ignored by default, as is the FireWire interface. To work
96 with these devices they either need to be specified on the command line,
97 be listed in --allowinterfaces or have an interface directive in
98 /etc/dhcpcd.conf.
99
100 Hooking into events
101 dhcpcd runs /usr/libexec/dhcpcd-run-hooks, or the script specified by the
102 -c, --script option. This script runs each script found in
103 /usr/libexec/dhcpcd-hooks in a lexical order. The default installation
104 supplies the scripts 01-test, 02-dump, 20-resolv.conf and 30-hostname.
105 You can disable each script by using the -C, --nohook option. See
106 dhcpcd-run-hooks(8) for details on how these scripts work. dhcpcd cur‐
107 rently ignores the exit code of the script.
108
109 More scripts are supplied in /usr/share/dhcpcd/hooks and need to be
110 copied to /usr/libexec/dhcpcd-hooks if you intend to use them. For exam‐
111 ple, you could install 29-lookup-hostname so that dhcpcd can lookup the
112 hostname of the IP address in DNS if no hostname is given by the lease
113 and one is not already set.
114
115 Fine tuning
116 You can fine-tune the behaviour of dhcpcd with the following options:
117
118 -b, --background
119 Background immediately. This is useful for startup scripts which
120 don't disable link messages for carrier status.
121
122 -c, --script script
123 Use this script instead of the default
124 /usr/libexec/dhcpcd-run-hooks.
125
126 -D, --duid [ll | lt | uuid | value]
127 Use a DHCP Unique Identifier. If a system UUID is available,
128 that will be used to create a DUID-UUID, otheriwse if persistent
129 storage is available then a DUID-LLT (link local address + time)
130 is generated, otherwise DUID-LL is generated (link local ad‐
131 dress). The DUID type can be hinted as an optional parameter if
132 the file /var/lib/dhcpcd/duid does not exist. If not ll, lt or
133 uuid then value will be converted from 00:11:22:33 format. This,
134 plus the IAID will be used as the -I, --clientid. The DUID gen‐
135 erated will be held in /var/lib/dhcpcd/duid and should not be
136 copied to other hosts. This file also takes precedence over the
137 above rules except for setting a value.
138
139 -d, --debug
140 Echo debug messages to the stderr and syslog.
141
142 -E, --lastlease
143 If dhcpcd cannot obtain a lease, then try to use the last lease
144 acquired for the interface.
145
146 --lastleaseextend
147 Same as the above, but the lease will be retained even if it ex‐
148 pires. dhcpcd will give it up if any other host tries to claim
149 it for their own via ARP. This violates RFC 2131, section 3.7,
150 which states the lease should be dropped once it has expired.
151
152 -e, --env value
153 Push value to the environment for use in dhcpcd-run-hooks(8).
154 For example, you can force the hostname hook to always set the
155 hostname with -e force_hostname=YES.
156
157 -g, --reconfigure
158 dhcpcd will re-apply IP address, routing and run
159 dhcpcd-run-hooks(8) for each interface. This is useful so that a
160 3rd party such as PPP or VPN can change the routing table and /
161 or DNS, etc and then instruct dhcpcd to put things back after‐
162 wards. dhcpcd does not read a new configuration when this hap‐
163 pens - you should rebind if you need that functionality.
164
165 -F, --fqdn fqdn
166 Requests that the DHCP server updates DNS using FQDN instead of
167 just a hostname. Valid values for fqdn are disable, none, ptr
168 and both. dhcpcd itself never does any DNS updates. dhcpcd en‐
169 codes the FQDN hostname as specified in RFC 1035.
170
171 -f, --config file
172 Specify a config to load instead of /etc/dhcpcd.conf. dhcpcd al‐
173 ways processes the config file before any command line options.
174
175 -h, --hostname hostname
176 Sends hostname to the DHCP server so it can be registered in DNS.
177 If hostname is an empty string then the current system hostname
178 is sent. If hostname is a FQDN (i.e., contains a .) then it will
179 be encoded as such.
180
181 -I, --clientid clientid
182 Send the clientid. If the string is of the format 01:02:03 then
183 it is encoded as hex. For interfaces whose hardware address is
184 longer than 8 bytes, or if the clientid is an empty string then
185 dhcpcd sends a default clientid of the hardware family and the
186 hardware address.
187
188 -i, --vendorclassid vendorclassid
189 Override the DHCPv4 vendorclassid field sent. The default is
190 dhcpcd-<version>:<os>:<machine>:<platform>. For example
191 dhcpcd-5.5.6:NetBSD-6.99.5:i386:i386
192 If not set then none is sent. Some badly configured DHCP servers
193 reject unknown vendorclassids. To work around it, try and imper‐
194 sonate Windows by using the MSFT vendorclassid.
195
196 -j, --logfile logfile
197 Writes to the specified logfile. dhcpcd still writes to
198 syslog(3). The logfile is reopened when dhcpcd receives the
199 SIGUSR2 signal.
200
201 -k, --release [interface]
202 This causes an existing dhcpcd process running on the interface
203 to release its lease and de-configure the interface regardless of
204 the -p, --persistent option. If no interface is specified then
205 this applies to all interfaces in Master mode. If no interfaces
206 are left running, dhcpcd will exit.
207
208 -l, --leasetime seconds
209 Request a lease time of seconds. -1 represents an infinite lease
210 time. By default dhcpcd does not request any lease time and
211 leaves it in the hands of the DHCP server.
212
213 -M, --master
214 Start dhcpcd in Master mode even if only one interface specified
215 on the command line. See the Multiple Interfaces section above.
216
217 -m, --metric metric
218 Metrics are used to prefer an interface over another one, lowest
219 wins. dhcpcd will supply a default metic of 200 +
220 if_nametoindex(3). An extra 100 will be added for wireless in‐
221 terfaces.
222
223 -n, --rebind [interface]
224 Notifies dhcpcd to reload its configuration and rebind the speci‐
225 fied interface. If no interface is specified then this applies
226 to all interfaces in Master mode. If dhcpcd is not running, then
227 it starts up as normal.
228
229 -N, --renew [interface]
230 Notifies dhcpcd to renew existing addresses on the specified
231 interface. If no interface is specified then this applies to all
232 interfaces in Master mode. If dhcpcd is not running, then it
233 starts up as normal. Unlike the -n, --rebind option above, the
234 configuration for dhcpcd is not reloaded.
235
236 -o, --option option
237 Request the DHCP option variable for use in
238 /usr/libexec/dhcpcd-run-hooks.
239
240 -p, --persistent
241 dhcpcd normally de-configures the interface and configuration
242 when it exits. Sometimes, this isn't desirable if, for example,
243 you have root mounted over NFS or SSH clients connect to this
244 host and they need to be notified of the host shutting down. You
245 can use this option to stop this from happening.
246
247 -r, --request address
248 Request the address in the DHCP DISCOVER message. There is no
249 guarantee this is the address the DHCP server will actually give.
250 If no address is given then the first address currently assigned
251 to the interface is used.
252
253 -s, --inform address[/cidr[/broadcast_address]]
254 Behaves like -r, --request as above, but sends a DHCP INFORM in‐
255 stead of DISCOVER/REQUEST. This does not get a lease as such,
256 just notifies the DHCP server of the address in use. You should
257 also include the optional cidr network number in case the address
258 is not already configured on the interface. dhcpcd remains run‐
259 ning and pretends it has an infinite lease. dhcpcd will not de-
260 configure the interface when it exits. If dhcpcd fails to con‐
261 tact a DHCP server then it returns a failure instead of falling
262 back on IPv4LL.
263
264 --inform6
265 Performs a DHCPv6 Information Request. No address is requested
266 or specified, but all other DHCPv6 options are allowed. This is
267 normally performed automatically when the IPv6 Router Advertises
268 that the client should perform this operation. This option is
269 only needed when dhcpcd is not processing IPv6RA messages and the
270 need for DHCPv6 Information Request exists.
271
272 -S, --static value
273 Configures a static DHCP value. If you set ip_address then
274 dhcpcd will not attempt to obtain a lease and just use the value
275 for the address with an infinite lease time.
276
277 Here is an example which configures a static address, routes and
278 DNS.
279 dhcpcd -S ip_address=192.168.0.10/24 \
280 -S routers=192.168.0.1 \
281 -S domain_name_servers=192.168.0.1 \
282 eth0
283
284 You cannot presently set static DHCPv6 values. Use the -e, --env
285 option instead.
286
287 -t, --timeout seconds
288 Timeout after seconds, instead of the default 30. A setting of 0
289 seconds causes dhcpcd to wait forever to get a lease. If dhcpcd
290 is working on a single interface then dhcpcd will exit when a
291 timeout occurs, otherwise dhcpcd will fork into the background.
292
293 -u, --userclass class
294 Tags the DHCPv4 message with the userclass class. DHCP servers
295 use this to give members of the class DHCP options other than the
296 default, without having to know things like hardware address or
297 hostname.
298
299 -v, --vendor code,value
300 Add an encapsulated vendor option. code should be between 1 and
301 254 inclusive. To add a raw vendor string, omit code but keep
302 the comma. Examples.
303
304 Set the vendor option 01 with an IP address.
305 dhcpcd -v 01,192.168.0.2 eth0
306 Set the vendor option 02 with a hex code.
307 dhcpcd -v 02,01:02:03:04:05 eth0
308 Set the vendor option 03 with an IP address as a string.
309 dhcpcd -v 03,\"192.168.0.2\" eth0
310 Set un-encapsulated vendor option to hello world.
311 dhcpcd -v ,"hello world" eth0
312
313 --version
314 Display both program version and copyright information. dhcpcd
315 then exits before doing any configuration.
316
317 -w Wait for an address to be assigned before forking to the back‐
318 ground. Does not take an argument, unlike the below option.
319
320 --waitip=[4 | 6]
321 Wait for an address to be assigned before forking to the back‐
322 ground. 4 means wait for an IPv4 address to be assigned. 6
323 means wait for an IPv6 address to be assigned. If no argument is
324 given, dhcpcd will wait for any address protocol to be assigned.
325 It is possible to wait for more than one address protocol and
326 dhcpcd will only fork to the background when all waiting condi‐
327 tions are satisfied.
328
329 -x, --exit [interface]
330 This will signal an existing dhcpcd process running on the
331 interface to exit. If no interface is specified, then the above
332 is applied to all interfaces in Master mode. See the -p,
333 --persistent option to control configuration persistence on exit,
334 which is enabled by default in dhcpcd.conf(5). dhcpcd then waits
335 until this process has exited.
336
337 -y, --reboot seconds
338 Allow reboot seconds before moving to the discover phase if we
339 have an old lease to use. Allow reboot seconds before starting
340 fallback states from the discover phase. IPv4LL is started when
341 the first reboot timeout is reached. The default is 5 seconds.
342 A setting of 0 seconds causes dhcpcd to skip the reboot phase and
343 go straight into discover. This has no effect on DHCPv6 other
344 than skipping the reboot phase.
345
346 Restricting behaviour
347 dhcpcd will try to do as much as it can by default. However, there are
348 sometimes situations where you don't want the things to be configured ex‐
349 actly how the DHCP server wants. Here are some options that deal with
350 turning these bits off.
351
352 Note that when dhcpcd is restricted to a single interface then the inter‐
353 face also needs to be specified when asking dhcpcd to exit using the com‐
354 mandline. If the protocol is restricted as well then the protocol needs
355 to be included with the exit instruction.
356
357 -1, --oneshot
358 Exit after configuring an interface. Use the -w, --waitip option
359 to specify which protocol(s) to configure before exiting.
360
361 -4, --ipv4only
362 Configure IPv4 only.
363
364 -6, --ipv6only
365 Configure IPv6 only.
366
367 -A, --noarp
368 Don't request or claim the address by ARP. This also disables
369 IPv4LL.
370
371 -B, --nobackground
372 Don't run in the background when we acquire a lease. This is
373 mainly useful for running under the control of another process,
374 such as a debugger or a network manager.
375
376 -C, --nohook script
377 Don't run this hook script. Matches full name, or prefixed with
378 2 numbers optionally ending with .sh.
379
380 So to stop dhcpcd from touching your DNS settings you would do:-
381 dhcpcd -C resolv.conf eth0
382
383 -G, --nogateway
384 Don't set any default routes.
385
386 -H, --xidhwaddr
387 Use the last four bytes of the hardware address as the DHCP xid
388 instead of a randomly generated number.
389
390 -J, --broadcast
391 Instructs the DHCP server to broadcast replies back to the
392 client. Normally this is only set for non-Ethernet interfaces,
393 such as FireWire and InfiniBand. In most instances, dhcpcd will
394 set this automatically.
395
396 -K, --nolink
397 Don't receive link messages for carrier status. You should only
398 have to use this with buggy device drivers or running dhcpcd
399 through a network manager.
400
401 -L, --noipv4ll
402 Don't use IPv4LL (aka APIPA, aka Bonjour, aka ZeroConf).
403
404 -O, --nooption option
405 Removes the option from the DHCP message before processing.
406
407 -P, --printpidfile
408 Print the pidfile dhcpcd will use based on commmand-line argu‐
409 ments to stdout.
410
411 -Q, --require option
412 Requires the option to be present in all DHCP messages, otherwise
413 the message is ignored. To enforce that dhcpcd only responds to
414 DHCP servers and not BOOTP servers, you can -Q dhcp_message_type.
415
416 -q, --quiet
417 Quiet dhcpcd on the command line, only warnings and errors will
418 be displayed. If this option is used another time then all con‐
419 sole output is disabled. These messages are still logged via
420 syslog(3).
421
422 -T, --test
423 On receipt of DHCP messages just call
424 /usr/libexec/dhcpcd-run-hooks with the reason of TEST which echos
425 the DHCP variables found in the message to the console. The in‐
426 terface configuration isn't touched and neither are any configu‐
427 ration files. The rapid_commit option is not sent in TEST mode
428 so that the server does not lease an address. To test INFORM the
429 interface needs to be configured with the desired address before
430 starting dhcpcd.
431
432 -U, --dumplease [interface]
433 Dumps the current lease for the interface to stdout. If no
434 interface is given then all interfaces are dumped. Use the -4 or
435 -6 flags to specify an address family. If a lease is piped in
436 via standard input then that is dumped. In this case, specifying
437 an address family is mandatory.
438
439 -V, --variables
440 Display a list of option codes, the associated variable and en‐
441 coding for use in dhcpcd-run-hooks(8). Variables are prefixed
442 with new_ and old_ unless the option number is -. Variables
443 without an option are part of the DHCP message and cannot be di‐
444 rectly requested.
445
446 -W, --whitelist address[/cidr]
447 Only accept packets from address[/cidr]. -X, --blacklist is ig‐
448 nored if -W, --whitelist is set.
449
450 -X, --blacklist address[/cidr]
451 Ignore all packets from address[/cidr].
452
453 -Z, --denyinterfaces pattern
454 When discovering interfaces, the interface name must not match
455 pattern which is a space or comma separated list of patterns
456 passed to fnmatch(3).
457
458 -z, --allowinterfaces pattern
459 When discovering interfaces, the interface name must match
460 pattern which is a space or comma separated list of patterns
461 passed to fnmatch(3). If the same interface is matched in -Z,
462 --denyinterfaces then it is still denied.
463
464 --inactive
465 Don't start any interfaces other than those specified on the com‐
466 mand line. This allows dhcpcd to be started in Master mode and
467 then wait for subsequent dhcpcd commands to start each interface
468 as required.
469
470 --configure
471 Allows dhcpcd to configure the system. This is the default be‐
472 haviour and sets if_configured=true.
473
474 --noconfigure
475 dhcpcd will not configure the system at all. This is only of use
476 if the --script that dhcpcd calls at each network event config‐
477 ures the system instead. This is different from -T, --test mode
478 in that it's not one shot and the only change to the environment
479 is the addition of if_configured=false.
480
481 --nodev
482 Don't load any /dev management modules.
483
485 Some interfaces require configuration by 3rd parties, such as PPP or VPN.
486 When an interface configuration in dhcpcd is marked as STATIC or INFORM
487 without an address then dhcpcd will monitor the interface until an ad‐
488 dress is added or removed from it and act accordingly. For point to
489 point interfaces (like PPP), a default route to its destination is auto‐
490 matically added to the configuration. If the point to point interface is
491 configured for INFORM, then dhcpcd unicasts INFORM to the destination,
492 otherwise it defaults to STATIC.
493
495 dhcpcd requires a Berkley Packet Filter, or BPF device on BSD based sys‐
496 tems and a Linux Socket Filter, or LPF device on Linux based systems for
497 all IPv4 configuration.
498
499 If restricting dhcpcd to a single interface and optionally address family
500 via the command-line then all further calls to dhcpcd to rebind, recon‐
501 figure or exit need to include the same restrictive flags so that dhcpcd
502 knows which process to signal.
503
504 Some DHCP servers implement ClientID filtering. If dhcpcd is replacing
505 an in-use DHCP client then you might need to adjust the clientid option
506 dhcpcd sends to match. If using a DUID in place of the ClientID, edit
507 /var/lib/dhcpcd/duid accordingly.
508
510 /etc/dhcpcd.conf
511 Configuration file for dhcpcd. If you always use the same options, put
512 them here.
513
514 /usr/libexec/dhcpcd-run-hooks
515 Bourne shell script that is run to configure or de-configure an inter‐
516 face.
517
518 /usr/lib64/dhcpcd/dev
519 Linux /dev management modules.
520
521 /usr/libexec/dhcpcd-hooks
522 A directory containing bourne shell scripts that are run by the above
523 script. Each script can be disabled by using the -C, --nohook option de‐
524 scribed above.
525
526 /var/lib/dhcpcd/duid
527 Text file that holds the DUID used to identify the host.
528
529 /var/lib/dhcpcd/secret
530 Text file that holds a secret key known only to the host.
531
532 /var/lib/dhcpcd/interface-ssid.lease
533 The actual DHCP message sent by the server. We use this when reading the
534 last lease and use the file's mtime as when it was issued.
535
536 /var/lib/dhcpcd/interface-ssid.lease6
537 The actual DHCPv6 message sent by the server. We use this when reading
538 the last lease and use the file's mtime as when it was issued.
539
540 /var/lib/dhcpcd/rdm_monotonic
541 Stores the monotonic counter used in the replay field in Authentication
542 Options.
543
544 /var/run/dhcpcd/pid
545 Stores the PID of dhcpcd running on all interfaces.
546
547 /var/run/dhcpcd/interface.pid
548 Stores the PID of dhcpcd running on the interface.
549
550 /var/run/dhcpcd/sock
551 Control socket to the master daemon.
552
553 /var/run/dhcpcd/unpriv.sock
554 Unprivileged socket to the master daemon, only allows state retrieval.
555
556 /var/run/dhcpcd/interface.sock
557 Control socket to per interface daemon.
558
560 fnmatch(3), if_nametoindex(3), dhcpcd.conf(5), resolv.conf(5),
561 dhcpcd-run-hooks(8), resolvconf(8)
562
564 RFC 951, RFC 1534, RFC 2104, RFC 2131, RFC 2132, RFC 2563, RFC 2855,
565 RFC 3004, RFC 3118, RFC 3203, RFC 3315, RFC 3361, RFC 3633, RFC 3396,
566 RFC 3397, RFC 3442, RFC 3495, RFC 3925, RFC 3927, RFC 4039, RFC 4075,
567 RFC 4242, RFC 4361, RFC 4390, RFC 4702, RFC 4074, RFC 4861, RFC 4833,
568 RFC 4941, RFC 5227, RFC 5942, RFC 5969, RFC 6106, RFC 6334, RFC 6355,
569 RFC 6603, RFC 6704, RFC 7217, RFC 7550, RFC 7844.
570
572 Roy Marples <roy@marples.name>
573
575 Please report them to http://roy.marples.name/projects/dhcpcd
576
577BSD November 25, 2020 BSD