But – sometimes you need something a bit more complicated, like a wildcard DNS.
Wildcard DNS, for those who don’t know – is a trick to allow any kind of host name – to have a specific same IP as it’s DNS name. For example, if my domain is hetz.com and my IP is 1.2.3.4, the record lab.hetz.com will also have the same IP: 1.2.3.4. Where do you need it? in many places where you’ll run tons of containers: Kubernetes, OpenShift, Rancher, etc..
The issue with Pi-Hole is that it’s possible to add a Wildcard DNS, but not through the GUI, only through the shell.
So, how do we add Wildcard DNS to Pi-Hole on our homelab? follow these steps:
- Login to your pi-hole and go to /etc/dnsmasq.d/
- Create a new file, lets call it 02-my-wildcard-dns.conf
- Edit the file, and add a line like this:
address=/mydomain.lab/192.168.1.20
- Save the file, and exit the editor
- Run the command: service pihole-FTL restart
That’s it! You can check using commands like nslookup (on Windows) or dig (FreeBSD, Linux, Mac) that it works. For example: dig -short mydomain.lab @pi-hole-IP (replace the pi-hole-IP with your pi-hole IP).
Enjoy 🙂