Dynamic Host Configuration Protocol ( DHCP )
Description
For the management of large networks, assignment of the ip addresses statically
may prove to be a tedious task for the administrator. A solution is to automatic
ip address assignment to the users via a Dynamic Host Configuration Protocol
( DHCP ) Server. Aims to get the readers to deploy a DHCP server in the network.
Introduction
- It is a network protocol that enable a DHCP server to automatically assign an IP address to an individual computer. DHCP assigns a number dynamically from a defined range of number ( i.e., a scope ) configured for a given network.
- Client computer configured to use DHCP for IP assignment do not need to have a statically assigned IP address.
- DHCP assigns a TCP/IP address when a system is started. Typically, it works like this:
1. A user turns on a computer with a DHCP client.
2. The client computer sends a broadcast request ( called DISCOVER or
DHCPDISCOVER ), looking for a DHCP server to answer.
3. The router directs the DISCOVER packet to the correct DHCP server.
4. The server receives the DISCOVER packet. Based on availability and usage
policies set on the server, the server determines an appropriate address
( if any ) to give to the client. The server then temporarily reserves that
address for the client and sends back to the client an OFFER ( or
DHCPOFFER) packet, with that address information. The server also
configures the client's DNS server, WINS serves, NTP servers and some-
-times other services as well.
5. The client sends a REQUEST ( or DHCPREQUEST ) packet, letting the server
know that it intends to use the address.
6. The server sends an ACK ( or DHCPACK ) packet, confirming that the client
has a been given a lease on the address for a server-specified period of time.
The DORA process in DHCP works as follows.
D ----------> Discover
O ----------> Offer
R ----------> Request
A ----------> Acknowledgement
1. Client makes a UDP Broadcast to the server with a DHCPDiscover, or
Discover packet.
2. DHCP offers to the client.
The server sends a DHCPOffer including other configuration parameters
(DHCP Options) for the client per the servers configuration file
3. In response to the offer Client requests the server.
The client replies DHCPRequest, unicast to the server, requesting the
offered address.
4. The server sends DHCPAck acknowledging the request which is the clients
final permission to take the address as offered. Before sending the ack the
server double checks that the offered address is still available, that the
parameters match the clients request and (if so) marks the address taken.
DHCP Installation and Configuration
Start the Linux machine and check if the DHCP server packages are installed.
# rpm -qa dhcp
# rpm -ivh dhcp*
- If you see the output show above the packages are installed or else you needto install them. However the version shown above might change depending on the version of the OS used.
- Now open the file /etc/sysconfig /dhcpd and edit the line as follows. The line which reads
DHCPARGS=
must now read.
DHCPARGS=eth0
Replace 'eth0' above with the network interface you want to use for dhcp.
- Now copy /usr/share/doc/dhcp-version naem/dhcp.conf.sample to /etc/ by name ' dhcpd.cof ' by typing the following command in the command prompt.
# cp /usr/share/doc/dhcp-version name/dhcpd.conf.sample /etc/dhcpd.conf
- You can also copy the configuration file from any other configured dhcp server
- also.
- Now edit /etc/dhcpd.conf file according to your requirements. A sample dhcp configuration file is shown below.
subnet 10.0.0.0 netmask 255.255.255.0 {
# --- default gateway
option routers 10.0.0.1;
option subnet-mask 255.255.255.0;
# option nis-domain "mydomain.com";
option domain-name "mydomain.com";
option domain-name-servers 216.227.56.120, 64.34.4.36; ---->name
server
option time-offset -28800; # Pacific Standard time
# option ntp-servers 192.168.1.1;
# option netbios-name-servers 192.168.1.1;
#--- Select point-to-point node ( default is hybrid ). Don't change this unless
#--- you understand Netbios very well
# option netbios-node-type 2;
range 10.0.0.50 10.0.0.254; -------------------> range of your ip adderss
default-lease-time 604800;
max-lease-time 604800;
hosts test {
# option dhcp-client-identifier "test";
hardware ethernet mac address 00:e0:18:90:28:b2;
fixed-address 10.0.0.10;
}
# we want the nameserver to appear at a fixed address
# host ns {
# next-server marvin.redhat.com;
# hardware ethernet 12:34:56:78:AB:CD;
# fixed-address 207.175.42.254;
# }
}
- In the above the range 10.0.0.50 to 10.0.0.254 have been set side for dynamice hosts; this allows anything between 10.0.0.1 and 10.0.0.49 to be set aside as static ips. In the example, host 'test' is given a static ip using its mac address. the option 'dhcp-client-identifier' may work as an alternative to mac address, but may require some additional configuration on the client. The max lease time of 604800 translates to 7 days. Lease times are automatically renewed by clients once 50% of the expiration date is reached. Because of this very long lease timesshould be unnecessary. If a very long one is required provide the client a static ip using the host declaration. Also the option time-offset setting is in seconds according to the manual page ; Red Hat's configuration document erroneously lists this setting in hours. Use option host-name "apex.example.com" in a host declaration to provide hostnames to clients.
- Once the dhcp.conf file is configured, Start/Restart the server.
- Note: When ever you make changes to the configuration file /etc/dhcpd.conf require the dhcp server should be restarted .
- And check dhcpd.lease file has been created automatically or not . If not create the file manually by using the following command .
# touch /var/lib/dhcp/dhcp.leases
- The lease database is recreated from time to so that it is not too large. First all known leases are saved in temporary lease database. The dhcpd.leases file is renamed dhcpd.leases~, and the temporary lease database is written to dhcpd.leases.
- Finally check whether the DHCP server is offering IP leases to clients.
No comments:
Post a Comment