DHCP server in Debian 9

These are the steps that I followed, in order to make a DHCP server in Debian 9 Stretch.

First of all we need to assign an IP address on our main ethernet interface. For this guide, I will use interface enp0s2. So we have to edit the file /etc/network/interfaces and add the following :

auto enp2s0
allow-hotplug enp2s0
iface enp2s0 inet static
dns-search mydomain.com

Then we need to download our dhcp package.

sudo apt install isc-dhcp-server

After the package installation we backup the default configuration file and we create a new one for our setup

sudo mv /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.backup
sudo nano /etc/dhcp/dhcpd.conf

Just add the following on /etc/dhcp/dhcpd.conf

option domain-name "mydomain.com";
option domain-name-servers;
default-lease-time 3600;
max-lease-time 7200;
subnet netmask {
option subnet-mask;
option broadcast-address;
option routers;

For ip reservations you can add the following on /etc/dhcp/dhcpd.conf

host station1 {
option host-name "station1.mydomain.local";
hardware ethernet 00:11:22:33:44:AA;

Last, we have to assing on which interface the DHCP server will listen. We edit the file /etc/default/isc-dhcp-server and we set the interfaces seperated by comma


Enable and start the DHCP service

sudo systemctl enable isc-dhcp-server.service
sudo systemctl start isc-dhcp-server.service

At anytime if you want to see the leases of the DHCP server, simply execute the following command

sudo dhcp-lease-list

Good luck

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)

Leave a Reply

Your email address will not be published. Required fields are marked *