1.2. dhclient --- DHCP client

1.2.1. Synopsis

dhclient [ -4 | -6 ] [ -S ] [ -N [ -N ... ] ] [ -T [ -T ... ] ] [ -P [ -P ... ] ] -R ] [ -i ] [ -I ] [ -4o6 <port> ] [ -D <LL|LLT> ] [ -p <port> ] [ -d ] [ -df <duid-lease-file> ] [ -e <VAR>*=*<value> ] [ -q ] [ -1 ] [ -r | -x ] [ -lf <lease-file> ] [ -pf <pid-file> ] [ --no-pid ] [ -cf <config-file> ] [ -sf <script-file> ] [ -s <server-addr> ] [ -g <relay> ] [ -n ] [ -nw ] [ -w ] [ --dad-wait-time <seconds> ] [ -v ] [ --version ] [ <if0> [ ... <ifN> ] ]

1.2.2. Description

dhclient configures one or more network interfaces using the DHCP Protocol, BOOTP protocol, or if these protocols fail, by statically assigning an address.

1.2.3. Operation

The DHCP protocol allows a host to contact a central server which maintains a list of IP addresses which may be assigned on one or more subnets. A DHCP client may request an address from this pool, and then use it on a temporary basis for communication on network. The DHCP protocol also provides a mechanism whereby a client can learn important details about the network to which it is attached, such as the location of a default router, the location of a name server, and so on.

There are two versions of the DHCP protocol --- DHCPv4 and DHCPv6. At startup the client may be started for one or the other via the -4 or -6 options.

On startup, dhclient reads the dhclient.conf(5) for configuration instructions. It then gets a list of all the network interfaces that are configured in the current system. For each interface, it attempts to configure the interface using the DHCP protocol.

In order to keep track of leases across system reboots and server restarts, dhclient keeps a list of leases it has been assigned in the dhclient.leases(5) file. On startup, after reading the dhclient.conf(5) file, dhclient reads the dhclient.leases(5) file to refresh its memory about what leases it has been assigned.

When a new lease is acquired, it is appended to the end of the dhclient.leases(5) file. In order to prevent the file from becoming arbitrarily large, from time to time dhclient creates a new dhclient.leases(5) file from its in-core lease database. The old version of the dhclient.leases(5) file is retained under the name dhclient.leases~ until the next time dhclient rewrites the database.

Old leases are kept around in case the DHCP server is unavailable when dhclient is first invoked (generally during the initial system boot process). In that event, old leases from the dhclient.leases(5) file which have not yet expired are tested, and if they are determined to be valid, they are used until either they expire or until the DHCP server becomes available.

A mobile host which may sometimes need to access a network on which no DHCP server exists may be preloaded with a lease for a fixed address on that network. When all attempts to contact a DHCP server have failed, dhclient will try to validate the static lease, and if it succeeds, will use that lease until it is restarted.

A mobile host may also travel to some networks on which DHCP is not available but BOOTP is. In that case, it may be advantageous to arrange with the network administrator for an entry on the BOOTP database, so that the host can boot quickly on that network rather than cycling through the list of old leases.

1.2.4. Command line

The names of the network interfaces that dhclient should attempt to configure may be specified on the command line. If no interface names are specified on the command line dhclient will normally identify all network interfaces, eliminating non-broadcast interfaces if possible, and attempt to configure each interface.

It is also possible to specify interfaces by name in the dhclient.conf(5) file. If interfaces are specified in this way, then the client will only configure interfaces that are either specified in the configuration file or on the command line, and will ignore all other interfaces.

The client normally prints no output during its startup sequence. It can be made to emit verbose messages displaying the startup sequence events until it has acquired an address by supplying the -v command line argument. In either case, the client logs messages using the syslog(3) facility.

1.2.5. Options

-4

Use the DHCPv4 protocol to obtain an IPv4 address and configuration parameters. This is the default and cannot be combined with -6.

-6

Use the DHCPv6 protocol to obtain whatever IPv6 addresses are available along with configuration parameters. It cannot be combined with -4. The -S, -T, -P, -N, and -D arguments provide more control over aspects of the DHCPv6 processing.

Note

It is not recommended to mix queries of different types together or even to share the lease file between them.

-4o6 <port>

Participate in the DHCPv4 over DHCPv6 protocol specified by RFC 7341. This associates a DHCPv4 and a DHCPv6 client to allow the v4 client to send v4 requests encapsulated in a v6 packet. Communication between the two clients is done on a pair of UDP sockets bound to ::1 <port> and <port> + 1. Both clients must be launched using the same <port> argument.

-1

Try to get a lease once. On failure exit with status 2. In DHCPv6 this sets the maximum duration of the initial exchange to timeout from dhclient.conf(5) with a default of 60 seconds.

