Recently I had a need for a DHCP server to speed up the configuration of a server rack. I had a rack with 12 Dell R630s, some Gigamon devices, and a few other pieces of hardware. The bulk of the work needed was on the R630s, mostly issuing racadm commands over ssh (see my post on that). This is easy to do with DHCP, since you can assign all the servers in a rack an IP address, then hit all those IPs with the ssh commands. However, I was working in a lab environment where we didn’t have access to the wider network, so I had to bring my own DHCP server. So of course I decided to use a Pi!

The Setup

I’m just setting up DHCP for a small “network” within a single server rack, so I just need a simple, lightweight DHCP software. dnsmasq fit the bill. It’s lightweight and easy to configure, and included in the Raspbian repository. First, install dnsmasq

sudo apt-get install dnsmasq

Next, you’ll want to configure DHCP. This is done via dnsmasq’s conf file, which by deafult is located at /etc/dnsmasq.conf. To get up and running with DHCP, it only takes one line:


This tells the Pi to only offer DHCP over the ethernet port, assign IPs in the range of, and to retain leases for 6 hours per host. After that, cycle the dnsmasq service, and you have yourself a quick and cheap DHCP server

sudo service dnsmasq restart

Another thing I also did with this was to setup PXE booting, which can be done with dnsmasq as well. A post with that info will be coming soon…