8.2. DHCP Server Setup for Linux

Retrieve DHCPD (if your machine does not already have it installed). Get DHCPD


If there is not a binary distribution for your version of linux, then you will have to compile DHCPD.

Edit your /etc/rc.d/rc.local to reflect an addition of a route for

Quoted from DHCPd README:

In order for dhcpd to work correctly with picky DHCP clients (e.g., Windows 95), it must be able to send packets with an IP destination address of Unfortunately, Linux insists on changing into the local subnet broadcast address (in this case, the address would be This results in a DHCP protocol violation. While many DHCP clients don't notice the problem, some (e.g., all Microsoft DHCP clients) will recognize the violation. Clients that have this problem will appear not to see DHCPOFFER messages from the server.

Type the following as root:

route add -host dev eth0

If the message appears: Unknown host

Try adding the following entry to your /etc/hosts file: dhcp

Then, try:

route add -host dhcp dev eth0

8.2.1. Options for DHCPD

Now you need to configure DHCPd. In order to do this, you will have to create or edit /etc/dhcpd.conf. There is a graphical interface for dhcpd configuration under linuxconf. This makes configuring and managing DHCPD extremely simple.

If you want to configure it by hand, you should follow instructions below. I suggest configuring it by hand at least once. It will help in the diagnostics that a GUI can't provide. Unfortunately Micrsoft doesn't believe this!

The simplest way to assign IP addresses is to assign them randomly. A sample configuration file that shows this type of setup is displayed below:

# Sample /etc/dhcpd.conf
# (add your comments here)
default-lease-time 1200;
max-lease-time 9200;
option subnet-mask;
option broadcast-address;
option routers;
option domain-name-servers,;
option domain-name "mydomain.org";
subnet netmask {

This will allow the DHCP server to assign the client an IP address from the range or

If the client doesn't request a longer time frame, then the DHCP server will lease an IP address for 1200 seconds. Otherwise, the maximum (allowed) lease the server will allow is 9200 seconds. The server sends the following parameters to the client:

Use as your subnet mask Use as your broadcast address Use as your default gateway USE and as your DNS servers.

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;

You can also assign specific IP addresses based on the clients' ethernet MAC address as follows:

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

This will assign IP address to a client with the ethernet MAC address of 08:00:2b:4c:59:23.

8.2.2. Starting the server

In most cases the DHCP installation doesn't create a "dhcpd.leases" file. Before you start the server, you must create an empty file:

touch /var/state/dhcp/dhcpd.leases

To start the DHCP server, simply type (or include in the bootup scripts):


This will start dhcpd on eth0 device. If you need to start it on another device, simply supply it on the command line as shown below:

/usr/sbin/dhcpd eth1

If you wish to test the configuration for any oddities, you can start dhcpd with the debugging mode. Typing the command below will allow you to see exactly what is going on with the server.

/usr/sbin/dhcpd -d -f

Boot up a client.Take a look at the console of the server. You will see a number of debugging messages appear on the screen.

Your done