dhclient.conf, dhclient-dhcpv6.conf

DHCP client configuration file

Name:

Description:

The dhclient.conf file contains configuration information for dhclient, the Internet Systems Consortium DHCP Client.

The dhclient.conf file is a free-form ASCII text file. It's parsed by the recursive-descent parser built into dhclient. The file 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 end at the end of the line.

The dhclient.conf file can be used to configure the behavior 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 doesn't 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.

Protocol timing

The timing behavior of the client needn't be configured by the user. If no timing configuration is provided by the user, a fairly reasonable timing behavior 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 behavior of the DHCP client if required, however:

Lease requirements and requests

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 isn't satisfactory.

There's 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. For more information, see the entry for DHCP options.

DHCP operation

The client doesn't yet have a default DHCPv6 Option Request Option (ORO), nor has it been integrated with the request and require syntax above. It is necessary to configure an ORO then:

send dhcp6.oro 1, 2, 7, 12, 13, 23, 24, 39;

The above ORO will request both identifiers (server, client), the preference, unicast, nameservers, domain-search, and FQDN(v6) options.

Dynamic DNS

The client now has some very limited support for doing DNS updates when a lease is acquired. This is prototypical, and probably doesn't do what you want. It also only works if you happen to have control over your DNS server, which isn't very likely.

Note: Everything in this section is true whether you are using DHCPv4 or DHCPv6. The exact same syntax is used for both.

To make it work, you haveto declare a key and zone as in the DHCP server (see dhcpd.conf for details). You also need to configure the fqdn option on the client, as follows:

send fqdn.fqdn "grosse.fugue.com.";
send fqdn.encoded on;
send fqdn.server-update off;
also request fqdn, dhcp6.fqdn;

The fqdn.fqdn option must be a fully-qualified domain name. You must define a zone statement for the zone to be updated. The fqdn.encoded option may need to be set to on or off, depending on the DHCP server you're using.

Option modifiers

In some cases, a client may receive option data from the server which isn't really appropriate for that client, or may not receive information that it needs, and for which a useful default value exists. It may also receive information which is useful, but which needs to be supplemented with local information. To handle these needs, several option modifiers are available:

Lease declaration

The lease declaration is as follows:

lease { lease-declaration [ ... lease-declaration ] }

The DHCP client may decide after some period of time (see Protocol timing) that it isn't going to succeed in contacting a server. At that time, it consults its own database of old leases and tests each one that hasn't 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 fixed leases in the client configuration file for networks where there's 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 dhclient.leases file in order to record leases that have been received from DHCP servers. Some of the syntax for leases as described below is needed only in the dhclient.leases 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:

bootp;
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.
interface "string";
The interface lease statement is used to indicate the interface on which the lease is valid. If set, this lease will be tried only 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 isn't required.
fixed-address 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).
filename "string";
The filename statement specifies the name of the boot filename to use. This isn't used by the standard client configuration script, but is included for completeness.
server-name "string";
The server-name statement specifies the name of the boot server name to use. This is also not used by the standard client configuration script.
option option-declaration;
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 configuration script to use if the predefined lease is used.
script "script-name";
The script statement is used to specify the pathname of the DHCP client configuration script. This script is used by the DHCP client to set each interface's initial configuration prior to requesting an address, to test the address once it has been offered, and to set the interface's final configuration once a lease has been acquired. If no lease is acquired, the script is used to test predefined leases, if any, and also called once if no valid lease can be identified. For more information, see dhclient-script.
vendor option space "name";
The vendor option space statement is used to specify which option space should be used for decoding the vendor-encapsulate-options option if one is received. The dhcp-vendor-identifier can be used to request a specific class of vendor options from the server. See the entry for DHCP options for details.
medium "media setup";
The medium statement can be used on systems where network interfaces can't automatically determine the type of network to which they are connected. The media setup string is a system-dependent parameter which is passed to the DHCP client configuration script when initializing the interface. On Unix and Unix-like systems, the argument is passed on the ifconfig command line when configuring the interface.

The DHCP client automatically declares this parameter if it uses a media type (see the media statement) when configuring the interface in order to obtain a lease. This statement should be used in predefined leases only if the network interface requires media type configuration.

renew date;
rebind date;
expire 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's using. The rebind statement defines the time at which the DHCP client should begin to try to contact any 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 hasn't 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 in one of the following ways. The software will output times in these formats depending on the value of the db-time-format configuration parameter:

  • default — date values appear 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 you're declaring a predefined lease, you can always specify it 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.

  • local — date values appear as follows:

    epoch seconds-since-epoch; # day-name month-name day-number hours:minutes:seconds year

    The seconds-since-epoch is as according to the system's local clock (often referred to as “Unix time”). The # symbol supplies a comment that describes what actual time this is as according to the system's configured time zone, at the time the value was written. It is provided only for human inspection; the epoch time is the only recommended value for machine inspection.

