Install and configure DHCP server on CentOS / RHEL / Scientific Linux

Posted: February 17, 2014 in DHCP
Tags: ,

DHCPDynamic Host Configuration Protocol (DHCP) is a client/server protocol that automatically provides an Internet Protocol (IP) host with its IP address and other related configuration information such as the subnet mask, default gateway and DNS details automatically to the clients. We need a DHCP Server configured for offering IP address to the clients when they required.

Features:
1. Provides automatic configuration of IPv4 clients
a. IPv4 address
b. Subnet mask
c. Default gateway
d. DNS Servers
e. NTP Servers
f. WINS Servers
2. Leases the address and related information bassed o predefined values:
a. 1 day
b. 1 week
c. 1 month
3. DHCP uses UDP Protocol and layer-2 information to request/assign addresses
4. DHCP Process – DORA

a. Discovery – client broadcasts on the local subnet for a DHCP Server
b. Offer – returned by the DHCP Server
c. Request – formal address request by client
d. Acceptance – Acknowledgement occurs
Note: DHCPD records leases in: /var/lib/dhcpd/dhcpd.leases
Step 1 : Install the DHCP server and client using the below command
[root@webmail ~]# yum install dhcp

Step 2 : After installing dhcp server packages along with dependencies. Assign a static ip (eg: “10.10.12.143″) 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 .

1
2
3
4
5
6
7
8
DEVICE=”eth0″
HWADDR=”6c:62:6d:b2:c2:a8″
NM_CONTROLLED=”yes”
ONBOOT=”yes”
BOOTPROTO=”none”
IPADDR=10.10.12.143
NETMASK=255.255.255.0
GATEWAY=10.10.12.1

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

1
2
# Command line options here
DHCPDARGS=eth0

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

subnet 10.10.12.0 netmask 255.255.255.0 {# — default gateway
option routers                           10.10.12.1;
option subnet-mask                   255.255.255.0;
option nis-domain                      “example.com”;
option domain-name                  “example.com”;
option domain-name-servers      10.10.12.143, 10.10.12.153;range dynamic-bootp 10.10.12.120 10.10.12.250;
default-lease-time 21600;
max-lease-time 43200;
# we want the nameserver to appear at a fixed addresshost ns {
hardware ethernet 12:34:56:78:MN:MD;
fixed-address 10.10.12.153;

}

}

Step 5 : Now start the service

[root@webmail ~]# service dhcpd start

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

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

That’s it .Clients can now get IP from DHCP server.

Advertisements
Comments
  1. […] Install and configure DHCP server on CentOS / RHEL / Scientific Linux […]

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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