Wednesday, July 17, 2013

Configure DHCP in RHEL6

Configure DHCP in RHEL6

Dynamic Host Configuration Protocol (DHCP) is a network protocol that automatically assigns TCP/IP information (including the IP address, gateway, and DNS servers) to client machines.


DHCP is also useful if an administrator wants to change the IP addresses of a large number of systems. Instead of reconfiguringall the systems, he can just edit one DHCP configuration file on the server for the new set of IP addresses.

Configuring a DHCP Server
First, install the package as the superuser:
# yum install dhcp
The sample configuration file can be found at /usr/share/doc/dhcp-<version>/dhcpd.conf.sample. You can copy this sample file over /etc/dhcp/dhcpd.conf, and then make changes according to your network need.
#cp /usr/share/doc/dhcp-<version>/dhcpd.conf.sample /etc/dhcp/dhcpd.conf

#vim /etc/dhcp/dhcpd.conf


#lease time setting

default-lease-time 600;
max-lease-time 7200;

#Subnet declaration

#The routers, subnet-mask, domain-search, and domainname-servers, options are used for any host statements declared below it. Additionally, a subnet can be declared, a subnet declaration must be in range of your  server ip range. If it is not, the DHCP server fails to start
.
subnet 192.168.1.0 netmask 255.255.255.0 {
option routers             192.168.1.254;
option subnet-mask         255.255.255.0;
option domain-name-servers 192.168.1.1;
range 192.168.1.10 192.168.1.100;

#Static IP address using DHCP if you want to fix an ip for particular system

host kamal {
hardware ethernet 00:A0:78:8E:9E:AA;
fixed-address 192.168.1.4;
}

#now save and exit file

#service dhcpd restart
#chkconfig dhcpd on


Configuring a DHCP Client

#vim /etc/sysconfig/network-scripts/ifcfg-eth0
#file should contain the following lines:

DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes
save and exit
#service network restart

it will try to obtain ip from dhcp server
#ifconfig    (to verify)

No comments:

Post a Comment