tips, thoughts

Wildcard DNS in Pihole

If you’re running a home lab (or a development environment) – you might be running a DNS server, like bind to manage your DNS records, zones, etc, and frankly, bind does an excellent job at that. However, sometime you might find your self running a home lab with a service like Pi-Hole (to keep those pesky ads away!), and Pi-Hole is doing a pretty good job as a DNS server as well.

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 and my IP is, the record will also have the same IP: 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:

  1. Login to your pi-hole and go to /etc/dnsmasq.d/
  2. Create a new file, lets call it 02-my-wildcard-dns.conf
  3. Edit the file, and add a line like this:
  4. Save the file, and exit the editor
  5. 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 🙂

Exit mobile version