Local DNS zones
Scenario
You want internal hosts to be reachable by name without hand-maintaining /etc/hosts files on every device. Specifically:
- A handful of static records (router, NAS, printer).
- Automatic A / AAAA / PTR records for every device that takes a DHCP lease.
- Forward and reverse lookups working for those names.
How routerd solves it
DNSZone stores local authoritative records for one DNS domain. It can combine manual records (declared in YAML) with DHCP-derived records (built from the lease database). DNSResolver reads DNSZone resources as one of its sources, so internal queries get answered locally and external queries fall through to the configured upstreams.
DHCP-derived records are kept in sync via the event bus: dnsmasq invokes routerd-dhcp-event-relay whenever a lease changes, the relay publishes a routerd event, and routerd-dns-resolver updates its in-memory zone tables. The dnsmasq lease file is also re-read at startup so records survive a daemon restart.
Example
- apiVersion: net.routerd.net/v1alpha1
kind: DNSZone
metadata:
name: lan
spec:
zone: lan.example.org
ttl: 300
dnssec:
enabled: false
records:
- hostname: router
ipv4: 192.0.2.1
ipv6: 2001:db8:1::1
- hostname: nas
ipv4: 192.0.2.10
dhcpDerived:
sources:
- DHCPv4Server/lan-dhcpv4
- DHCPv6Server/lan-dhcpv6
ttl: 60
leaseFile: /var/lib/routerd/dnsmasq/dnsmasq.leases
After this resource is applied, queries for nas.lan.example.org and <dhcp-client-name>.lan.example.org resolve to local addresses, and PTR lookups for 192.0.2.x return the same names.
Notes
- Different static hostnames may share an IPv4 or IPv6 address. All declared names retain their A / AAAA answers; the first static name declared for each address supplies its PTR answer. DHCP-derived names do not replace these static answers.
- Choose a domain you control or one that is reserved for internal use (
example.org,home.arpa, etc.). Do not invent suffixes that collide with the public DNS namespace (such as.lan). dnssec.enabled: truesets the AD bit on local answers. It does not validate upstream DNSSEC signatures or sign the local zone.- PTR records are generated from the configured and DHCP-derived addresses; no separate reverse-zone list is needed.