Files
mrcharles 2440188f1f feat(tooling): containerize dns-cli in tooling-cli/dns
Consolidate the Technitium DNS CLI into tooling-cli/dns/ with a
containerized bash CLI (src/dns_cli.sh), Dockerfile (alpine +
curl/python3/bind-tools/bash), README, AGENTS.md, validate.sh, and
.env.example. Env vars aligned to the centralized ~/.creds/technitium.env
store (TECHNITIUM_URL, TECHNITIUM_DNS_TOKEN, TECHNITIUM_DNS_ZONE).

Image built and pushed to the registry as
git.knownelement.com/reachableceo/dns-cli:latest. Verified live:
zones, list, and search all return data.

💘 Generated with Crush

Assisted-by: Crush:glm-5.2
2026-08-10 10:21:37 -05:00

83 lines
2.6 KiB
Markdown

# dns-cli
A Docker container that lets an AI agent (or a human) manage DNS records on a
[Technitium DNS Server](https://technitium.com/dns/) instance through its REST
API. A small bash CLI built on `curl` + `python3` + `dig`.
## Requirements
- Docker on the host.
- A Technitium DNS Server instance with the REST API enabled.
- A DNS API token (Technitium → Settings → API Token).
## Configuration
Credentials live in the **centralized credential store** at
`~/.creds/technitium.env` (see `tooling-cli/KNELCredsManager`). It holds:
```
TECHNITIUM_URL=http://pfv-netinfra-01:5380
TECHNITIUM_DNS_TOKEN=your-api-token
TECHNITIUM_DNS_ZONE=knel.net
```
Use `.env.example` in this directory as a template if you need to create one.
Permissions: directory `700`, the env file `600` (owner read/write only).
## Build
```bash
docker build -t git.knownelement.com/reachableceo/dns-cli:latest .
```
The image is also available in the Gitea registry:
```
git.knownelement.com/reachableceo/dns-cli:latest
```
## Usage
Invoke the container directly with `docker run`. Pass credentials from the
centralized store via `--env-file`:
```bash
docker run --rm --env-file ~/.creds/technitium.env \
git.knownelement.com/reachableceo/dns-cli:latest zones
docker run --rm --env-file ~/.creds/technitium.env \
git.knownelement.com/reachableceo/dns-cli:latest list
docker run --rm --env-file ~/.creds/technitium.env \
git.knownelement.com/reachableceo/dns-cli:latest search ns1
docker run --rm --env-file ~/.creds/technitium.env \
git.knownelement.com/reachableceo/dns-cli:latest add myhost 192.168.1.50
docker run --rm --env-file ~/.creds/technitium.env \
git.knownelement.com/reachableceo/dns-cli:latest delete myhost 192.168.1.50
docker run --rm --env-file ~/.creds/technitium.env \
git.knownelement.com/reachableceo/dns-cli:latest flush
```
## Commands
| Command | Description |
|---------|-------------|
| `zones` | List all zones. |
| `list [zone]` | List records in a zone (default: `TECHNITIUM_DNS_ZONE`). |
| `get <name>` | Resolve a record via `dig` (A/AAAA). |
| `add <name> <ip> [ttl]` | Add an A record with auto-PTR (default TTL 3600). |
| `delete <name> <ip>` | Delete an A record. |
| `flush` | Flush the DNS cache. |
| `search <pattern>` | Search records by name pattern (case-insensitive). |
## Environment variables
| Variable | Required | Description |
|----------|----------|-------------|
| `TECHNITIUM_URL` | yes | Base URL of the Technitium instance. |
| `TECHNITIUM_DNS_TOKEN` | yes | API token for the DNS REST API. |
| `TECHNITIUM_DNS_ZONE` | yes | Default zone for add/delete/search operations. |