I want to create a service health check script that monitors my DoHs. I couldn’t get it done with my poor scripting skill.
I surely appreciate any help. Original script
:log info "DNS HealthCheck Started"
:local currentDNS [/ip dns get use-doh-server]
:local DoHMain "https://record.domain-A.tld/dns-query"
:local DoHSec "https://record.domain-B.tld/dns-query"
:local TDomain "www.domain.tld"
:if ($currentDNS =$DoHMain) do={
:do {
:resolve $TDomain
} on-error={
/ip dns set use-doh-server=$DoHSec
:log info message="DOH Server=$DoHSec"
}
}
:delay 180s
else={
:do {
/ip dns set use-doh-server=$DoHMain
:resolve $TDomain
:log info message="DOH Server=$DoHMain""
} on-error={
/ip dns set use-doh-server=$DoHSec
:log info message="DOH Server=$DoHSec"
}
}
:log info "DNS HealthCheck Done"
I tried the final script, but it didn’t work even with the default request record of www.example.com.
How should I encode the requested record? I have tried several online Base64url encoders, none of which worked with the error status “400 bad requests”.
.
The AAABAAABAAAAAAAAA3d3dwdleGFtcGxlA2NvbQAAAQAB is base64 encoded DNS query for A record of > www.example.com
\00\00\01\00\00\01\00\00\00\00\00\00\03www\07example\03com\00\00\01\00\01
(you use parameters from $str2base64 instead of the appropriate for $base64dec, “url” and “nopad” must not be used on DNS query)
the (really are not [ and ] but a special character that represent unprintable characters) are presents
because NULL 0x00, SOH 0x01 and other special characters really are hex values of the DNS query following RFC 8484.
For compose your own string, replace the value in this:
\00\00\01\00\00\01\00\00\00\00\00\00
length of the next part on hex \03
next part “www”
length of the next part on hex \07
next part “example”
length of the next part on hex \03
next part “com”
\00\00\01\00\01
for example for smtp.mypreferreddonmain.cloud = 4 + 18 (0x12) + 5
Hi @own3r1138 , could you please post your working script? This is exactly what I am trying to set up now as well and am failing at the check if doh works script part.
I am not using the certificate verification in my case
Thanks!