# Setting up a DHCP server

One free software DHCP server is ISC `dhcpd`. For &debian-gnu;, the `isc-dhcp-server` package is recommended. Here is a sample configuration file for it (see `/etc/dhcp/dhcpd.conf`):

    option domain-name "example.com";
    option domain-name-servers ns1.example.com;
    option subnet-mask 255.255.255.0;
    default-lease-time 600;
    max-lease-time 7200;
    server-name "servername";

    subnet 192.168.1.0 netmask 255.255.255.0 {
      range 192.168.1.200 192.168.1.253;
      option routers 192.168.1.1;
    }

    host clientname {
      filename "/tftpboot.img";
      server-name "servername";
      next-server servername;
      hardware ethernet 01:23:45:67:89:AB;
      fixed-address 192.168.1.90;
    }

In this example, there is one server `servername` which performs all of the work of DHCP server, TFTP server, and network gateway. You will almost certainly need to change the domain-name options, as well as the server name and client hardware address. The `filename` option should be the name of the file which will be retrieved via TFTP.

After you have edited the `dhcpd` configuration file, restart it with `/etc/init.d/isc-dhcp-server restart`.

## Enabling PXE Booting in the DHCP configuration

Here is another example for a `dhcp.conf` using the Pre-boot Execution Environment (PXE) method of TFTP.

    option domain-name "example.com";

    default-lease-time 600;
    max-lease-time 7200;

    allow booting;
    allow bootp;

    # The next paragraph needs to be modified to fit your case
    subnet 192.168.1.0 netmask 255.255.255.0 {
      range 192.168.1.200 192.168.1.253;
      option broadcast-address 192.168.1.255;
    # the gateway address which can be different
    # (access to the internet for instance)
      option routers 192.168.1.1;
    # indicate the dns you want to use
      option domain-name-servers 192.168.1.3;
    }

    group {
      next-server 192.168.1.3;
      host tftpclient {
    # tftp client hardware address
      hardware ethernet  00:10:DC:27:6C:15;
      filename "pxelinux.0";
     }
    }

Note that for PXE booting, the client filename `pxelinux.0` is a boot loader, not a kernel image (see tftp-images below).

If your machine uses UEFI to boot, you will have to specify a boot loader appropriate for UEFI machines, for example

    group {
      next-server 192.168.1.3;
      host tftpclient {
    # tftp client hardware address
      hardware ethernet  00:10:DC:27:6C:15;
      filename "debian-installer/amd64/bootnetx64.efi";
     }
    }