89 lines
4.8 KiB
Markdown
89 lines
4.8 KiB
Markdown
# Deployment
|
||
|
||
## After installing the .deb package
|
||
|
||
```bash
|
||
sudo apt install ./dist/easydns_0.1.0-1_amd64.deb
|
||
sudo easydns zone create example.com --ns ns1.example.com=192.0.2.10 --ip 192.0.2.80
|
||
sudo systemctl enable --now easydns
|
||
sudo easydns status # no key to generate or pass
|
||
easydig @127.0.0.1 example.com SOA +short
|
||
```
|
||
The package installs the default hybrid configuration (`/etc/easydns/config.yaml`:
|
||
`0.0.0.0:53` + `[::1]:53`, recursion for `192.168.0.0/16`, `10.0.0.0/8`, `127.0.0.1`),
|
||
creates `/etc/easydns/{zones.d,keys.d,data/zones}` and the `easydns` user. Layout:
|
||
[configuration.md](configuration.md#default-installation-layout). On hosts where
|
||
systemd-resolved occupies `127.0.0.53:53` there is no conflict (different address); if
|
||
another DNS server listens on `0.0.0.0:53`, stop it or change `server.listen`.
|
||
|
||
## Upgrading the package (keeping your configuration)
|
||
|
||
```bash
|
||
sudo tar czf /root/easydns-backup-$(date +%F).tgz /etc/easydns # config, zones, keys, data
|
||
scripts/build-deb.sh # → dist/easydns_<ver>_<arch>.deb
|
||
sudo apt install -o Dpkg::Options::=--force-confold ./dist/easydns_*_amd64.deb
|
||
```
|
||
* `/etc/easydns/config.yaml` and `root.hints` are conffiles: `--force-confold` keeps your
|
||
version without asking; the new default is saved next to it as `config.yaml.dpkg-dist`
|
||
(without the option dpkg asks – answer **N** to keep yours).
|
||
* Files in `zones.d/`, `keys.d/` and `data/` are never touched by the package.
|
||
* A running server is restarted only if the new version accepts the configuration
|
||
(`easydns check-config` as the `easydns` user); otherwise the old version keeps
|
||
running and the reason is in `/tmp/easydns-upgrade-check.log`.
|
||
* Secondary zone copies from older versions (`data/secondary/`) are moved automatically
|
||
to `data/zones/secondary/` on the first start, so zones are served immediately.
|
||
* After the upgrade: `sudo easydns check-config`, `journalctl -u easydns -n 50`, and
|
||
query a few zones (`easydig @127.0.0.1 example.com SOA +short`).
|
||
|
||
## systemd (manual installation)
|
||
|
||
```bash
|
||
sudo useradd --system --home /etc/easydns/data --shell /usr/sbin/nologin easydns
|
||
sudo deploy/install.sh /usr # binaries (+ short tool names when free)
|
||
sudo install -d -o root -g easydns -m 0750 /etc/easydns /etc/easydns/zones.d /etc/easydns/keys.d
|
||
sudo install -d -o easydns -g easydns -m 0750 /etc/easydns/data /etc/easydns/data/zones
|
||
sudo install -m 0640 -g easydns config/config.yaml /etc/easydns/config.yaml # or config/primary.yaml, secondary.yaml, …
|
||
sudo cp deploy/systemd/easydns.service /etc/systemd/system/
|
||
sudo systemctl daemon-reload && sudo systemctl enable --now easydns
|
||
sudo systemctl reload easydns # hot reload (SIGHUP)
|
||
```
|
||
Secrets for `env:` references (optional) go to `/etc/easydns/easydns.env` (mode 0640).
|
||
Block list updates: `deploy/systemd/easydns-blocklists.{service,timer}`.
|
||
|
||
## Docker
|
||
|
||
`docker compose up -d` builds `deploy/docker/Dockerfile` (multi-stage, Debian slim,
|
||
non-root, `CAP_NET_BIND_SERVICE` only, read-only root). Mount `./config` to `/etc/easydns`
|
||
and keep `/etc/easydns/data` on a volume. Multi-arch:
|
||
`docker buildx build --platform linux/amd64,linux/arm64 -f deploy/docker/Dockerfile .`
|
||
|
||
## Ports
|
||
|
||
53/udp+tcp (DNS), 853/tcp (DoT, optional), DoH port as configured (e.g. 443), 9953 API (loopback) and
|
||
9090 metrics on loopback by default. Do not expose the API, metrics or recursion to the
|
||
Internet without explicit ACLs and TLS (reverse proxy).
|
||
|
||
## Packages and archives
|
||
|
||
`scripts/build-deb.sh [--arch amd64,arm64] [--debian bookworm] [--revision N] [--test]` builds
|
||
`dist/easydns_<version>-<rev>_<arch>.deb` entirely inside Docker (`deploy/docker/Dockerfile.deb`,
|
||
control/maintainer scripts in `deploy/packaging/debian/`); `--test` installs the package in a
|
||
clean container and runs a smoke query. The package installs a `easydns` system user, the
|
||
systemd units, `/etc/easydns/config.yaml` (conffile), man page, completions, and creates short
|
||
tool names only where they are free.
|
||
|
||
|
||
`deploy/release.sh` builds x86_64/aarch64 archives with SHA256SUMS; `deploy/packaging/nfpm.yaml`
|
||
builds .deb/.rpm (`nfpm pkg -p deb|rpm`). `cargo install --path crates/dns-cli` and
|
||
`--path crates/dns-tools` work too. `easydns --version` prints version and commit.
|
||
|
||
## Backup / restore / upgrade
|
||
|
||
* Back up `/etc/easydns` – one directory holds everything: config, `zones.d/`,
|
||
`keys.d/` (secrets!) and `data/` (zone files, snapshots, journals, signed zones, audit log).
|
||
* Purging the package never deletes `/etc/easydns` (your zones and keys).
|
||
* Restore: put the directories back and start; secondaries re-validate EXPIRE on startup.
|
||
* Upgrades are in place; formats are versionless/forward-tolerant (zone files, JSON
|
||
lines). Rollback = previous binary + the same directories. A corrupt journal is
|
||
truncated automatically (IXFR then falls back to AXFR).
|