Poster of Linux kernelThe best gift for a Linux geek


Section: Maintenance Commands (8) Updated: SMM
Local index Up

BSD mandoc


dhcpcd - an RFC 2131 compliant DHCP client  


[-bdgknpqwABDEGHJKLTV ] [-c , -script script ] [-e , -env value ] [-f , -config file ] [-h , -hostname hostname ] [-i , -vendorclassid vendorclassid ] [-l , -leasetime seconds ] [-m , -metric metric ] [-o , -option option ] [-r , -request address ] [-s , -inform address [/cidr ] ] [-t , -timeout seconds ] [-u , -userclass class ] [-v , -vendor code , value ] [-y , -reboot seconds ] [-z , -allowinterfaces pattern ] [-C , -nohook hook ] [-F , -fqdn FQDN ] [-I , -clientid clientid ] [-O , -nooption option ] [-Q , -require option ] [-S , -static value ] [-W , -whitelist address [/cidr ] ] [-X , -blacklist address [/cidr ] ] [-Z , -denyinterfaces pattern ] [interface] [...]
-k , -release [interface]
-U, -dumplease interface
-x , -exit [interface]
-v , -version  


is an implementation of the DHCP client specified in RFC 2131 gets the host information Po IP address, routes, etc Pc from a DHCP server and configures the network interface of the machine on which it is running. then runs the configuration script which writes DNS information to resolvconf(8), if available, otherwise directly to /etc/resolv.conf If the hostname is currently blank, (null) or localhost, or force_hostname is YES or TRUE or 1 then sets the hostname to the one supplied by the DHCP server. then daemonises and waits for the lease renewal time to lapse. It will then attempt to renew its lease and reconfigure if the new lease changes.

is also an implementation of the BOOTP client specified in RFC 951  

Local Link configuration

If failed to obtain a lease, it probes for a valid IPv4LL address Po aka ZeroConf, aka APIPA Pc . Once obtained it restarts the process of looking for a DHCP server to get a proper address.

When using IPv4LL, nearly always succeeds and returns an exit code of 0. In the rare case it fails, it normally means that there is a reverse ARP proxy installed which always defeats IPv4LL probing. To disable this behaviour, you can use the -L , -noipv4ll option.  

Multiple interfaces

If a list of interfaces are given on the command line, then only works with those interfaces, otherwise discovers available Ethernet interfaces. If any interface reports a working carrier then will try and obtain a lease before forking to the background, otherwise it will fork right away. This behaviour can be modified with the -b , -background and -w , -waitip options.

If a single interface is given then only works for that interface and runs as a separate instance. The -w , -waitip option is enabled in this instance to maintain compatibility with older versions.

Interfaces are preferred by carrier, DHCP lease/IPv4LL and then lowest metric. For systems that support route metrics, each route will be tagged with the metric, otherwise changes the routes to use the interface with the same route and the lowest metric. See options below for controlling which interfaces we allow and deny through the use of patterns.  

Hooking into DHCP events

runs /lib/dhcpcd/dhcpcd-run-hooks or the script specified by the -c , -script option. This script runs each script found in /lib/dhcpcd/dhcpcd-hooks in a lexical order. The default installation supplies the scripts 01-test 10-mtu 20-resolv.conf and 30-hostname You can disable each script by using the -C , -nohook option. See dhcpcd-run-hooks8 for details on how these scripts work. currently ignores the exit code of the script.  

Fine tuning

You can fine-tune the behaviour of with the following options:

