From befa6aac3e27682e1392750886180abe1f28e149 Mon Sep 17 00:00:00 2001 From: Gemini Bot Date: Tue, 9 Dec 2025 19:22:32 +0000 Subject: [PATCH] fix: Remove GEMINI.md and update .env.example --- .env.example | 21 ++++++++--------- .gitignore | 1 + GEMINI.md | 64 ---------------------------------------------------- 3 files changed, 10 insertions(+), 76 deletions(-) delete mode 100644 GEMINI.md diff --git a/.env.example b/.env.example index 013bc8b..585eb0a 100644 --- a/.env.example +++ b/.env.example @@ -5,15 +5,12 @@ NETBOX_URL=http://netbox.example.com NETBOX_TOKEN=0123456789abcdef0123456789abcdef01234567 -# --- Configuration (Defaults shown are generic) --- -ZONE_NAME=example.com -REVERSE_ZONE_NAME=1.168.192.in-addr.arpa -REFRESH_INTERVAL=600 - -# Paths inside the container -OUTPUT_FILE_FWD=/zones/db.fwd -OUTPUT_FILE_REV=/zones/db.rev - -# Fallback Nameserver (used if no NS records found in NetBox) -FALLBACK_NS_HOSTNAME=ns1 -FALLBACK_NS_IP=127.0.0.1 \ No newline at end of file +# Optional Configuration +# REFRESH_INTERVAL=600 +# NETBOX_SSL_VERIFY=true +# ZONE_NAME=example.com +# REVERSE_ZONE_NAME=1.168.192.in-addr.arpa +# OUTPUT_FILE_FWD=/zones/db.fwd +# OUTPUT_FILE_REV=/zones/db.rev +# FALLBACK_NS_HOSTNAME=ns1 +# FALLBACK_NS_IP=127.0.0.1 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 0eb8597..04a9b13 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ __pycache__/ *.pyc .env .DS_Store +GEMINI.md diff --git a/GEMINI.md b/GEMINI.md deleted file mode 100644 index 279a27f..0000000 --- a/GEMINI.md +++ /dev/null @@ -1,64 +0,0 @@ -# CoreDNS NetBox Sync - -This project automates the generation of DNS zone files for CoreDNS (or BIND) by synchronizing data from [NetBox](https://github.com/netbox-community/netbox). It fetches IPAM data (active IPs with DNS names) and DNS plugin entries to maintain up-to-date Forward and Reverse zones. - -## Project Overview - -* **Core Logic:** A Python script (`sync.py`) runs in a continuous loop, fetching data from the NetBox API. -* **Output:** Generates standard DNS zone files compatible with CoreDNS and BIND. -* **Resilience:** If the NetBox API is unreachable, the script preserves existing zone files to prevent DNS outages (NXDOMAIN). -* **Environment:** designed to run as a Docker container, sharing the generated zone files via a volume with the CoreDNS container. - -## Key Files - -* `sync.py`: The main application logic. Handles API authentication, data fetching, data formatting, and file writing. -* `Dockerfile`: Defines the minimal Python 3.11 Alpine-based image for running the script. -* `.env.example`: Template for required environment variables. -* `README.md`: Official project documentation (German). - -## Configuration - -Configuration is handled entirely via environment variables. - -| Variable | Required | Default | Description | -| :--- | :---: | :--- | :--- | -| `NETBOX_URL` | Yes | - | Full URL to NetBox (e.g., `http://netbox.local`). | -| `NETBOX_TOKEN` | Yes | - | API Token (Read-only sufficient). | -| `ZONE_NAME` | No | `klenzel.net` | The DNS zone to manage. | -| `REVERSE_ZONE_NAME` | No | `172.in-addr.arpa` | The reverse lookup zone. | -| `REFRESH_INTERVAL` | No | `600` | Sync interval in seconds. | -| `OUTPUT_FILE_FWD` | No | `/zones/db.klenzel.net` | Path for the forward zone file. | -| `OUTPUT_FILE_REV` | No | `/zones/db.reverse.arpa` | Path for the reverse zone file. | -| `FALLBACK_NS_HOSTNAME`| No | `fks-01-cl-cdns` | Fallback NS hostname if none in NetBox. | -| `FALLBACK_NS_IP` | No | `172.25.16.152` | Fallback NS IP for glue record. | - -## Development & Usage - -### Building the Image - -```bash -docker build -t local/dns-sync . -``` - -### Running Locally (for testing) - -1. Create a `.env` file with your NetBox credentials. -2. Run the container: - -```bash -docker run -d \ - --name dns-sync-test \ - --env-file .env \ - -v $(pwd)/zones:/zones \ - local/dns-sync -``` - -*(Ensure the `./zones` directory exists locally before running)* - -### Logic Details - -* **IPAM Fetch:** Queries `/api/ipam/ip-addresses/?status=active&dns_name__n=&limit=0`. -* **Plugin Fetch:** Queries `/api/plugins/netbox-dns/records/?zone__name={ZONE_NAME}&limit=0`. -* **Nameserver Logic:** - * If NetBox has NS records for the zone, the first one is used as the Primary SOA. - * If **no** NS records exist, it falls back to `FALLBACK_NS_HOSTNAME` and creates a Glue Record (A record) for it to ensure the zone is valid.