Why dnsmasq is so Awesome!

In my last post, I walked you through the steps in setting up disk-less booting. Pretty cool that we went from booting from SD cards, to USB drives, to booting off the network! But for some reason, the TFTP server that I installed, won’t stay running as a service. Looking at the documentation and the couple of people on the Internet that use it, it’s not apparent whether I’m supposed to launch it with systemctl or xinitd. Wait, what? XINITD? WHAT IS THIS? The 80’s?!? UGH!

I was getting alarms from Nagios that my netboot clients were all down. Makes sense. I was cleaning my work area, and I MIGHT have bumped a power strip switch. When the netboot clients didn’t come back online, nagios started nagging.

So, I investigated and found that the tftp-hba didn’t reload. UGH Again? I thought that was sorted when I wrote the last post. So, I went back and looked and, sure enough, tftp-hba wasn’t running. There’s gotta be a better way. I had initially ruled out dnsmasq as my TFTP server because it’s mostly a DNS server and a DHCP server. I’m running in on my PI-HOLE server, but I don’t have the file space on that Raspberry for the TFTP server too. But why couldn’t I run it on my boot server and just turn off those services and keep TFTP on dnsmasq? Let’s give it a shot!

To install dnsmasq on your Raspberry Pi:

apt -y install dnsmasq
#don't forget to get rid of tftp-hba
apt -y remove tftp-hba

Once it finishes, we need to edit the config file /etc/dnsmasq.conf. Let’s take a look at what we’re getting into here. Let’s grep for all the lines that aren’t comments:

grep -v "#" /etc/dnsmasq.conf

Wait. What? Nothing? Everything is commented out! We just need to turn on the bit that we want. Take the “#” out of these two lines and then change the second one to point to the directory where you’ve got your boot images:

enable-tftp
tftp-root=/tftpboot

Restart:

systemctl restart dnsmasq

And you’re done. By the time I went to check to see if it was working, I got recovery notifications from nagios! Yay! dnsmasq rules!

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.