I recently decided to dust off one of my Raspberry Pi’s and put it into service as a DNS and DHCP server. Initially I was just going to setup dnsmasq myself, but I came across a cool project called pi-hole. Pi-hole installs dnsmasq and puts a nice web front end on everything. It also functions as a whole network ad-blocker which is nice bonus.
One problem I wanted to solve was how do I get DNS resolution of devices that I have setup with static IPs? I could hand edit /etc/hosts on the pi-hole… But my preference is to use the pi-hole UI and create DHCP reservations for those hosts. I wrote a tool to update /etc/hosts with the DHCP reservations from pi-hole’s dnsmasq. So now I have resolution that includes hosts that don’t have active leases with the server.
Check out my github repo for full details and installation instructions: https://github.com/npwolf/pi-hole-dhcp-to-hosts