Wednesday, January 2, 2013

DHCP configuration


DHCP ( Dynamic Host Configuration Protocol ) helps you to assign IP address to the clients automatically based on the predefined pool of IP addresses.

A. DHCP server set up

1. Install DHCP software package
# yum install dhcp

2. Once installed, configure your dncp
# cat /etc/sysconfig/dhcpd
    –DHCPDARGS=eth1
Note: You specify your interface here.

3. Now, copy sample dhcp configuration for your DHCP configuration
# cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample  /etc/dhcp/dhcpd.conf

4. Edit the config file and make following parameter change.
# cat  /etc/dhcp/dhcpd.conf
option domain-name "expanor.local";
option domain-name-servers 192.168.10.110, 192.168.10.8;


default-lease-time 600;
max-lease-time 7200;
authoritative;
log-facility local7;

# Update subnet details as per your network.
# our network is 192.168.10.0/24
subnet 192.168.10.0 netmask 255.255.255.0

{
option routers 192.168.10.1;
option subnet-mask 255.255.255.0;
option domain-search "expanor.local";
option domain-name-servers 192.168.10.110;
# Specify Eastern Standard Time
option time-offset -18000;
range 192.168.10.2 192.168.10.210;
}

## Pre-assign IP address to your host

host sama
{
option host-name "ruma.expanor.local";
hardware ethernet 00:0B:DB:C6:05:07;
fixed-address 192.168.10.120;
}

5. Now, restart the services

# service dhcp stop
# service dhcp start
# chkconfig –levels 345 dhcp on

6 Configure log server to capture log
Note: syslog might have already been installed. if now
# rpm -qa | grep rsyslog
# yum search rsyslog
# yum install rsyslog

a. Append the following at the end of the config file
# tail -f /etc/rsyslog.conf
     –local7.* /var/log/dhcpd.log

Once you made change, restart the syslog service
# service rsyslog restart

b. Once you restart the service, it should start writing to log file.
# tail -f /var/log/dhcpd.log

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

B. Configure DHCP Client

1. Login to your system and edit network configuration
# cat  /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=dhcp
TYPE=Ethernet
ONBOOT=yes

# service network restart
# ifconfig

Note: Most of the places, you will see commercial products used on most of the companies. They are for specific purpose and might be for specific environment. On real production, we always use static IP

No comments:

Post a Comment