How To Install DHCP Server In Ubuntu & Debian. DHCP (Dynamic Host Configuration Protocol) is a network protocol used for assigning the IP address to network clients dynamically from predefined IP pool. It is useful for LAN network, but not generally used for production servers. Read more about DHCP here.

Advertisement

Install DHCP Server

This tutorial will help you to install DHCP Server on Ubuntu, Debian, and LinuxMint systems.

Step 1 – Install DHCP Server

Debian based systems provides package ‘isc-dhcp-server’ for installing DHCP server. Open a terminal on your system and install DHCP using the following command.

sudo apt install isc-dhcp-server

Step 2: Configure DHCP Server

Follow the below steps to configure your DHCP server.

2.1 – Setup Interfaces to Listen

First of all, edit /etc/default/isc-dhcp-server to specify the interface to listen by dhcpd. You can specify multiple interfaces seprate by space.


INTERFACES="eth0 eth1"

2.2 – Global Configuration

First of all, edit DHCP configuration file /etc/dhcp/dhcpd.conf and set the global settings for domain-name and domain-name-servers to be used for local clients.


option domain-name "local.tecadmin.net";
option domain-name-servers ns1.tecadmin.net, ns2.tecadmin.net;

Furthermore, if you want this DHCP server as an official DHCP server for the local network, uncomment the authoritative directive


authoritative;

2.3 – IP Subnet Declaration

Let’s set up your first subnet for your local network. You can create multiple subnets with different-2 settings, as per your requirements in /etc/dhcp/dhcpd.conf

subnet 192.168.1.0 netmask 255.255.255.0 {
   range  192.168.1.10   192.168.1.100;
   option routers                  192.168.1.1;
   option subnet-mask              255.255.255.0;
   option domain-search            "local.tecadmin.net";
   option domain-name-servers      n1.local.tecadmin.net;
   option time-offset              -18000; 
   option broadcast-address 192.168.1.255;
   default-lease-time 600;
   max-lease-time 7200;
}

2.4 – Setup Host with Fixed IP

In addition, you can also specify the fixed IPs for some systems based on MAC address. For example system with MAC address “00:11:1A:2B:3C:AB”, will get ip 192.168.1.99.

host station1 {
   option host-name "station1.local.tecadmin.net";
   hardware ethernet 00:11:1A:2B:3C:AB;
   fixed-address 192.168.1.99;
}

Step 3: Start/Stop DHCP Service

Finally, you have successfully installed and configured DHCP server. Use the following command to start/stop and restart service.

sudo systemctl start isc-dhcp-server.service
sudo systemctl stop isc-dhcp-server.service
sudo systemctl restart isc-dhcp-server.service
Share.

5 Comments

  1. Could you help me to solve the issue as below:
    root@tedkuoszufw:/home/tedkuoszufw# sudo systemctl status isc-dhcp-server.service
    ● isc-dhcp-server.service – ISC DHCP IPv4 server
    Loaded: loaded (/lib/systemd/system/isc-dhcp-server.service; enabled; vendor preset: enabled)
    Active: failed (Result: exit-code) since Thu 2017-09-21 16:03:37 CST; 9s ago
    Docs: man:dhcpd(8)
    Process: 4532 ExecStart=/bin/sh -ec CONFIG_FILE=/etc/dhcp/dhcpd.conf; if [ -f /etc/ltsp/dhcpd.conf ]; the
    Main PID: 4532 (code=exited, status=1/FAILURE)

    9月 21 16:03:37 tedkuoszufw sh[4532]: Not configured to listen on any interfaces!
    9月 21 16:03:37 tedkuoszufw sh[4532]: If you think you have received this message due to a bug rather
    9月 21 16:03:37 tedkuoszufw sh[4532]: than a configuration issue please read the section on submitting
    9月 21 16:03:37 tedkuoszufw sh[4532]: bugs on either our web page at http://www.isc.org or in the README file
    9月 21 16:03:37 tedkuoszufw sh[4532]: before submitting a bug. These pages explain the proper
    9月 21 16:03:37 tedkuoszufw sh[4532]: process and the information we find helpful for debugging..
    9月 21 16:03:37 tedkuoszufw sh[4532]: exiting.
    9月 21 16:03:37 tedkuoszufw systemd[1]: isc-dhcp-server.service: Main process exited, code=exited, status=1/FAILURE
    9月 21 16:03:37 tedkuoszufw systemd[1]: isc-dhcp-server.service: Unit entered failed state.
    9月 21 16:03:37 tedkuoszufw systemd[1]: isc-dhcp-server.service: Failed with result ‘exit-code’.

    Best regards,
    Ted.

    • Hi Ted,

      I think you are using Debian 9.
      I have same problem but solved it.
      The reason is isc-dhcp-service can not start at startup by command systemctl enable isc-dhcp-server.service.
      You must start by this command /lib/systemd/systemd-sysv-install enable isc-dhcp-server and then restart server. Everything will work well.

      Good luck.

      Trinh

Reply To Ted Cancel Reply

Exit mobile version