If you’re using Pi-hole as your DNS resolver and need to point multiple subdomains of the same domain to a single IP, you can do it with a wildcard DNS entry. This is useful in a development environment where you want *.local.dev to resolve to a specific machine on your network.

Since Pi-hole uses dnsmasq under the hood, you can add custom DNS rules directly through its configuration files.

Creating the wildcard entry

Go to the /etc/dnsmasq.d folder and create a new file called 02-my-wildcard-dns.conf:

Using Pi-hole with Docker?

If you’re running Pi-hole through Docker, the folder is etc-dnsmasq.d (mapped as a volume).

02-my-wildcard-dns.conf
address=/local.dev/192.168.1.20

Replace 192.168.1.20 with the IP of the machine you want the domain to resolve to.

This tells dnsmasq to resolve local.dev and all its subdomains (e.g., myproject.local.dev, api.local.dev) to the specified IP address.

Multiple domains

You can add multiple entries in the same file if you need to resolve different domains:

02-my-wildcard-dns.conf
address=/local.dev/192.168.1.20
address=/home.lab/192.168.1.30

Applying the changes

Save the file and restart the DNS service:

pihole restartdns

Or you can do it through the graphical interface at Settings > Restart DNS resolver.

Verifying it works

You can verify the configuration is working by using nslookup or dig:

nslookup myproject.local.dev
Server:		192.168.1.1
Address:	192.168.1.1#53
 
Name:	myproject.local.dev
Address: 192.168.1.20

After that, all subdomains (e.g., myproject.local.dev) and the domain itself (local.dev) will resolve to the specified IP.