rsaeon
Patron
How did you setup the redundancy between the two ? Also are they connected to the network on wifi ?
They're connected by ethernet, the redundacy/failover is handled by the router — Mikrotik routers have a tool called netwatch, which can trigger a script to run when a device becomes online or offline, I have it set to update DNS servers. This coupled with a DHCP lease time of 60 seconds keeps the devices on the network updated with whatever DNS servers are currently online.
Netwatch - RouterOS - MikroTik Documentation
help.mikrotik.com
Here are the scripts, with sensitive information redacted. They're pretty much human readable. The UP script:
C-like:
:local activedns [:toarray ""]
:local notifydns
:if ([/ping 192.168.254.1 count=1]=0) do={
:set notifydns "AdBlockerOne is offline"
} else={
:set activedns ($activedns, "192.168.254.1")
:set notifydns "AdBlockerOne is online"
}
:if ([/ping 192.168.254.2 count=1]=0) do={
:set notifydns ($notifydns."%0AAdBlockerTwo is offline")
} else={
:set activedns ($activedns, "192.168.254.2")
:set notifydns ($notifydns."%0AAdBlockerTwo is online")
}
:if ([/ping 192.168.254.3 count=1]=0) do={
:set notifydns ($notifydns."%0AAdBlockerBM3 is offline")
} else={
:set activedns ($activedns, "192.168.254.3")
:set notifydns ($notifydns."%0AAdBlockerBM3 is online")
}
:if ([/ping 192.168.254.4 count=1]=0) do={
:set notifydns ($notifydns."%0AAdBlockerBM4 is offline")
} else={
:set activedns ($activedns, "192.168.254.4")
:set notifydns ($notifydns."%0AAdBlockerBM4 is online")
}
[/ip dns set servers=$activedns]
[/tool fetch url="https://api.telegram.org/botX:X/sendMessage\?chat_id=X&disable_notification=true&text=$notifydns" keep-result=no]
The DOWN script is identical but with these additional commands:
C-like:
:if ([:len $activedns]=0) do={
:set activedns ($activedns, "1.1.1.1")
:set notifydns ($notifydns."%0APublic DNS activated")
}
[/tool fetch url="https://api.telegram.org/botY:Y/sendMessage\?chat_id=Y&text=Network configuration invalid,%0Aautomatic reset in 60 seconds." keep-result=no]
Both scripts are active across all of the adblockers. They're hardcoded for now as I refine my networking setup, the proper way to do it is probably a loop with array/variables.
AdBlockerOne and AdBlockerTwo are proxmox VM's on a host that I've turned off because of the current heatwave. BM3 and BM4 are these two adblockers on 'bare metal'.
These scripts also send telegram notifications, I have two groups/channels set up for these kind notifications. The first one has more technical information and it's primarily for myself:
The other is for family, primarily to let them know if there are issues with the wifi/internet:
The 'automatic reset' is the DHCP refresh time that'll push out whichever DNS servers are active.
Last edited: