Dynamic Host Configuration Protocol (DHCP)

DHCP is a network protocol for automatically assigning TCP/IP information to client machines. Each DHCP client connects to the centrally-located DHCP server which returns that client's network configuration including IP address, gateway, and DNS servers.

Setting up DHCP server on Redhat Linux system

01. Install the dhcp server software if not already installed

  # yum install dhcp.x86_64

02. The dhcp server configuration file is /etc/dhcpd.conf. A sample file can be found at /usr/share/doc/dhcp-<version>/dhcpd.conf.sample. Copy this sample file as /etc/dhcpd.conf and modify the file as required.

 # cat /etc/dchpd.conf

 #DHCP server sample config file
 ddns-update-style interim;
 ignore client-updates;
 # if more than one network interface card present in the system, then specify to which 
 # interface the DHCP server has to listion in the following line
 DHCPDARGS=eth0;

 subnet 192.168.1.0 netmask 255.255.255.0 {

        option routers                  192.168.1.1; # --- default gateway
        option subnet-mask              255.255.255.0;
        option broadcast-address        192.168.1.255;
        option domain-name              "yourdomain.com";
        option domain-name-servers      192.131.255.10, 206.206.206.206; # DNS servers IP

        range dynamic-bootp 192.168.1.100 192.168.1.254;
        default-lease-time 86400;
        max-lease-time 86400;
        option ip-forwarding off;
 }

 # To assign an IP address to a client based on the MAC address of the network interface card, 
 # use the hardware ethernet  parameter within a host declaration.
 host test {
   option host-name "test.example.com";
   hardware ethernet 00:A0:78:8E:9E:AA; 
   fixed-address 192.168.1.104;
 }

03. Start the DHCPD server

 # service dhcpd start

04. Make the DHCPD Server to start automatically during next reboot

 # chkconfig dhcpd on

Lease Database

On the DHCP server, the file /var/lib/dhcp/dhcpd.leases stores the DHCP client lease database. This file should not be modified by hand. DHCP lease information for each recently assigned IP address is automatically stored in the lease database. The information includes the length of the lease, to whom the IP address has been assigned, the start and end dates for the lease, and the MAC address of the network interface card that was used to retrieve the lease. All times in the lease database are in Greenwich Mean Time (GMT), not local time.

The lease database is recreated from time to time so that it is not too large. First, all known leases are saved in a temporary lease database. The dhcpd.leases file is renamed dhcpd.leases~, and the temporary lease database is written to dhcpd.leases.

The DHCP daemon could be killed or the system could crash after the lease database has been renamed to the backup file but before the new file has been written. If this happens, the dhcpd.leases file does not exist, but it is required to start the service. Do not create a new lease file. If you do, all the old leases will be lost and cause many problems. The correct solution is to rename the dhcpd.leases~ backup file to dhcpd.leases and then start the daemon.

Help for DHCP


Help is available from the following man pages

 man dhcp-eval
 man dhcpd.conf
 man dhcpd.leases
 man dhcpd
 man dhcrelay

More information for configuring DHCP server can be found at the following link
http://centos.org/docs/5/html/Deployment_Guide-en-US/ch-dhcp.html

configuring dynamic dns udate along with DHCP

  http://en.opensuse.org/Howto_setup_SUSE_as_SAMBA_PDC_with_OpenLDAP,_DYNDNS_and_CLAM