Objective 1: DHCP Configuration

DHCP is a superset of bootp and a replacement for that earlier protocol; both are used to assign IP addresses to clients on a network. DHCP is used for dynamic hosts that can move, connect, and disconnect from networks. DHCP can dynamically assign IP addresses from preassigned IP ranges in /etc/dhcpd.config and set up static IP addresses based on the network interface card's Media Access Controller (MAC) address. DHCP can even restrict access by accepting requests only from specified MAC addresses.

Setting Up a DHCP Server

To set up a DHCP server, first ensure you have your DHCP package installed. Also read the README file, because it's full of useful information. Next, follow these steps:

  1. Configure your /etc/dhcpd.conf file (an example for setting random IPs for clients is in the next section).

  2. Start the DHCP server in debug mode (/usr/sbin/dhcpd -d -f) to verify that DHCP is working properly.

  3. To start the server for actual use, enter /etc/init.d/dhcpd start or just /usr/bin/dhcpd, sending it into the background as a daemon.

Configuring DHCP options

The DHCP protocol has a vast number of options that it can pass to clients to configure them correctly. Some of the most important are shown in the following example:

default-lease-time 21600; max-lease-time 43200; option subnet-mask 255.255.255.0; option broadcast-address 192.168.1.255; option routers 192.168.1.254; option domain-name-servers 192.168.1.1, 192.168.1.2; option domain-name "example.com"; ...

Get LPI Linux Certification in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.