Basic DHCP Installation

The main DHCP server package for Linux is written by the Internet Software Consortium (ISC; http://www.isc.org/products/DHCP/). This server usually ships in a package called dhcp, dhcp-server, or dhcp3-server (the current version is 3.0p2), and it is a widely distributed reference DHCP server. ISC also makes available a DHCP client, dhcpcd, which ships with many Linux distributions. The client, though, doesn't have the dominant position in the Linux world that the ISC dhcpd server holds. Other DHCP clients, most notably dhclient, run on many systems. The ISC dhcpd server works with these non-ISC DHCP clients, as well as with DHCP clients on other OSs.

Typically, a DHCP server has a static IP address itself. When it comes time to declare a range of IP addresses the server should deliver, you must be careful to exclude the server's own IP address from this range.

You can install the DHCP server using your usual Linux package management tools, as described in Chapter 11, "Managing Packages." If you prefer, you can download the source code, compile it, and install the server that way. Installing the package for your distribution is likely to be simpler, though, because it includes the necessary startup scripts. The DHCP server is best run from SysV or local startup scripts.

Recent versions of the DHPC server rely on the presence of a couple of specific kernel features that you might overlook if you rebuild your kernel yourself. These options are the Packet Socket and Socket Filtering features, which are accessible from the Networking Features submenu. This submenu is accessed from the Networking Support menu (as shown in Figure 27.1 for a 2.5.66 kernel) when you configure a kernel. (These options are in the main Networking Options menu in 2.4.x kernels, which also use a different configuration tool than is shown in Figure 27.1.)

Figure 27.1: You must enable certain kernel options to run a recent DHCP server.

The DHCP server configuration file is /etc/dhcpd.conf. This file can contain comments, denoted by a leading hash mark (#). Lines that aren't comments are either parameters, which describe general configuration features; or declarations, which describe the network's computers and the IP addresses the server can deliver to those computers. The upcoming section, "Setting Network-wide Options," describes parameters in more detail. The following two sections, "Configuring Delivery of Dynamic Addresses" and "Configuring Delivery of Fixed Addresses," describe declarations in more detail. Some declarations are fairly complex and include parameters within them. These declarations indicate their multiline nature by using curly braces ({}). The opening curly brace marks the beginning of a block of parameters that make up the declaration, and the closing curly brace marks the end of this block.

Some DHCP clients (particularly some Windows systems) require responses from the DHCP server to be addressed to 255.255.255.255. Unfortunately, Linux sometimes changes such replies to have a return address corresponding to your network's broadcast address, such as 172.27.255.255 for the 172.27.0.0/16 network. If some of your clients don't seem to pick up network configurations when you use DHCP, you can change the Linux server's behavior by adding an appropriate route for the 255.255.255.255 address:

# route add -host 255.255.255.255 dev ethO

Of course, you should adjust this command if the device isn't ethO. This problem is particularly likely to occur if your DHCP server has multiple network interfaces. Some DHCP configurations add this route by default. If yours doesn't, you can modify the DHCP startup script or add the command to a local startup script, as described in Chapter 9, "Bypassing Automatic Configurations to Gain Control." You can verify whether or not this route is present by typing route -n. If the route is present, it should appear at the top of the output, as follows:

Destination Gateway Genmask Flags Metric Ref Use Iface 255.255.255.255 0.0.0.0 255.255.255.255 UH 0 0 0 ethO

0 0

Post a comment