dhcpcd

QNX SDP8.0Utilities ReferenceUtilities

Dynamic Host Configuration Protocol client

Syntax:

dhcpcd    [-146ABbDdEGgHJKLMNPpqTV] [-C, --nohook hook]
          [-c, --script script] [-e, --env value] [-F, --fqdn fqdn]
          [-f, --config file] [-h, --hostname hostname]
          [-I, --clientid clientid] [-i, --vendorclassid vendorclassid]
          [-j, --logfile logfile] [-l, --leasetime seconds]
          [-m, --metric metric] [-O, --nooption option]
          [-o, --option option] [-Q, --require option]
          [-r, --request address] [-S, --static value]
          [-s, --inform address[/cidr[/broadcast_address]]] [--inform6]
          [-t, --timeout seconds] [-u, --userclass class]
          [-v, --vendor code, value] [-W, --whitelist address[/cidr]] [-w]
          [--waitip=[4 | 6]] [-y, --reboot seconds]
          [-X, --blacklist address[/cidr]] [-Z, --denyinterfaces pattern]
          [-z, --allowinterfaces pattern] [--inactive] [--configure]
          [--noconfigure] [interface] [...]
          dhcpcd -n, --rebind [interface]
          dhcpcd -k, --release [interface]
          dhcpcd -U, --dumplease [interface]
          dhcpcd --version
          dhcpcd -x, --exit [interface]

Runs on:

QNX OS

Options:

Fine-tuning options

-b, --background
Run in the background immediately. This option is useful for startup scripts that don't disable link messages for carrier status.
-c, --script script
Use the specified script instead of the default one (/sbin/dhcpcd-run-hooks).
-D, --duid [ll | lt | uuid | value]
Use a DHCP Unique Identifier (DUID). If a system UUID is available, it is used to create a DUID-UUID. If no system UUID is available and persistent storage is available, a DUID-LLT (link local address + time) is generated; otherwise, a DUID-LL is generated (link local address). The DUID type can be hinted as an optional parameter if the file /var/db/duid does not exist. If none of ll, lt, or uuid is specified, then value is converted from 00:11:22:33 format. This value plus the IAID is used as the -I and --clientid value. The DUID generated is held in /var/db/duid and should not be copied to other hosts. This file also takes precedence over the above rules except for setting a value.
-d, --debug
Echo debug messages to stderr and the system logger.
-E, --lastlease
If dhcpcd cannot obtain a lease, then try to use the last lease acquired for the interface.
--lastleaseextend
Same as -E and --lastlease, but the lease is retained even if it expires. The dhcpcd utility gives it up if any other host tries to claim it for their own via ARP. This violates RFC 2131, section 3.7, which states that the lease should be dropped once it has expired.
-e, --env value
Push value to the environment for use in dhcpcd-run-hooks. For example, to force the hostname hook to always set the hostname, use -e force_hostname=YES.
-g, --reconfigure
Instruct dhcpcd to re-apply the IP address and routing, and run dhcpcd-run-hooks for each interface. This is useful when a third party such as PPP or VPN can change the routing table, DNS, and so on, and then instruct dhcpcd to restore things afterwards. Because dhcpcd does not read a new configuration when this happens, you should rebind if you need that functionality.
-F, --fqdn fdqn
Request that the DHCP server updates the DNS using FQDN instead of just a hostname. Valid values for fqdn are: disable, none, ptr, and both. The dhcpcd utility itself never does any DNS updates. It encodes the FQDN hostname as specified in RFC 1035.
-f, --config file
Specify a configuration file to load instead of /etc/dhcpcd.conf. The dhcpcd utility always processes the configuration file before any command line options.
-h, --hostname hostname
Send the specified hostname to the DHCP server so that it can be registered in the DNS. If the hostname value is an empty string, then the current system hostname is sent. If hostname is a FQDN (i.e., contains a .) then that's how it is encoded.
-I, --clientid clientid
Send the specified client ID. If the string is of the format 01:02:03, it is encoded as hex. For interfaces whose hardware address is longer than 8 bytes, or if the client ID is an empty string, dhcpcd sends a default client ID of the hardware family and the hardware address.
-i, --vendorclassid vendorclassid
Override the DHCPv4 vendor class ID field sent. The default is dhcpcd-version:os:machine:platform. For example:
dhcpcd-5.5.6:NetBSD-6.99.5:i386:i386

