Most machines do not have a hand-typed IP address. They ask for one using DHCP, the Dynamic Host Configuration Protocol. dhclient is the DHCP client from the ISC DHCP project.
How a lease is obtained
DHCP for IPv4 usually takes four messages:
- Discover: the client looks for servers.
- Offer: a server proposes an address.
- Request: the client asks for that offer.
- Acknowledge: the server confirms it.
The result is a lease: an address lent for a limited time, normally with a subnet mask, gateway and DNS servers. The client renews it before it expires.
Is it still on your system?
ISC ended maintenance of its DHCP software in 2022. Many distributions now use NetworkManager's built-in client, systemd-networkd or dhcpcd, and may not ship dhclient at all. Check with:
$ command -v dhclientNo output means it is not installed or not in your path. If another tool manages the interface, do not run dhclient on it too, as the two can fight.
Requesting a lease
Use a test machine, and replace eth0 with your interface:
$ sudo dhclient -v eth0
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 3
DHCPOFFER of 192.168.1.50 from 192.168.1.1
DHCPREQUEST for 192.168.1.50 on eth0 to 255.255.255.255 port 67
DHCPACK of 192.168.1.50 from 192.168.1.1The output is shortened and varies by version. -v prints the conversation.
Releasing and renewing
$ sudo dhclient -r eth0
$ sudo dhclient eth0-r releases the current lease and stops the running client. Running dhclient again asks for a new lease. You may well get the same address back.
Releasing on the interface carrying your SSH session will disconnect you before you can type the second command.
Where information is kept
Configuration is usually /etc/dhcp/dhclient.conf. Lease records are commonly under /var/lib/dhcp/ on Debian-based systems and /var/lib/dhclient/ on Red Hat-based systems.
Try it
- Run
command -v dhclientto see whether you have it. - Run
ip -br addr showand note your current address. - In a virtual machine with console access, release and renew, then compare the address.
Check your understanding
dhclient
All 4 sections ยท no timer
Unlimited retries
Questions from every section are combined into one assessment. Answer them all correctly to complete the article.
Your completion saves in this browser. Sign in to sync it to your account.