-d

Force dhclient to run as a foreground process. Normally the DHCP client will run in the foreground until is has configured an interface at which time it will revert to running in the background.

-nw

Become a daemon immediately (nowait) rather than waiting until an IP address has been acquired.

-q

Be quiet at startup. This is the default.

-v

Enable verbose log messages.

-w

Continue running even if no broadcast interfaces were found. Normally dhclient will exit if it isn't able to identify any network interfaces to configure. On laptop computers and other computers with hot-swappable I/O buses, it is possible that a broadcast interface may be added after system startup. This argument can be used to cause the client not to exit when it doesn't find any such interfaces. The omshell(1) program can then be used to notify the client when a network interface has been added or removed, so that the client can attempt to configure an IP address on that interface.

-n

Do not configure any interfaces. This is most likely to be useful in combination with the -w argument.

-e <VAR>=<value>

Define additional environment variables for the environment in which dhclient-script(8) executes. Multiple -e arguments may be specified on the command line.

-r

Release the current lease and stop the running dhclient process as previously recorded in the PID file. When shutdown via this method, dhclient-script(8) will be executed with the specific reason for calling the script set.

Note

The client normally doesn't release the current lease as this is not required by the DHCP protocol but some cable ISPs require their clients to notify the server if they wish to release an assigned IP address.

-x

Without releasing the current lease, stop the running dhclient process as previously recorded in the PID file. When shutdown via this method dhclient-script(8) will be executed with the specific reason for calling the script set.

-p <port>

The UDP port number on which dhclient should listen and transmit. If unspecified, dhclient uses the default port of 68. This is mostly useful for debugging purposes. If a different port is specified on which the client should listen and transmit, the client will also use a different destination port --- one less than the specified <port>.

-s <server-address>

Specify the server IP address or fully qualified domain name to use as a destination for DHCP protocol messages before dhclient has acquired an IP address. Normally, dhclient transmits these messages to 255.255.255.255 (the IP limited broadcast address). Overriding this is mostly useful for debugging purposes. This feature is not supported in DHCPv6 mode (-6).

-g <relay>

Set the giaddr field of all packets to the relay IP address simulating a relay agent. This is for testing purposes only and should not be expected to work in any consistent or useful way.

-i

Use a DUID with DHCPv4 clients. If no DUID is available in the lease file, one will be constructed and saved. The DUID will be used to construct an RFC 4361 style client ID that will be included in the client's messages. This client ID can be overridden by setting a client ID in the configuration file. Overridding the client ID in this fashion is discouraged.

-I

Use the standard DNS UPDATE scheme from RFC 4701 and RFC 4702.

--version

Print version number and exit.

1.2.5.1. Options available for DHCPv6 only

-S

Use Information-request to get only stateless configuration parameters (i.e., without address). This implies -6. It also doesn't rewrite the lease database.

-T

Ask for IPv6 temporary addresses, one set per -T argument. This implies -6 and also disables the normal address query. See -N to restore it.

-P

Enable IPv6 prefix delegation. This implies -6 and also disables the normal address query. See -N to restore it. Multiple prefixes can be requested with multiple -P arguments.

Note

Only one requested interface is allowed.

-R

Require that responses include all of the items requested by any -N, -T, or -P options. Normally even if the command line includes a number of these the client will be willing to accept the best lease it can even if the lease doesn't include all of the requested items. This option causes the client to only accept leases that include all of the requested items.

Warning

Using this option may prevent the client from using any leases it receives if the servers aren't configured to supply all of the items.

-D <LL|LLT>

Override the default when selecting the type of DUID to use. By default, DHCPv6 dhclient creates an identifier based on the link-layer address (DUID-LL) if it is running in stateless mode (with -S, not requesting an address), or it creates an identifier based on the link-layer address plus a timestamp (DUID-LLT) if it is running in stateful mode (without -S, requesting an address). When DHCPv4 is configured to use a DUID using -i option the default is to use a DUID-LLT. -D overrides these default, with a value of either LL or LLT.

-N

Restore normal address query for IPv6. This implies -6. It is used to restore normal operation after using -T or -P. Multiple addresses can be requested with multiple -N arguments.

--dad-wait-time <seconds>

Specify maximum time (in seconds) that the client should wait for the duplicate address detection (DAD) to complete on an interface. This value is propagated to the dhclient-script(8) in a dad_wait_time environment variable. If any of the IPv6 addresses on the interface are tentative (DAD is in progress), the script will wait for the specified number of <seconds> for DAD to complete. If the script ignores this variable, then the parameter has no effect.

1.2.5.2. Modifying default file locations

The following options may be used to modify the locations a client uses for its files. For example, they can be particularly useful if /var or /run have not been mounted when the dhclient process is started.

