Friday, November 28

DHCP Server Configuration on Linux RHEL/CentOS

  • DHCP stands for Dynamic Host Configuration Protocol, One of the basic element found on all networks is a DHCP Server, making it an important part of any network.
  • DHCP makes Network Administration easy because you can make changes to a single point on your network and let those changes filter down to the rest of the network.
DHCP follows the ”  DORA “ process, DORA means

                       D – Discover

                       O – Offer

                       R – Request

                       A – ACK                                                         

Boot P Server: 

            In this method the Administrator used to collect the MAC Address to them. The list of MAC Address and IP Address was maintained in a Server called as a Boot P Server. When ever client request for IP Address Boot P Server assign the IP. In this method the Administrator used to collect the MAC Address.

  •        It gives IP – Address automatically to the clients who is requesting for an IP Address.
  •       It provides centralized IP-Address management.
  •      DHCP reduces the complexity and amount of administrative work by assigning TCP/IP configuration.

Steps to Install Configuration:

Step1: Start by installing the dhcp Package

              #yum  –y install dhcp  

Step2: Verify that the package is installed correctly

            # rpm –qa / grep dhcp

Step3: Make sure that the dhcpd service starts when the system boots as well

          # chkconfig  dhcpd  on

Step4: Verify that the DHCP service starts on boot

              # chkconfig  dhcpd  --list

Step 5: Edit  /etc/sysconfig/dhcpd file 

         Firstly we need to set ethernet interface name as DHCPDARGS in /etc/sysconfig/dhcpd file. Edit this configuration file and update the ethernet name.


Step6: DHCP Configuration

 To start the configuration, let’s look at the important files that handle the options for the DHCP services:

        /etc/dhcp/dhcpd.conf             :  Main Config file for the DHCP Service.

       /var/lib/dhcpd/dhcpd.leases    : IPV4 client lease file

DHCP creates an empty configuration file /etc/dhcp/dhcpd.conf. Also it provides a sample configuration file at /usr/share/doc/dhcp*/dhcpd.conf.sample.  To Copy the Sample file, use the following command.

          # cp   /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample      /etc/dhcp/dhcpd.conf

Step 6.1 : Parameter & IP Subnet Declaration

  Open the main Configuration file in vi editor, and change the configuration like below

         # vim   /etc/dhcp/dhcpd.conf

    In this example we are configuring DHCP for LAN network.

subnet    netmask {
        option routers                       ;
        option subnet-mask             ;
        option domain-name                     "";
        option domain-name-servers;
        default-lease-time                          21600;
        max-lease-time                               43200;
#Client IP range
                range  dynamic-bootp;

:wq! (save&quit)

Step6.2: Check the config file for any errors

   # service   dhcpd   configtest

Step6.3: Assign Static IP-Address to host

     Assigning IP-Address dynamically has some problem that every time a client system boots it is not sure that it will get the same IP, So it will be tedious task for other systems to find the particular system. To solve the above problem we can do MAC address binding of the IP address for this provide its entity in the fixed address portion.

Open the Main Config file :

    # vim /etc/dhcpd/dhcpd.conf 

Host client1  {
             Option host-name  “”;
            Hardware Ethernet   03:C6:7C:45:GG:RR;
            Fixed-address  ;

Step7 : Restart the DHCP service

       # service dhcpd restart     (or)

      # /etc/init.d/dhcpd  restart

Step8 : Linux Client side Configuration

  Client configuration is very easy and straightforward. All you need to do is set IP address to dynamic in the properties of lan card.

# vim /etc/sysconfig/network-scripts/ifcfg-eth0


Make sure BOOTPROTO is set to dhcp

Now restart the network services in client system, Dynamic IP address is assigned to ur System.

   # service  network  restart

Step9 : Windows Client Configuration

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

Go on command prompt and check new ip address

1 comment:

:: Linux - Legends ::