Wiedza Perfect DNS Setup: Ubiquiti UCG Fiber + dnsmasq (strict-order custom conf) + Pi-hole + QNAP

Silas Mariusz

rm -rf /
Help us, GOD!
5 Kwiecień 2008
9 998
39
3 727
153
40
Nowy Sącz
forum.qnap.net.pl
QNAP
TS-x77
Ethernet
1 GbE
The biggest problem with Ubiquiti and Pi-hole is that if the Pi-hole server goes down, the DNS server in Ubiquiti will stop functioning properly. If you want to set up failover, in practice this is impossible. Adding a second DNS server in Ubiquiti will result in Ubiquiti using them alternately, which makes Pi-hole meaningless. The only solution is to set "strict-order" in the dnsmasq config, with DNS1 in Ubiquiti set to Pi-hole, and DNS2 set, for example, to the public 8.8.8.8. Below is a patch that enables this behavior.

1. Install FAN control for UCG Fiber which will add to auto start with router restart
Bash:
curl -sSL https://raw.githubusercontent.com/iceteaSA/ucg-max-fan-control/main/install.sh | sudo bash
( Source: GitHub - iceteaSA/ucg-max-fan-control: UXG-Max/Fibre Dynamic Fan Control )

2. Once installed go to:
Bash:
cd /data/fan-control/

3. Create 05-custom_apply.conf file with commands:
Bash:
apt install mc
medit 05-custom_apply.conf

4. Paste code bellow:
INI:
strict-order            # dnsmasq will send queries to any of the upstream servers
no-negcache             # Disable negative caching
min-cache-ttl=1800      # min 30 min
max-cache-ttl=86400     # 1 day maximum
cache-size=10240

# reload
# sudo pkill -USR1 dnsmasq && tail -50 /var/log/daemon.log |grep dnsmasq

5. Edit fan-control.sh:
Bash:
mcedit fan-control.sh

6. Bellow bash header enter:
Bash:
[ -f "/etc/dnsmasq.d/05-custom_apply.conf" ] || cp -af 05-custom_apply.conf /etc/dnsmasq.d/05-custom_apply.conf

7. From now each reboot your dnsmasq custom conf will apply.