OPNsense
This guide was developed using OPNsense 23.7.12, but should work for others too.
!!! note There is no single way to do it right. Choose the one best fitting your needs.
Using PiHole as a global DNS server¶
This sets up PiHole as your global DNS server. Unless manually configured otherwise, all devices on your network will use PiHole as their DNS server.
- In PiHole, navigate to
Settings -> DNS
and ensure you have at least one external upstream DNS server enabled.
Do not use your OPNsense IP address as this will cause a circular dependency.
- In OPNsense navigate to
Settings -> General -> Networking
. - Under DNS Servers, enter the IPv4 address of your PiHole server, and set the gateway to your WAN interface.
- Uncheck
Allow DNS server list to the overridden by DHCP/PPP on WAN
. - Click Save.
Using PiHole as a DNS server for a single interface¶
You can set up custom DNS servers to use per local interface. For instance, you might want to use PiHole on your LAN, but not on your Guest Wifi network.
- In PiHole, navigate to
Settings -> DNS
. You should either have at least one external DNS server configured, or have your OPNsense IP address set as an external DNS server. - In OPNsense, navigate to
Services -> DHCPv4 -> [<YOUR INTERFACE>]
- Under DNS servers, remove any other IP addresses and add your PiHole server's IP address to the list.
- Click Save
- You will also need to ensure that clients connected to that interface can communicate with PiHole by adding a relevant firewall entry.