-b , -background
Background immediately. This is useful for startup scripts which don't disable link messages for carrier status.
-c , -script script
Use this script instead of the default /lib/dhcpcd/dhcpcd-run-hooks
-d , -debug
Echo debug messages to the stderr and syslog.
-e , -env value
Push value to the environment for use in dhcpcd-run-hooks8. For example, you can force the hostname hook to always set the hostname with -e force_hostname=YES
-g , -reconfigure
will re-apply IP address, routing and run dhcpcd-run-hooks8 for each interface. This is useful so that a 3rd party such as PPP or VPN can change the routing table and / or DNS, etc and then instruct to put things back afterwards. does not read a new configuration when this happens - you should rebind if you need that functionality.
-f , -config file
Specify a config to load instead of /etc/dhcpcd.conf always processes the config file before any command line options.
-h , -hostname hostname
Sends hostname to the DHCP server so it can be registered in DNS. If hostname is an empty string then the current system hostname is sent. If hostname is a FQDN (ie, contains a .) then it will be encoded as such.
-i , -vendorclassid vendorclassid
Override the vendorclassid field sent. The default is dhcpcd <version>. If not set then none is sent.
-k , -release
This causes an existing process running on the interface to release its lease, de-configure the interface and then exit. then waits until this process has exited.
-l , -leasetime seconds
Request a specific lease time in seconds By default does not request any lease time and leaves it in the hands of the DHCP server.
-m , -metric metric
Metrics are used to prefer an interface over another one, lowest wins. will supply a default metic of 200 + if_nametoindex3. An extra 100 will be added for wireless interfaces.
-o , -option option
Request the DHCP option variable for use in /lib/dhcpcd/dhcpcd-run-hooks
-n , -rebind
Notifies to reload its configuration and rebind its interfaces. If is not running, then it starts up as normal.
-p , -persistent
normally de-configures the interface and configuration when it exits. Sometimes, this isn't desirable if, for example, you have root mounted over NFS. You can use this option to stop this from happening.
-r , -request [address ]
normally sends a DHCP DISCOVER to find servers to offer an address. then requests the address used. You can use this option to skip the DISCOVER phase and just request the address The downside is if you request an address the DHCP server does not know about or the DHCP server is not authoritative, it will remain silent. In this situation, we go back to the init state and DISCOVER again. If no address is given then the first address currently assigned to the interface is used.
-s , -inform [address [/cidr ] ]
Behaves like -r , -request as above, but sends a DHCP INFORM instead of a REQUEST. This does not get a lease as such, just notifies the DHCP server of the address in use. You should also include the optional cidr network number in case the address is not already configured on the interface. remains running and pretends it has an infinite lease. will not de-configure the interface when it exits. If fails to contact a DHCP server then it returns a failure instead of falling back on IPv4LL.
-t , -timeout seconds
Timeout after seconds instead of the default 30. A setting of 0 seconds causes to wait forever to get a lease.
-u , -userclass class
Tags the DHCP message with the userclass class DHCP servers use this to give members of the class DHCP options other than the default, without having to know things like hardware address or hostname.
-v , -vendor code , value
Add an encapsulated vendor option. code should be between 1 and 254 inclusive. To add a raw vendor string, omit code but keep the comma. Examples.

Set the vendor option 01 with an IP address. Set the vendor option 02 with a hex code. Set the vendor option 03 with an IP address as a string. Set un-encapsulated vendor option to hello world.

-v , -version
Display both program version and copyright information. then exits before doing any configuration.
-w , -waitip
Wait for an address to be assigned before forking to the background.
-x , -exit
This will signal an existing process running on the interface to de-configure the interface and exit. then waits until this process has exited.
-y , -reboot seconds
Allow reboot seconds before moving to the discover phase if we have an old lease to use. The default is 10 seconds. A setting of 0 seconds causes to skip the reboot phase and go straight into discover.
-D , -duid
Generate an RFC 4361 compliant clientid. This requires persistent storage and not all DHCP servers work with it so it is not enabled by default. generates the DUID and stores it in /etc/dhcpcd.duid This file should not be copied to other hosts.
-E , -lastlease
If cannot obtain a lease, then try to use the last lease acquired for the interface. If the -p, -persistent option is not given then the lease is used if it hasn't expired.
-F , -fqdn fqdn
Requests that the DHCP server updates DNS using FQDN instead of just a hostname. Valid values for fqdn are disable, none, ptr and both. itself never does any DNS updates. encodes the FQDN hostname as specified in RFC1035
-I , -clientid clientid
Send the clientid If the string is of the format 01:02:03 then it is encoded as hex. For interfaces whose hardware address is longer than 8 bytes, or if the clientid is an empty string then sends a default clientid of the hardware family and the hardware address.


Restricting behaviour

will try to do as much as it can by default. However, there are sometimes situations where you don't want the things to be configured exactly how the the DHCP server wants. Here are some options that deal with turning these bits off.