Note that when defining a static lease, you may use either time format you wish, and you needn't include the comment or values after it.

If the time is infinite in duration, then the date is never instead of an actual date.

Alias declarations

alias {  declarations ... }

Some DHCP clients running TCP/IP roaming protocols may require that in addition to the lease they may acquire via DHCP, their interface also be configured with a predefined IP alias so that they can have a permanent IP address even while roaming. The Internet Systems Consortium DHCP client doesn't support roaming with fixed addresses directly, but in order to facilitate such experimentation, the dhcp client can be set up to configure an IP alias using the alias declaration.

The alias declaration resembles a lease declaration, except that options other than the subnet-mask option are ignored by the standard client configuration script, and expiry times are ignored. A typical alias declaration includes an interface declaration, a fixed-address declaration for the IP alias address, and a subnet-mask option declaration. A medium statement should never be included in an alias declaration.

Other declarations

db-time-format [ default | local ] ;
The db-time-format option determines which output methods is used for printing times in leases files. The default format provides day-and-time in UTC, whereas local uses seconds-since-epoch to store the time value, and helpfully places a local time zone time in a comment on the same line. The formats are described in detail in Lease declarations,” above.
reject cidr-ip-address [, ... cidr-ip-address ] ;
The reject statement causes the DHCP client to reject offers from servers whose server identifier matches any of the specified hosts or subnets. 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.

The cidr-ip-address configuration type is of the form ip-address[/prefixlen], where ip-address is a dotted quad IP address, and prefixlen is the CIDR prefix length of the subnet, counting the number of significant bits in the netmask starting from the leftmost end. For example:

reject 192.168.0.0/16, 10.0.0.5;

The above example would cause offers from any server identifier in the entire RFC 1918 “Class C” network 192.168.0.0/16, or the specific single address 10.0.0.5, to be rejected.

interface "name" { declarations ... }
A client with more than one network interface may require different behavior, depending on which interface is being configured. All timing parameters and declarations other than lease and alias 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.
CAUTION:
ISC dhclient maintains only one list of interfaces, which is either determined at startup from command-line arguments, or otherwise is autodetected. If you supplied the list of interfaces on the command line, this configuration clause will add the named interface to the list in such a way that will cause it to be configured by DHCP, which may not be the result you had intended. This is an undesirable side effect that will be addressed in a future release.
pseudo "name" real-name { declarations ... }
Under some circumstances it can be useful to declare a pseudo-interface and have the DHCP client acquire a configuration for that interface. Each interface that the DHCP client is supporting normally has a DHCP client state machine running on it to acquire and maintain its lease. A pseudo-interface is just another state machine running on the interface named real-name, with its own lease and its own state. If you use this feature, you must provide a client identifier for both the pseudo-interface and the actual interface, and the two identifiers must be different. You must also provide a separate client script for the pseudo-interface to do what you want with the IP address. For example:
interface "ep0" {
     send dhcp-client-identifier "my-client-ep0";
}
pseudo "secondary" "ep0" {
     send dhcp-client-identifier "my-client-ep0-secondary";
     script "/etc/dhclient-secondary";
}

The client script for the pseudo-interface shouldn't configure the interface up or down; essentially, all it needs to handle are the states where a lease has been acquired or renewed, and the states where a lease has expired. See dhclient-script for more information.

media "media setup" [, "media setup", ...];
The media statement defines one or more media configuration parameters which may be tried while attempting to acquire an IP address. The DHCP client will cycle through each media setup string on the list, configuring the interface using that setup and attempting to boot, and then trying the next one. This can be used for network interfaces which aren't capable of sensing the media type unaided; whichever media type succeeds in getting a request to the server and hearing the reply is probably right (no guarantees).

The media setup is only used for the initial phase of address acquisition (the DHCPDISCOVER and DHCPOFFER packets). Once an address has been acquired, the DHCP client will record it in its lease database and will record the media type used to acquire the address. Whenever the client tries to renew the lease, it will use that same media type. The lease must expire before the client will go back to cycling through media types.

Contributing author

dhclient was written by Ted Lemon under a contract with Vixie Labs. Funding for this project was provided by Internet Systems Consortium. Information about Internet Systems Consortium can be found at http://www.isc.org.

See also:

RFC2132, RFC2131

Examples:

The following configuration file is used on a laptop running NetBSD 1.3. The laptop has an IP alias of 192.5.5.213, and 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;
    script "/sbin/dhclient-script";
    media "media 10baseT/UTP", "media 10base2/BNC";
}

alias {
  interface "ep0";
  fixed-address 192.5.5.213;
  option subnet-mask 255.255.255.255;
}

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.