-cf <config-file>

Specify path to the dhclient.conf(5) configuration file.

-df <duid-lease-file>

Specify path to a secondary lease file. If the primary lease file doesn't contain a DUID, this file will be searched. The DUID read from the secondary will be written to the primary. This option can be used to allow an IPv4 instance of the client to share a DUID with an IPv6 instance. After starting one of the instances the second can be started with this option pointing to the lease file of the first instance. There is no default. If no file is specified no search is made for a DUID should one not be found in the main lease file.

-lf <lease-file>

Specify path to the dhclient.leases(5) leases file.

-pf <pid-file>

Specify path to a file where the dhclient process ID is written.

--no-pid

Disable writing process ID files. By default, dhclient will write a process ID file. If it is invoked with this option it will not check for an existing dhclient process.

-sf <script-file>

Specify path to the dhclient-script(8) network configuration script invoked by dhclient when it gets a lease.

1.2.6. UDP and TCP ports

During operations the client may use multiple UDP and TCP ports to provide different functions. Which ports are used depends on the configuration in use. The following should provide an idea of what ports may be used.

Normally a DHCPv4 client will open a raw UDP socket to receive and send most DHCPv4 packets. It also opens a fallback UDP socket for use in sending unicast packets. Normally these will both use the well known port number for BOOTPC.

For DHCPv6 the client opens a UDP socket on the well known client port and a fallback UDP socket on a random port for use in sending unicast messages. Unlike DHCPv4 the well known socket doesn't need to be opened in raw mode.

If there is an omapi-port statement in the configuration file, then the client will open a TCP socket on that port to listen for OMAPI connections. When something connects another port will be used for the established connection.

When DNS UPDATE is used, the client will open a v4 and a v6 UDP socket on random ports. These ports are not opened unless/until the client first attempts to do an update. If the client is not configured to do DNS UPDATEs, the ports will never be opened.

1.2.7. Configuration

See dhclient.conf(5) for the syntax of dhclient's configuration file.

1.2.8. OMAPI

dhclient provides the capability to control some aspects of it while it is running, without stopping it. This capability is currently provided using OMAPI (Object Management Application Programming Interface) --- an API for manipulating remote objects. OMAPI clients connect to the dhclient process using TCP/IP, authenticate, and can then examine the client's current status and make changes to it.

Rather than implementing the underlying OMAPI protocol directly, user programs should use the dhcpctl(5) API or omapi(5) itself. dhcpctl(5) is a wrapper that handles some of the housekeeping chores that OMAPI does not do automatically.

Warning

The above paragraph about dhcpctl(5) and omapi(5) should be replaced with a discussion of using omshell(1).

Most things you'd want to do with the client can be done directly using the omshell(1) command, rather than having to write a special program.

Warning

This section has to be rewritten, or moved to the developer documentation.

1.2.8.1. The control object

The control object allows dhclient to be shutdown gracefully, releasing all leases that it holds and deleting any DNS records it may have added. It also allows the DHCP client to be paused --- this unconfigures any interfaces the client is using. It can then be restarted, which causes it to reconfigure those interfaces. The client would typically be paused prior to going into hibernation or sleep on a laptop computer. It would then be resumed after power comes back. This allows PC cards to be shutdown while the computer is hibernating or sleeping, and then reinitialized to their previous state once the computer comes out of hibernation or sleep.

The control object has one attribute --- the state attribute.

  • To shutdown the client, its state attribute must be set to 2. It will automatically do a DHCPRELEASE.

  • To pause the client, its state attribute must be set to 3.

  • To resume the client, its state attribute must be set to 4.

1.2.9. Environment variables

The following environment variables may be defined to override the builtin defaults for file locations.

Note

The use of the corresponding command-line options will ignore the corresponding environment variable settings.

PATH_DHCLIENT_CONF

Path to the dhclient.conf(5) configuration file.

PATH_DHCLIENT_DB

Path to the dhclient.leases(5) database.

PATH_DHCLIENT_PID

Path to the process ID file.

PATH_DHCLIENT_SCRIPT

Path to the dhclient-script(8) file.

1.2.10. Files

/usr/bin/dhclient-script

The DHCP client network configuration script. See dhclient-script(8) for more details.

/etc/lease/dhclient.conf

The configuration file for the dhclient program. See dhclient.conf(5) for more details.

/var/lib/lease/dhclient.leases

The leases file. See dhclient.leases(5) for more details.

/var/lib/lease/dhclient.leases~

Old leases file.

/run/lease/dhclient.pid

The default process ID file.

1.2.11. See also

dhcpd(8), dhcrelay(8), dhclient-script(8), dhclient.conf(5), dhclient.leases(5), dhcp-eval(5), omshell(1)