OpenBSD manual page server

Manual Page Search Parameters

DHCLIENT.CONF(5) File Formats Manual DHCLIENT.CONF(5)

dhclient.confDHCP client configuration file

dhclient.conf is the configuration file for dhclient(8).

The dhclient.conf file is a free-form ASCII text file that may contain extra tabs and newlines for formatting purposes. Keywords in the file are case-insensitive. Comments may be placed anywhere within the file (except within quotes). Comments begin with the ‘#’ character and extend to the end of the current line.

The dhclient.conf file can be used to configure the behaviour of the client in a wide variety of ways: protocol timing, information requested from the server, information required of the server, defaults to use if the server does not provide certain information, values with which to override information provided by the server, or values to prepend or append to information provided by the server. The configuration file can also be preinitialized with addresses to use on networks that don't have DHCP servers.

The timing behaviour of the client need not be configured by the user. If no timing configuration is provided by the user, a fairly reasonable timing behaviour will be used by default - one which results in fairly timely updates without placing an inordinate load on the server.

The following statements can be used to adjust the timing behaviour of the DHCP client if required, however:

time;
The timeout statement determines the amount of time that must pass between the time that the client begins to try to determine its address and the time that it decides that it's not going to be able to contact a server. After the timeout has passed, if there are any static leases defined in the configuration file, or any leases remaining in the lease database that have not yet expired, the client will loop through these leases attempting to validate them, and if it finds one that appears to be valid, it will use that lease's address. If there are no valid static leases or unexpired leases in the lease database, the client will restart the protocol after the defined retry interval.

By default, timeout is set to thirty seconds.

time;
The retry statement determines the time that must pass after the client has determined that there is no DHCP server present before it tries again to contact a DHCP server.

By default, retry is set to one second.

time;
It is possible (some might say desirable) for there to be more than one DHCP server serving any given network. In this case, it is possible that a client may be sent more than one offer in response to its initial lease discovery message. It may be that one of these offers is preferable to the other (e.g., one offer may have the address the client previously used, and the other may not).

The select-timeout is the time after the client sends its first lease discovery request at which it stops waiting for offers from servers, assuming that it has received at least one such offer. If no offers have been received by the time the select-timeout has expired, the client will accept the first offer that arrives.

By default, select-timeout is set to zero seconds i.e. the client will immediately take the first offer it sees.

time;
When the client is restarted, it first tries to reacquire the last address it had. This is called the INIT-REBOOT state. If it is still attached to the same network it was attached to when it last ran, this is the quickest way to get started. The reboot statement sets the time that must elapse after the client first tries to reacquire its old address before it gives up and tries to discover a new address.

The value of reboot is also used to control how long a client will attempt unicast renewal requests before falling back to using broadcast requests.

By default, reboot is set to one second.

time;
The client uses an exponential backoff algorithm with some randomness, so that if many clients try to configure themselves at the same time, they will not make their requests in lockstep. The backoff-cutoff statement determines the maximum amount of time that the client is allowed to back off.

By default backoff-cutoff is set to ten seconds.

time;
The initial-interval statement sets the amount of time between the first attempt to reach a server and the second attempt to reach a server. Each time a message is sent, the interval between messages is incremented by twice the current interval multiplied by a random number between zero and one. If it is greater than the backoff-cutoff amount, it is set to that amount.

By default initial-interval is set to one second.

The link-timeout statement sets the amount of time to wait for an interface link before timing out. The value zero requests that dhclient not wait for a link state change before timing out.

By default link-timeout is set to ten seconds.

The DHCP protocol allows the client to request that the server send it specific information, and not send it other information that it is not prepared to accept. The protocol also allows the client to reject offers from servers if they don't contain information the client needs, or if the information provided is not satisfactory.

There is a variety of data contained in offers that DHCP servers send to DHCP clients. The data that can be specifically requested is what are called . DHCP Options are defined in dhcp-options(5).

[option, ...];
The ignore statement causes the client to discard values provided by the server for the specified options. Only option names should be specified in the ignore statement - not option values. Only the last ignore statement has any effect, overriding any previous ignore statement.
[option, ...];
The request statement causes the client to request that any server responding to the client send the client its values for the specified options. Only option names should be specified in the request statement - not option values. Only the last request statement has any effect, overriding any previous request statement.
[option, ...];
The require statement lists options that must be sent in order for an offer to be accepted. Offers that do not contain all the listed options will be ignored. Only option names should be specified in the require statement - not option values. Only the last require statement has any effect, overriding any previous require statement.
option option-value;
The send statement causes the client to send the specified option and value to the server. Options that are always sent in the DHCP protocol should not be specified here. One use for this statement is to send information to the server that will allow it to differentiate between this client and other clients or kinds of clients.

Options in the lease can be modified before being accepted.

Several option modifiers are available.

option option-value;
Use option-value for the given option, if no value is supplied by the server.
option option-value;
Use option-value for the given option, regardless of the value supplied by the server.
option option-value;
Use option-value for the given option, and then use the value supplied by the server. prepend can only be used for options which allow more than one value to be given. The restriction is not enforced - if violated, the results are unpredictable.
option option-value;
Use option-value for the given option, after first using the value supplied by the server. append can only be used for options which allow more than one value to be given. The restriction is not enforced - if violated, the results are unpredictable.

The lease declaration:

lease { lease-declaration; ...; }

The DHCP client may decide after some period of time (see PROTOCOL TIMING) that it is not going to succeed in contacting a server. At that time, it consults its own database of old leases and tests each one that has not yet timed out by pinging the listed router for that lease to see if that lease could work. It is possible to define one or more leases in the client configuration file for networks where there is no DHCP or BOOTP service, so that the client can still automatically configure its address. This is done with the lease statement.

NOTE: the lease statement is also used in the /var/db/dhclient.leases.IFNAME⟩ file in order to record leases that have been received from DHCP servers. Some of the syntax for leases as described below is only needed in the /var/db/dhclient.leases.IFNAME⟩ file. Such syntax is documented here for completeness.

A lease statement consists of the lease keyword, followed by a left curly brace, followed by one or more lease declaration statements, followed by a right curly brace. The following lease declarations are possible:

;
The bootp statement is used to indicate that the lease was acquired using the BOOTP protocol rather than the DHCP protocol. It is never necessary to specify this in the client configuration file. The client uses this syntax in its lease database file.

"string";
The interface lease statement is used to indicate the interface on which the lease is valid. If set, this lease will only be tried on a particular interface. When the client receives a lease from a server, it always records the interface number on which it received that lease. If predefined leases are specified in the dhclient.conf file, the interface should also be specified, although this is not required.

ip-address;
The fixed-address statement is used to set the IP address of a particular lease. This is required for all lease statements. The IP address must be specified as a dotted quad (e.g., 12.34.56.78).

"string";
The filename statement specifies the name of the boot filename to use. This is not used by the standard client, but is included for completeness.

"string";
The server-name statement specifies the name of the boot server name to use. This is not used by the standard client, but is included for completeness.

option option-value;
The option statement is used to specify the value of an option supplied by the server, or, in the case of predefined leases declared in dhclient.conf, the value that the user wishes the client to use if the predefined lease is used.

date;
 
date;
 
date;
The renew statement defines the time at which the DHCP client should begin trying to contact its server to renew a lease that it is using. The rebind statement defines the time at which the DHCP client should begin to try to contact DHCP server in order to renew its lease. The expire statement defines the time at which the DHCP client must stop using a lease if it has not been able to contact a server in order to renew it.

These declarations are automatically set in leases acquired by the DHCP client, but must also be configured in predefined leases - a predefined lease whose expiry time has passed will not be used by the DHCP client.

Dates are specified as follows:

<weekday> <year>/<month>/<day> <hour>:<minute>:<second>

The weekday is present to make it easy for a human to tell when a lease expires - it's specified as a number from zero to six, with zero being Sunday. When declaring a predefined lease, it can always be specified as zero. The year is specified with the century, so it should generally be four digits except for really long leases. The month is specified as a number starting with 1 for January. The day of the month is likewise specified starting with 1. The hour is a number between 0 and 23, the minute a number between 0 and 59, and the second also a number between 0 and 59.

ip-address;
The reject statement causes the DHCP client to reject offers from servers who use the specified address as a server identifier. This can be used to avoid being configured by rogue or misconfigured DHCP servers, although it should be a last resort - better to track down the bad DHCP server and fix it.
"name" { declaration; ...; }
A client with more than one network interface may require different behaviour depending on which interface is being configured. All timing parameters and declarations other than lease declarations can be enclosed in an interface declaration, and those parameters will then be used only for the interface that matches the specified name. Interfaces for which there is no interface declaration will use the parameters declared outside of any interface declaration, or the default settings.

The following configuration file is used on a laptop which has one interface, ep0 (a 3Com 3C589C). Booting intervals have been shortened somewhat from the default, because the client is known to spend most of its time on networks with little DHCP activity. The laptop does roam to multiple networks.

timeout 60;
retry 60;
reboot 10;
select-timeout 5;
initial-interval 2;
reject 192.33.137.209;

interface "ep0" {
    send host-name "andare.fugue.com";
    send dhcp-client-identifier 1:0:a0:24:ab:fb:9c;
    send dhcp-lease-time 3600;
    supersede domain-name "fugue.com rc.vix.com home.vix.com";
    prepend domain-name-servers 127.0.0.1;
    request subnet-mask, broadcast-address, time-offset, routers,
	    domain-name, domain-name-servers, host-name;
    require subnet-mask, domain-name-servers;
}

This is a very complicated dhclient.conf file - in general, yours should be much simpler. In many cases, it's sufficient to just create an empty dhclient.conf file - the defaults are usually fine.

dhclient.leases(5), dhcp-options(5), dhcpd.conf(5), dhclient(8), dhcpd(8)

R. Droms, Dynamic Host Configuration Protocol, RFC 2131, March 1997.

S. Alexander and R. Droms, DHCP Options and BOOTP Vendor Extensions, RFC 2132, March 1997.

dhclient(8) was written by Ted Lemon <mellon@vix.com> under a contract with Vixie Labs.

The current implementation was reworked by Henning Brauer <henning@openbsd.org>.

July 31, 2017 OpenBSD-6.2