Thursday, January 20, 2011

DHCP Server

Dynamic Host Configuration Protocol
Works on following ports:
# cat /etc/services | grep dhcp
bootpc          68/tcp          dhcpc           # BOOTP client
bootpc          68/udp          dhcpc
dhcpv6-client   546/tcp
dhcpv6-client   546/udp
dhcpv6-server   547/tcp
dhcpv6-server   547/udp
dhcp-failover   647/tcp                 # DHCP Failover
dhcp-failover   647/udp                 # DHCP Failover
dhcp-failover2  847/tcp                 # dhcp-failover 2
dhcp-failover2  847/udp                 # dhcp-failover 2
qip-qdhcp       2490/tcp                # qip_qdhcp
qip-qdhcp       2490/udp                # qip_qdhcp

bootps          67/tcp                          # BOOTP server
bootps          67/udp

DHCP is used for allocating the IP Addresses Automatically i.e Dynamically.

DHCP Lease Allocation Process:
It is very important to understand the lease allocation process of DHCP.

Allocation process is done in following 4 steps:
1. DHCPDISCOVER message: Client requests the DHCP Server in the network in the form  of broadcast packet
2. DHCPOFFER message: Any of the available DHCP server gives response to the Discover message
3. DHCPREQUEST message: A client can receive DHCP offers from multiple servers, but it will accept only one DHCP offer and broadcast a DHCP request message
4. DHCPACK message: When the DHCP server receives the DHCPREQUEST message from the client, the configuration process enters its final phase. The acknowledgement phase involves sending a DHCPACK packet to the client. This packet includes the lease duration and any other configuration information that the client might have requested. At this point, the IP configuration process is completed.

Now we will configure the basic DHCP server which will allocate IP, Netmask,Gateway and DNS information to the cleint.This configuration has been tested on CentOS- 5.5 

First search for required RPMs
# rpm -qa | grep -i dhcp
dhcpv6_client-0.10-33.el5
dhcp-3.0.5-3.el5
dhcp-devel-3.0.5-3.el5
dhcpv6-0.10-33.el5

If not available install it using yum
# yum -y install dhcp*

Edit the /etc/dhcpd.conf file as given below :
# vim /etc/dhcpd.conf
ddns-update-style interim;
ignore client-updates;
option wpad-url code 252 = text;
one-lease-per-client true;
subnet 192.168.1.0 netmask 255.255.255.0 
{
option routers                               192.168.1.1; # Default Gateway
option subnet-mask                       255.255.255.0;
option nis-domain                         "example";
option domain-name                     "example.com";
option domain-name-servers         192.168.1.3;
option time-offset                          -18000; # Eastern Standard Time
option ntp-servers                          192.168.1.1;
option netbios-name-servers          192.168.1.1;
range dynamic-bootp                     192.168.1.102 192.168.1.220;
default-lease-time                           86400;
max-lease-time                               604800;
next-server                                     192.168.1.3;  # For PXE-Boot
filename                                         "pxelinux.0";     # For PXE-Boot

}
# We want Lisa to appear at a fixed address
#1.Lisa Dsouza
      host node03.example.com
              {hardware ethernet  00:21:97:2C:09:A5;
               fixed-address 192.168.1.108;
              }

Following two lines will be used(as in the above configuration file) if you are doing the over the  network installation using DHCP/BOOTP and NFS. This will be covered in my other posts.
next-server                                     192.168.1.3;     # For PXE-Boot
filename                                         "pxelinux.0";     # For PXE-Boot

Some of the other configurations would be :
  • Fail Over DHCP Server : Primary and Secondary DHCP Servers
  • Configuring the Multiple DHCP Servers on Multiple LAN cards serving multiple subnets
  • Configuring single DHCP server serving multiple subnets
  • Configuring DHCP Relay Agent
  • Configuring DHCP PXE-BOOT Server
Most of the above mentioned options/configurations will be posted soon.

No comments:

Post a Comment