An Introduction to DHCP

Confused about what DHCP offers and how you can take advantage of it on your Linux system? Here are some tips and pointers.

DHCP stands for dynamic host configuration protocol. What it does is dynamically assign network settings from a server. In other words, instead of having to configure the parameters related to how your computer communicates with a network, it happens automatically.

Assigning an IP address dynamically is the most basic piece but there is a lot more to DHCP. This includes the netmask, host name, domain name, gateway and name servers. In addition, DHCP can supply other information such as a time server.

Many people are anti-DHCP, because they see it as a way that an ISP offers you an IP address that changes. This, of course, makes it difficult to advertise a server. On the other hand, DHCP can save you a lot of ongoing configuration work within your company or organization.

Besides the ISP-provided DHCP servers, they commonly exist in inexpensive router boxes. Netgear, Linksys and other vendors offer these systems with multiple LAN ports, an 802.11b wireless interface or both. The Netgear RP114 is an example of a wired LAN, while the Linksys WAP11 is an 802.11b type. Many other product choices are available. When you use one, the router box becomes the system that the ISP knows about, and all of your real computers hide behind this box.

Hide? Effectively, yes. What is visible to the public Internet is the router. The LAN has private IP addresses and uses network address translation (NAT) to handle connections from the internal systems to the Internet. Although this isn't really a firewall, NAT offers a basic level of protection.

Most routers in this class allow you to:

  • Clone the MAC (hardware) address of one of your computers. This allows you to make the ISP think it is talking to a computer system you previously identified rather than to a router with possibly multiple machines connected to it.

  • Handle static IP addresses. This means you could pick a local network address (192.168.1.x, for example) and assign specific addresses in this range.

  • Dynamically assign IP addresses from a specified range. For example, the router could be configured to offer DHCP for 20 different addresses, say thru

That is the basics of "DHCP for Beginners". If you simply are trying to decide between using DHCP or a static IP address, this may be enough information. On the other hand, you could decide to run a DHCP server on a Linux system. In that case, there are more options.

Linux as a DHCP Server

Dhcpd from ISC is the most common DHCP server shipped with Linux systems. When started, it takes its directions from a configuration file usually found at /etc/dhcpd.conf. Here is a sample configuration file:

# Sample configuration file for ISC dhcpd

# option definitions common to all supported networks...
option domain-name "";
option domain-name-servers,;

default-lease-time 600;
max-lease-time 7200;

# if you do not use dynamical DNS updates:
# this statement is needed by dhcpd-3 needs at least this statement.
# you have to delete it for dhcpd-2, because it does not know it.
# if you want to use dynamical DNS updates, you should first read
# read /usr/share/doc/packages/dhcp-server/DDNS-howto.txt
ddns-update-style none; ddns-updates off;

# network, the authoritative directive should be uncommented.

# have to hack syslog.conf to complete the redirection).
log-facility local7;

# This is a very basic subnet declaration.

subnet netmask {
  option routers,;

# A slightly different configuration for an internal subnet.
subnet netmask {
  option domain-name-servers;
  option domain-name "";
  option routers;
  option broadcast-address;
  default-lease-time 600;
  max-lease-time 7200;

# Hosts which require special configuration options can be listed in
# will still come from the host declaration.

host passacaglia {
  hardware ethernet 0:0:c0:5d:bd:95;
  filename "vmunix.passacaglia";
  server-name "";

# set.
host fantasia {
  hardware ethernet 08:00:07:26:c0:a5;

The man page associated with this file, dhcpd.conf(5) is quite thorough, and I am not going to attempt to reproduce all that information here. Simply typing man dhcpd.conf| will display it. It runs over 25 printed pages, but should you want to print it for off-line study, the following commands should suffice:

cd /usr/share/man/man5
zcat dhcpd.conf.5.gz | groff -man | lpr

The file is divided into two types of statements. Parameter statements say how dhcpd should do something. Declaration statements describe the network. Thus, parameters establish things that declarations may depend upon. In the example above, default-lease-time is an example of a parameter. The block beginning with host fantasia { is a declaration. The option statements appearing outside of any block are global parameters, meaning they are global in scope. Those within declarations have a local scope.

I hope this introduction helps you work with DHCP. Being a DHCP client is easy, and it is not really complicated on the server side either. Once you decide what you want your DHCP server to do, translating that information into what is needed in /etc/dhcpd.conf is a simple process.

Copyright (c) 2004, Dean Wilson. Originally published in Linux Gazette issue 98. Copyright (c) 2004, Specialized Systems Consultants, Inc.

Dean Wilson is a system administrator and occasional updater of his Web pages.



Comment viewing options


deny users that did not acquire ip from the dhcp server?

Saritha's picture

how do i deny users that did not acquire ip from the dhcp server?

Debian dhcp server setup

Anonymous's picture

if you want to configure your debian server for dhcp very good and nice tutorial here



Learn More

Sponsored by Bit9

Linux Backup and Recovery Webinar



Learn More

Sponsored by Storix