Pihole and site to site pivpn Wireguard VPN

Hi everyone,

I have currently 2 Rpi that are running Pihole and PiVPN on 2 different geographical sites.
Boths are connected with Wireguard in site to site mode and both sites have different ip ranges and dedicated local domains.
Everything works, but from any computers of the sites the DNS resolution is only working with hostnames FQDN.
I would like to use shortname hostnames, I have tested by adding DNS Suffix list on the clients NIC and it works.
Now how can I set this DNS Suffix list in the DHCP of the Piholes?

Many thanks in advance!

In a cross-site scenario as yours, it may be preferable to use FQDNs to access hosts by name. Using plain, short names may produce unexpected resolution results if two hosts on each of your sites would use the same name (which would be true for pi.hole, e.g.).

If you still would want to supply multiple search domains, you could create a custom dnsmasq configuration file (e.g. /etc/dnsmasq.d/42-search-domains.conf) containing a line like:

dhcp-option=option:domain-search,site1,site2

Substitute each of site1 and site2 with your respective search suffix as required; refer to dnsmasq documentation for additonal details.

Then run a dnsmasq syntax check:

pihole-FTL dnsmasq-test

If ok, restart Pi-hole:

pihole restartdns

Note however that there is no guarantee this would work:
Not every DHCP client may request and honor that option.
You may take care of the former by changing above line to:

dhcp-option-force=option:domain-search,site1,site2

This will make Pi-hole's DHCP server provide that option to a DHCP client, regardless whether it was requested or not. It won't do anything if a client does not digest it at all.
I'd recommend monitoring each of your clients for the desired behaviour.

1 Like

Thank you very much, it works as expected :wink:
About same hostname, I agree but you should mitigate the issue by putting the local domain at first place in the list (so local domains will be "crossed" depending of their location)
I have tried and correct devices are replying, I will see in the future if it need more tuning.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.