:::admonition[Experimental]{type=danger} This service is experimental and will change in the future. :::
:::admonition[VPN only]{type=warning}
CoreDNS must listen only on a VPN interface (WireGuard, ZeroTier, Mycelium,
Yggdrasil, Tor, etc.) and must never be reachable from the public internet.
Set the server role's ip to an address only your clan peers can reach.
A public-facing bind turns the machine into an open DNS resolver: it
leaks your internal zone and can be abused as a DNS amplifier in DDoS
attacks.
:::
This service gives your clan an internal DNS zone. Pick a top-level domain
like .clan, publish services from any clan machine under that TLD, and
every peer can reach them at http://<service>.clan without touching
external DNS.
The service has two roles:
serverruns CoreDNS on one machine and answers queries for the TLD.defaultgoes on every clan machine (including the server). It points TLD lookups at theservermachine over the VPN and lets the host publish its own services into the zone.
Example
We'll set up a TLD called .foo. dnsserver runs CoreDNS. server01
publishes http://one.foo, server02 publishes http://two.foo, and
client only consumes the zone.
inventory = {
machines = {
dnsserver = { }; # 192.168.1.2
server01 = { }; # 192.168.1.3
server02 = { }; # 192.168.1.4
client = { }; # 192.168.1.5
};
instances = {
coredns = {
module.name = "coredns";
module.input = "self";
roles.default.tags = [ "all" ];
roles.server.machines."dnsserver".settings = {
ip = "192.168.1.2";
tld = "foo";
};
roles.default.machines."server01".settings = {
ip = "192.168.1.3";
services = [ "one" ];
};
roles.default.machines."server02".settings = {
ip = "192.168.1.4";
services = [ "two" ];
};
};
};
};
When client resolves http://one.foo, the query is forwarded to
dnsserver over the VPN and comes back as 192.168.1.3. External names
like clan.lol still go through the DHCP-provided resolver.
Why the server role requires an ip
The ip option has no default on purpose. CoreDNS binds to that single
address, so it only accepts queries on the interface you point it at.
That interface must be the VPN, not a public one. See the warning at
the top of this page.
The same address is reused as the ns A-record or AAAA-record (depends
on the address scheme) in the generated zone file and as the stub target
that default-role machines forward TLD queries to, so every clan peer
has to be able to reach it.
Startup and VPN readiness
CoreDNS can't bind to a VPN address before the VPN interface exists.
The service waits for network-online.target and for the common clan
VPN units (ZeroTier, Mycelium, Yggdrasil, Tor) to come up. If the VPN
comes up late or CoreDNS loses its bind for any other reason, the
service restarts with exponential backoff from 5 seconds up to 5
minutes, capped at 10 attempts per hour.
If you use a VPN that isn't in that list (for example WireGuard with a custom interface name), add its unit to the CoreDNS service's ordering yourself.