DHCP Clients

DHCP stands for Dynamic Host Configuration Protocol. It is a protocol used by many sites to automatically provide information such as IP addresses, subnet masks and routing information to computers. If your network uses DHCP, you will need a DHCP client in order to connect to it. DHCP is also used by some cable modems.

BLFS currently provides installation instructions for two DHCP clients, dhclient (from the dhcp package) and dhcpcd. BLFS presents both sets of installation instructions and discusses how to create an appropriate service script to work with the network bootscript and the DHCP client of your choice.


The DHCP package comes with both a client (dhclient) and a server program for using DHCP. If you want to install this package, the instructions can be found at DHCP-3.0pl2. Note that if you only want to use the client, you do not need to run the server and so do not need the startup script and links provided for the server daemon. You only need to run the DHCP server if you're providing this service to a network, and it's likely that you'll know if that's the case; if it isn't, don't run the server! Once you have installed the package, return here for information on how to configure the client (dhclient).

To configure dhclient, you need to first install the network service script, /etc/sysconfig/network-devices/services/dhclient included in the blfs-bootscripts-5.1 package.

make install-service-dhclient

Next, create the ifconfig.eth0 file with the following commands. Adjust as necessary for additional interfaces.

Note: this will overwrite any existing file.

cat > /etc/sysconfig/network-devices/ifconfig.eth0 << "EOF"
DHCP_START="[place appropriate start parameters here]"
DHCP_STOP="-r [add additional stop parameters here]"

For more information on the appropriate DHCP_START and DHCP_STOP values, examine the man page for dhclient.

You should then create /etc/dhclient.conf using the following commands. Append to the file if you have more than one interface:

cat > /etc/dhclient.conf << "EOF"
# dhclient.conf

interface "eth0"{
prepend domain-name-servers;
request subnet-mask, broadcast-address, time-offset, routers,
        domain-name, domain-name-servers, host-name;
require subnet-mask, domain-name-servers;
# end dhclient.conf

Finally, if the DHCP configured interface is used as your default gateway, you should remove the GATEWAY and GATEWAY_IF variables from /etc/sysconfig/network:

sed -i "s/GATEWAY/#GATEWAY/" /etc/sysconfig/network