Is it possible to configure Pi-hole to resolve local DNS entries only? I'm using the Pi-hole in a lab network and I want it to act as a local-only DHCP server and DNS resolver for local system names and local DNS entries that I manually enter.
Currently it looks like the webUI does not allow you to deselect all upstream DNS providers. Basically I want to only resolve domain names with the lab.lan prefix (this is the FQDN specified in the DHCP server settings).
When Pi-hole is used as DHCP it will announce itself as DNS server via DHCP to clients. Do you plan to use some other local DNS server? How do you want to set the other one on the clients?
Some important added context. This lab network does not have internet access but the Pi-Hole host does as it is connected to both the lab LAN and a WiFi network that does have internet access for package updates and pulling new software.
I want the other lab network clients that are connecting with DHCP to use the Pi-hole as the only DNS server. I just want the pi-hole to only respond to dns requests for local hosts.
How about setting a non-existing internal IP as upstream for your Pi-hole? It will answer all local DNS records but forwards everything else to a non-existing IP.
Just make sure, your device hosting Pi-hole is not using Pi-hole itself as DNS resolver to not break its DNS resolution.
Thanks yubiuser! I've applied the following RegEx to filter the DNS requests. Probably setting the upstream DNS doesn't matter now, but I will leave it just the same.
Blacklist ^(.*\.*)
Whitelist ^(.*\.foo\.bar)
Where foo.bar is the domain of my local network.
All results going to other sites are bounced in a timely manner where as example.foo.bar is resolved normally!
I found equivalent for doing it with a dnsmasq directive.
Below returns 0.0.0.0 or :: for anything other than local:
address=/#/#
pi@ph5b:~ $ man dnsmasq
[..]
-A, --address=/<domain>[/<domain>...]/[<ipaddr>]
Specify an IP address to return for any host in the given
domains. Queries in the domains are never forwarded and
always replied to with the specified IP address which may
be IPv4 or IPv6. To give both IPv4 and IPv6 addresses for a
domain, use repeated --address flags. To include multiple
IP addresses for a single query, use --addn-hosts=<path>
instead. Note that /etc/hosts and DHCP leases override
this for individual names. A common use of this is to rediā
rect the entire doubleclick.net domain to some friendly loā
cal web server to avoid banner ads. The domain specificaā
tion works in the same was as for --server, with the addiā
tional facility that /#/ matches any domain. Thus --adā
dress=/#/1.2.3.4 will always return 1.2.3.4 for any query
not answered from /etc/hosts or DHCP and not sent to an upā
stream nameserver by a more specific --server directive. As
for --server, one or more domains with no address returns a
no-such-domain answer, so --address=/example.com/ is equivā
alent to --server=/example.com/ and returns NXDOMAIN for
example.com and all its subdomains. An address specified as
'#' translates to the NULL address of 0.0.0.0 and its IPv6
equivalent of :: so --address=/example.com/# will return
NULL addresses for example.com and its subdomains. This is
partly syntactic sugar for --address=/example.com/0.0.0.0
and --address=/example.com/:: but is also more efficient
than including both as separate configuration lines. Note
that NULL addresses normally work in the same way as localā
host, so beware that clients looking up these names are
likely to end up talking to themselves.