Skip to content

Commit d66e8f2

Browse files
authored
Avoid repeated Cloudlflare attempts when DNS over TLS is blocked (#134)
When a first resolve attempt on the fallback chain (:5553) fails, the fallback plug-in of the main chain will trigger health check. By default health checks sends a request every 0.5s as long as upstream reports unhealthy (default value). Unfortuntely the fallback plug-in's health check can't be confiugred currently. Each of these health checks will trigger a 5s resolve attempt by the fallback chains forward plug-in. And since we get a health check every 0.5s, and health checks on the fallback chain are disabled, this leads to non-stop resolve attempts, forever. On-top of that, even when the primary/DHCP provided DNS server is working, the loop plug-in will trigger a first resolve attempt on the fallback chain still! This means, even with a working primary DNS sever, the fallback chain will enter a runaway loop still! This change does several things: - Handle the loop check using a template plug-in. This avoids a loop test requests to Cloudflare. With that, and a working primary DNS server, no DNS requests will get sent to Cloudflare by default. - Handle the health check of the fallback plug-in using a template plug-in. This essentially "disables" health check on the primary chains fallback plug-in (which would be the better approach, if that were possible). - Reenable health checks in the fallback chain, to avoid repeated attempts to Cloudflare when it's not available.
1 parent 363ada0 commit d66e8f2

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

rootfs/etc/corefile

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,34 @@
1010
template ANY AAAA local.hass.io hassio {
1111
rcode NOERROR
1212
}
13+
template ANY A local.hass.io hassio {
14+
rcode NXDOMAIN
15+
}
1316
mdns
14-
forward . dns://172.0.0.11:53 dns://127.0.0.1:5553 {
17+
forward . dns://127.0.0.11 {
1518
except local.hass.io
1619
policy sequential
1720
health_check 1m
21+
max_fails 5
1822
}
23+
fallback REFUSED,SERVFAIL,NXDOMAIN . dns://127.0.0.1:5553
1924
cache
2025
}
2126

2227
.:5553 {
2328
log
2429
errors
30+
template IN NS . {
31+
rcode REFUSED
32+
}
33+
template IN HINFO . {
34+
rcode REFUSED
35+
}
2536
forward . tls://1.1.1.1 tls://1.0.0.1 {
2637
tls_servername cloudflare-dns.com
38+
max_fails 2
2739
except local.hass.io
28-
health_check 5m
40+
health_check 10m
2941
}
30-
cache
42+
cache 600
3143
}

rootfs/usr/share/tempio/corefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,18 @@
3030
class error
3131
}{{ end }}
3232
errors
33+
template IN NS . {
34+
rcode REFUSED
35+
}
36+
template IN HINFO . {
37+
rcode REFUSED
38+
}
3339
{{ if .debug }}debug{{ end }}
3440
forward . tls://1.1.1.1 tls://1.0.0.1 {
3541
tls_servername cloudflare-dns.com
36-
max_fails 0
42+
max_fails 2
3743
except local.hass.io
44+
health_check 10m
3845
}
3946
cache 600
4047
}

0 commit comments

Comments
 (0)