Dhcpcd

From LQWiki
Jump to navigation Jump to search

dhcpcd is a mature and stable standards compliant DHCP client. It is used to obtain an IP address and other information from a dhcp server, renew the IP address lease time, and automatically configure the network interface. The program performs a similar function as dhclient.


Obtaining and Installing

Most GNU/Linux distributions come with a dhcp client such as dhcpcd. The dhcpcd project website can be found at http://developer.berlios.de/projects/dhcpcd/. Installation instructions can be found in the source tarball.

Usage

Detailed usage instructions can be found in the man page for dhcpcd.

dhcpcd can be invoked from the command line with dhcpcd <network interface>. If the network interface is not specified, dhcpcd will assume eth0. After invocation, dhcpcd will attempt to obtain an IP address from the dhcp server. A particular address can be specified at the command line with the option -s xxx.xxx.xxx.xxx, where xxx.xxx.xxx.xxx is the requested IP address. If no address is specified, dhcpcd will use the IP address assigned to the network interface. If the network interface is not assigned an IP address, dhcpcd will use the last assigned IP address, which is stored in the file dhcpcd-<interface>.conf, located in the dhcpcd's configuration directory.

Without further instruction, dhcpcd will possibly replace the files /etc/yp.conf (Network Information Service (NIS) configuration file), /etc/resolv.conf, and /etc/ntp.conf (configuration file for NTP) using information obtained from the dhcp server. This behavior is generally desired and necessary for normal network functionality. It can, however, be overridden by invoking dhcpcd with the flags -R, -Y, or -N respectively.

After configuring the network interface, dhcpcd will fork to the background and work without further instruction from the user. By default, dhcpcd will not fork until it has recieved an IP address from the dhcp server. This behavior can be changed by calling dhcpcd with the timeout option, -t <timeout interval in seconds>.

Common Issues

Many dhcp servers require that a hostname be set. A particular hostname can be set by calling dhcpcd with the -h <hostname> option. Using the -H option, dhcpcd can be configured to set the hostname that is recieved from the dhcpcd server. Moreover, dhcpcd can be configured to set the domainname of the client to the domainname supplied by the dhcp server with the -H option.

Some dhcp servers require that clients send two DHCP_DISCOVER messages before it will reply. dhcpcd will not do this by default and this behavior can be specified with the -S option.

Some dhcp servers use outdated or uncommon protocols and dhcpd can be configured to use these protocols. Detailed instructions can be found in the man page for dhcpcd.

Distribution Specific Information

Debian, Red Hat, and most of their derivatives prefer dhclient over dhcpcd. Slackware uses dhcpd by default, although it does come with dhclient. dhcpcd is generally called during boot. In Slackware, boot-time configuration options for dhcpcd can be set in the file /etc/rc.d/rc.inet.conf.

Security

Older versions of dhcpcd (versions prior to 1.3.22) are vulnerable to a DOS attack. The security risk is mild and exploitation may result in the dhcpcd daemon crashing. This vulnerability works by tricking dhcpcd to read past the end of the supplied dhcp buffer. This vulnerability has been patched in later versions and it is recommended that users upgrade. Every major GNU/Linux distribution has already supplied a patch for this problem.