This configuration is doable at the dnsmasq level, which Pi-hole utilizes as its internal DNS.

  1. Enable Custom Configuration
    Ensure your Pi-hole environment is permitted to process custom configuration files in the web panel.

  2. Set Environment Variables
    Set the FTLCONF_misc_etc_dnsmasq_d environment variable to true.
    For a Docker Compose setup, simply add:

environment:
  ...
  FTLCONF_misc_etc_dnsmasq_d: true
  1. Configure volumes
    Map your custom configuration into /etc/dnsmasq.d. Using a named volume is the recommended approach:
volumes:
  ...
  - 'pihole_etc_dnsmasqd:/etc/dnsmasq.d'

You can also use a bind mount to map a specific host directory instead of a named volume.

  1. Create the wildcard.conf file
    Inside the mapped directory, create a file named wildcard.conf and use the following syntax:

    address=/.domain.local/xxx.xxx.xxx.xxx
    

    Example:

    address=/.homelab.local/192.168.1.5
    
  2. Restart the container

  3. Verify the resolution using dig:

    dig +short subdomain.domain.local @server_ip
    

    Example:

    dig +short test.homelab.local @192.168.1.1