How to Setup a DHCP Server on CentOS 6.2

In this scenario, we have a CentOS server with two network cards, but it will only listen the dhcp request on one card (eth1).

Here is the configuration of eth1 interface:

cat /etc/sysconfig/network-scripts/ifcfg-eth1

CentOS as DHCP Server:

To install dhcp server, enter the following command at a terminal prompt:

sudo yum -y install dhcp

To make the dhcp server start at boot time, use this commands:

sudo chkconfig dhcpd on

As we are using more than one network card(s) in our CentOS server, so we need to specify on which interface our server will be listen for dhcp request. (By default, it listens on eth0).

You can change this by editing  /etc/sysconfig/dhcpd file:

sudo nano /etc/sysconfig/dhcpd

Add the name of the interface on which you want that your server will listen for dhcp request (In my case, it is eth1):


Copy the default configuration file from  /usr/share/doc/dhcp-versidhcp/dhcpd.conf.sample to the /etc/dhcp/dhcpd.conf :

sudo cp /usr/share/doc/dhcp-*/dhcpd.conf.sample /etc/dhcp/dhcpd.conf

Now we will change the default configuration by editing /etc/dhcp/dhcpd.conf, I normally delete everything inside the file and manually add the configuration that suits my needs :-)

sudo nano /etc/dhcp/dhcpd.conf

Here is my dhcpd.conf file, you need to change it according to your needs:

ddns-update-style none;
log-facility local7;
default-lease-time 600;
max-lease-time 7200;
option subnet-mask;
option broadcast-address;
option routers;
option domain-name-servers;
option domain-name "centos.local";
subnet netmask {

Restart dhcp service using the following command:

sudo service dhcpd restart

Configure Windows as DHCP Client:

Just follow these steps, in order to configure your Windows machine as DHCP client (In my case, it’s Windows XP):

To check the IP Address on Windows XP:

To Check the DHCP Leases on CentOS Server:
cat /var/lib/dhcpd/dhcpd.leases

Hope this will help you!

Please Remember me in your prayers!

6 responses to “How to Setup a DHCP Server on CentOS 6.2

  1. marko May 26, 2012 at 8:53 pm

    Is there any chance to write this kind of tutorial for DNS server on CentOS 6.x?

  2. Anup October 17, 2012 at 10:08 am

    How to make dhcp server to listen in two interface and assign IP depending upon from which inteface request came.

    For example assign 172.16.x.x ip for the request coming form eth0 and 172.18.x.x for the request coming form eth1.

  3. Pingback: Centos 6 : Install Squid Transparent Proxy With DHCP Server | Muhammad Bintang's Weblog

  4. Pingback: Dhcp Server Centos | Kuplux's

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: