DHCP daemon on Raspberry Pi
DHCP stands for “Dynamic Host Configuration Protocol”. The DHCP daemon is the process which assigns IP addresses to computers when they join a network, and gives them other important information about the network.
Here is how to set up and configure dhcpd on Raspbian Stretch:
- Install: Install the package:
sudo apt-get install isc-dhcp-server
When you install this package it is configured to run automatically at boot time. - Configure: There are two files to edit:
-
- Move the existing file /etc/dhcp/dhcpd.conf out of the way so you can replace it with your own:
sudo mv /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.ORIG
(You should keep it because it contains good documentation and examples).
Then create and edit a new file /etc/dhcp/dhcpd.conf containing:1# # Configuration file for DHCP server on Rasberry Pi # ddns-update-style none; option domain-name "wifipi.local"; option domain-name-servers 8.8.8.8; default-lease-time 3600; max-lease-time 86400; authoritative; log-facility local7; # Configure service for local network 192.168.47.0 (the wireless AP) subnet 192.168.47.0 netmask 255.255.255.0 { range 192.168.47.50 192.168.47.250; option routers 192.168.47.1; } ##
- Also edit the file /etc/default/isc-dhcp-server to add the line:
INTERFACESv4="wlan0"
Change the name of the interface if you are using something else. (My setup actually runs dhcpd on wlan1.)
- Move the existing file /etc/dhcp/dhcpd.conf out of the way so you can replace it with your own:
-
- Restart: The service should already be enabled, and is probably already running. Restart it with
sudo systemctl restart isc-dhcp-server
The service should already be configured to start automatically. If it does not, use the `systemctl` command to enable the service.
References
- “How to: Make a Raspberry Pi Powered Wifi Repeater” by Dryfire117, https://pastebin.com/A4jUp2Nq ↩
I did all the instructions you mentioned, but it prints this error in terminal when I execute
“sudo systemctl restart isc-dhcp-server”
the error is the following.
job for isc-dhcp-server.service failed because the control process exited with error code.
Yep this configuration is giving error.
Looking over this page again I see a potential problem, in that I run the DHCP daemon on wlan1 (my pi has two wifi interfaces). If you only have one wifi interface then you should change to “wlan0” . I’ve changed these instructions to use wlan0 and added a comment about using a different interface.
Also, even if there is a problem with the restart, the service might still start up after a reboot. It should be configured automatically to start up at boot time.
do you know if this dhcp server supports multiple subnets and multiple listening interfaces?
I’m afraid I do not know if this particular dhcp server supports those.
My dhcp server doesn’t start again after reboot. Tried everything. Someone please help.