dhclient

from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
Jump to: navigation, search

Navigation

computing: software: operating systems: Linux: dhclient

Note: This page needs to be merged with dhcpcd, as they both refer to the same command.

Overview

dhclient, known on some systems as dhcpcd, is a both an interactive command and a daemon for managing a client connection to a DHCP server.

The normal network restart process (invoked either at boot time or manually by "/etc/init.d/networking restart" or similar) automatically runs dhclient for every interface which has the "dhcp" attribute specified in the /etc/network/interfaces file.

Normal Behavior

The standard process, as with most DHCP clients, is for dhclient to send a broadcast request for DHCP service on port 67, corresponding to this message printed by dhclient:

DHCPREQUEST on eth0 to 255.255.255.255 port 67

At some point, dhclient either receives the proper acknowledgment:

DHCPACK from 192.168.0.1

...or it does not, in which case it tries for a little while longer and then takes some default action which may be distro-dependent. The network card being configured may or may not still have access to the network if the request fails, depending on what the default action is and how appropriate it is to the existing situation.

dhclient also overwrites the resolv.conf file, so if you have alternate DNS servers listed in that file, they will get clobbered if you accidentally run dhclient.

Options

The default broadcast address of 255.255.255.255 can be overridden by the -s option to request DHCP service only from a particular DHCP server:

dhclient -s server eth0

Where:

  • server is the network name (domain name, WINS name, or whatever will resolve correctly) or IP address of the desired DHCP server
  • eth0 is the name of the network interface to configure via DHCP. "eth0" is the most common, but this can be "eth1", "wlan0", etc. (Need instructions on how to determine what network interfaces are actually available.)

Notes

In situations where the network has multiple DHCP servers (not generally a good idea, but may be temporarily necessary when both network debugging and network usage are needed simultaneously), it's not clear if this command should be expected to work. I have had no luck with it; dhclient prints the following:

root@gonzo:/home/woozle# dhclient -s rizzo eth0
There is already a pid file /var/run/dhclient.pid with pid 22362
killed old client process, removed PID file
Internet Systems Consortium DHCP Client V3.0.4
Copyright 2004-2006 Internet Systems Consortium.
All rights reserved.
For info, please visit http://www.isc.org/sw/dhcp/

Listening on LPF/eth0/00:e0:18:ab:f4:8c
Sending on   LPF/eth0/00:e0:18:ab:f4:8c
Sending on   Socket/fallback
DHCPREQUEST on eth0 to 192.168.0.139 port 67
send_packet: Network is unreachable
send_packet: please consult README file regarding broadcast address.
DHCPREQUEST on eth0 to 192.168.0.139 port 67
send_packet: Network is unreachable
send_packet: please consult README file regarding broadcast address.

Note the "Network is unreachable". No clue where that "README" file might be, either.