If not set, then none is sent. Some badly configured DHCP servers reject unknown vendor class IDs. To work around it, try to impersonate Windows by using the MSFT vendor class ID.

-j, --logfile logfile
Write to the specified logfile, in addition to the system log. The logfile is reopened when dhcpcd receives the SIGUSR2 signal.
-k, --release interface
Cause an existing dhcpcd process running on the interface to release its lease and de-configure the interface regardless of whether -p or --persistent is specified. If no interface is specified, then this option applies to all interfaces in manager mode (see Specifying multiple, single, or no interfaces). If no interfaces are left running, dhcpcd exits.
-l, --leasetime seconds
Request a lease time of the specified number of seconds. -1 represents an infinite lease time. By default, dhcpcd does not request any lease time and leaves it to be determined by the DHCP server.
-M, --manager
Start dhcpcd in manager mode even if only one interface is specified on the command line. See Specifying multiple, single, or no interfaces.
-m, --metric metric
Use the specified metric to prefer an interface over another one (lowest wins). The dhcpcd utility supplies a default metric of 1000 + if_nametoindex(). This value is offset by 2000 for wireless interfaces, with additional offsets of 1000000 for IPv4LL and 2000000 for roaming interfaces.
-n, --rebind interface
Reload the dhcpcd configuration and rebind the specified interface. If no interface is specified, this action applies to all interfaces in manager mode. If dhcpcd is not running, then it starts up as normal.
-N, --renew interface
Notify dhcpcd to renew existing addresses on the specified interface. If no interface is specified, this renewal applies to all interfaces in manager mode. If dhcpcd is not running, then it starts up as normal. Unlike -n and --rebind, the configuration for dhcpcd is not reloaded.
-o, --option option
Request the DHCP option variable for use in /sbin/dhcpcd-run-hooks.
-p, --persistent
Stop dhcpcd from de-configuring the interface and configuration when it exits. This behavior may be desirable if, for example, you have root mounted over NFS or SSH clients connect to this host and they need to be notified of the host shutting down. You can use this option to stop this from happening.
-r, --request address
Request the address in the DHCP DISCOVER message. There is no guarantee this is the address the DHCP server will actually give. If no address is specified, then the first address currently assigned to the interface is used.
-s, --inform [/cidr[/broadcast_address]]
Behave like -r or --request, but send a DHCPINFORM instead of DHCPDISCOVER or DHCPREQUEST. This behavior does not get a lease as such, it 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. The dhcpcd utility remains running and pretends it has an infinite lease. It does not deconfigure the interface when it exits. If dhcpcd fails to contact a DHCP server, then it returns a failure instead of falling back on IPv4LL.
--inform6
Perform a DHCPv6 Information-Request. No address is requested or specified, but all other DHCPv6 options are allowed. This action is normally performed automatically when the IPv6 Router advertises that the client should perform this operation. This option is only needed when dhcpcd is not processing IPv6RA messages and the need for DHCPv6 Information Request exists.
-S, --static value
Configure a static DHCP value. If the value sets ip_address, dhcpcd does not attempt to obtain a lease and just uses the value for the address with an infinite lease time.

Here is an example that configures a static address, routes, and DNS:

dhcpcd -S ip_address=192.168.0.10/24 \
-S routers=192.168.0.1 \
-S domain_name_servers=192.168.0.1 \
eth0
You cannot presently set static DHCPv6 values. Use -e or --env instead.
-t, --timeout seconds
Timeout after the specified number of seconds, instead of the default (30). A setting of 0 seconds causes dhcpcd to wait forever to get a lease. If dhcpcd is working on a single interface, then dhcpcd exits when a timeout occurs; otherwise, dhcpcd forks into the background.
-u, --userclass class
Tag the DHCPv4 message with the specified user class. DHCP servers use this setting 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. The code value 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.

dhcpcd -v 01,192.168.0.2 eth0

Set the vendor option 02 with a hex code.

