DEV Community


Setting up Pi-hole to provide DHCP service

Linux Admin, Anime|| Currently working as Hosting support tech.
・2 min read

I recently setup my raspberry pi as a pi-hole server, however, before this I used to use it as a DNS and DHCP server using dnsmasq, luckily Pi-hole comes with its own fork of dnsmasq which made this process super easy.

Let's get to it.

Firstly, I use archlinux arm so you would need to consult the documentation to install pihole.

If you use Archlinux then follow the steps here
The official documentation is here

Once you have your Pi-hole and your web administration server running you can now begin setting up your DHCP and DNS server, I have used the default Pi-hole blocklists you can choose to use additional ones.

Once you complete your installation open your Web Admin interface for Pi-hole.
Go to Settings => DHCP
alt text

Once you have the DHCP server enabled pi-hole will add its custom configuration to /etc/dnsmasq.d/
Make sure you have conf-dir=/etc/dnsmasq.d/,*.conf
commented out in /etc/dnsmasq.conf

~$ ls /etc/dnsmasq.d/
01-pihole.conf  02-pihole-dhcp.conf  03-pihole-custom.conf
Enter fullscreen mode Exit fullscreen mode

Once you have your dhcp server enabled you can add additional commands by creating a file like


Make sure you restart dnsmasq using

~]$ sudo systemctl restart dnsmasq.service
Enter fullscreen mode Exit fullscreen mode


~]$ pihole restartdns
Enter fullscreen mode Exit fullscreen mode

This is how my custom file looks like, since I want to push my raspberry-pi IP's as DNS servers to my clients.

~$ cat /etc/dnsmasq.d/03-pihole-custom.conf 

Enter fullscreen mode Exit fullscreen mode

You can add static hosts using the dhcp-host option like I did above and all the things that dnsmasq supports.

This helps in resolving local domains for example, or to resolve IP addresses to hostnames.

~]$ dig +short a medusa-arch

~]$ dig +short -x
Enter fullscreen mode Exit fullscreen mode

Pi-hole basically does most of the heavy lifting using dnsmasq.

I hope this helps, I would be writing up a detailed post on how to install Pihole later.

Thank you for reading.

Discussion (4)

brandonwallace profile image

You might as well add NTP (Network Time Protocol) to the server. It will go along nicely with the other services.

afrocoder profile image
Leon Author

Hey thanks for your suggestion, just had a small follow up question, I'm sort of new to the whole sysadmin thing, do people often use a NTP server to perform some task?

brandonwallace profile image

An NTP server is used to provide accurate time to all the devices on the network. It is very easy to set up. You can use the ntp or chrony package. There are public NTP server available on the internet just like public DNS servers. Use the NTP servers closest to you.

Thread Thread
afrocoder profile image
Leon Author

Thanks I'll set it up with this.