The method we use on the Stubby installer may do what you want.
If you replace the “$(nvram get lan_ipaddr)” with the IP address of the pi-hole, all clients will get their DNS from the pi-hole even if they have specified another DNS.
Code:
iptables -t nat -D PREROUTING -i br0 -p udp --dport 53 -j DNAT --to "$(nvram get lan_ipaddr)" 2>/dev/null
iptables -t nat -D PREROUTING -i br0 -p tcp --dport 53 -j DNAT --to "$(nvram get lan_ipaddr)" 2>/dev/null
iptables -t nat -A PREROUTING -i br0 -p udp --dport 53 -j DNAT --to "$(nvram get lan_ipaddr)"
iptables -t nat -A PREROUTING -i br0 -p tcp --dport 53 -j DNAT --to "$(nvram get lan_ipaddr)"
Best practice is to place the commands in a script, e.g. mydns_rules.sh. Place a she-band in the first line e.g #!/bin/sh
Make executable, e.g chmod mydns_rules.sh 755
Call the script from nat start e.g. sh /jffs/scripts/mydns_rules.sh
You also need to add the she-bang to nat-start and make it executable. nat-start will run at boot. But we had an issue where nat-start can run concurrently under certain conditions. We had to place a lock on the file to prevent this. If you want to persue this method, let me know and I can post the lock file code.
The Network Services recommendation by
@ColinTaylor sounds easier to implement. Try that first.