Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Network Services»How To Install DHCP Server in Ubuntu & Debian

    How To Install DHCP Server in Ubuntu & Debian

    By RahulJuly 7, 20182 Mins Read

    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
    

    DHCP DHCP Server dhcpd
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    How to Set a Custom SSH Login Banner and MOTD

    How to Install and Secure OpenSSH Server on Pop!_OS

    Setting Up SFTP User in Ubuntu 22.04

    How to Create SFTP User in Ubuntu 22.04 (No Shell Access)

    View 5 Comments

    5 Comments

    1. Nasorenga on November 24, 2019 10:32 pm

      Worked like a dream – Thanks!

      Reply
    2. Abdou karim Cissokho on February 26, 2018 1:49 pm

      Thanks. I like it

      Reply
    3. Ted on September 21, 2017 8:11 am

      Could you help me to solve the issue as below:
      [email protected]:/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.

      Reply
      • Trinh on December 28, 2018 6:39 pm

        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
    4. Virendra Pratap Singh on March 23, 2017 3:41 am

      Thanks for your step by step tutorial. I like it.

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • How to List Manually Installed Packages in Ubuntu & Debian
    • 10 Bash Tricks Every Developer Should Know
    • How to Validate Email Address in JavaScript
    • Firewalld: Common Firewall Rules and Commands
    • 12 Apk Commands in Alpine Linux Package Management
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.