Community discussions

MikroTik App
 
MrWillGFC
just joined
Topic Author
Posts: 13
Joined: Sat Aug 29, 2020 5:55 pm

Failover DNS Server when my Pi Hole goes down

Sun Feb 06, 2022 11:16 pm

Posted this on the Scripting Forum but it wasn't approved so I'm guessing because it wasn't strictly Scripting related it should go here instead.

I set up a Pi Hole this week as my network DNS resolver. I've also set up some NAT rules to forward anything trying to exit the network on port 53 to be redirected to the router itself (which in turn is set to use the Pi Hole as its DNS server)

The last part was to script a failover in case my Pi Hole (or the Proxmox server that it runs within) goes down (monitored by netwatch)

This is all working and tested, but I'm having problems with one thing.

Part of the script to enable to nat rules that direct the traffic on port 53 to 1.1.1.1 is supposed to send me an email to let me know that the Pi Hole is down
ip firewall nat enable [find comment="Failover DNS"]

:delay 10s

tool e-mail send to="******@gmail.com" subject="Pi Hole Down" \
body=" Pi Hole Down at $[/system clock get time]"
But despite the fact that a manual ping using tool >ping on the router can resolve the smtp.gmail.com address, the tool >email always fails while the Pi Hole is down.
Emails work fine when the Pi Hole is up (or when the DNS server of the router is set to 1.1.1.1 directly and not just through a dstnat rule)

Any ideas why the tool > email isn't following the NAT rules or how I can make it behave?

Manual emails don't work either if I use the email command in the terminal so maybe the Scripting forum isn't the right place for this?

I have put in a workaround of actually changing the DNS setting on the router too 1.1.1.1 which is working, but I'm still interested to know what I'm doing wrong and why the router is still trying to use the Pi Hole when everything else is redirecting to 1.1.1.1

Also, I exported the config with "hide sensitive" but it still spat out all my mac addresses and open ports, is that intended?

Also also, please don't judge my Vlan setups. They work but I don't thin they're the most elegant creation ever
You do not have the required permissions to view the files attached to this post.