Support wildcards in local DNS records

Share my steps:

  1. Create a folder named etc-dnsmasq.d alongside Pi-hole’s docker-compose.yml file.
  2. Inside the etc-dnsmasq.d folder, create a file named wildcards.conf with the following content:
   # wildcards.conf
   #
   # Support wildcards in local DNS records
   # address=/.mydomain.com/192.168.31.22
   address=/.yourdomain.com/your-IP-address
  1. In Pi-hole’s docker-compose.yml, make sure you have:

environment:
  # Instructs Pi-hole’s FTL service to use the custom dnsmasq.d directory
  FTLCONF_misc_etc_dnsmasq_d: 'true'

volumes:
  # Uncomment this if you want to persist custom dnsmasq config files.
  # Not needed for most new Pi-hole v6 setups. If you’re upgrading from v5
  # and have used this directory before, keep it enabled during the first
  # v6 container start to allow for a complete migration, then you can remove it.
  # Requires FTLCONF_misc_etc_dnsmasq_d: 'true'.
  - './etc-dnsmasq.d:/etc/dnsmasq.d'

4.Finally, run:
docker compose down && docker compose up -d