d4rk notes
Projects

DNS Rewrites Sync

Python CLI for keeping Pi-hole, AdGuard Home, Cloudflare, OPNsense, Unbound, and generic DNS rewrite targets aligned from one source of truth.

dami2026-06-02pythondnshomelabautomation

Status

live

Difficulty

advanced

Time Required

25m

Last Tested

2026-06-01

Overview

DNS Rewrites Sync is a Python command-line tool for synchronizing local DNS rewrite records across multiple DNS platforms.

The project solves a real homelab problem: every resolver tends to grow its own copy of local hostnames. Pi-hole, AdGuard Home, router DNS, Cloudflare, and Unbound can all drift unless one system is treated as the source of truth.

What It Does

  • Uses a hub-and-spoke model for DNS rewrite propagation
  • Supports Pi-hole v6+, AdGuard Home, Cloudflare DNS, OPNsense or pfSense, Unbound, and generic API targets
  • Handles A and CNAME-style records depending on target support
  • Stores credentials through an encrypted secrets manager
  • Provides CLI commands for server setup, testing, listing, dry runs, and sync
  • Includes systemd service and timer assets for scheduled syncs

Architecture

The codebase is a small Python application built around typed server adapters. A registry maps server type keys to metadata and implementation classes, while the CLI drives setup and sync operations.

Important pieces include the config manager, encrypted secrets manager, server factory, and per-platform implementations under dns_sync/servers. The project keeps the operational surface intentionally light: HTTP APIs, YAML config, encrypted credentials, and systemd for scheduling.

Why It Matters

Local DNS records are invisible infrastructure until they break. This project turns a brittle manual chore into a repeatable service with dry-run support and explicit source-of-truth behavior.

Current Status

The README, requirements, installer scripts, tests, and blog notes show an active CLI project with a service/timer deployment model. It is one of the more infrastructure-heavy projects in the Python directory.