Linux DHCP Server Configuration
Linux DHCP Server Configuration
Abstract
This article is a guide on how to configure an ISCs(Internet Service
Consortium’s) DHCP server which ships with or is available for most
Linux systems.
1
Contents
1 INTRODUCTION 3
1.1 What is DHCP? . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 Planning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2 CONFIGURATION 3
2.1 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.2 Starting the server . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.3 Subsequent DHCP start up . . . . . . . . . . . . . . . . . . . . . 7
3 TROULESHOOTING 7
3.1 The 169.254.0.0 address . . . . . . . . . . . . . . . . . . . . . . . 8
3.2 Other DHCP failures . . . . . . . . . . . . . . . . . . . . . . . . . 8
2
1 INTRODUCTION
1.1 What is DHCP?
The Dynamic Host Configuration Protocol-widely known as DHCP, is a net-
working protocol that is used to issue an IP address and other configuration to
active network hosts.
1.2 Planning
Network planning is a critical process that should be carried out before setting
up a new network or expanding an existing one. It helps ensure that the ne-
towrk can sustain the task for which it was intended. A good network plan
should consider growth, technology change, migration and new application de-
ployments.
2 CONFIGURATION
In this section, we shall indulge into the configuration of ISC’s DHCP server
which bundles with a majority of Linux operation systems.
2.1 Configuration
Prior to starting, we shall confirm that the dhcp application is installed in our
intended DHCP server by using the RPM query command. The machine would
return the DHCP version installed in a new line if any. This is shown below:
[stuart@desert ~]$ rpm -q dhcp
dhcp-3.0.5-21.el5
[stuart@desert ~]$
Then, we proceed to view the default dhcp configuration which normally sits
in the /etc/ directory using the cat command; which accepts the file to view as
a parameter.
[stuart@desert ~]$ cat /etc/dhcpd.conf
#
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd.conf.sample
#[stuart@desert ~]$
3
At this stage, we copy the sample configuration file from the location given
above to the /etc/ directory. We can confirm it is copied by using the cat
command again.
4
Finally, open and edit the default configuration file to suit your requirements.
My final configuration is shown below. Explanations for the configuration are
given hereafter.
[stuart@sandstorm ~]$ cat /etc/dhcpd.conf
1 | ddns-update-style interim;
2 | ignore client-updates;
3 |
4 | subnet 192.168.1.0 netmask 255.255.255.224 {
5 |
6 | # --- default gateway
7 | option routers 192.168.1.1;
8 | option subnet-mask 255.255.255.128;
9 |
10|
11| option nis-domain "sandstorm.org";
12| option domain-name "sandstorm.org";
13| option domain-name-servers 192.168.1.1;
14|
15| option time-offset 10800; # East African Time
16| # option ntp-servers 192.168.1.1;
17| # option netbios-name-servers 192.168.1.1;
18| # --- Selects point-to-point node (default is hybrid). Don’t change this unless
19| # -- you understand Netbios very well
20| # option netbios-node-type 2;
21|
22| range dynamic-bootp 192.168.1.10 192.168.1.30;
23| default-lease-time 21600;
24| max-lease-time 43200;
25|
26| # we want the nameserver to appear at a fixed address
27| host HPlaptop {
28| next-server dune.sandstorm.org;
29| hardware ethernet 00:16:d4:c0:9e:b0;
30| fixed-address 192.168.1.9;
31| }
32| }
Line 7 defines the IP address to be used as the gateway of the network defined
above whereas Line 8 issues its netmaks address.
Line 12 defines the name of the domain that the hosts shall be assigned when
they recieve an reply from the DHCP server.
Line 15 gives the time offset from GMT which the server uses to manage
and log address leases. 10800 is an equivalent of 3 hours given in seconds (that
5
is, 3 x 60 x 60).
Line 23 & 24 define the default and maximum lease times(that is, length
of time it can use the same configuration) in seconds which are 6 hours and 12
hours respectively.
Keep in mind that all lines that commence with the hash or pound(#) sign
are comments.
[stuart@desert ~]$
Once this is confirmed, we can start the DHCP daemon as shown below from
the command line.
If in doubt that the dhcp server is running, the command below may be used
which displays its process number-also known as PID, start time among others.
Or alternatively,
6
[stuart@desert ~]$ ps -aux | grep dhcp
Warning: bad syntax, perhaps a bogus ’-’? See /usr/share/doc/procps-3.2.7/FAQ
root 4552 0.0 0.1 7460 1260 ? Ss 20:44 0:00 /usr/sbin/dhcpd
stuart 4565 0.0 0.0 61160 728 pts/2 R+ 20:47 0:00 grep dhcp
[stuart@desert ~]$
Take note of the process IDs of the DHCP process in the two commands
executions above.
To view the which IP addresses has been given to a host, the following com-
mand can be executed on the terminal that acts as the DHCP server.
lease 192.168.1.9 {
starts 2 2010/03/02 17:56:17;
ends 2 2010/03/02 23:56:17;
binding state active;
next binding state free;
hardware ethernet 00:16:d4:c0:9e:b0;
}
[stuart@desert ~]$
As mentioned earlier, the DHCP server daemon uses its time in GMT. My
laptop was issues an IP address at 20:56:17 hours on March 2, 2010 which is
written as 2010/03/02 17:56:17.
3 TROULESHOOTING
Most commmon DHCP problems arise from the DHCP clients rather than the
server. So, in the event that this occurs don’t change tour configuration yet,
unless the DHCP process in the server can’t start.
7
3.1 The 169.254.0.0 address
Microsoft windows DHCP clients assign themselves an address in the 169.24.0.0
network in the event that the DHCP server is unavailable or unreachable to
them. This will be until the server is accessible again. A condition normally
referred to as Automatic Private IP Addressing(APIPO). Here are some steps
to troubleshoot a DHCP client:
• Ensure that no firewall block the BOOTP protocol used by DHCP. The
server recieves requests on UDP port 67 and return a reply to the client
on port 68.
Always check /var/log/messages for DHCP errors. You can also run tcpdump
on the NIC through which the DHCP process shall server its configuration.