I had a working setup of my own DNS names with Pihole for the longest time. Since I have got multiple PiHole instances that I deploy (one at home, one at my parent’s house, another one in the cloud), I needed some automated way to define my own DNS entries - and worked out quite good - until now. Lately, PiHole got an upgrade to v6, which broke my setup. So this is a write-up what I have done now.
Files to be considered
I essentially have two important files:
a-names.txt
- A set of A names. Each line (that is not a comment or empty) looks something like this:
In v5, Pihole was actually able to directly process such a file if it was placed in192.198.0.42 my-server.tech-tales.blog
/etc/pihole/custom.list
.cname-names.txt
- Initially, this was just a set ofCNAME
s; but it grew and now it is a combination ofCNAME
s,TXT
s and some other stuff. Until now, this file was placed in/etc/dnsmanq.d
and hence directly processed bydnsmasq
- the program that PiHole builds on. Some entries look as follows:# Add a CNAME from server-b to server-a, so you need an IP associated with server-a cname=server-b.tech-tales.blog,server-a.tech-tales.blog # Add a TXT record txt-record=tech-tales.blog,"Hello world!"
The problem
Pihole now has got a configuration file. Which essentially broke my setup for two reasons:
- Parsing files from
/etc/dnsmasq.d
by default is turned off in the configuration file. - The A names are not in the
custom.list
file any more, but written into the configuration file.
Pihole was clever enough to pull both the custom.list
contents and the contents of my cnames-names.txt
file into the configuration when upgrading, so my setup did not break immediately.
Still, just updating the configuration file was a way I did not want to go - particularly due to the different non-CNAME records in my dnsmasq file, which seem to not work with PiHole’s new approach. So I had to work around that.
My solution
Make Pihole parsing the dnsmasq
file was simple: Pihole now has the configuration option etc_dnsmasq_d
. Set that to true
(the default is false
) and be happy.
The custom.list
file was a bit more tricky. Pihole polled all the names into it’s configuration file and seemed to now ignore this file, so I had to work around it. My solution was the following:
- In
cname-names.txt
, I now have a new line on top that statesaddn-hosts=/etc/pihole/a-names.list
. - The
a-names.txt
file is now deployed to/etc/pihole/a-names.list
.
Note that I did not directly push the file to /etc/dnsmasq.d
. The reason for that is that dnsmasq seems to not be able to work with this file directly, as it then would require some other format. But with this workaround, everything is fine!
Restarting Pihole
Previously, running pihole restartdns
was enough to apply the changes; this is not the case any more. So I changed my restart command to systemctl restart pihole-FTL
.
Cleaning up
As a last step, I had to slim down Pihole’s configuration, to avoid later confusion. So I changed two things:
dns.hosts
- This was an array with all my A names; it is not any more.dns.cnameRecords
- The same with my CNAMEs.
Summing up
Major version changes break things…
Thankfully, I waited until I had the time to actually react on these changes. After figuring out the problems, upgrading the other hosts was quite straight-forward.