dhcpcd -v 02,01:02:03:04:05 eth0

Set the vendor option 03 with an IP address as a string.

dhcpcd -v 03,\"192.168.0.2\" eth0

Set un-encapsulated vendor option to hello world.

dhcpcd -v ,"hello world" eth0
--version
Display both program version and copyright information. The dhcpcd utility then exits before doing any configuration.
-u, --userclass class
Tag the DHCPv4 message with the specified user class. DHCP servers use this setting to give members of the class DHCP options other than the default, without having to know things like hardware address or hostname.
-w
Wait for an address to be assigned before forking to the background. Does not take an argument, unlike --waitip.
--waitip[=[4 | 6]]
Wait for an address to be assigned before forking to the background. Specify 4 to wait for an IPv4 address to be assigned, or 6 to wait for an IPv6 address to be assigned. If no argument is given, dhcpcd waits for any address protocol to be assigned. It is possible to wait for more than one address protocol, in which case dhcpcd only forks to the background when all waiting conditions are satisfied.
-x, --exit interface
Signal an existing dhcpcd process running on the interface to exit. If no interface is specified, then the action is applied to all interfaces in manager mode. Use -p or --persistent to control configuration persistence on exit, which is enabled by default in dhcpcd.conf. The dhcpcd utility then waits until this process has exited.
-y, --reboot seconds
Allow a reboot for the specified number of seconds before moving to the discover phase if there is an old lease to use. Allow a reboot for the specified number of seconds before starting fallback states from the discover phase. IPv4LL is started when the first reboot timeout is reached. The default is 5 seconds. A setting of 0 seconds causes dhcpcd to skip the reboot phase and go straight into discover. This has no effect on DHCPv6 other than skipping the reboot phase.

Options for restricting behavior

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

When dhcpcd is restricted to a single interface, the interface also needs to be specified when asking dhcpcd to exit using the command line. If the protocol is restricted as well, then the protocol needs to be included with the exit instruction.

-1, --oneshot
Exit after configuring an interface. Use -w or --waitip to specify which protocol or protocols to configure before exiting.
-4, --ipv4only
Configure IPv4 only.
-6, --ipv6only
Configure IPv6 only.
-A, --noarp
Don't request or claim the address by ARP. This also disables IPv4LL.
-B, --nobackground
Don't run in the background when a lease is acquired. This option 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 the specified hook script. Matches full name, or prefixed with two numbers optionally ending with .sh.

For example, the following command options stop dhcpcd from touching the DNS settings:

dhcpcd -C resolv.conf eth0
-G, --nogateway
Don't set any default routes.
-H, --xidhwaddr
Use the last four bytes of the hardware address as the DHCP transaction identifier (xid) instead of a randomly generated number.
-J, --broadcast
Instruct 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, dhcpcd sets 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 dhcpcd through a network manager.
-L, --noipv4ll
Don't use IPv4LL (also known as APIPA, Bonjour, or ZeroConf).
-O, --nooption option
Remove the specified option from the DHCP message before processing.
-P, --printpidfile
Print the PID file that dhcpcd uses based on command-line arguments to stdout.
-Q, --require option
Require the specified option to be present in all DHCP messages; otherwise, the message is ignored. To enforce that dhcpcd only responds to DHCP servers and not BOOTP servers, use -Q dhcp_message_type.
-q, --quiet
Make dhcpcd quiet on the command line. Only warnings and errors are displayed. If this option is specified a second time, all console output is disabled. These messages are still logged via the system log.
-T, --test
On receipt of DHCP messages, call /sbin/dhcpcd-run-hooks with a reason of TEST, which echoes the DHCP variables found in the message to the console. The interface configuration isn't touched and neither are any configuration files. The rapid commit option is not sent in TEST mode so that the server does not lease an address. To test INFORM, the interface needs to be configured with the desired address before starting dhcpcd.
-U, --dumplease interface
Dump the current lease for the interface to stdout. If no interface is given, all interfaces are dumped. Use -4 or -6 to specify an address family. If a lease is piped in via standard input, then that is dumped. In the case of a piped-in lease, specifying an address family is mandatory.
-V, --variables
Display a list of option codes, the associated variable, and encoding for use in dhcpcd-run-hooks. 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 the specified address. -X and --blacklist are ignored if -W or --whitelist is set.
-X, --blacklist address[/cidr]
Ignore all packets from the specified address.
-Z, --denyinterfaces pattern
When discovering interfaces, ignore any interface with a name that matches the specified pattern, which is a space- or comma-separated list of patterns passed to fnmatch().
-z, --allowinterfaces pattern
When discovering interfaces, the interface name must match the specified pattern, which is a space- or comma-separated list of patterns passed to fnmatch(). If the same interface matches a pattern specified by -Z or --denyinterfaces, it is still denied.
--inactive
Don't start any interfaces other than those specified on the command line. This restriction allows you to start dhcpcd in manager mode and then wait for subsequent dhcpcd commands to start each interface as required.
--configure
Allow dhcpcd to configure the system. This is the default behaviour and sets the if_configured environment variable to true.
--noconfigure
Instruct dhcpcd to not configure the system at all. Used only if the script that dhcpcd calls at each network event (specifed by --script) configures the system instead. This option is different from -T and --test in that it's not one shot and the only change to the environment is the addition of setting the if_configured variable to false.
--nodev
Don't load any /dev management modules.

