* dhcpd * 20030607 INTRO: DHCP, or dynamic host configuration protocol, is used so that clients can obtain IP addresses automatically by querying a server (via dhcp arp). The DHCP server may give arbitrary IPs to all querying hosts or it may give specific IPs to hosts with specific hardware (MAC) addresses. This document assumes the latter, as that is how we have been using it. In theory, all DHCP clients have the same behavior; in reality, different OSes treat DHCP slightly differently. This document covers the ISC DHCP distribution (dhcpd). For more information man dhcpd and dhcpd.conf, read the docs in /usr/share/doc/dhcp/, and see: http://www.isc.org/products/DHCP/ http://www.tldp.org/HOWTO/mini/DHCP/. SETUP: The package is dhcp; install it with 'apt-get install dhcpd'. dhcpd won't start running until you explicitly tell it to by modifying /etc/init.d/dhcp, which is a good thing because you never want to have two dhcp servers on the same (physical) network. The main configuration file is /etc/dhcpd.conf (more on this later). You also need to tell dhcp what interface(s) to run on in /etc/default/dhcp. The daemon is dhcpd and can be started with '/etc/init.d/dhcp start' or '/usr/sbin/dhcpd eth0' (assuming eth0 is the correct interface). The configuration of /etc/dhcpd.conf is not very complicated, but needs to be done with some amount of care, as dhcpd will not start if the syntax of the file is not correct. More specifically, use a semicolon (';') at the end of each statement and group declarations with curly braces ('{' and '}'). Lines beginning with '#' are comments. Do not omit any information. dhcpd.conf consists of three parts: lease information, subnet declarations, and assigned leases. * lease information: Lease information includes default-lease-time, max-lease-time, and any options which will apply to all subnets. For example, guardian's dhcpd.conf file begins as follows: # dhcpd.conf default-lease-time 36000; max-lease-time 108000; option domain-name "example.com"; option domain-name-servers 192.168.0.1,192.168.0.2; * subnet declarations: A declaration for the shared-network follows the leaase information, with sub-declarations for each subnet. Options include (but need not be limited to): routers (typically first address in the subnet), broadcast-address (last address in the subnet), and subnet-mask (netmask). An excerpt of guardian's dhcpd.conf, serving dhcp to three different subnets, follows: shared-network CAMELID { # IP group 1: subnet 192.168.1.0 netmask 255.255.255.0 { option broadcast-address 192.168.1.255; option routers 192.168.1.1; option netbios-name-servers 192.168.1.1; } # IP group 2: subnet 64.209.122.0 netmask 255.255.255.0 { option broadcast-address 192.168.2.255; option routers 192.168.2.1; option netbios-name-servers 192.168.2.1; } } * assigned leases: Finally, there are assigned leases. Host can be assigned IPs "randomly" by specifying a range of available IPs. This is accomplished by adding a range line to the subnet declaration. For example, to specify that the IPs from 192.168.2.20 to 192.168.2.250 are available for dhcp clientsm, add the line: range 192.168.2.20 192.168.2.250; Alternatively/additionally, hosts can be assigned IPs/hostnames which are tied to their hardware address. There needs to be a separate host entry for each such hosts. For example, to assign the address camel.example.com to mac address 00:01:02:03:04:05: host camel { hardware ethernet 00:01:02:03:04:05; fixed-address camel.example.com; } MAINTENANCE: * logs: dhcp logs lease activity (DHCPDISCOVER, DHCPREQUEST, DHCPACK) to /var/log/daemon.log. To find out when a particular machine (IP or mac adddress) obtained a lease, 'grep DHCPACK /var/log/daemon.log | grep searchstring'. Dyanmic leases, if allowed, are recorded in /var/lib/dhcp/dhcpd.leases. If dynamic leases are not allowed, you can find unregistered machines with 'grep -B1 free /var/log/daemon.log'. In the event of multiple DHCP servers on the same subnet, there should be DHCPNAK lines in /var/log/daemon.log. * process management: dhcpd must be restarted after configurations are made. The process id of dhcpd is recorded in /var/run/dhcpd.pid (as in, 'kill `cat /var/run/dhcpd.pid` && /usr/sbin/dhcpd eth0'). dhcpd is started at boot time with '/etc/init.d/dhcp start' (or rather by running /etc/rc*.d/S*dhcp). When restarting dhcp, run 'tail -f /var/log/daemon.log' to look for errors.