Install and configure dhcp server in Slackware Linux

A computer needs an ip address in order to communicate with other computer in a networking environment while a server needs to provide ip addresses for all its clients (users). There are two types of server that provide ip addresses to clients, a dynamic ip address server and static ip address server. A server that provides dynamic ip address is called a DHCP server (DHCP - Dynamic Host Configuration Protocol). That is the server that we are going to setup here.

Before we begin, let's look at how dhcp server works and some basic information about dhcp. A dhcp server not only handing over ip addresses to clients but also provides complete networking requirements such as subnet mask, DNS address and gateway router address. All these information are given automatically during boot up when a client has been configured to be a dhcp client.

A dhcp server is reasonable in a network environment where over 15 clients needed ip addresses. The reason is static ip addresses are hard to manage and in case of organization is planning for expenditure, dhcp is future proof. A dhcp server needs to be configured with a range of ip addresses that it can assign to network clients. When a client is boot up, it will provide an ip address along with other required addresses and prepare the next ip address in range for the next client. The ip address is never fix for one client, that's why it's called dynamic. When a client computer is shutdown, its ip address is released and can be assigned to another computer.That how a dhcp server works.

Install dhcp server in Slackware

A Linux server needs a dhcp service which is called a dhcpd (it's dhcp daemon) installed before dhcp can be configured. Slackware compiled dhcpd package is in /slackware-12.1/source/n/dhcp directory in Slackware installation dvd. It's recommended to download the latest dhcpd packages from Linux distribution's website or package maintainer website.

In Slackware Linux, installing a package is easy with a package utility called pkgtool. Pkgtool is a menu base tool. To use the utility, just type pkgtool in command line terminal. However you need to download whatever package you want to install because pkgtool can't get package from the Internet.

Go to Slackware packages website to download latest dhcpd package released.

Search current dhcpd package, choose nearest mirror and download it. Save dhcpd package in /tmp directory.

Slackware search current dhcp package

Change directory to /tmp. Type pkgtool at command line terminal.

[email protected]:# cd /tmp
[email protected]:/tmp# pkgtool

Choose Current - Install packages from the current directory.

Install dhcp packages from the current directory

Choose Yes - Install package dhcp-3.0.6-i486-1.

Install package dhcp-3.0.6-i486-1

Slackware also has software package management system called slackpkg which works similar to Debian aptitude. Slackpkg can automatically install and update software package via the Internet. You can install slackpkg from Slackware dvd in extra package. The steps for slackpkg installation from cd or dvd using pkgtool is the same as dhcp installation above. For more information about Slackware slackpkg, see slackpkg - Slackware package management system tutorial. Here is a slackpkg syntax to install and upgrade dhcpd package:

  1. [email protected]:~# slackpkg install dhcpd
  2. [email protected]:~# slackpkg upgrade dhcpd

When you invoke the slackpkg install dhcpd, dhcpd package will be downloaded from the chosen mirror when setting up slackpkg. If you experienced slow connectivity or dhcp download failed, choose other slackpkg mirror. That's all. With slackpkg, you just type the command, and slackpkg will do the rest.

Configure dhcp server in Slackware

The first step is done, now we are going to configure dhcp server in Slackware Linux. Before we continue, let's check whether dhcp package was successfully installed in our system:

[email protected]:~# slackpkg search dhcp

The list below shows all packages with the selected pattern.

[ installed ] - kdelibs-3.5.9-i486-4
[ installed ] - dhcp-3.0.6-i486-1
[ installed ] - dhcpcd-2.0.4-i486-2
[ installed ] - iproute2-2.6.16_060323-i486-2

[email protected]:~#

If you don't have slackpkg, use pkgtool to view the installed packages. You can also check dhcpd package in installed packages log with this command:

[email protected]:~# ls -l /var/log/packages | grep dhcpd

A dhcp server configuration file is called dhcpd.conf. You can find it in /etc directory. Here, see this:

[email protected]:~# cd /etc/
[email protected]:/etc# ls -l | grep dhcp
drwxr-xr-x 2 root root 4096 2006-07-26 14:09 dhcpc/
-rw-r--r-- 1 root root 75 2008-04-09 10:16 dhcpd.conf
[email protected]:/etc#

Let's see what is in the configuration file:

[email protected]:/etc# cat dhcpd.conf
# dhcpd.conf
# Configuration file for ISC dhcpd (see 'man dhcpd.conf')
[email protected]:/etc#

It's nothing inside. No dhcp configuration's example. Is that means we must start everything from zero? No, don't worry. We have an example of dhcp server configuration in /usr/doc/dhcp-3.0.6/examples/dhcpd.conf. So we just copy the dhcp configuration file and replace our dhcpd.conf file in /etc directory. Here we go:

[email protected]:~# cp /usr/doc/dhcp-3.0.6/examples/dhcpd.conf /etc/dhcpd.conf
[email protected]:~#

Update: Slackware64 14.1 has dhcpd.conf.example in /etc directory.

What we need to do next is to use text editor and edit configuration for our network. Here is example of my dhcpd.conf configuration:

# dhcpd.conf
# Sample configuration file for ISC dhcpd

# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.

# A slightly different configuration for an internal subnet.
# I choose this section to edit for my local dhcp configuration
subnet netmask {
option domain-name "";
option broadcast-address;
option domain-name-servers;
option subnet-mask;
option routers;
default-lease-time 600;
max-lease-time 7200;

You can add a static server if you have it in your network. Just edit the default example configuration. After you are done setting up server and ip address required in the dhcpd.conf configuration file, save it. It's time to start the dhcp service (dhcp daemon) now.

Start dhcpd service

First we must enable dhcpd service in /etc/rc.d directory and make it executable. If you don't have /etc/rc.d/rc.dhcpd, then copy the code below and save it as rc.dhcpd. Here is the easy way to do it:

1 - Copy this code:

# /etc/rc.d/rc.dhcpd
# This shell script takes care of starting and stopping
# the ISC DHCPD service

# Put the command line options here that you want to pass to dhcpd:

[ -x /usr/sbin/dhcpd ] || exit 0

[ -f /etc/dhcpd.conf ] || exit 0

start() {
# Start daemons.
echo -n "Starting dhcpd: /usr/sbin/dhcpd $DHCPD_OPTIONS "
/usr/sbin/dhcpd $DHCPD_OPTIONS
stop() {
# Stop daemons.
echo -n "Shutting down dhcpd: "
killall -TERM dhcpd
status() {
PIDS=$(pidof dhcpd)
if [ "$PIDS" == "" ]; then
echo "dhcpd is not running!"
echo "dhcpd is running at pid(s) ${PIDS}."
restart() {

# See how we were called.
case "$1" in
echo "Usage: $0 {start|stop|status|restart}"
exit 0

2 - In Slackware command line terminal, type cat > rc.dhcpd and enter. Right-click mouse to paste the code that you copy just now. See example below:

[email protected]:~# cat > rc.dhcpd
# /etc/rc.d/rc.dhcpd
# Start/stop/restart the DHCP daemon.
# To make dhcpd start automatically at boot, make this
# file executable: chmod 755 /etc/rc.d/rc.dhcpd

Press Ctrl+d to save and exit. You can view the file with less or cat command. Now move the rc.dhcpd file to /etc/rc.d/ directory. See complete step by step instructions example below:

[email protected]:~# less rc.dhcpd
[email protected]:~# mv rc.dhcpd /etc/rc.d/rc.dhcpd
[email protected]:~# ls -l /etc/rc.d/rc.dhcpd
-rw-r--r-- 1 root root 792 2008-12-02 15:47 /etc/rc.d/rc.dhcpd
[email protected]:~# chmod 755 /etc/rc.d/rc.dhcpd
[email protected]:~# ls -l /etc/rc.d/rc.dhcpd
-rwxr-xr-x 1 root root 792 2008-12-02 15:47 /etc/rc.d/rc.dhcpd*
[email protected]:~#

Now add the lines below to the /etc/rc.d/rc.local file to start dhcpd at boot:

if [ -x /etc/rc.d/rc.dhcpd ]; then
/etc/rc.d/rc.dhcpd start

Let's start the dhcpd service now:

[email protected]:~# /etc/rc.d/rc.dhcpd start
Starting DHCPD...
[email protected]:~#

We can check to see if dhcpd daemon is running using daemon status check. See example below:

[email protected]:~# /etc/rc.d/rc.dhcpd status
dhcpd is not running!
[email protected]:~#

The example shows that dhcpd is not running. There must be something wrong. We can troubleshoot dhcpd error by looking at the system's log. Use tail /var/log/syslog and tail /var/log/messages to read the last 10 logs. Carefully read the error and try suggestion given. See example below:

[email protected]:~# cat /var/log/syslog
Jun 20 14:23:15 slackware dhcpd: /etc/dhcpd.conf line 57: semicolon expected.
Jun 20 14:23:15 slackware dhcpd: option domain-name-servers 200.
Jun 20 14:23:15 slackware dhcpd: ^
Jun 20 14:23:15 slackware dhcpd: Configuration file errors encountered -- exiting
Jun 20 14:23:15 slackware dhcpd:
Jun 20 14:23:15 slackware dhcpd: If you did not get this software from, please
Jun 20 14:23:15 slackware dhcpd: get the latest from and install that before
Jun 20 14:23:15 slackware dhcpd: requesting help.
Jun 20 14:23:15 slackware dhcpd:
Jun 20 14:23:15 slackware dhcpd: If you did get this software from and have not
Jun 20 14:23:15 slackware dhcpd: yet read the README, please read it before requesting help.
Jun 20 14:23:15 slackware dhcpd: If you intend to request help from the [email protected]
Jun 20 14:23:15 slackware dhcpd: mailing list, please read the section on the README about
Jun 20 14:23:15 slackware dhcpd: submitting bug reports and requests for help.
Jun 20 14:23:15 slackware dhcpd:
Jun 20 14:23:15 slackware dhcpd: Please do not under any circumstances send requests for
Jun 20 14:23:15 slackware dhcpd: help directly to the authors of this software - please
Jun 20 14:23:15 slackware dhcpd: send them to the appropriate mailing list as described in
Jun 20 14:23:15 slackware dhcpd: the README file.
Jun 20 14:23:15 slackware dhcpd:
Jun 20 14:23:15 slackware dhcpd: exiting.
[email protected]:~#

The example above shows that we are missing a semicolon in the /etc/dhcpd.conf file. Actually we got semicolon there but the exact error dhcpd daemon won't start is we need to put a comma to separate two dns ip addresses. So go back and fix the error and start dhcpd daemon again. When dhcpd daemon successfully started, then we can test client computer to connect to the Slackware dhcp server.

Setup dhcp client on Windows Vista

The dhcp server is ready, now it's time to setup dhcp client. Here is the example to setup dhcp client in Windows Vista. Click Start, choose All Programs and right-click Network. Choose Properties. See picture below:

Windows Vista dhcp client setup image

In Windows Vista Network Properties, choose View Status (Windows 7 changes the name to Local Area Connection). See image below:

Windows Vista Network Properties image

When you click 'View Status', the Local Area Connection Status window pops up. Here we just click Properties. See image below:

Windows Vista Local Area Connection Status image

Now the Local Area Network Properties window pops up. We choose Internet protocol version 4 and click Properties. See image below:

Windows Vista Local Area Network Properties image

In this window, make sure both Obtain an IP address automatically button and Obtain DNS server address automatically are clicked. Click OK and we are done. See picture below:


Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.