Description:

The dhcpcd utility is an implementation of the DHCP client specified in RFC 2131.

It performs the following tasks:

  1. Gets the host information (IP address, routes, etc.) from a DHCP server and configures the network interface of the machine on which it is running.
  2. Runs the configuration script which writes DNS information to /etc/resolv.conf.
    The dhcpcd utility sets the hostname to the one supplied by the DHCP server if:
    • the hostname is currently blank, null, or local-host, or
    • force_hostname is YES or TRUE or 1.
  3. Daemonises and waits for the lease renewal time to lapse.
  4. Attempts to renew its lease and reconfigure if the new lease changes when the lease begins to expire or the DHCP server sends a message to renew early.

If any interface reports a working carrier, dhcpcd tries to obtain a lease before forking to the background; otherwise, it forks right away. This behavior can be modified with -b,--background, -w, or --waitip.

If you use the command line to restrict dhcpcd to a single interface and, optionally, address family, all further calls to dhcpcd to rebind, reconfigure, or exit need to include the same restrictive flags so that dhcpcd knows which process to signal.

This dhcpcd utility is an implementation of:

  • The BOOTP client specified in RFC 951.
  • The IPv6 Router Solicitor as specified in RFC 4861 and RFC 6106.
  • The IPv6 Privacy Extensions to Auto-Conf as specified in RFC 4941. For more information, see Enabling privacy extensions to auto-configuration.
  • The DHCPv6 client as specified in RFC 3315. By default, dhcpcd only starts DHCPv6 when instructed to do so by an IPV6 Router Advertisement. If no Identity Association is configured, then a Non-Temporary Address is requested.

Local link configuration

If dhcpcd fails to obtain a lease, it probes for a valid IPv4LL address (also known as ZeroConf or APIPA). After it obtains this address, it restarts the process of looking for a DHCP server to get a proper address.

When using IPv4LL, dhcpcd 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 behavior, you can use -L or --noipv4ll.

Specifying multiple, single, or no interfaces

If one or more interfaces are specified on the command line, dhcpcd manages those interfaces only. For example, the following instance of dchcpcd only manages vtnet0.

dhcpcd -bqq vtnet0

If no interface is specified, dhcpcd discovers available Ethernet interfaces that can be configured. This is called manager mode.

If a single interface is given, then dhcpcd only works for that interface and runs as a separate instance to other dhcpcd processes. Enable -w or --waitip to maintain compatibility with older versions. Using a single interface also affects -k, -N, -n and -x, where the same interface needs to be specified, as a lack of an interface implies manager mode, which this is not. To force starting in manager mode with only one interface, use -M or --manager.

Interfaces are preferred by carrier, DHCP lease or IPv4LL, and then lowest metric. For systems that support route metrics, each route is tagged with the metric; otherwise, dhcpcd changes the routes to use the interface with the same route and the lowest metric. See Options for restricting behavior for options that control which interfaces are allowed and denied through the use of patterns.

