Skip to content
Mementropy
Lab NotesHomelab notebookField note

Three CoreDNS ordering problems with home.arpa names

Only one hosts block is allowed, musl lookups failed with SERVFAIL, and the template plugin runs before hosts.

By Ryan Hammang

I wanted to replace the per-pod hostAliases copies with one DNS answer for my home.arpa names, using K3s’s coredns-custom ConfigMap.

It took three tries.

One hosts block per server block. K3s’s CoreDNS already has a hosts block in its main server block. My first attempt added another one through an .override file. CoreDNS crash-looped:

plugin/hosts: this plugin can only be used once per Server Block

I moved my records into separate home.arpa:53 and tailnet server blocks using a .server file.

SERVFAIL broke Alpine. Then the Alpine-based runner pod couldn’t install packages. apk add failed with a transient DNS error. musl, Alpine’s C library, tries each search domain, so it asked for dl-cdn.alpinelinux.org.home.arpa. My hosts block didn’t know that name and had nothing after it, so CoreDNS answered SERVFAIL. musl gives up on any SERVFAIL. I added fallthrough and a template that returns NXDOMAIN.

template runs before hosts. Then pods without their old hostAliases got NXDOMAIN even for names I’d listed. CoreDNS runs plugins in a compiled order, and template comes before hosts. My NXDOMAIN template was answering everything first.

The fix was the file plugin, with a real zone file and wildcard records for each cluster. Listed names return their address. AAAA returns no data rather than NXDOMAIN. Unknown names return NXDOMAIN.

I applied it to both clusters.

Recipes written later from this work: