Networking / Beginners

DHCPD Configuration

Now that you have basically installed and enabled ISC DHCPD, you should set up your configuration file carefully, before starting to use your brand new DHCP server. The configuration file contains general information about how your DHCP server should assign IP addresses, and what information it should offer to the clients.

ddns-updates off;
ddns-update-style ad-hoc;
option domain-name "example.com";
option domain-name-servers 192.168.0.5, 192.168.0.6;
default-lease-time 600;
max-lease-time 7200;
log-facility local7;

# Our Network
subnet 192.168.0.0 netmask 255.255.255.0
{
	range 192.168.0.30 192.168.0.254;
	option routers 192.168.0.1;
	option subnet-mask 255.255.255.0;
}

The above example configuration file assigns dynamic IP addresses to hosts from subnet 192.168.0.0/24. In fact, the server assigns from 192.168.0.30 to 192.168.0.254 (leaving a small subnet of the address space for static allocation). The DHCP server also advertises the 192.168.0.1 as the default gateway for the network and also subnet mask 255.255.255.0 to the clients. In addition, there are two DNS servers and the default domain name (in this case example.com).

According to our configuration, the default lease time for each address is 600 seconds (10 minutes), if the client does not request any specific lease time. The maximum possible lease time we have specified is 7200 seconds (2 hours). You may want to modify these parameters according to your network configuration and resources.

To keep track of assigned IP addresses, DHCP server maintains a lease file at /var/ db/dhcpd/dhcpd.leases. This is where DHCP server writes down the IP addresses assigned to each client, and whether the leases are active or inactive. The file also contains additional information about each client, such as MAC address. This address is used to identify unique hosts, as well as start and end times for leases and also the binding state field. This will be useful for a system administrator to see which systems are online and have active leases (by looking at binding state field) and which hosts are not online. You can also modify this file to remove inactive leases, or easily assign a specific IP address to each client. Removing this file will lead the DHCP server to lose track of its assignment history, and all the leases will be reset.

The following sample shows a dhcpd.leases file that contains two entries, the first entry for an expired (and reserved) address and the second entry for an active (currently assigned) IP address as shown here:

# cat /var/db/dhcpd/dhcpd.leases
    lease 192.168.0.220
    {
      starts 0 2008/03/16 17:25:09;
      ends 0 2008/03/16 17:35:09;
      tstp 0 2008/03/16 17:35:09;
      binding state free;
      hardware ethernet 00:18:f3:03:f4:5b;
      uid "\001\000\030\363\003\364[";
    }
    lease 192.168.0.219
    {
      starts 0 2008/03/16 19:22:01;
      ends 0 2008/03/16 19:32:01;
      binding state active;
      next binding state free;
      hardware ethernet 00:a0:d1:3d:00:dd;
      uid "\001\000\240\321=\000\335";
      client-hostname "pixel";
    }
[Previous] [Contents] [Next]