Non-Ethernet interfaces and some virtual Ethernet interfaces such as TAP and bridge are ignored by default, as is the FireWire interface. To work with these devices, they either need to be specified on the command line, be listed in --allowinterfaces, or have an interface directive in /etc/dhcpcd.conf.

Hooking into events

The dhcpcd utility runs /sbin/dhcpcd-run-hooks, or the script specified by -c or --script. The /sbin/dhcpcd-run-hooks script runs each script found in /sbin/dhcpcd-hooks in a lexical order. The default installation supplies the scripts 20-resolv.conf and 30-hostname. To use additional scripts, copy them to /sbin/dhcpcd-run-hooks. You can disable each script by using -C or --nohook. See the dhcpcd-run-hooks entry for details on how these scripts work. The dhcpcd utility currently ignores the exit code of the script.

Third-party link management

Some interfaces require configuration by third parties, such as PPP or VPN. When an interface configuration in dhcpcd is marked as STATIC or INFORM without an address, dhcpcd monitors the interface until an address is added or removed from it, and then acts 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 is configured for INFORM, then dhcpcd unicasts INFORM to the destination; otherwise, it defaults to STATIC.

Enabling privacy extensions to auto-configuration

The IPv6 Privacy Extensions feature generates privacy addresses for each IPv6 interface as described in RFC 4941. Use the sysctl variables net.inet6.ip6.use_tempaddr and net.inet6.ip6.prefer_tempaddr to enable it. In most cases, because you want this feature enabled before the interface is created, set the systcl variables using the configuration file.

Files:

/etc/dhcpcd.conf
Configuration file for dhcpcd. If you always use the same options, put them here. See the /etc/dhcpcd.conf entry.
/sbin/dhcpcd-run-hooks
Bourne shell script you run to configure or de-configure an interface. See the dhcpcd-run-hooks entry.
/lib/dhcpcd/dev
Linux /dev management modules.
/sbin/dhcpcd-hooks
A directory containing bourne shell scripts that are run by /sbin/dhcpcd-run-hooks. Each script can be disabled using -C or --nohook.
/var/db/duid
A text file that holds the DUID used to identify the host.
/var/db/secret
A text file that holds a secret key known only to the host.
/var/db/interface-ssid.lease
The actual DHCP message sent by the server. The dhcp utility uses it when reading the last lease and considers the time when the file was last modified (mtime) to be the time when the lease was originally issued.
/var/db/interface-ssid.lease6
The actual DHCPv6 message sent by the server. The dhcp utility uses it when reading the last lease and considers the time when the file was last modified (mtime) to be the time when the lease was originally issued.
/var/db/rdm_monotonic
Stores the monotonic counter used in the replay field in authentication options.
/var/run/dhcpcd/pid
Stores the PID of dhcpcd running on all interfaces.
/var/run/dhcpcd/interface.pid
Stores the PID of dhcpcd running on the interface.
/var/run/dhcpcd/sock
Control socket to the manager daemon.
/var/run/dhcpcd/unpriv.sock
Unprivileged socket to the manager daemon, only allows state retrieval.
/var/run/dhcpcd/interface.sock
Control socket to per interface daemon.
/var/run/dhcpcd/interface.unpriv.sock
Unprivileged socket to per interface daemon, only allows state retrieval.

Standards:

RFC 951, RFC 1534, RFC 2104, RFC 2131, RFC 2132, RFC 2563, RFC 2855, RFC 3004, RFC 3118, RFC 3203, RFC 3315, RFC 3361, RFC 3633, RFC 3396, RFC 3397, RFC 3442, RFC 3495, RFC 3925, RFC 3927, RFC 4039, RFC 4075, RFC 4242, RFC 4361, RFC 4390, RFC 4702, RFC 4074, RFC 4861, RFC 4833, RFC 4941, RFC 5227, RFC 5942, RFC 5969, RFC 6106, RFC 6334, RFC 6355, RFC 6603, RFC 6704, RFC 7217, RFC 7550, RFC 7844

Contributing author:

Roy Marples roy@marples.name
Page updated: