Skip to main content

Install and configure DHCP server on centos 6

Setup DHCP server on Centos 6 :

Dynamic Host Configuration Protocol (DHCP) is used to assign IP addresses and other stuff like gateway and DNS details automatically to the clients. we need a DHCP server configured for offering ipaddress to the clients when it is required .

Installing DHCP server on Centos 6:

After installing Centos 6 (Centos 6 installation step by step screenshots ) and configuring network (How to setup network in centos 6)

Update yum repositories and packages by typing the below command

[root@localhost ~]# yum update

Step 1 » Install dhcp server and client using the below command

[root@localhost ~]# yum install dhcp

Step 2 » After installing dhcp server packages along with dependencies .Assign a static ip (eg: “192.168.1.11”) in the same DHCP range for the listening interface ( eg : “eth0” ). Open /etc/sysconfig/network-scripts/ifcfg-eth0 file and make the changes as per your requirement .

Step 3 » Now open /etc/sysconfig/dhcpd file and add the preferred interface name to DHCPDARGS variable as below

Step 4 » open /etc/dhcp/dhcpd.conf file and paste the below lines and save it.

Step 5 » Now start the service

[root@localhost ~]# service dhcpd start

and type this below command to start dhcp service automatically while booting.

[root@localhost ~]# chkconfig --levels 235 dhcpd on

That’s it .Clients can get IP from DHCP server and Please ensure you don’t have any other dhcp servers in the same network ( Routers might have DHCP enabled ).

  • este error
    setgroups: Operation not permitted

    • Hi luis,
      It just because of selinux . please disable selinux and reboot your machine and try again.

      #vim /etc/selinux/config
      find this line
      SELINUX=enforcing
      and replace with
      SELINUX=disabled

      and reboot your machine .

  • chris

    thanks for this article, it works, now i know where to start as i go deeper studies on dhcp server.

  • chris

    thanks for this article, it works, now i know where to start as i go deeper studies on dhcp server.

  • rosesa

    +1 for selinux troubleshooting comment

  • rosesa

    +1 for selinux troubleshooting comment

  • I have installed and configured dhcp,exactly as told in this post but when I am starting dhcpd service it’s getting failed …..can u please help me …and I also have disabled the selinux….but problem is still persisting……

  • I have installed and configured dhcp,exactly as told in this post but when I am starting dhcpd service it’s getting failed …..can u please help me …and I also have disabled the selinux….but problem is still persisting……

    • Yaseen Khan

      turn off your firewall and reboot your system

  • Daniel Raiche

    I’m having an odd problem, it keeps telling me semicolon expected when I start the dhcpd service, but I’m sitting here looking at the semicolon in the config file. I’ve re-created a few times and the same thing happens, won’t allow me to start the service.

  • Daniel Raiche

    I’m having an odd problem, it keeps telling me semicolon expected when I start the dhcpd service, but I’m sitting here looking at the semicolon in the config file. I’ve re-created a few times and the same thing happens, won’t allow me to start the service.

  • shell

    thank you very much for the information here..it really helps a lot..

  • shell

    thank you very much for the information here..it really helps a lot..

  • shell

    I have a problem in configuring my dhcp server…when i tried to service dhcpd restart it will always failed.

  • shell

    I have a problem in configuring my dhcp server…when i tried to service dhcpd restart it will always failed.

  • Christopher William Hawker

    I never needed to disable selinux on a fresh install of Centos 6.6, worked straight away after installing.

  • Miguel C

    the people that get “Fail” when restart the DHCP, delete the dhcpd and download and install again. I had that problem and i fixed that issue doing that. Later just backup the dhcp file in another folder. To download dhcp use this command: yum install dhcp
    and if you want to delete the dhcp folder use this command: yum remove dhcpd