How to Install and Configure DHCP Server on Centos 6

By | February 28, 2016
Install and configure DHCP Server on Centos 6 - #ilovebash

Install and configure DHCP Server on Centos 6 – #ilovebash

How to Install and Configure DHCP Server on Centos 6

DHCP Server – DHCP (Dynamic Host Configuration Protocol) is the protocol used to assign IP addresses (and gateway and DNS servers) to new clients on a specific local network.

Installation of DHCP Server on Centos 6

As a first step you should ensure that your operating system software is up to date using yum –

yum update

Step 2 – Install DHCP Server and client

yum install dhcp

Step 3 – Configuring DHCP interface

You need to ensure that your server has an IPADDR on the network you want to act as a DHCP Server for. Check your interface files in /etc/sysconfig/network-scripts as below –

[root]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
HWADDR=00:25:90:DE:44:17
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=none
IPADDR=192.168.2.123
NETMASK=255.255.255.0
GATEWAY=192.168.2.1

You can see from the above that your interface you want to use is eth0, and that it can provide ip addresses for the 192.168.2.0 network.

Step 4 – Configure DHCP Server to use eth0 as the interface for ip address allocation

Edit the file /etc/sysconfig/dhcpd and set the line as below –

DHCPDARGS=eth0

Step 5 – Configure your DHCP Server network, ip range, and gateway

Next file to edit is /etc/dhcp/dhcpd.conf and set the following –

option domain-name "yourdomain.com";
option domain-name-servers 8.8.8.8, 8.8.4.4;
default-lease-time 600;
max-lease-time 7200;
log-facility local7;

subnet 192.168.2.0 netmask 255.255.255.0 {
range 192.168.2.200 192.168.2.254;
option broadcast-address 192.168.2.255;
option routers 192.168.2.1;
}

As you can see the parameters above are pretty self explanatory. In the above example I have specified Google Public DNS servers (8.8.8.8 and 8.8.4.4) for convenience, you can just as well specify your own local DNS Servers.

The above example also allocates the ip range from 192.168.2.200 – 192.168.2.254 for the DHCP Server to use to allocate to client connections.

And I have set the option routers 192.168.2.1 to the default route needed (copied from my ifcfg-eth0 file)

One mistake it is easy to make is to forget to put the semi-colon on the end of each line (it will be obvious to you if it fails to start on the next step)

Step 6 – Start the DHCP Server Service

service dhcpd start

Step 7 – And configure DHCP to auto start after a server reboot

chkconfig dhcpd on

Thats it. You can see debug messages as new clients use your DHCP Server in the system messages file /var/log/messages as well as any error messages it encounters.

Check out -  Timelapse Video - Construction of Dreamland Oasis in Chakvi, Georgia - Multiple Webcams

Leave a Reply