Installing DHCP Server to Raspberry Pi 3

In this blog, I am going to show you how to set up a DHCP on Raspberry Pi 3 and assign IP addresses to the devices in our network.

Let’s make sure our Pi is up-to-date:

sudo apt-get update && sudo apt-get upgrade

We will use isc-dhcp-server:

sudo apt-get install isc-dhcp-server -y

It is OK to get errors as we did not set our DHCP Server.

To make our setting we will edit “dhcpd.conf”

sudo vi /etc/dhcp/dhcpd.conf

Set it up like the network we want, I want my network to:

  • use 10.0.0.0/24 IP Addresses,
  • route it over 10.0.0.1,
  • have 255.255.255.0 netmask,
  • have a range of 10.0.0.10-10.0.0.30 IP Addresses.
subnet 10.0.0.0 netmask 255.255.255.0 {
 range 10.0.0.10 10.0.0.30;
 option routers 10.0.0.1;
}

Save it:

sudo dhcpd -cf /etc/dhcp/dhcpd.conf

Set the interface’s IP Address with ifconfig and restart the service:

sudo ifconfig eth0 10.0.0.1
sudo service isc-dhcp-server restart

After we connect it to a hub or a switch with devices connected to it, we will see the devices getting the IP Addresses.

Restart the service if it doesn’t.

Leave a Reply

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