Wednesday, October 17, 2012

Installing a dhcp server in Centos6.x

1 Install CentOS 6.3 or find an adequate server to run the dhcpd daemon
 

2 Run the following steps:
 

sudo yum install dhcp
3 Configuration steps

Edit the following file as shown below:
 

vim /etc/dhcp/dhcp.conf

Edit to fit your environment

# DHCP Server Configuration file.
#   see /usr/share/doc/dhcp*/dhcpd.conf.sample
#   see 'man 5 dhcpd.conf'
#


subnet 10.10.10.0 netmask 255.255.255.0 {
       option routers                  10.10.10.1; #Default Gateway
       option subnet-mask              255.255.255.0;
       option domain-name              "myorg.net";
       option domain-name-servers      10.10.10.100;
    range dynamic-bootp 10.10.10.101 10.10.10.199;  #DHCP Range to assign
       default-lease-time 43200;
       max-lease-time 86400;
}


3.1    CONFIGURE DHCP TO LISTEN ON A SPECIFIC INTERFACE

If more than one network interface is attached to the system, but the DHCP server should only be started on one of the interface, configure the DHCP server to start only on that device. In /etc/sysconfig/dhcpd, add the name of the interface to the list of DHCPDARGS:

# Command line options here
 

DHCPDARGS=eth0
3.2    STARTING THE DHCP SERVICE

To start the DHCP service, use the command 


/sbin/service dhcpd start

To stop the DHCP server, use the command 

/sbin/service dhcpd stop

3.3    DHCP SERVER LOGS

On the DHCP server, the file /var/lib/dhcp/dhcpd.leases stores the DHCP client lease database. This file should not be modified by hand. DHCP lease information for each recently assigned IP address is automatically stored in the lease database. The information includes the length of the lease, to whom the IP address has been assigned, the start and end dates for the lease, and the MAC address of the network interface card that was used to retrieve the lease.

All times in the lease database are in Greenwich Mean Time (GMT), not local time.
The lease database is recreated from time to time so that it is not too large. First, all known leases are saved in a temporary lease database. The dhcpd.leases file is renamed dhcpd.leases~, and the temporary lease database is written to dhcpd.leases.

The DHCP daemon could be killed or the system could crash after the lease database has been renamed to the backup file but before the new file has been written. If this happens, the dhcpd.leases file does not exist, but it is required to start the service. Do not create a new lease file. If you do, all the old leases will be lost and cause many problems. The correct solution is to rename the dhcpd.leases~ backup file to dhcpd.leases and then start the daemon.

3.4   DHCP RELAY AGENT 


The DHCP Relay Agent (dhcrelay) allows for the relay of DHCP and BOOTP requests from a subnet with no DHCP server on it to one or more DHCP servers on other subnets.

When a DHCP client requests information, the DHCP Relay Agent forwards the request to the list of DHCP servers specified when the DHCP Relay Agent is started.

When a DHCP server returns a reply, the reply is broadcast or unicast on the network that sent the original request.

The DHCP Relay Agent listens for DHCP requests on all interfaces unless the interfaces are specified in /etc/sysconfig/dhcrelay with the INTERFACES directive. 


To start the DHCP Relay Agent, use the command 


service dhcrelay start

No comments:

Post a Comment