Skip to content

PowerDNS (local secondary of web01)

Poweradmin + PowerDNS Authoritative in the community-scripts powerdns LXC on node04. It holds a read-only copy (secondary) of every zone that DirectAdmin serves on web01.discloud.biz, so the homelab can answer for those zones itself and has a current copy when web01 is down.

DirectAdmin (web01)                     homelab
 BIND primary  ──AXFR over TCP/53 (TSIG homelab-axfr)──▶  powerdns LXC (PowerDNS secondary, sqlite)
 named-checkconf -l ──zone list──▶ Semaphore "powerdns sync" (*/15) ──▶ pdns-secondary-sync
Piece Where
Create + configure playbooks/powerdns.yml (runs ct/powerdns.sh unattended on node04 once)
Sync playbooks/powerdns_sync.yml — Semaphore schedule every 15 min, also in Actions → deploy
PowerDNS settings roles/powerdns_secondary → /etc/powerdns/pdns.d/infra.conf
Sync script /usr/local/sbin/pdns-secondary-sync (adds / re-points / refreshes / prunes secondaries)
BIND on web01 roles/directadmin_axfr: key file next to named.conf, include + allow-transfer { key "homelab-axfr"; … }
Metrics pdns webserver :8081/metrics (scraped as app_metrics), sync textfile pdns_secondary_*
Alerts PowerDNSSecondarySyncStale, PowerDNSSecondarySyncFailing, PowerDNSSecondaryBehind, plus the generic ServiceDown probes (Poweradmin :80, DNS tcp/53, web01 :2222 + tcp/53)

How the sync works

  1. The TSIG key homelab-axfr is generated on the PowerDNS LXC (pdnsutil generate-tsig-key) and copied into BIND on web01 by the same run — it is not in the repo or the vault.
  2. On web01 a small script adds the key include and the key to the options-level allow-transfer (existing entries stay, none is replaced). named-checkconf must pass, otherwise the edited file is restored from its .infra-backup copy. The edited file is the one that holds options { }: /etc/bind/named.conf.options on Ubuntu/Debian, named.conf on CentOS-style hosts. Then rndc reconfig.
  3. named-checkconf -l lists every primary zone; .arpa and localhost zones are skipped (directadmin_zone_exclude*).
  4. pdns-secondary-sync creates missing zones as secondary of web01 with AXFR-MASTER-TSIG, asks web01 for the SOA serial of the others and retrieves zones that differ, and deletes secondaries web01 no longer has (powerdns_sync_prune). Zones of other primaries and zones you create yourself in Poweradmin are never touched.

No NOTIFY: that would need UDP/53 from the internet forwarded to the LXC. A change on web01 therefore shows up within 15 minutes (or at the zone's SOA refresh). With a port forward, set powerdns_allow_notify_from: [<web01 IP>] and add also-notify on web01.

One-time setup

  1. Put the root public key of the Semaphore CT (pct exec 157 -- cat /root/.ssh/id_ed25519.pub) and of the gh-runner into root@web01:~/.ssh/authorized_keys. Different SSH port: ansible_port in inventory/host_vars/web01.yml.
  2. ansible-playbook playbooks/powerdns.yml (or Actions → deploy → powerdns.yml). Poweradmin admin password: cat ~/poweradmin.creds in the CT → AliasVault.
  3. Re-run scripts/semaphore/configure.sh on node04: adds the templates powerdns and powerdns sync and the 15-minute schedule.
  4. Dry run any time: ansible-playbook playbooks/powerdns_sync.yml --check --diff (shows the named.conf diff and which zones would be added/removed).

Checks

pct exec <ct> -- pdnsutil list-all-zones secondary | wc -l
dig @<powerdns-ip> discloud.biz SOA +short      # same serial as:
dig @web01.discloud.biz discloud.biz SOA +short