In any event, how do I force applications with hard-coded DNS addresses to go through specific DNS servers (in my case: pi-hole no. 1 & pi-hole no. 2, if the first one is down) without firewall rules? And if I need firewall rules for that, how do I set FW rules to redirect DNS queries to one of the two DNS servers (whichever is up)?Thank you again!
Hi all,I need your help with configuring a failover mechanism (firewall rules) in case my Pi-hole goes down.
sudo nano /usr/local/etc/dnsmasq.conf.d/0-subnet-strict.conf
add-subnet=32add-macstrict-order
under Services --> DHCPv4 --> DNS servers, there are only two fields to specify 2 DNS servers (not three).
Probably it was not clear from my post, so it is worth noting that the DHCP server runs on my OPNsense (an not on my pi-hole).
In any event, how do I force applications with hard-coded DNS addresses to go through specific DNS servers (in my case: pi-hole no. 1 & pi-hole no. 2, if the first one is down) without firewall rules? And if I need firewall rules for that, how do I set FW rules to redirect DNS queries to one of the two DNS servers (whichever is up)?
You can try this: https://labzilla.io/blog/force-dns-pihole (it is actually mostly NAT)Also if you run more than 1 pihole consider gravity sync or other syncing utilities.
Remember that certain clients (*cough Windows *cough) will only consider a DNS server unavailable when it stops pinging. A dual DNS server is more for updating one at a time without an outage. A load balancer will give you high availability for partial failures.
There are good arguments for having separate servers for different services. The built-in DHCP/DNS/Squid in OPNsense are there to provide a drop-in replacement for ISP routers IMHO. There are many posts in this forum about on-board WiFi from that same perspective.Ars did a good article about this recently https://arstechnica.com/information-technology/2024/02/doing-dns-and-dhcp-for-your-lan-the-old-way-the-way-that-works/ I reckon the pi-hole makes a better DHCP than OPNsense but a dedicated server (or container) trumps both. It is also a good learning experience.
Here is a solution... see if it works for you.
DNS is not a security enforcement technique. It exists because wetware cannot remember IP addresses Firewall (policy) sits in level-3 of your network - that means that everything is by IP address. If you want to restrict higher up in the stack, you need a proxy (like Squid for web access)As a service to make life easier for your users, it's great. A dedicated user (e.g. a teenager) can by-pass your restrictions by SOCKS, DOH, VPN, etc. Since malware isn't (yet) at that level, you can reduce its impact with a filtering DNS server (like pi-hole).Concentrate on making DNS fast (local) and available (resilience). DNS on your firewall is for your firewall to use. Give your users the servers they need by DHCP and allow those servers to resolve.