dhclient
Obtain IP address from DHCP server
TLDR
Get an IP address for the eth0 interface
Release an IP address for the eth0 interface
SYNOPSIS
dhclient [-r|-d|-v|-q] [-cf config-file] [-lf lease-file] [-p port] [-I client-id] [-H hostname] [interface ...]
PARAMETERS
-r
Release the current lease and shut down the interface.
-d
Force dhclient
to run in the foreground (debug mode).
-v
Enable verbose output to stderr.
-q
Be quiet; suppress non-essential output.
-cf config-file
Specify an alternative configuration file path.
-lf lease-file
Specify an alternative lease database file path.
-p port
Specify the UDP port number dhclient
should use.
-I client-id
Specify the client identifier to send to the DHCP server.
-H hostname
Specify the hostname to send to the DHCP server.
interface
The network interface (e.g., eth0, enp0s3) to configure.
DESCRIPTION
dhclient
is the ISC DHCP client program, responsible for obtaining an IP address and other network configuration parameters from a DHCP server. When executed, it sends DHCP discovery requests, receives DHCP offers, and then requests and acknowledges a lease for network configuration. This typically includes an IP address, subnet mask, default gateway, DNS server addresses, and possibly other options like NTP servers or domain search lists.
The command often runs as a daemon, managing the network interface throughout its lifecycle, including lease renewal and release. It reads configuration from /etc/dhcp/dhclient.conf
and stores lease information in /var/lib/dhclient/dhclient.leases
. Upon successful configuration, dhclient
executes the dhclient-script
(typically found at /usr/sbin/dhclient-script
) to apply the network settings to the operating system. This makes dhclient
a critical component for most dynamic network setups on Linux systems.
CAVEATS
Running dhclient
typically requires root privileges as it modifies network interface settings. Ensure no conflicting network management services (e.g., NetworkManager, systemd-networkd) are also attempting to configure the same interface, which can lead to unpredictable behavior. When using dhclient
, the lease file is critical; if it becomes corrupted or lost, the client may not correctly remember its previous lease information, potentially leading to delays or issues in obtaining a new IP address.
LEASE MANAGEMENT AND RENEWAL
dhclient
actively manages the obtained IP address lease. Before a lease expires, dhclient
attempts to renew it with the DHCP server, typically at 50% and 87.5% of the lease duration. If renewal fails, it will attempt to rebind to the server, and if that also fails, it will seek a new lease. This continuous process ensures uninterrupted network connectivity.
CONFIGURATION AND SCRIPTING
Beyond the command-line options, dhclient
's behavior is heavily influenced by /etc/dhcp/dhclient.conf
, which can specify requested DHCP options, preferred lease times, and various client behaviors. Upon receiving a lease, dhclient
invokes /usr/sbin/dhclient-script
(or a system-specific equivalent), which is a powerful shell script responsible for actually configuring the network interface, updating DNS settings in /etc/resolv.conf
, and executing any custom hooks defined in /etc/dhcp/dhclient-enter-hooks.d/
or /etc/dhcp/dhclient-exit-hooks.d/
directories.
HISTORY
dhclient
is a fundamental component of the Internet Systems Consortium (ISC) DHCP distribution, a widely adopted open-source implementation of the DHCP protocol. Its origins trace back to the early days of DHCP, providing robust and standards-compliant client functionality for Unix-like operating systems. Over the years, it has been continually maintained and updated, adapting to new RFCs and operating system changes, making it a cornerstone for dynamic network configuration across countless Linux and Unix deployments.
SEE ALSO
dhcpd(8), dhclient.conf(5), dhclient-script(8), ip(8), systemctl(1)