DHCP (Dynamic Host Configuration Protocol)

Manually configuring IP addresses of servers is a fairly simple task. However, manually configuring IP addresses for an entire department, building, or enterprise of heterogeneous systems can be mundane and time consuming.
The DHCP (Dynamic Host Configuration Protocol) client and server is the standard solution. The client machine is configured to receive its IP address from the network. When the DHCP client software is started, it broadcasts a request onto the network for an IP address. If all goes well, a DHCP server on the network will respond, issuing an address and other necessary information to complete the client's network configuration. The necessary information includes name servers, a network mask, and a default gateway. The DHCP server maintains a list of addresses it can issue.
DHCP server process
DHCP server process

This chapter will cover the process of configuring a DHCP server and client

Configuring the DHCP Server

RPM of dhcp server looks like this dhcp-3.0.5-18.el5.i386.rpm.
The minimum tools you need to get the DHCP server working are:
After the DHCP server is running, it listens to UDP port 67 for requests from DHCP clients on the LAN. The client to send out a DHCP discovery request to (the global broadcast address).

Configuring the /etc/dhcpd.conf file

Consider you have a single pool of IP addresses that you want to distribute to a set of computers that are all on the same subnetwork.
Here is an example of a simple dhcpd.conf file:
ddns-update-style none;
subnet	netmask	{
	option routers;
	option subnet-mask;
	option domain-name		"";
	option domain-name-servers;
	default-lease-time 21600;
	max-lease-time	43200;
In this example, this DHCP server provides IP addresses for client computers on a small LAN. The first two lines tell the DHCP server not to update DNS records for the local domain based on the IP addresses it assigns.
The DHCP server is serving a single LAN, represented by a network address with a netmask.
A single server at address is used as the router (or gateway) and DNS server for the LAN.
The pool of addresses handed out by this DHCP server is to, as set by the range line. Along with the IP address that each client is assigned, the client is also given the associated subnet-mask and domain name.
The IP addresses that the DHCP server hands out are leased to each client for a particular time. The default-lease-time (set to 21,600 seconds here, or 6 hours) is the time assigned if the client doesn't request a particular lease period. The max-lease-time (43,200 seconds here, or 12 hours) is the highest amount of time the server will assign, if the client requests it.

Starting the DHCP server

After the /etc/dhcpd.conf file is configured, you can start the DHCP server
[root@ server ~] # service dhcpd start
To run dhcp at boot time.
[root@ server ~] # chkconfig dhcpd on
There are a few ways you can verify that your DHCP server is working:

Setting Up a DHCP Client

To configure windows system as dhcp clients open lan card properties and select tcp/ip and click on properties and set obtain ip address automatically.
DHCP client
DHCP client

Go on command prompt and check new ip address
DHCP server verification
DHCP server verification

Type command ipconfig /all (windows system)
DHCP server verification for lease
DHCP server verification for lease

There are a few ways you can verify that your DHCP server is working:
  • Check the /var/log/messages file. If the DHCP service has trouble starting, you will see messages in this file indicating what the problem is.
  • Check the /var/lib/dhcpd/dhcpd.leases file. If a client has been assigned addresses successfully from the DHCP server, a lease line should appear in that file. There should be one set of information that looks like the following for each client that has leased an IP address as shown in figure.
  • DHCP server /var/lib/dhcpd/dhcpd.leases
    DHCP server /var/lib/dhcpd/dhcpd.leases

This is the simple configuration and example to show you how dhcp works. I hope you enjoyed the chapter, do like, share and give your feed back in comment box.