Last active
January 8, 2025 17:26
-
-
Save jhmartin/2b7c4e5e3d71c9697ea2e117cccaf7f8 to your computer and use it in GitHub Desktop.
Mikrotik DNS failover
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:global testDomain "dnstest.local" ;# Domain to test DNS resolution | |
:global queryServer "192.168.1.29" ;# Specific DNS server to query, local AdGuard instance | |
:global successDNS "192.168.1.29" ;# DNS server if the DNS request is successful, local AdGuard instance | |
:global failureDNS "9.9.9.11" ;# DNS server if the DNS request fails, | |
:log info "Testing DNS resolution for $testDomain using $queryServer." | |
# Perform a DNS lookup using a specific server | |
:do {:resolve domain-name="dnstest.local" server=$queryServer; /ip dns set servers=$successDNS; } on-error={/ip dns set servers=$failureDNS;} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Runs every 5 minutes in my Mikrotik router. If the local proxmox instance dies it fails DNS back to a public DNS so that the local network isn't perma-broken. dnstest.local is set up as a local DNS rewrite in AdGuard.