Redirect DNS + Pi Hole

Hi all,

Ive been using the following lines to prevent users from using their own dns settings:

/ip firewall 
add action=dst-nat chain=dstnat dst-port=53 log-prefix="" protocol=tcp  to-addresses=37.235.1.174 to-ports=53
add action=dst-nat chain=dstnat dst-port=53 log-prefix="" protocol=udp to-addresses=37.235.1.174 to-ports=53

so if a user sets 8.8.8.8 it will force the use of 37.235.1.174

Now I want to use my PiHole as default DNS setting, so I set the DHCP Network as follows:
(PiHole is set to use 37.235.1.174)

/ip dhcp-server network
add address=192.168.22.0/24 dns-server=192.168.22.254 domain=KITMIKRO.LAN gateway=192.168.22.1 netmask=24

the user now gets the default DNS 192.168.22.254 and benefits from the pihole and 37.235.1.174

Unless the user sets it’s own DNS to 8.8.8.8, then they wil skip the PiHole.

I can’t seem to think of a way of redirecting through the Pi-Hole

It’s probably something easy and I am at this for to long… So how do I do this?

It seems to me that you just need to change your original rules to have to-addresses=192.168.22.254. Plus add haipin NAT, because you’ll be redirecting requests to outside address back to LAN. And finally you’ll need to exclude 192.168.22.254 from redirection.

oh man… I already tried that but had my own IP excluded… :blush: