Chapter - 13 Dynamic Host Configuration Protocol (DHCP)
Chapter - 13 Dynamic Host Configuration Protocol (DHCP)
Chapter - 13 Dynamic Host Configuration Protocol (DHCP)
•Use of DHCP
•Configuring DHCP
Dynamic Host Configuration
Protocol (DHCP) is network protocol
for automatically assigning TCP/IP
information to client machines. Each
DHCP client connects to the centrally
located DHCP server that returns the
client's network configuration including
IP address, gateway, and DNS
servers.
Why Use DHCP?
DHCP is useful for fast delivery of client network
configuration. When configuring the client system, the
administrator can choose DHCP and not have to enter an IP
address, netmask, gateway, or DNS servers.
You can declare a subnet. You must include a subnet declaration for
every subnet in your network. If you do not, the DHCP server will fail to
start.
In this example, there are global options for every DHCP client
in the subnet and a range declared. Clients are assigned an IP
address within the range.
host apex {
option host-name apex.example.com";
hardware ethernet 00:A0:78:8E:9E:AA;
fixed-address 192.168.1.4;
}
Lease Database
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.
The first time you start the DHCP
service, it will fail unless the lease database
exists. Use the command
touch /var/lib/dhcpd.leases to create the file
before starting the server for the first time. Once
the file exists and the server has been started, do
not try to create a new lease database file.
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, there is no
dhcpd.leases file that is required to start the
service. Do not create a new lease file if this
occurs. 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.
Starting and Stopping the Server
To start the DHCP service, use the command
/sbin/service dhcpd start.
To stop the DHCP server, use the command
/sbin/service dhcpd stop.
NETWORKING=yes
DEVICE=eth0
BOOTPROTO=dhcpO
NBOOT=yes