The author developed a failover mechanism for DNS over HTTPS (DoH) on MikroTik routers running RouterOS. The system addresses the limitation where RouterOS supports only one active DoH upstream, preventing automatic switching during outages.

The project was initiated after a branch network experienced intermittent connectivity issues. DNS queries returned valid IP addresses, such as 8.6.112.0 and 8.47.69.0, but these routes were unreachable from the specific network, causing timeouts for services like Tailwind CSS.

The solution involves a monitoring script that performs HTTPS requests to a DNS-JSON API rather than relying on standard DNS resolution. It validates responses against a list of control domains to ensure the returned IP addresses are functional and not just valid-looking stubs.

The monitoring script implements a hysteresis mechanism with failure and recovery thresholds. It requires two consecutive failed or successful checks before switching between endpoints, preventing frequent toggling due to transient network instability.

The configuration includes static DNS entries for DoH endpoints to prevent circular dependencies. It also enforces certificate verification, requiring the correct root CA certificates to be imported into the RouterOS trust store to avoid total DNS failure.