Pin Me

Creating a Linux DHCP Server

written by: Kristen Grubb•edited by: Michael Dougherty•updated: 10/29/2009

A DHCP (Dynamic Host Configuration Protocol) server handles the assignment of IP addresses, subnet masks and broadcast addresses to clients within the network which do not have static IP addresses. This article explains how to set up your own DHCP server on Linux.

  • slide 1 of 2

    Creating the Server

    The distribution used in this article is Ubuntu but the steps for creating a DHCP server are the same for any version of Linux. The DHCP server package is called dhcp3-server. The command to install the software on Ubuntu is "sudo apt-get install dhcp3-server." Once the server software is installed, the configuration file will be found at /etc/dhcp3/dhcp.conf for Debian and Ubuntu servers and /etc/dhcp.conf for Red Hat based servers. A backup of this file should be made before any changes are made.

    The first line of this file must be:

    ddn-update-style interim;

    This line tells the dhcp server to update the DNS server if the IP address if the IP address of one of the servers in your network has changed.

    The dhcp.conf file is well commented, so setting up the file should be self explanatory. The most important thing to remember is that there must be a separate subnet section for each network interface on your server. In each subnet section you will provide the following information:

    • The range of IP addresses the DHCP server is allowed to assign
    • The address of the DNS server to use
    • The default lease time and the max lease time
    • The broadcast address to be used
    • The gateway address that should be assigned to requesting clients
    • Whether IP-forwarding will be used
    • The address of the NTP server (if necessary)
    • The address of the Netbios name server (if necessary)

    The default lease time and the max lease time specify the amount of time, in seconds, that the client will be allowed to keep the IP address. The IP-forwarding option is used to specify whether you want the DHCP requests from on network interface to be forwarded to a different network interface. The NTP-server option provides the address of the Network Time Protocol server that is to be used. The Netbios name server option is used if you need to specify a WINS server for your windows clients.

    Once you have created the dhcp.conf file for your network, you will start the server with the command "sudo /etc/init.d/dhcp3-server restart." You can ensure that the server is running correctly by checking for the process with the ps aux command or by running the netstat -uap command. Errors will be logged in the /var/log/syslog file.

  • slide 2 of 2


    Installing the software and editing the configuration file is all that is involved in setting up a Linux DHCP server. Once you have checked to see that there is no errors when the server starts, you can point all of the computers to the IP address of your brand new server for all of their DHCP requests.