Local DNS zones

Scenario

You want internal hosts to be reachable by name without hand-maintaining /etc/hosts files on every device. Specifically:

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

See also