More Linux Server Topics - Network Diagram - About This Site


Chapter 22


Configuring The DHCP Server


= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

In This Chapter


 Chapter 22

Configuring The DHCP Server

Download and Install The DHCP Package

The /etc/dhcp.conf File

Upgrading Your DHCP Server

How to get DHCP started

Modify Your Routes for DHCP on Linux Server

Configuring Linux clients to use DHCP

Error Found When Upgrading From Redhat 7.3 To 8.0


© Peter Harrison,


= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

Normally if you have a cable modem or DSL you get your home PC's IP address dynamically assigned from your service provider. If you install a home cable/DSL router between your modem and home network your PC will most likely get its IP address at boot time from the home router instead. You can choose to disable the DHCP server feature on your home router and set up a Linux box as the DHCP server.

This chapter only covers the configuration of a DHCP server that provides IP addresses. The configuration of a Linux DHCP client that gets its IP address from a DHCP server is covered in the Linux Networking Topics chapter.

Download and Install The DHCP Package

Most RedHat Linux software products are available in the RPM format. Downloading and installing RPMs isn’t hard. If you need a refresher, the RPM chapter covers how to do this in detail.

·     For example, the RedHat 8.0 RPM as of this writing was:




·     Install the package using the following command:


[root@bigboy tmp]# rpm -Uvh dhcp-3.0pl1-9.i386.rpm


The /etc/dhcp.conf File

When DHCP starts it reads the file /etc/dhcp.conf. It uses the commands here to configure your network. Normally you can find a sample copy of dhcpd.conf in the following directory which you can always use as a guide.  




Here is a quick explanation of the dhcp.conf file: Most importantly, there must be a "subnet" section for each interface on your Linux box.


ddns-update-style interim # Redhat Version 8.0+


subnet netmask {


# The range of IP addresses the server

# will issue to DHCP enabled PC clients

# booting up on the network




# Set the amount of time in seconds that

# a client may keep the IP address

default-lease-time 86400;
max-lease-time 86400;


# Set the default gateway to be used by

# the PC clients


option routers;

# Don't forward DHCP requests from this

# NIC interface to any other NIC

# interfaces


option ip-forwarding off;


# Set the broadcast address and subnet mask

# to be used by the DHCP clients

option broadcast-address;
option subnet-mask;


# Set the DNS server to be used by the

# DHCP clients

option domain-name-servers;


# Set the NTP server to be used by the

# DHCP clients


option nntp-server;


# If you specify a WINS server for your Windows clients,

# you need to include the following option in the dhcpd.conf file:

option netbios-name-servers;



# List an unused interface here

subnet netmask {

# You can also assign specific IP addresses based on the clients'

# ethernet MAC address as follows (Host's name is "smallfry":

host smallfry {

hardware ethernet 08:00:2b:4c:59:23;



There many more options statements you can use to configure DHCP. These include telling the DHCP clients where to go for services such as finger and IRC. Check the dhcp-options man page after you do your install. The command to do this follows:


[root@bigboy tmp]# man dhcp-options

Upgrading Your DHCP Server

Always refer to this sample file after doing an upgrade as new required commands may have been added. For example, in Redhat Version 8.0 (dhcpd version 3.0b2pl11) you will need to add the line at the very top of the config file or else you will get errors::


ddns-update-style interim



How to get DHCP started

·     Before you start the DHCP server for the first time, it will fail unless there is an existing dhcpd.leases file. Use the command "touch /var/lib/dhcp/dhcpd.leases" to create the file if it does not exist.


[root@bigboy tmp]# touch /var/lib/dhcp/dhcpd.leases


·     Use the chkconfig command to get DHCP configured to start at boot:


[root@bigboy tmp]# chkconfig --level 35 dhcpd on


·     Use the /etc/init.d/dhcpd script to start/stop/restart DHCP after booting


[root@bigboy tmp]# /etc/init.d/dhcpd start
[root@bigboy tmp]# /etc/init.d/dhcpd stop
[root@bigboy tmp]# /etc/init.d/dhcpd restart


·     Remember to restart the DHCP process every time you make a change to the conf file for the changes to take effect on the running process. You also can test whether the DHCP process is running with the following command, you should get a response of plain old process ID numbers:


[root@bigboy tmp]# pgrep dhcpd


·     Finally, always remember to set your PC to get its IP address via DHCP. 

Modify Your Routes for DHCP on Linux Server

When a DHCP configured PC boots, it will request its IP address from the DHCP server. It does this by sending a standardized DHCP broadcast request packet to the DHCP server with a source IP address of

You will have to add a route for this address on your Linux DHCP server so that it knows the interface on which to send the reply. (In both examples below, we’re assuming that DHCP requests will be coming in on interface eth0).

Note:    More information on adding Linux routes and routing may be found in the Linux Networking chapter.

Temporary solution

o        Add the route to from the command line.


[root@bigboy tmp]# route add -host dev eth0


o        If the message Unknown host appears then try adding the following entry to your /etc/hosts file: dhcp


Then, try:


route add -host dhcp dev eth0

Permanent Solution

o        Edit /etc/sysconfig/static-routes, which is read on booting, and add the following line:


eth0 host


o        If this doesn't work properly try adding the following entry to your /etc/hosts file: dhcp


Then, try:


eth0 host dhcp


Configuring Linux clients to use DHCP 

Remember to have your Linux based clients configured to have DHCP obtained IP addresses


Error Found When Upgrading From Redhat 7.3 To 8.0

This dhcpd startup error is caused by not having the following line at the very top of your /etc/dhcpd.conf file:


ddns-update-style interim


Sample error:


Starting dhcpd: Internet Software Consortium DHCP Server V3.0pl1
Copyright 1995-2001 Internet Software Consortium.
All rights reserved.
For info, please visit

** You must add a ddns-update-style statement to /etc/dhcpd.conf.
To get the same behaviour as in 3.0b2pl11 and previous
versions, add a line that says "ddns-update-style ad-hoc;"
Please read the dhcpd.conf manual page for more information. **

If you did not get this software from, please
get the latest from and install that before
requesting help.

If you did get this software from and have not
yet read the README, please read it before requesting help.
If you intend to request help from the
mailing list, please read the section on the README about
submitting bug reports and requests for help.

Please do not under any circumstances send requests for
help directly to the authors of this software - please
send them to the appropriate mailing list as described in
the README file.