-q , -quiet
Quiet on the command line, only warnings and errors will be displayed. The messages are still logged though.
-z , -allowinterfaces pattern
When discovering interfaces, the interface name must match pattern which is a space or comma separated list of patterns passed to fnmatch(3). If the same interface is matched in -Z , -denyinterfaces then it is still denied.
-A , -noarp
Don't request or claim the address by ARP. This also disables IPv4LL.
-B , -nobackground
Don't run in the background when we acquire a lease. This is mainly useful for running under the control of another process, such as a debugger or a network manager.
-C , -nohook script
Don't run this hook script. Matches full name, or prefixed with 2 numbers optionally ending with .sh

So to stop from touching your DNS or MTU settings you would do:-

-G , -nogateway
Don't set any default routes.
-H , -xidhwaddr
Use the last four bytes of the hardware address as the DHCP xid instead of a randomly generated number.
-J , -broadcast
Instructs the DHCP server to broadcast replies back to the client. Normally this is only set for non Ethernet interfaces, such as FireWire and InfiniBand. In most instances, will set this automatically.
-K , -nolink
Don't receive link messages for carrier status. You should only have to use this with buggy device drivers or running through a network manager.
-L , -noipv4ll
Don't use IPv4LL (aka APIPA, aka Bonjour, aka ZeroConf).
-O , -nooption option
Don't request the specified option. If no option given, then don't request any options other than those to configure the interface and routing.
-Q , -require option
Requires the option to be present in all DHCP messages, otherwise the message is ignored. To enforce that only responds to DHCP servers and not BOOTP servers, you can -Q dhcp_message_type
-S, -static value
Configures a static value If you set ip_address then will not attempt to obtain a lease and just use the value for the address with an infinite lease time.

Here is an example which configures a static address, routes and dns.

-T, -test
On receipt of DHCP messages just call /lib/dhcpcd/dhcpcd-run-hooks with the reason of TEST which echos the DHCP variables found in the message to the console. The interface configuration isn't touched and neither are any configuration files. To test INFORM the interface needs to be configured with the desired address before starting .
-U, -dumplease interface
Dumps the last lease for the interface to stdout. interface could also be a path to a DHCP wire formatted file.
-V, -variables
Display a list of option codes and the associated variable for use in dhcpcd-run-hooks8. Variables are prefixed with new_ and old_ unless the option number is -. Variables without an option are part of the DHCP message and cannot be directly requested.
-W, -whitelist address [/cidr]
Only accept packets from address [/cidr] -X, -blacklist is ignored if -W, -whitelist is set.
-X, -blacklist address [/cidr ]
Ignore all packets from address [/cidr ]
-Z , -denyinterfaces pattern
When discovering interfaces, the interface name must not match pattern which is a space or comma separated list of patterns passed to fnmatch(3).



Some interfaces require configuration by 3rd parties, such as PPP or VPN. When an interface configuration in is marked as STATIC or INFORM without an address then will monitor the interface until an address is added or removed from it and act accordingly. For point to point interfaces (like PPP), a default route to its destination is automatically added to the configuration. If the point to point interface if configured for INFORM, then unicasts INFORM to the destination, otherwise it defaults to STATIC.  


requires a Berkley Packet Filter, or BPF device on BSD based systems and a Linux Socket Filter, or LPF device on Linux based systems.  


Configuration file for dhcpcd. If you always use the same options, put them here.
Text file that holds the DUID used to identify the host.
Bourne shell script that is run to configure or de-configure an interface.
A directory containing bourne shell scripts that are run by the above script. Each script can be disabled by using the -C , -nohook option described above.
/var/lib/dhcpcd5/dhcpcd- interface .lease
The actual DHCP message send by the server. We use this when reading the last lease and use the files mtime as when it was issued.
Stores the PID of running on all interfaces.
/var/run/dhcpcd- interface .pid
Stores the PID of running on the interface



dhcpcd.conf5, dhcpcd-run-hooks8, resolv.conf5, resolvconf(8), if_nametoindex3, fnmatch(3)  


RFC 951, RFC 1534, RFC 2131, RFC 2132, RFC 2855, RFC 3004, RFC 3361, RFC 3396, RFC 3397, RFC 3442, RFC 3927, RFC 4361, RFC 4390, RFC 4702.  


An Roy Marples Aq  


Please report them to



Local Link configuration
Multiple interfaces
Hooking into DHCP events
Fine tuning
Restricting behaviour

This document was created by man2html, using the manual pages.
Time: 22:01:30 GMT, April 16, 2011