This commit is contained in:
Mateusz Gruszczyński committed 2026-11-23 09:31:05 +01:00
1 parent 6e57b9e1b8
commit 7b8c7e93fb
48 files changed
+1010 -116

No files matched your search

+13
View File
@@ -2,6 +2,19 @@
All notable changes follow [Keep a Changelog](https://keepachangelog.com/) and SemVer.
## [0.1.2] – 2026-11-23
### Changed
- **Zone data layout**: `data/zones/` is split by owner – `zones/primary/` (your zone files; default of `easydns zone create` and of zones created through the API), `zones/secondary/` (transferred copies, as before) and `zones/signed/` (DNSSEC, was `data/signed/`). Signed zones are moved automatically on the first start, so signatures are reused. Existing primary zones keep working from their current `file:` path; moving them is optional (commands in `docs/deployment.md`).
- Example configurations, `dev.sh`, the container (`compose.yaml` mounts `./zones/primary`) and the packages use the installed layout; sample zone files moved to `zones/primary/` in the repository, `config/hybrid.yaml` no longer uses `../` paths.
- Sample zone definitions in `config/zones.d/` are named after the zone (`example.org.yaml`), the same as `easydns zone create` writes them.
- systemd unit: removed `StateDirectory=easydns` – it created an unused, empty `/var/lib/easydns` (data lives in `/etc/easydns/data`).
### Added
- **Hosts files** (`hosts:`), like dnsmasq: names from `/etc/hosts`-format files (`hosts.files`, globs allowed) are answered before local zones, block lists, forwarding and recursion – A/AAAA for every name and alias, PTR for the address (first name), NODATA for other types so the name never leaves the host. Only for clients in `recursion.allowed_clients`. `hosts.domain` also answers bare names as `<name>.<domain>` (`expand-hosts`), `hosts.ttl` sets the TTL (default 0, like `local-ttl`), and changed files are re-read every `hosts.reload_interval` (default 5 s) without a reload. Missing files are a `check-config` warning and are read once they appear. Guide with a dnsmasq translation table: `docs/hosts.md`.
## [0.1.1] – 2026-11-22
First public release. Packages (DEB, RPM for RHEL, RPM for SUSE; amd64) are published on
Generated
+12 -12
View File
@@ -359,7 +359,7 @@ dependencies = [
[[package]]
name = "dns-api"
version = "0.1.1"
version = "0.1.2"
dependencies = [
"axum",
"data-encoding",
@@ -380,7 +380,7 @@ dependencies = [
[[package]]
name = "dns-authoritative"
version = "0.1.1"
version = "0.1.2"
dependencies = [
"data-encoding",
"dns-config",
@@ -396,7 +396,7 @@ dependencies = [
[[package]]
name = "dns-cache"
version = "0.1.1"
version = "0.1.2"
dependencies = [
"dns-config",
"dns-core",
@@ -406,7 +406,7 @@ dependencies = [
[[package]]
name = "dns-cli"
version = "0.1.1"
version = "0.1.2"
dependencies = [
"clap",
"clap_complete",
@@ -425,7 +425,7 @@ dependencies = [
[[package]]
name = "dns-config"
version = "0.1.1"
version = "0.1.2"
dependencies = [
"dns-core",
"ipnet",
@@ -437,7 +437,7 @@ dependencies = [
[[package]]
name = "dns-core"
version = "0.1.1"
version = "0.1.2"
dependencies = [
"bytes",
"data-encoding",
@@ -459,7 +459,7 @@ dependencies = [
[[package]]
name = "dns-forwarder"
version = "0.1.1"
version = "0.1.2"
dependencies = [
"dns-config",
"dns-core",
@@ -472,7 +472,7 @@ dependencies = [
[[package]]
name = "dns-metrics"
version = "0.1.1"
version = "0.1.2"
dependencies = [
"tracing",
"tracing-subscriber",
@@ -480,7 +480,7 @@ dependencies = [
[[package]]
name = "dns-policy"
version = "0.1.1"
version = "0.1.2"
dependencies = [
"dns-config",
"dns-core",
@@ -491,7 +491,7 @@ dependencies = [
[[package]]
name = "dns-recursive"
version = "0.1.1"
version = "0.1.2"
dependencies = [
"dns-authoritative",
"dns-cache",
@@ -505,7 +505,7 @@ dependencies = [
[[package]]
name = "dns-server"
version = "0.1.1"
version = "0.1.2"
dependencies = [
"bytes",
"data-encoding",
@@ -534,7 +534,7 @@ dependencies = [
[[package]]
name = "dns-tools"
version = "0.1.1"
version = "0.1.2"
dependencies = [
"clap",
"data-encoding",
+1 -1
View File
@@ -3,7 +3,7 @@ resolver = "3"
members = ["crates/*"]
[workspace.package]
version = "0.1.1"
version = "0.1.2"
edition = "2024"
rust-version = "1.85"
license = "MIT"
+13 -6
View File
@@ -8,11 +8,11 @@ resolver**, a **Forwarder** and any **Hybrid** combination of them – and comes
> Migration from BIND: [docs/migration-from-bind.md](docs/migration-from-bind.md) · Feature status and gaps: [docs/spec-gaps.md](docs/spec-gaps.md)
## Project status: 0.1.1 – first public release, beta
## Project status: 0.1.2 – beta
All DNS roles listed below are implemented and covered by automated
tests (unit, integration with real servers on loopback, DNSSEC chains, DoT/DoH, API, CLI,
robustness – 102 test cases, `cargo clippy -D warnings` clean). **It has not yet been
robustness – 113 test cases, `cargo clippy -D warnings` clean). **It has not yet been
verified in production conditions.** Before it can be called production-ready, the items
in [Production readiness](#production-readiness) must be completed. Until then use it:
@@ -73,6 +73,9 @@ in [Production readiness](#production-readiness) must be completed. Until then u
* hybrid: local zones → policy → forward zones → recursion/forwarding, with separate cache
namespaces; private names never leak to the Internet (RFC 6761/6303 local-only names)
* split-horizon **views**, block/allow lists (exact, suffix, wildcard, regex, hosts files)
* **local names from `/etc/hosts`** (and other hosts-format files) answered first, like
dnsmasq: A/AAAA/PTR, optional domain for bare names, re-read automatically on change –
[docs/hosts.md](docs/hosts.md)
### Transport and security
@@ -96,7 +99,8 @@ in [Production readiness](#production-readiness) must be completed. Until then u
* `easydns` / `edns` CLI: run, check-config, status, zone create, zones, cache, upstreams,
block lists, root hints, DNSSEC keys, completions, man page – works locally **without
generating or passing an API key** (local control token, API on `127.0.0.1:9953`)
* one directory for everything: `/etc/easydns` (config, `zones.d/`, `keys.d/`, `data/zones/`)
* one directory for everything: `/etc/easydns` (config, `zones.d/`, `keys.d/`; data in
`data/zones/primary/`, `data/zones/secondary/`, `data/zones/signed/`)
* packages for Debian/Ubuntu, RHEL/Alma/Rocky and SUSE from
[repo.linuxiarz.pl](https://repo.linuxiarz.pl), Dockerfile + compose, systemd units,
install script, developer runner `dev.sh`
@@ -169,7 +173,7 @@ BIND first. Development from source:
```
The installed default ([config/config.yaml](config/config.yaml)): hybrid mode,
`0.0.0.0:53` + `[::1]:53`, recursion for `acl:lan`, zones in `/etc/easydns/data/zones/`,
`0.0.0.0:53` + `[::1]:53`, recursion for `acl:lan`, zone files in `/etc/easydns/data/zones/primary/`,
definitions in `/etc/easydns/zones.d/`, BIND key files in `/etc/easydns/keys.d/`.
Example configurations: [primary](config/primary.yaml), [secondary](config/secondary.yaml),
@@ -245,7 +249,9 @@ flowchart TD
OP -- UPDATE --> U[RFC 2136 on primary]
OP -- QUERY --> X{AXFR/IXFR?}
X -- yes --> XA[ACL + TSIG → transfer]
X -- no --> Z{local zone in client view?}
X -- no --> H{name in hosts files? client may resolve}
H -- yes --> HA[answer from hosts file AA=1]
H -- no --> Z{local zone in client view?}
Z -- yes --> AA[authoritative answer AA=1]
Z -- no --> R{client allowed to recurse?}
R -- no --> REF[REFUSED]
@@ -296,7 +302,8 @@ restricted permissions, runs unprivileged with `CAP_NET_BIND_SERVICE`. Details:
[**migration from BIND**](docs/migration-from-bind.md) · [feature status](docs/spec-gaps.md) ·
[**operations: master & resolution**](docs/operations.md) · [**zone transfer variants**](docs/zone-transfer-variants.md) ·
[**performance vs BIND (estimates)**](docs/performance.md) ·
[**encrypted DNS: DoT/DoH**](docs/secure-dns.md)
[**encrypted DNS: DoT/DoH**](docs/secure-dns.md) ·
[**local names from /etc/hosts (dnsmasq style)**](docs/hosts.md)
## Tests
+1 -1
View File
@@ -23,7 +23,7 @@ services:
required: false
volumes:
- ./config:/etc/easydns:ro
- ./zones:/etc/easydns/data/zones
- ./zones/primary:/etc/easydns/data/zones/primary # primary zone files
- easydns-data:/etc/easydns/data
read_only: true
cap_drop: [ALL]
+7 -1
View File
@@ -15,7 +15,7 @@ server:
listen: ["0.0.0.0:53", "[::1]:53"]
udp: true
tcp: true
data_dir: /etc/easydns/data # zone files in data/zones/, secondary copies, journals
data_dir: /etc/easydns/data # zones/primary/ (yours), zones/secondary/, zones/signed/, journals
max_udp_payload: 1232
logging:
@@ -35,6 +35,12 @@ recursion:
resolution:
default: recursive # recursive | forward | forwardthenrecursive | refuse
# Local names from /etc/hosts answered first (like dnsmasq), see docs/hosts.md:
# hosts:
# files: ["/etc/hosts"]
# domain: lan # also answer "nas" as "nas.lan"
# Encrypted forwarding instead of recursion (DNS-over-TLS to public resolvers):
# resolution: { default: forward }
# upstreams:
+5 -4
View File
@@ -1,5 +1,6 @@
# EasyDNS example configuration (hybrid node). All addresses are documentation/test ranges.
# Validate with: easydns check-config -c config/hybrid.yaml (or: econf check config/hybrid.yaml)
# Install as /etc/easydns/config.yaml, copy the sample zones (zones/primary/*.zone in the
# repository) to /etc/easydns/data/zones/primary/ and validate: easydns check-config
# Zone definitions can live in separate files (like BIND `include`):
include: ["zones.d/*.yaml"]
@@ -8,7 +9,7 @@ server:
listen: ["127.0.0.1:5353", "[::1]:5353"]
udp: true
tcp: true
data_dir: ../data # secondary snapshots, IXFR journals, audit log
data_dir: /etc/easydns/data # zones/primary|secondary|signed, journals, audit log
max_udp_payload: 1232
logging:
@@ -37,13 +38,13 @@ recursion:
zones:
- name: example.com
type: primary
file: ../zones/example.com.zone # relative to data_dir
file: zones/primary/example.com.zone # relative to data_dir
transfer_acl: ["127.0.0.1/32"] # secondaries allowed to AXFR/IXFR (IP only)
# transfer_tsig_key: xfr-key # optional: also require a TSIG key
notify: [] # e.g. ["192.168.1.20:53"]
- name: 2.0.192.in-addr.arpa
type: primary
file: ../zones/2.0.192.in-addr.arpa.zone # relative to data_dir
file: zones/primary/2.0.192.in-addr.arpa.zone
forward_zones:
- domain: corp.internal
+1 -1
View File
@@ -4,7 +4,7 @@ server: { mode: primary, listen: ["0.0.0.0:53", "[::]:53"], data_dir: /etc/easyd
zones:
- name: example.com
type: primary
file: zones/example.com.zone # = /etc/easydns/data/zones/example.com.zone
file: zones/primary/example.com.zone # = /etc/easydns/data/zones/primary/example.com.zone
transfer_acl: ["192.168.1.20/32"] # secondaries allowed to AXFR/IXFR
notify: ["192.168.1.20:53"] # send NOTIFY after every change
resolution: { default: refuse }
+11 -4
View File
@@ -1,4 +1,11 @@
Zone definitions included by `config/config.yaml` (`include: ["zones.d/*.yaml"]`).
One file per zone or per customer; files are read in alphabetical order, hidden files
and `*~` backups are ignored. Relative `file:` paths are resolved against the directory
of the main configuration file.
Zone definitions included by `config/config.yaml` (`include: ["zones.d/*.yaml"]`), installed
as `/etc/easydns/zones.d/`. One file per zone, named after the zone (`example.com.yaml` –
`easydns zone create` writes exactly that); files are read in alphabetical order, hidden
files and `*~` backups are ignored.
Relative `file:` paths are resolved against `server.data_dir`:
| Zone type | Zone file |
|---|---|
| primary | `file: zones/primary/example.com.zone` → `/etc/easydns/data/zones/primary/example.com.zone` (you edit it; DDNS/API write it too) |
| secondary | no `file:` needed – the copy is kept in `/etc/easydns/data/zones/secondary/example.com.zone` |
File renamed without changes.
File renamed without changes.
+1 -1
View File
@@ -225,7 +225,7 @@ pub async fn zone_create(State(st): St, Extension(c): Extension<Caller>, Json(b)
if let Err(e) = dns_authoritative::Zone::from_records(&name, records) {
return error(StatusCode::UNPROCESSABLE_ENTITY, &e.to_string());
}
let file = rt.cfg.data_dir().join("zones").join(format!("{}zone", name.to_ascii()));
let file = rt.cfg.data_dir().join("zones").join("primary").join(format!("{}zone", name.to_ascii()));
if let Err(e) = dns_core::zonefile::atomic_write(&file, text.as_bytes()) {
return error(StatusCode::INTERNAL_SERVER_ERROR, &e.to_string());
}
+46 -11
View File
@@ -121,14 +121,10 @@ fn acl_contains(acl: &[IpNet], ip: IpAddr) -> bool {
acl.iter().any(|n| n.contains(&ip))
}
/// Default copy of a secondary zone: `<data_dir>/zones/secondary/<zone>.zone`.
///
/// Versions before 0.1.x-unreleased kept it in `<data_dir>/secondary/`. An existing old
/// copy (with its `.meta.json`) is moved to the new place, so an upgrade keeps serving
/// the zone from the local copy instead of transferring everything again.
fn default_secondary_file(data_dir: &Path, zone_ascii: &str) -> PathBuf {
let new = data_dir.join("zones").join("secondary").join(format!("{zone_ascii}zone"));
let old = data_dir.join("secondary").join(format!("{zone_ascii}zone"));
/// Move a server-written file from its pre-0.1.2 location to the current one (together
/// with `<file>.meta.json` when present), so an upgrade keeps using it. Returns the path
/// to use: the new one, or the old one when it could not be moved.
fn migrate_default(new: PathBuf, old: PathBuf, what: &str) -> PathBuf {
if !new.exists() && old.is_file() {
let meta = |p: &Path| {
let mut m = p.as_os_str().to_owned();
@@ -141,9 +137,9 @@ fn default_secondary_file(data_dir: &Path, zone_ascii: &str) -> PathBuf {
.and_then(|_| std::fs::rename(&old, &new))
.and_then(|_| if meta(&old).exists() { std::fs::rename(meta(&old), meta(&new)) } else { Ok(()) });
match moved {
Ok(()) => tracing::info!(from = %old.display(), to = %new.display(), "moved secondary zone copy to the new location"),
Ok(()) => tracing::info!(from = %old.display(), to = %new.display(), "moved {what} to the new location"),
Err(e) => {
tracing::warn!(path = %old.display(), error = %e, "could not move secondary zone copy; using the old location");
tracing::warn!(path = %old.display(), error = %e, "could not move {what}; using the old location");
return old;
}
}
@@ -151,6 +147,31 @@ fn default_secondary_file(data_dir: &Path, zone_ascii: &str) -> PathBuf {
new
}
/// Default copy of a secondary zone: `<data_dir>/zones/secondary/<zone>.zone`.
///
/// Versions before 0.1.1 kept it in `<data_dir>/secondary/`. An existing old copy (with
/// its `.meta.json`) is moved to the new place, so an upgrade keeps serving the zone from
/// the local copy instead of transferring everything again.
fn default_secondary_file(data_dir: &Path, zone_ascii: &str) -> PathBuf {
migrate_default(
data_dir.join("zones").join("secondary").join(format!("{zone_ascii}zone")),
data_dir.join("secondary").join(format!("{zone_ascii}zone")),
"secondary zone copy",
)
}
/// Last signed version of a DNSSEC zone: `<data_dir>/zones/signed/<zone>.zone`.
///
/// Versions before 0.1.2 kept it in `<data_dir>/signed/`; it is moved, so the first start
/// after an upgrade reuses the signatures instead of re-signing under the same serial.
fn default_signed_file(data_dir: &Path, zone_ascii: &str) -> PathBuf {
migrate_default(
data_dir.join("zones").join("signed").join(format!("{zone_ascii}zone")),
data_dir.join("signed").join(format!("{zone_ascii}zone")),
"signed zone",
)
}
impl ZoneEntry {
fn new(cfg: &Config, zc: &ZoneConfig, ring: &KeyRing) -> Result<Self, String> {
let name = dns_core::names::parse_name(&zc.name).map_err(|e| e.to_string())?;
@@ -184,7 +205,7 @@ impl ZoneEntry {
}
_ => None,
};
let signed_file = cfg.data_dir().join("signed").join(format!("{}zone", name.to_ascii()));
let signed_file = default_signed_file(&cfg.data_dir(), &name.to_ascii());
Ok(Self {
signer: Mutex::new(signer),
source: Mutex::new(None),
@@ -612,4 +633,18 @@ mod migration_tests {
assert_eq!(default_secondary_file(&d, "example.net."), d.join("zones/secondary/example.net.zone"));
let _ = std::fs::remove_dir_all(&d);
}
#[test]
fn old_signed_zone_is_moved_to_new_location() {
let d = std::env::temp_dir().join(format!("edns-sig-mig-{}", std::process::id()));
let _ = std::fs::remove_dir_all(&d);
std::fs::create_dir_all(d.join("signed")).unwrap();
std::fs::write(d.join("signed/example.com.zone"), "signed").unwrap();
let p = default_signed_file(&d, "example.com.");
assert_eq!(p, d.join("zones/signed/example.com.zone"));
assert_eq!(std::fs::read_to_string(&p).unwrap(), "signed");
assert!(!d.join("signed/example.com.zone").exists());
assert_eq!(default_signed_file(&d, "example.net."), d.join("zones/signed/example.net.zone"));
let _ = std::fs::remove_dir_all(&d);
}
}
+1 -1
View File
@@ -120,7 +120,7 @@ enum ConfigCmd {
#[derive(Subcommand)]
enum ZonesCmd {
/// Create a new primary zone with minimal records (SOA, NS, glue) in <data_dir>/zones/
/// Create a new primary zone with minimal records (SOA, NS, glue) in <data_dir>/zones/primary/
Create(zonecreate::CreateArgs),
List,
Show {
+5 -5
View File
@@ -1,6 +1,6 @@
//! `easydns zone create`: write a minimal, valid primary zone and its definition.
//!
//! Creates `<data_dir>/zones/<zone>.zone` (SOA, NS, glue for in-zone name servers and
//! Creates `<data_dir>/zones/primary/<zone>.zone` (SOA, NS, glue for in-zone name servers and
//! optional apex addresses) and `<config dir>/zones.d/<zone>.yaml`, which the default
//! configuration includes. Nothing is overwritten without `--force`, and the zone is
//! parsed and checked before anything is written.
@@ -136,7 +136,7 @@ pub fn render(a: &CreateArgs, serial: u32) -> Result<(String, String), String> {
}
let _ = glue_used_apex;
let file = format!("zones/{bare}.zone");
let file = format!("zones/primary/{bare}.zone");
let mut def = format!("# {bare} – created by `easydns zone create`\n- name: {bare}\n type: primary\n file: {file}\n");
let list = |v: &[String]| v.iter().map(|x| format!("\"{x}\"")).collect::<Vec<_>>().join(", ");
if !a.allow_transfer.is_empty() {
@@ -192,7 +192,7 @@ pub fn create(cfg: &Config, config_path: &Path, a: &CreateArgs) -> Result<Create
let records = dns_core::zonefile::parse_str(&text, &zone, None).map_err(|e| format!("generated zone does not parse: {e}"))?;
dns_authoritative::Zone::from_records(&zone, records).map_err(|e| format!("generated zone is invalid: {e}"))?;
let zone_file = cfg.data_dir().join("zones").join(format!("{bare}.zone"));
let zone_file = cfg.data_dir().join("zones").join("primary").join(format!("{bare}.zone"));
let conf_dir = config_path.parent().map(Path::to_path_buf).unwrap_or_default();
let includes_zones_d = cfg.include.iter().any(|p| p.starts_with("zones.d/"));
let definition_file = (!a.no_config && includes_zones_d).then(|| conf_dir.join("zones.d").join(format!("{bare}.yaml")));
@@ -244,7 +244,7 @@ mod tests {
assert!(t.contains("ns1\tIN A 192.0.2.1"));
assert!(t.contains("@\tIN A 192.0.2.1"));
assert_eq!(valid(&t, "example.com"), 4); // SOA, NS, glue, apex A
assert!(def.contains("file: zones/example.com.zone"));
assert!(def.contains("file: zones/primary/example.com.zone"));
}
#[test]
@@ -279,7 +279,7 @@ mod tests {
let mut a = args("example.com");
a.ns = vec!["ns.example.net".into()];
let c = create(&cfg, &cfgp, &a).unwrap();
assert!(c.zone_file.ends_with("data/zones/example.com.zone") && c.zone_file.is_file());
assert!(c.zone_file.ends_with("data/zones/primary/example.com.zone") && c.zone_file.is_file());
assert!(d.join("zones.d/example.com.yaml").is_file());
// the new definition is picked up and the zone loads
let cfg2 = Config::load(&cfgp).unwrap();
+78 -3
View File
@@ -42,6 +42,8 @@ pub struct Config {
pub resolution: ResolutionConfig,
pub cache: CacheConfig,
pub policy: PolicyConfig,
/// Names answered from hosts files (`/etc/hosts` format) before anything else, like dnsmasq.
pub hosts: HostsConfig,
pub rate_limit: RateLimitConfig,
pub tls: TlsConfig,
pub api: ApiConfig,
@@ -277,8 +279,8 @@ pub struct ZoneConfig {
pub name: String,
#[serde(rename = "type")]
pub zone_type: ZoneType,
/// Zone file. A relative path is relative to `server.data_dir` (e.g. `zones/example.com.zone`
/// = `<data_dir>/zones/example.com.zone`). Primary: required. Secondary: optional; defaults to
/// Zone file. A relative path is relative to `server.data_dir` (e.g. `zones/primary/example.com.zone`
/// = `<data_dir>/zones/primary/example.com.zone`). Primary: required. Secondary: optional; defaults to
/// `<data_dir>/zones/secondary/<zone>.zone`.
#[serde(default)]
pub file: Option<PathBuf>,
@@ -505,6 +507,43 @@ fn yes() -> bool {
true
}
/// Hosts files answered locally (dnsmasq `addn-hosts` / reading `/etc/hosts`).
///
/// Every `address name [alias...]` line yields A/AAAA records for the names and a PTR
/// record for the address (first name). Names found here are answered before local
/// zones, forwarding and recursion, to clients allowed to resolve
/// (`recursion.allowed_clients`). Off while `files` is empty.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(deny_unknown_fields, default)]
pub struct HostsConfig {
/// Files in hosts format, e.g. `["/etc/hosts", "/etc/hosts.d/*.hosts"]`. Relative paths
/// are resolved against the configuration directory; `*`/`?` globs are allowed in the
/// file name. A missing file is a warning, not an error (it is picked up once it appears).
pub files: Vec<String>,
/// TTL of the answers (dnsmasq `local-ttl`, default 0: clients do not cache them).
pub ttl: u32,
/// Domain appended to names without a dot (dnsmasq `expand-hosts` + `domain=`):
/// with `domain: lan` the line `192.168.1.10 nas` answers both `nas` and `nas.lan`.
#[serde(skip_serializing_if = "Option::is_none")]
pub domain: Option<String>,
/// How often the files are checked for changes (modification time and size); changed
/// files are re-read without a reload. `0s` turns it off (then only `easydns reload`).
#[serde(with = "duration")]
pub reload_interval: Duration,
}
impl Default for HostsConfig {
fn default() -> Self {
Self { files: Vec::new(), ttl: 0, domain: None, reload_interval: Duration::from_secs(5) }
}
}
impl HostsConfig {
pub fn enabled(&self) -> bool {
!self.files.is_empty()
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(deny_unknown_fields, default)]
pub struct PolicyConfig {
@@ -853,6 +892,27 @@ impl Config {
}
}
/// Expand `hosts.files` (paths relative to the config directory, `*`/`?` globs in the
/// file name). Returns the existing files (sorted per pattern, without duplicates) and
/// the literal paths that do not exist.
pub fn hosts_file_paths(&self) -> (Vec<PathBuf>, Vec<PathBuf>) {
let base = self.server.base_dir.clone().unwrap_or_default();
let (mut found, mut missing) = (Vec::new(), Vec::new());
for pat in &self.hosts.files {
match include::expand(&base, pat) {
Ok(v) => {
for f in v {
if !found.contains(&f) {
found.push(f);
}
}
}
Err(_) => missing.push(self.resolve_path(Path::new(pat))),
}
}
(found, missing)
}
/// Resolve a path relative to the config file directory.
pub fn resolve_path(&self, p: &Path) -> PathBuf {
if p.is_absolute() {
@@ -875,7 +935,7 @@ impl Config {
}
/// Resolve a zone `file:`. Relative paths are relative to the data directory
/// (`zones/example.com.zone` → `<data_dir>/zones/example.com.zone`). For configurations
/// (`zones/primary/example.com.zone` → `<data_dir>/zones/primary/example.com.zone`). For configurations
/// written before this rule, a relative path that exists only relative to the config
/// directory is still accepted.
pub fn zone_file_path(&self, p: &Path) -> PathBuf {
@@ -959,6 +1019,21 @@ impl Config {
#[cfg(test)]
mod tests {
#[test]
fn hosts_section_parses_and_validates() {
let c: super::Config =
serde_norway::from_str("hosts: { files: [/etc/hosts, /nonexistent/x.hosts], ttl: 60, domain: lan, reload_interval: 2s }\n")
.unwrap();
assert!(c.hosts.enabled());
assert_eq!(c.hosts.ttl, 60);
assert_eq!(c.hosts.reload_interval, std::time::Duration::from_secs(2));
let issues = c.validate();
assert!(issues.iter().any(|i| i.path == "hosts.files" && !i.is_error()), "{issues:?}");
let bad: super::Config = serde_norway::from_str("hosts: { files: [/etc/hosts], domain: \"a..b\" }\n").unwrap();
assert!(bad.validate().iter().any(|i| i.path == "hosts.domain" && i.is_error()));
assert!(!super::Config::default().hosts.enabled());
}
#[test]
fn zone_path_with_parent_dir_before_data_dir_exists() {
let d = std::env::temp_dir().join(format!("edns-zp-{}", std::process::id()));
+14
View File
@@ -364,6 +364,20 @@ pub(crate) fn validate(c: &Config) -> Vec<ValidationIssue> {
v.err(format!("{p}.url"), "only https:// URLs are allowed");
}
}
if c.hosts.enabled() {
let (_, missing) = c.hosts_file_paths();
for m in missing {
v.warn("hosts.files", format!("file not found: {} (it is read once it exists)", m.display()));
}
if let Some(d) = &c.hosts.domain
&& dns_core::names::parse_lower(d).is_err()
{
v.err("hosts.domain", format!("invalid domain name '{d}'"));
}
if !c.hosts.reload_interval.is_zero() && c.hosts.reload_interval < std::time::Duration::from_secs(1) {
v.warn("hosts.reload_interval", "intervals below 1s only add load; 1s or more is plenty");
}
}
if let Err(e) = c.expand_acl(&c.policy.exempt_clients) {
v.err("policy.exempt_clients", e);
}
+2 -2
View File
@@ -4,8 +4,8 @@
//! * [`RateLimiter`] – per-client token buckets with a global ceiling,
//! * [`BlockPolicy`] – allow/block lists with exact, suffix, wildcard and (bounded) regex rules.
//!
//! Processing order (documented in docs/security.md): rate limit → ACL/view →
//! local zones → allowlist → blocklist → resolution.
//! Processing order (documented in docs/hybrid.md): rate limit → ACL/view →
//! hosts files → local zones → allowlist → blocklist → resolution.
#![cfg_attr(test, allow(clippy::unwrap_used, clippy::expect_used))]
use std::collections::{HashMap, HashSet};
+16
View File
@@ -336,6 +336,15 @@ async fn handle_query(ctx: &Ctx<'_>, req: &Message, mut resp: Message) -> Reply
let view = rt.views.classify(ip);
let qname = q.name.clone();
// 0. Hosts files (dnsmasq-style), for clients allowed to resolve.
if rt.hosts.enabled() && rt.recursion_acl.contains(ip) {
if let Some(records) = rt.hosts.table().lookup(&qname, q.query_type, rt.hosts.ttl) {
resp.metadata.authoritative = true;
resp.answers = records;
return ctx.finish(req, resp, Source::Local, Some("hosts file"));
}
}
// 1. Local authoritative data.
if let Some(entry) = rt.zones.find(&LowerName::new(&qname), view) {
let Some(zone) = entry.current() else {
@@ -435,6 +444,13 @@ async fn resolve_target(
let mut out = Answer::new(ResponseCode::NoError, Source::Authoritative);
let mut cur = target.clone();
for _ in 0..MAX_CROSS_CNAME {
if ctx.rt.hosts.enabled()
&& ctx.rt.recursion_acl.contains(ip)
&& let Some(records) = ctx.rt.hosts.table().lookup(&cur, qtype, ctx.rt.hosts.ttl)
{
out.answers.extend(records);
return out;
}
if let Some(entry) = ctx.rt.zones.find(&LowerName::new(&cur), view) {
let Some(zone) = entry.current() else { return Answer::servfail(Source::Authoritative, "zone unavailable") };
match zone.lookup(&cur, qtype, dnssec_ok) {
+330
View File
@@ -0,0 +1,330 @@
//! Answers from hosts files (`/etc/hosts` format), like dnsmasq.
//!
//! Each line `address name [alias...]` gives A/AAAA records for every name and a PTR record
//! for the address pointing at the first name. Comments (`#`) and blank lines are ignored,
//! as are lines that do not parse (counted and logged once per load). A name that is
//! present answers authoritatively: a type the file has no data for gets NODATA, so the
//! question never leaves the host (the dnsmasq behaviour).
//!
//! The table is swapped atomically when the files change (see [`HostsStore::refresh`]);
//! lookups take a read lock only long enough to clone an `Arc`.
use std::collections::HashMap;
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
use std::path::{Path, PathBuf};
use std::sync::{Arc, Mutex, RwLock};
use std::time::SystemTime;
use dns_config::Config;
use dns_core::proto::rr::rdata::{A, AAAA, PTR};
use dns_core::proto::rr::{LowerName, Name, RData, Record, RecordType};
#[derive(Debug, Default, Clone)]
struct Addrs {
v4: Vec<Ipv4Addr>,
v6: Vec<Ipv6Addr>,
}
/// One parsed set of hosts files.
#[derive(Debug, Default)]
pub struct HostsTable {
by_name: HashMap<LowerName, Addrs>,
by_addr: HashMap<LowerName, Name>,
/// Lines that could not be parsed.
pub skipped: usize,
}
impl HostsTable {
/// Parse hosts-format text. `domain` is appended to names without a dot.
pub fn parse_into(&mut self, text: &str, domain: Option<&Name>) {
for line in text.lines() {
let line = line.split('#').next().unwrap_or("").trim();
if line.is_empty() {
continue;
}
let mut parts = line.split_whitespace();
let Some(addr) = parts.next() else { continue };
// link-local zone index (`fe80::1%eth0`) is meaningless in DNS
let addr = addr.split('%').next().unwrap_or(addr);
let Ok(ip) = addr.parse::<IpAddr>() else {
self.skipped += 1;
continue;
};
let mut first: Option<Name> = None;
let mut any = false;
for raw in parts {
let Some(name) = parse_host_name(raw) else {
self.skipped += 1;
continue;
};
any = true;
let bare = name.num_labels() == 1;
if first.is_none() {
// PTR prefers the qualified form when the name is bare
first = Some(match (bare, domain) {
(true, Some(d)) => name.clone().append_domain(d).unwrap_or_else(|_| name.clone()),
_ => name.clone(),
});
}
self.add(&name, ip);
if bare
&& let Some(d) = domain
&& let Ok(q) = name.clone().append_domain(d)
{
self.add(&q, ip);
}
}
if !any {
self.skipped += 1;
continue;
}
if let Some(f) = first
&& !ip.is_unspecified()
{
// first line for an address wins, like dnsmasq / glibc
self.by_addr.entry(LowerName::new(&dns_core::names::reverse_name(ip))).or_insert(f);
}
}
}
fn add(&mut self, name: &Name, ip: IpAddr) {
let e = self.by_name.entry(LowerName::new(name)).or_default();
match ip {
IpAddr::V4(v4) if !e.v4.contains(&v4) => e.v4.push(v4),
IpAddr::V6(v6) => {
// v4-mapped addresses are IPv4 hosts
match v6.to_ipv4_mapped() {
Some(v4) if !e.v4.contains(&v4) => e.v4.push(v4),
Some(_) => {}
None if !e.v6.contains(&v6) => e.v6.push(v6),
None => {}
}
}
_ => {}
}
}
/// Number of distinct names.
pub fn names(&self) -> usize {
self.by_name.len()
}
pub fn is_empty(&self) -> bool {
self.by_name.is_empty() && self.by_addr.is_empty()
}
/// Records for `qname`/`qtype`. `None`: the name is not in the files (continue normally);
/// `Some(empty)`: the name is known but has no data of this type (NODATA).
pub fn lookup(&self, qname: &Name, qtype: RecordType, ttl: u32) -> Option<Vec<Record>> {
let key = LowerName::new(qname);
if let Some(e) = self.by_name.get(&key) {
let mut out = Vec::new();
if matches!(qtype, RecordType::A | RecordType::ANY) {
out.extend(e.v4.iter().map(|a| Record::from_rdata(qname.clone(), ttl, RData::A(A::from(*a)))));
}
if matches!(qtype, RecordType::AAAA | RecordType::ANY) {
out.extend(e.v6.iter().map(|a| Record::from_rdata(qname.clone(), ttl, RData::AAAA(AAAA::from(*a)))));
}
return Some(out);
}
if let Some(target) = self.by_addr.get(&key) {
let mut out = Vec::new();
if matches!(qtype, RecordType::PTR | RecordType::ANY) {
out.push(Record::from_rdata(qname.clone(), ttl, RData::PTR(PTR(target.clone()))));
}
return Some(out);
}
None
}
}
/// Host names in hosts files are plain ASCII/IDN labels; anything else is skipped.
fn parse_host_name(raw: &str) -> Option<Name> {
if raw.is_empty() || raw.starts_with('.') || raw.contains("..") {
return None;
}
dns_core::names::parse_name(raw).ok().filter(|n| !n.is_root())
}
/// Modification time and size of every file: a change in either triggers a re-read.
type Stamp = Vec<(PathBuf, Option<SystemTime>, u64)>;
fn stamp(files: &[PathBuf]) -> Stamp {
files
.iter()
.map(|f| match std::fs::metadata(f) {
Ok(m) => (f.clone(), m.modified().ok(), m.len()),
Err(_) => (f.clone(), None, 0),
})
.collect()
}
/// Hosts data of one runtime: the configuration plus the current table.
pub struct HostsStore {
cfg: Arc<Config>,
domain: Option<Name>,
pub ttl: u32,
table: RwLock<Arc<HostsTable>>,
last: Mutex<Stamp>,
}
impl HostsStore {
/// Read the configured files. Unreadable files are logged and skipped; the server
/// still starts (dnsmasq does the same).
pub fn build(cfg: Arc<Config>) -> Result<Self, String> {
let domain = match &cfg.hosts.domain {
Some(d) => Some(dns_core::names::parse_name(d).map_err(|e| format!("hosts.domain: {e}"))?),
None => None,
};
let s = Self { ttl: cfg.hosts.ttl, cfg, domain, table: RwLock::new(Arc::new(HostsTable::default())), last: Mutex::new(Vec::new()) };
if s.enabled() {
s.refresh(true);
}
Ok(s)
}
pub fn enabled(&self) -> bool {
self.cfg.hosts.enabled()
}
pub fn table(&self) -> Arc<HostsTable> {
self.table.read().unwrap_or_else(|e| e.into_inner()).clone()
}
/// Re-read the files if the set of files, a modification time or a size changed (or
/// always with `force`). Returns true when the table was replaced.
pub fn refresh(&self, force: bool) -> bool {
if !self.enabled() {
return false;
}
let (files, _missing) = self.cfg.hosts_file_paths();
let now = stamp(&files);
{
let mut last = self.last.lock().unwrap_or_else(|e| e.into_inner());
if !force && *last == now {
return false;
}
*last = now;
}
let table = load(&files, self.domain.as_ref());
tracing::info!(files = files.len(), names = table.names(), skipped_lines = table.skipped, "hosts files loaded");
*self.table.write().unwrap_or_else(|e| e.into_inner()) = Arc::new(table);
true
}
}
fn load(files: &[PathBuf], domain: Option<&Name>) -> HostsTable {
let mut t = HostsTable::default();
for f in files {
match read(f) {
Ok(text) => t.parse_into(&text, domain),
Err(e) => tracing::warn!(file = %f.display(), error = %e, "hosts file not readable"),
}
}
t
}
/// Hosts files are small; refuse absurd sizes instead of exhausting memory.
const MAX_FILE: u64 = 64 << 20;
fn read(p: &Path) -> std::io::Result<String> {
let len = std::fs::metadata(p)?.len();
if len > MAX_FILE {
return Err(std::io::Error::other(format!("larger than {} MiB", MAX_FILE >> 20)));
}
let bytes = std::fs::read(p)?;
Ok(String::from_utf8_lossy(&bytes).into_owned())
}
#[cfg(test)]
mod tests {
use super::*;
fn n(s: &str) -> Name {
dns_core::names::parse_name(s).unwrap()
}
const HOSTS: &str = "\
127.0.0.1\tlocalhost
::1 localhost ip6-localhost ip6-loopback
# comment line
192.168.1.10 nas nas.home # trailing comment
192.168.1.11 NAS # second address for the same name
fd00::10 nas
fe80::1%eth0 router
0.0.0.0 ads.example.com
not-an-ip broken
10.0.0.1
";
#[test]
fn parses_names_aliases_and_comments() {
let mut t = HostsTable::default();
t.parse_into(HOSTS, None);
let a = t.lookup(&n("nas"), RecordType::A, 0).unwrap();
assert_eq!(a.len(), 2);
let aaaa = t.lookup(&n("NAS."), RecordType::AAAA, 0).unwrap();
assert_eq!(aaaa.len(), 1);
assert_eq!(t.lookup(&n("nas.home"), RecordType::A, 0).unwrap().len(), 1);
assert_eq!(t.lookup(&n("ip6-localhost"), RecordType::AAAA, 0).unwrap().len(), 1);
assert_eq!(t.lookup(&n("router"), RecordType::AAAA, 0).unwrap().len(), 1);
assert_eq!(t.lookup(&n("ads.example.com"), RecordType::A, 0).unwrap().len(), 1);
assert_eq!(t.skipped, 2);
assert!(t.lookup(&n("example.com"), RecordType::A, 0).is_none());
}
#[test]
fn known_name_without_data_is_nodata() {
let mut t = HostsTable::default();
t.parse_into("192.168.1.10 printer\n", None);
assert_eq!(t.lookup(&n("printer"), RecordType::AAAA, 0), Some(vec![]));
assert_eq!(t.lookup(&n("printer"), RecordType::MX, 0), Some(vec![]));
assert_eq!(t.lookup(&n("printer"), RecordType::ANY, 0).unwrap().len(), 1);
}
#[test]
fn ptr_uses_first_name_and_first_line() {
let mut t = HostsTable::default();
t.parse_into("192.168.1.10 nas nas.home\n192.168.1.10 other\n0.0.0.0 blocked\n", None);
let r = t.lookup(&n("10.1.168.192.in-addr.arpa"), RecordType::PTR, 0).unwrap();
assert_eq!(r.len(), 1);
assert_eq!(r[0].data, RData::PTR(PTR(n("nas"))));
assert!(t.lookup(&dns_core::names::reverse_name("0.0.0.0".parse().unwrap()), RecordType::PTR, 0).is_none());
let v6 = dns_core::names::reverse_name("fd00::10".parse().unwrap());
assert!(t.lookup(&v6, RecordType::PTR, 0).is_none());
}
#[test]
fn domain_expands_bare_names() {
let mut t = HostsTable::default();
t.parse_into("192.168.1.10 nas\n192.168.1.20 tv.other\n", Some(&n("lan")));
assert!(t.lookup(&n("nas"), RecordType::A, 0).is_some());
assert!(t.lookup(&n("nas.lan"), RecordType::A, 0).is_some());
assert!(t.lookup(&n("tv.other.lan"), RecordType::A, 0).is_none());
let r = t.lookup(&n("10.1.168.192.in-addr.arpa"), RecordType::PTR, 0).unwrap();
assert_eq!(r[0].data, RData::PTR(PTR(n("nas.lan"))));
}
#[test]
fn ttl_is_applied() {
let mut t = HostsTable::default();
t.parse_into("192.168.1.10 nas\n", None);
assert_eq!(t.lookup(&n("nas"), RecordType::A, 42).unwrap()[0].ttl, 42);
}
#[test]
fn store_reloads_on_change() {
let d = std::env::temp_dir().join(format!("edns-hosts-{}", std::process::id()));
std::fs::create_dir_all(&d).unwrap();
let f = d.join("hosts");
std::fs::write(&f, "192.168.1.10 nas\n").unwrap();
let mut cfg = Config::default();
cfg.hosts.files = vec![f.display().to_string(), d.join("missing").display().to_string()];
let s = HostsStore::build(Arc::new(cfg)).unwrap();
assert!(s.table().lookup(&n("nas"), RecordType::A, 0).is_some());
assert!(!s.refresh(false), "unchanged files are not re-read");
std::fs::write(&f, "192.168.1.10 nas\n192.168.1.11 tv\n").unwrap();
assert!(s.refresh(false));
assert!(s.table().lookup(&n("tv"), RecordType::A, 0).is_some());
let _ = std::fs::remove_dir_all(&d);
}
}
+3 -1
View File
@@ -4,7 +4,8 @@
//! 1. parse / FORMERR, drop responses, rate limit (UDP),
//! 2. TSIG verification, opcode dispatch (QUERY / NOTIFY / UPDATE),
//! 3. zone transfers (AXFR/IXFR) with ACL + TSIG,
//! 4. most specific local authoritative zone visible in the client's view → AA answer,
//! 4. names from hosts files (`hosts.files`, for clients allowed to resolve) → AA answer,
//! then the most specific local authoritative zone visible in the client's view → AA answer,
//! 5. clients without recursion permission → REFUSED (no open resolver, no leaks),
//! 6. local-only names (RFC 6761/6303) → NXDOMAIN without leaving the host,
//! 7. allow/block policy,
@@ -16,6 +17,7 @@ pub mod audit;
pub mod check;
pub mod coalesce;
pub mod handler;
pub mod hosts;
pub mod listener;
pub mod packet_cache;
pub mod router;
+6 -1
View File
@@ -26,6 +26,8 @@ pub struct Runtime {
pub local_only: SuffixSet,
pub router: Router,
pub resolver: Option<Arc<dns_recursive::Resolver>>,
/// Hosts files (`hosts:`), answered before local zones.
pub hosts: crate::hosts::HostsStore,
}
impl Runtime {
@@ -67,9 +69,12 @@ impl Runtime {
let ratelimit = RateLimiter::from_config(&cfg)?;
let policy = BlockPolicy::from_config(&cfg)?;
let recursion_acl = Acl(cfg.expand_acl(&cfg.recursion.allowed_clients)?);
let cfg = Arc::new(cfg);
let hosts = crate::hosts::HostsStore::build(Arc::clone(&cfg))?;
// Zones last: building the store has side effects (stopping removed secondaries).
let (zones, fresh) = ZoneStore::build(&cfg, &ring, previous.map(|p| p.zones.as_ref()))?;
let rt = Runtime {
hosts,
recursion_acl,
views,
ratelimit,
@@ -79,7 +84,7 @@ impl Runtime {
resolver,
zones: Arc::new(zones),
ring,
cfg: Arc::new(cfg),
cfg,
};
Ok((rt, fresh))
}
+26
View File
@@ -130,6 +130,32 @@ impl Server {
}
}));
}
// Hosts files: re-read when they change (modification time / size).
{
let shared = Arc::clone(&shared);
let mut rx = rx.clone();
tasks.push(tokio::spawn(async move {
loop {
let rt = shared.rt();
let interval = rt.cfg.hosts.reload_interval;
let active = rt.hosts.enabled() && !interval.is_zero();
drop(rt);
tokio::select! {
_ = tokio::time::sleep(if active { interval } else { Duration::from_secs(5) }) => {}
_ = rx.changed() => return,
}
if !active {
continue;
}
let rt = shared.rt();
let changed = tokio::task::spawn_blocking(move || rt.hosts.refresh(false)).await.unwrap_or(false);
if changed {
// cached answers may contain the old addresses
shared.packet_cache.invalidate();
}
}
}));
}
// Upstream health checks.
{
let shared = Arc::clone(&shared);
+130
View File
@@ -0,0 +1,130 @@
//! Hosts files (`hosts:`): dnsmasq-style answers before local zones and forwarding.
#![allow(clippy::unwrap_used, clippy::expect_used)]
mod common;
use std::time::Duration;
use common::*;
use dns_core::proto::op::ResponseCode;
use dns_core::proto::rr::RecordType;
/// Upstream: an authoritative server for `example.org`.
async fn upstream(dir: &std::path::Path, port: u16) -> dns_server::ServerHandle {
let d = dir.join("upstream");
std::fs::create_dir_all(&d).unwrap();
write(
&d,
"example.zone",
"$TTL 300\n@ SOA ns hm 1 3600 600 86400 300\n@ NS ns\nns A 127.0.0.3\nwww A 203.0.113.80\noverride A 203.0.113.99\n",
);
start(
&d,
&format!(
"server: {{ listen: [\"127.0.0.3:{port}\"], data_dir: data }}\napi: {{ enabled: false }}\nrate_limit: {{ enabled: false }}\n\
zones:\n - {{ name: example.org, type: primary, file: ../example.zone }}\n"
),
)
.await
}
fn forwarder_yaml(port: u16, upstream_port: u16, extra: &str) -> String {
format!(
"server: {{ mode: hybrid, listen: [\"127.0.0.2:{port}\"], data_dir: data }}\napi: {{ enabled: false }}\n\
rate_limit: {{ enabled: false }}\nupstreams: {{ servers: [\"127.0.0.3:{upstream_port}\"] }}\n\
resolution: {{ default: forward }}\n{extra}"
)
}
#[tokio::test(flavor = "multi_thread")]
async fn hosts_answer_first_then_forward() {
let dir = tmpdir("hosts");
let (port, up_port) = (free_port(), free_port());
let _up = upstream(&dir, up_port).await;
write(
&dir,
"hosts",
"127.0.0.1 localhost\n192.168.1.10 nas nas.home\nfd00::10 nas\n192.168.1.50 override.example.org\n10.9.9.9 shadow.local.example.net\n",
);
write(
&dir,
"local.zone",
"$TTL 300\n@ SOA ns hm 1 3600 600 86400 300\n@ NS ns\nns A 127.0.0.2\nshadow A 10.0.0.1\nzoneonly A 10.0.0.2\n",
);
let yaml = forwarder_yaml(
port,
up_port,
"recursion: { allowed_clients: [\"127.0.0.0/8\"] }\n\
hosts: { files: [hosts, missing.hosts], ttl: 30, domain: lan, reload_interval: 100ms }\n\
zones:\n - { name: local.example.net, type: primary, file: ../local.zone }\n",
);
let s = start(&dir, &yaml).await;
let addr = s.bound.dns[0];
// names from the hosts file, with the domain appended to bare names
let m = q(addr, "nas.", RecordType::A).await;
assert_eq!(answers(&m), vec!["A 192.168.1.10"]);
assert!(m.metadata.authoritative);
assert_eq!(m.answers[0].ttl, 30);
assert_eq!(answers(&q(addr, "nas.lan.", RecordType::A).await), vec!["A 192.168.1.10"]);
assert_eq!(answers(&q(addr, "nas.home.", RecordType::AAAA).await), Vec::<String>::new());
assert_eq!(answers(&q(addr, "nas.", RecordType::AAAA).await), vec!["AAAA fd00::10"]);
// known name, no data of that type: NODATA, not forwarded
let m = q(addr, "nas.", RecordType::MX).await;
assert_eq!(m.metadata.response_code, ResponseCode::NoError);
assert!(m.answers.is_empty());
// reverse lookup from the same file (private range would otherwise be NXDOMAIN locally)
let m = q(addr, "10.1.168.192.in-addr.arpa.", RecordType::PTR).await;
assert_eq!(answers(&m), vec!["PTR nas.lan."]);
// hosts override both the upstream and local zones
assert_eq!(answers(&q(addr, "override.example.org.", RecordType::A).await), vec!["A 192.168.1.50"]);
assert_eq!(answers(&q(addr, "shadow.local.example.net.", RecordType::A).await), vec!["A 10.9.9.9"]);
assert_eq!(answers(&q(addr, "zoneonly.local.example.net.", RecordType::A).await), vec!["A 10.0.0.2"]);
// everything else goes on to the upstream
assert_eq!(answers(&q(addr, "www.example.org.", RecordType::A).await), vec!["A 203.0.113.80"]);
// edits are picked up without a reload
write(&dir, "hosts", "192.168.1.11 nas\n192.168.1.60 tv\n");
eventually("hosts file change", || async { answers(&q(addr, "tv.", RecordType::A).await) == vec!["A 192.168.1.60"] }).await;
assert_eq!(answers(&q(addr, "nas.", RecordType::A).await), vec!["A 192.168.1.11"]);
// removed name falls through to the upstream again
assert_eq!(answers(&q(addr, "override.example.org.", RecordType::A).await), vec!["A 203.0.113.99"]);
// a file that appears later is read too
write(&dir, "missing.hosts", "192.168.1.70 printer\n");
eventually("new hosts file", || async { answers(&q(addr, "printer.", RecordType::A).await) == vec!["A 192.168.1.70"] }).await;
s.shutdown().await;
}
#[tokio::test(flavor = "multi_thread")]
async fn hosts_not_served_to_clients_without_resolution() {
let dir = tmpdir("hosts-acl");
let (port, up_port) = (free_port(), free_port());
write(&dir, "hosts", "192.168.1.10 nas\n");
let yaml =
forwarder_yaml(port, up_port, "recursion: { allowed_clients: [\"10.0.0.0/8\"] }\nhosts: { files: [hosts], reload_interval: 0s }\n");
let s = start(&dir, &yaml).await;
let m = q(s.bound.dns[0], "nas.", RecordType::A).await;
assert_eq!(m.metadata.response_code, ResponseCode::Refused);
tokio::time::sleep(Duration::from_millis(10)).await;
s.shutdown().await;
}
#[tokio::test(flavor = "multi_thread")]
async fn hosts_follow_reload() {
let dir = tmpdir("hosts-reload");
let (port, up_port) = (free_port(), free_port());
write(&dir, "a.hosts", "192.168.1.10 nas\n");
write(&dir, "b.hosts", "192.168.1.20 nas\n");
let base = "recursion: { allowed_clients: [\"127.0.0.0/8\"] }\n";
let s = start(&dir, &forwarder_yaml(port, up_port, &format!("{base}hosts: {{ files: [a.hosts], reload_interval: 0s }}\n"))).await;
let addr = s.bound.dns[0];
assert_eq!(answers(&q(addr, "nas.", RecordType::A).await), vec!["A 192.168.1.10"]);
write(&dir, "config.yaml", &forwarder_yaml(port, up_port, &format!("{base}hosts: {{ files: [\"*.hosts\"], reload_interval: 0s }}\n")));
s.reload().unwrap();
assert_eq!(answers(&q(addr, "nas.", RecordType::A).await), vec!["A 192.168.1.10", "A 192.168.1.20"]);
s.shutdown().await;
}
+1 -1
View File
@@ -11,7 +11,7 @@ RUN cargo build --release --locked -p dns-cli -p dns-tools \
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates libcap2-bin && rm -rf /var/lib/apt/lists/* \
&& useradd --system --home /etc/easydns/data --shell /usr/sbin/nologin easydns \
&& mkdir -p /etc/easydns/zones.d /etc/easydns/keys.d /etc/easydns/data/zones && chown -R easydns:easydns /etc/easydns/data
&& mkdir -p /etc/easydns/zones.d /etc/easydns/keys.d /etc/easydns/data/zones/primary /etc/easydns/data/zones/secondary && chown -R easydns:easydns /etc/easydns/data
COPY --from=build /out/ /usr/local/bin/
COPY config/root.hints /etc/easydns/root.hints
RUN setcap cap_net_bind_service=+ep /usr/local/bin/easydns
+3 -3
View File
@@ -1,10 +1,10 @@
# syntax=docker/dockerfile:1
# Builds EasyDNS .deb packages inside Docker. Used by scripts/build-deb.sh:
# docker buildx build -f deploy/docker/Dockerfile.deb --platform linux/amd64 \
# --build-arg VERSION=0.1.0 --output type=local,dest=dist .
# --build-arg VERSION=0.1.2 --output type=local,dest=dist .
ARG DEBIAN_RELEASE=bookworm
FROM rust:1-${DEBIAN_RELEASE} AS build
ARG VERSION=0.1.0
ARG VERSION=0.1.2
ARG REVISION=1
ARG TARGETPLATFORM
WORKDIR /src
@@ -30,7 +30,7 @@ RUN --mount=type=cache,target=/usr/local/cargo/registry \
&& cp -r docs config zones /pkg/usr/share/doc/easydns/
FROM debian:${DEBIAN_RELEASE}-slim AS package
ARG VERSION=0.1.0
ARG VERSION=0.1.2
ARG REVISION=1
COPY --from=build /pkg /pkg
COPY deploy/packaging/debian /debian-src
+5 -3
View File
@@ -7,8 +7,10 @@ if [ "$1" = "configure" ]; then
fi
# /etc/easydns: config, zones.d/, keys.d/ (root:easydns, not world-readable – may hold keys)
install -d -o root -g easydns -m 0750 /etc/easydns /etc/easydns/zones.d /etc/easydns/keys.d
# data_dir: zone files (data/zones/), secondary copies, journals, control token
install -d -o easydns -g easydns -m 0750 /etc/easydns/data /etc/easydns/data/zones
# data_dir: zones/primary/ (your zone files), zones/secondary/ (transferred copies),
# zones/signed/ (DNSSEC), journals, control token
install -d -o easydns -g easydns -m 0750 /etc/easydns/data /etc/easydns/data/zones \
/etc/easydns/data/zones/primary /etc/easydns/data/zones/secondary
chgrp easydns /etc/easydns/config.yaml 2>/dev/null || true
chmod 0640 /etc/easydns/config.yaml 2>/dev/null || true
# Short tool names only when the name is free (e.g. `ed` is often the line editor).
@@ -37,7 +39,7 @@ if [ "$1" = "configure" ]; then
fi
elif [ -z "$2" ]; then
echo "EasyDNS installed (hybrid: authoritative + recursive for LAN)."
echo " config: /etc/easydns/config.yaml zones: /etc/easydns/data/zones/"
echo " config: /etc/easydns/config.yaml zones: /etc/easydns/data/zones/primary/"
echo " new zone: easydns zone create example.com --ns ns1.example.com --ip 192.0.2.1"
echo " start: systemctl enable --now easydns then: easydns status"
fi
+2 -2
View File
@@ -1,6 +1,6 @@
# Build .deb and .rpm with nfpm (https://nfpm.goreleaser.com):
# ARCH=amd64 VERSION=0.1.1 nfpm pkg -f deploy/packaging/nfpm.yaml -p deb
# ARCH=arm64 VERSION=0.1.1 nfpm pkg -f deploy/packaging/nfpm.yaml -p rpm
# ARCH=amd64 VERSION=0.1.2 nfpm pkg -f deploy/packaging/nfpm.yaml -p deb
# ARCH=arm64 VERSION=0.1.2 nfpm pkg -f deploy/packaging/nfpm.yaml -p rpm
name: easydns
arch: "${ARCH}"
platform: linux
+1 -1
View File
@@ -2,7 +2,7 @@
# Create the service user and short tool names when they do not collide.
set -e
systemd-sysusers /usr/lib/sysusers.d/easydns.conf 2>/dev/null || true
mkdir -p /etc/easydns/zones.d /etc/easydns/keys.d /etc/easydns/data/zones
mkdir -p /etc/easydns/zones.d /etc/easydns/keys.d /etc/easydns/data/zones/primary /etc/easydns/data/zones/secondary
chown -R easydns:easydns /etc/easydns/data 2>/dev/null || true
chgrp easydns /etc/easydns /etc/easydns/zones.d /etc/easydns/keys.d /etc/easydns/config.yaml 2>/dev/null || true
chmod 0750 /etc/easydns /etc/easydns/zones.d /etc/easydns/keys.d /etc/easydns/data 2>/dev/null || true
-2
View File
@@ -14,8 +14,6 @@ ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
RestartSec=2s
EnvironmentFile=-/etc/easydns/easydns.env
StateDirectory=easydns
StateDirectoryMode=0750
ConfigurationDirectory=easydns
LimitNOFILE=65536
TasksMax=4096
+5 -5
View File
@@ -31,9 +31,9 @@ mkdir -p "$DEV"
[ -f "$DEV/tsig.secret" ] || head -c 32 /dev/urandom | base64 > "$DEV/tsig.secret"
[ -f "$DEV/admin.token" ] || echo "dev-$(head -c 12 /dev/urandom | base64 | tr -dc 'a-zA-Z0-9')" > "$DEV/admin.token"
chmod 600 "$DEV"/*.secret "$DEV"/*.token 2>/dev/null || true
mkdir -p "$DEV/data/zones" # same layout as an installation: zone files in <data_dir>/zones/
[ -f "$DEV/data/zones/example.com.zone" ] || cp "$ROOT/zones/example.com.zone" "$DEV/data/zones/example.com.zone"
[ -f "$DEV/data/zones/reverse.zone" ] || cp "$ROOT/zones/2.0.192.in-addr.arpa.zone" "$DEV/data/zones/reverse.zone"
mkdir -p "$DEV/data/zones/primary" # same layout as an installation: zone files in <data_dir>/zones/primary/
[ -f "$DEV/data/zones/primary/example.com.zone" ] || cp "$ROOT/zones/primary/example.com.zone" "$DEV/data/zones/primary/"
[ -f "$DEV/data/zones/primary/2.0.192.in-addr.arpa.zone" ] || cp "$ROOT/zones/primary/2.0.192.in-addr.arpa.zone" "$DEV/data/zones/primary/"
[ -f "$DEV/block.txt" ] || printf 'ads.example\n*.tracker.example\n' > "$DEV/block.txt"
upstreams_yaml() { local IFS=,; for u in $UPSTREAMS; do printf '"%s", ' "$u"; done | sed 's/, $//'; }
@@ -49,14 +49,14 @@ recursion: { enabled: true, allowed_clients: ["127.0.0.0/8", "::1/128"], dnssec_
zones:
- name: example.com
type: primary
file: zones/example.com.zone
file: zones/primary/example.com.zone
transfer_acl: ["127.0.0.1/32"]
transfer_tsig_key: xfr-key
notify: ["127.0.0.1:$((PORT+1))"]
notify_tsig_key: xfr-key
update_keys: [xfr-key]
update_acl: ["127.0.0.1/32"]$dnssec
- { name: 2.0.192.in-addr.arpa, type: primary, file: zones/reverse.zone }
- { name: 2.0.192.in-addr.arpa, type: primary, file: zones/primary/2.0.192.in-addr.arpa.zone }
forward_zones: []
upstreams: { strategy: fastest, servers: [$(upstreams_yaml)] }
resolution: { default: recursive }
+3 -2
View File
@@ -60,16 +60,17 @@ journal (IXFR then falls back to AXFR); snapshots are plain zone files.
| Path (`data_dir`) | Content |
|---|---|
| `zones/primary/<zone>.zone` | primary zone files (operator, `zone create`, API, DDNS) |
| `zones/secondary/<zone>.zone` + `.meta.json` | last valid secondary copy + last successful refresh |
| `zones/signed/<zone>.zone` | last signed version of DNSSEC zones (keeps signatures stable across restarts) |
| `journal/<zone>.jnl` | IXFR differences |
| `signed/<zone>.zone` | last signed version of DNSSEC zones (keeps signatures stable across restarts) |
| `zones/` | zones created via the API |
| `api-overlay.yaml` | API changes (zones, upstreams, allowlist, block rules) merged on load |
| `blocklists/` | downloaded/API block lists |
| `audit.log` | JSON lines of administrative actions |
## Hybrid decision order
0. hosts files (`hosts.files`), for clients allowed to resolve → AA answer, NODATA for other types;
1. local authoritative zone (most specific, visible in the client's view) → AA answer;
2. client not allowed to recurse → REFUSED;
3. local-only names (RFC 6761/6303, configurable) → NXDOMAIN, never sent out;
+4 -4
View File
@@ -31,8 +31,8 @@ server, mode 0640, readable by root and the `easydns` group). So after installat
### Creating a zone
`easydns zone create` writes a minimal, valid primary zone – SOA, NS, glue for in-zone
name servers and optional apex addresses – into `<data_dir>/zones/<zone>.zone`
(`/etc/easydns/data/zones/`) and its definition into `/etc/easydns/zones.d/<zone>.yaml`.
name servers and optional apex addresses – into `<data_dir>/zones/primary/<zone>.zone`
(`/etc/easydns/data/zones/primary/`) and its definition into `/etc/easydns/zones.d/<zone>.yaml`.
The zone is parsed and validated before anything is written; existing files are never
overwritten without `--force`.
@@ -66,7 +66,7 @@ ns1 IN A 192.0.2.10
# /etc/easydns/zones.d/example.com.yaml
- name: example.com
type: primary
file: zones/example.com.zone
file: zones/primary/example.com.zone
```
| Option | Meaning (default) |
@@ -99,7 +99,7 @@ output is structured. Exit codes: 0 success (a DNS answer, also NXDOMAIN for `ed
| `etrace` / `easytrace` | dig +trace | `etrace example.com --dnssec --json` |
| `ednssec` / `easydnssec` | delv | `ednssec example.com A -v` (secure/insecure/bogus with reason; exit 2 = bogus) |
| `eptr` / `easyptr` | dig -x | `eptr 192.0.2.1 2001:db8::1 --verify` (forward-confirmed) |
| `ezone` / `easyzone` | named-checkzone | `ezone check zones/example.com.zone --origin example.com`, `ezone validate --all -c config.yaml`, `ezone canonical ...` |
| `ezone` / `easyzone` | named-checkzone | `ezone check zones/primary/example.com.zone --origin example.com`, `ezone validate --all -c config.yaml`, `ezone canonical ...` |
| `econf` / `easyconf` | named-checkconf | `econf check config.yaml`, `econf print config.yaml` |
| `ebench` / `easybench` | dnsperf | `ebench @127.0.0.1 --qps 1000 --duration 30s -c 50 -d queries.txt` (high load needs `--i-own-this-server`) |
| `ediff` / `easydiff` | – | `ediff example.com MX @1.1.1.1 @8.8.8.8 --json` (order-insensitive, TTL shown not compared) |
+22 -6
View File
@@ -15,11 +15,15 @@ Validate offline: `easydns check-config -c config.yaml` or `econf check config.y
| `/etc/easydns/zones.d/*.yaml` | zone definitions, one file per zone (`easydns zone create` writes here) | root:easydns 0750 |
| `/etc/easydns/keys.d/*.conf` | TSIG keys – BIND `key "…" { … };` files copied unchanged | root:easydns 0640 |
| `/etc/easydns/data/` | `server.data_dir`: everything the server writes | easydns:easydns 0750 |
| `/etc/easydns/data/zones/` | zone files of primary zones (`file: zones/example.com.zone`) | easydns |
| `/etc/easydns/data/zones/secondary/` | copies of secondary zones (+ `.meta.json`) | easydns |
| `/etc/easydns/data/zones/primary/` | **your** primary zone files (`file: zones/primary/example.com.zone`); `zone create`, the API and DDNS write here too – back them up | easydns |
| `/etc/easydns/data/zones/secondary/` | copies of secondary zones (+ `.meta.json`) – recreated by a transfer | easydns |
| `/etc/easydns/data/zones/signed/` | signed versions of DNSSEC zones – recreated by signing | easydns |
| `/etc/easydns/data/journal/` | IXFR journals | easydns |
| `/etc/easydns/data/control.token` | local admin token for the CLI | easydns 0640 |
| `/etc/easydns/data/audit.log`, `api-overlay.yaml`, `signed/` | audit trail, API changes, signed zones | easydns |
| `/etc/easydns/data/audit.log`, `api-overlay.yaml`, `blocklists/` | audit trail, API changes, downloaded block lists | easydns |
In short: `/etc/easydns/` is configuration you write, `data/zones/primary/` is zone data
you own, everything else under `data/` is created by the server.
The default configuration runs a **hybrid** node: authoritative for the zones in
`zones.d/`, recursive resolver for `acls.lan` (`192.168.0.0/16`, `10.0.0.0/8`,
@@ -28,8 +32,10 @@ The default configuration runs a **hybrid** node: authoritative for the zones in
## Zone file paths
A relative zone `file:` is relative to `server.data_dir`: `file: zones/example.com.zone`
is `/etc/easydns/data/zones/example.com.zone`. Absolute paths are used as they are.
A relative zone `file:` is relative to `server.data_dir`: `file: zones/primary/example.com.zone`
is `/etc/easydns/data/zones/primary/example.com.zone`. Absolute paths are used as they are,
and any other relative path works too – `zones/primary/` is the convention used by
`easydns zone create`, the API and the examples, not a requirement.
(Older configurations whose relative paths point next to the config file keep working:
if the file is not found under `data_dir` but exists relative to the configuration
directory, that one is used.)
@@ -144,7 +150,7 @@ recursion:
zones: # see primary.md / secondary.md
- name: example.com
type: primary
file: zones/example.com.zone # relative to data_dir
file: zones/primary/example.com.zone # relative to data_dir
transfer_acl: [] # IPs allowed to AXFR/IXFR
transfer_tsig_key: null # optional key for transfers
notify: [] # secondaries to NOTIFY
@@ -165,6 +171,7 @@ cache: { enabled: true, max_entries: 100000, min_ttl: 0, max_ttl: 86400, max_neg
prefetch: true } # refresh popular resolver entries before they expire
policy: { blocklists: [ { name, file|url, category, enabled } ], allowlist: [], block_action: nxdomain|refused|null|address,
block_address_v4: 0.0.0.0, block_address_v6: "::", block_ttl: 60, exempt_clients: [], log_blocked: true }
hosts: { files: [], ttl: 0, domain: null, reload_interval: 5s } # /etc/hosts-format files answered first (dnsmasq style), see hosts.md
rate_limit: { enabled: true, per_client_qps: 200, burst: 400, global_qps: 0, slip: 2, exempt_clients: [loopback] } # global_qps 0 = no server-wide cap
tls: { cert_file, key_file, dot_listen: [], doh_listen: [], doh_plaintext_behind_proxy: false } # certificate files re-read within 60 s of a change
api: { enabled: true, listen: 127.0.0.1:9953, auth_required: true, local_token: true, tokens: [], allowed_clients: [loopback], requests_per_minute: 600 }
@@ -190,6 +197,15 @@ hits are answered directly in the receive loop (batched with `sendmmsg` on Linux
* Memory: about 0.3–1 KiB per entry (20 000 entries ≈ 6–20 MB at most).
* Metrics: `dns_answer_cache_hits_total`, `…_misses_total`, `…_inserts_total`, `dns_answer_cache_entries`.
### Hosts files (`hosts`)
`hosts.files: ["/etc/hosts"]` answers the names in those files (A, AAAA and PTR) before
local zones, block lists, forwarding and recursion – the dnsmasq behaviour. A name that
is in the files but lacks the asked type gets NODATA and is not forwarded. Only clients
in `recursion.allowed_clients` get these answers. `domain: lan` also answers bare names
as `<name>.lan`; files are re-read automatically every `reload_interval` when they
change. Details and a dnsmasq translation table: [hosts.md](hosts.md).
## Upstream syntax
`1.1.1.1`, `1.1.1.1:53`, `[2606:4700::1111]:53`, `tcp://1.1.1.1`,
+15 -4
View File
@@ -35,7 +35,7 @@ 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:
creates `/etc/easydns/{zones.d,keys.d,data/zones/primary,data/zones/secondary}` and the `easydns` user. Layout:
[configuration.md](configuration.md#default-installation-layout). Example configurations
are in `/usr/share/doc/easydns/examples/`.
@@ -72,8 +72,19 @@ sudo apt update && sudo apt install -o Dpkg::Options::=--force-confold easydns
* 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.
* Files the server keeps are moved automatically on the first start: secondary copies
`data/secondary/` → `data/zones/secondary/` (0.1.1) and signed zones `data/signed/` →
`data/zones/signed/` (0.1.2), so zones are served at once and signatures are reused.
* Your own primary zone files are **not** moved: `file:` in `zones.d/` points at them and
keeps working. To adopt the 0.1.2 layout (`data/zones/primary/`), move them and fix the
paths, then reload:
```bash
sudo -u easydns sh -c 'cd /etc/easydns/data/zones && mkdir -p primary && mv -- *.zone primary/'
sudo sed -i 's|file: zones/\([^/ ]*\.zone\)|file: zones/primary/\1|' /etc/easydns/zones.d/*.yaml /etc/easydns/config.yaml
sudo easydns check-config && sudo easydns reload
```
Zones created through the API keep their absolute path in `data/api-overlay.yaml`; new
ones go to `zones/primary/`.
* 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`).
@@ -83,7 +94,7 @@ sudo apt update && sudo apt install -o Dpkg::Options::=--force-confold easydns
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 -d -o easydns -g easydns -m 0750 /etc/easydns/data /etc/easydns/data/zones /etc/easydns/data/zones/primary
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
+4 -4
View File
@@ -40,7 +40,7 @@ emergency rollover; a leaked key lets others sign data for your domain.
```yaml
- name: example.com
type: primary
file: zones/example.com.zone # stays unsigned – keep editing it as before
file: zones/primary/example.com.zone # stays unsigned – keep editing it as before
transfer_acl: ["198.51.100.20"]
notify: ["198.51.100.20:53"]
dnssec:
@@ -51,7 +51,7 @@ emergency rollover; a leaked key lets others sign data for your domain.
sudo easydns check-config && sudo easydns reload
```
EasyDNS adds DNSKEY, NSEC and RRSIG records, bumps the serial, stores the signed copy in
`/etc/easydns/data/signed/` and sends NOTIFY, so the secondaries transfer the signed zone.
`/etc/easydns/data/zones/signed/` and sends NOTIFY, so the secondaries transfer the signed zone.
(If the key directory is empty, `auto_generate: true` creates the key at this point –
step 1 is then optional; get the DS with step 4.)
@@ -160,7 +160,7 @@ primary, remove the old DS) – see [migration-from-bind.md](migration-from-bind
zones:
- name: example.com
type: primary
file: zones/example.com.zone # stays unsigned
file: zones/primary/example.com.zone # stays unsigned
dnssec:
keys_dir: /etc/easydns/data/keys/example.com
algorithm: ed25519 # ed25519 | ecdsap256 | ecdsap384 (13 = ecdsap256 is the most widely accepted by registrars)
@@ -177,7 +177,7 @@ zones:
NODATA, wildcard expansions and unsigned delegations.
* Every change (file reload, API, DDNS) re-signs and bumps the serial; an hourly task
re-signs when signatures expire within `resign_before`. The signed zone is persisted in
`<data_dir>/signed/` so a restart does not produce new signatures under the same serial.
`<data_dir>/zones/signed/` so a restart does not produce new signatures under the same serial.
* Rollover: add the new key file, reload (both keys published and used), wait DNSKEY TTL
(+ parent DS TTL for KSKs, after updating the DS), remove the old key file, reload.
* Secondaries simply transfer the signed zone (signing on secondaries is rejected).
+194
View File
@@ -0,0 +1,194 @@
# Hosts files (local names, dnsmasq style)
EasyDNS can answer names from files in `/etc/hosts` format, the way dnsmasq does by
default. A name found there is answered **locally and first** – before local zones, the
block lists, forwarding and recursion. Everything else continues to the usual resolution.
```yaml
hosts:
files: ["/etc/hosts"] # [] (off)
ttl: 0 # [0] TTL of the answers, like dnsmasq local-ttl
domain: lan # [none] also answer bare names as <name>.lan
reload_interval: 5s # [5s] check the files for changes; 0s = only on reload
```
The feature is off while `files` is empty.
## File format
The standard hosts format, one address per line, followed by one or more names:
```
# /etc/hosts
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
192.168.1.1 router gw
192.168.1.10 nas nas.home # comments are allowed at the end of a line
fd00::10 nas
192.168.1.50 git.linuxiarz.pl # override a public name inside the LAN
```
* IPv4 and IPv6 addresses; a link-local zone index (`fe80::1%eth0`) is ignored,
IPv4-mapped addresses (`::ffff:192.0.2.1`) are treated as IPv4.
* All names on a line get the address (A or AAAA). The same name may appear on several
lines; all its addresses are returned (duplicates are removed).
* Names are case-insensitive. Lines that do not parse are skipped and counted in the
`hosts files loaded … skipped_lines=N` log message.
* Files are read as UTF-8 (invalid bytes are replaced); files over 64 MiB are refused.
## Answers
| Query | Answer |
| --- | --- |
| `A` / `AAAA` for a name in the files | its addresses of that family, AA flag set, TTL = `hosts.ttl` |
| `A` for a name that has only IPv6 addresses (or the reverse), or any other type (`MX`, `TXT`, …) | **NODATA** (NOERROR, empty answer) – the question is not forwarded |
| `ANY` | all A and AAAA addresses of the name |
| `PTR` for an address from the files | the **first name** of the **first line** with that address (as glibc and dnsmasq do); with `domain:` set, a bare name is returned qualified (`nas.lan.`) |
| a name not in the files | normal processing: local zones, policy, forwarding, recursion |
`0.0.0.0` / `::` lines are answered as written (handy for blocking a name), but no PTR
record is made for them.
The NODATA rule means a name in the hosts files "owns" the name: an `AAAA` query for an
IPv4-only host returns an empty answer at once instead of a slow or misleading upstream
lookup. This is what dnsmasq does as well.
## Bare names and `domain`
A name without a dot (`nas`) is answered as `nas.` – clients that try the plain name, and
dnsmasq-style setups that rely on it, work unchanged.
With `domain: lan`, every bare name is also answered as `<name>.lan` (dnsmasq
`expand-hosts` + `domain=lan`). Names that already contain a dot are not changed. To make
the whole domain local – unknown `*.lan` names get NXDOMAIN and are never sent to the
Internet, like dnsmasq `local=/lan/` – also list it in `recursion.local_only_suffixes`:
```yaml
hosts: { files: ["/etc/hosts"], domain: lan }
recursion:
local_only_suffixes: [lan]
```
(Names such as `local`, `home.arpa`, `test`, `localhost` and the private reverse zones are
local-only already; see [hybrid.md](hybrid.md).)
## Several files and globs
```yaml
hosts:
files:
- /etc/hosts
- /etc/easydns/hosts.d/*.hosts # dnsmasq addn-hosts / hostsdir
- lan.hosts # relative to the directory of config.yaml
```
* `*` and `?` are allowed in the file name (not in directory names). Hidden files (`.x`)
and editor backups (`x~`) are ignored; matching files are read in alphabetical order.
* A missing file is not an error: `check-config` reports a warning and the file is read
as soon as it appears. A glob that matches nothing is simply empty.
* Files are read in the order listed; for PTR records the first line wins across all files.
## Who gets these answers
Hosts answers are given to clients that may resolve, i.e. clients in
`recursion.allowed_clients` (the same list that controls forwarding and recursion).
Other clients – for example the Internet asking an authoritative server – never see the
contents of the hosts files; they get the usual answer (local zone or REFUSED).
Precedence for allowed clients:
1. **hosts files**
2. local authoritative zones (most specific zone in the client's view)
3. local-only names (RFC 6761/6303 and `recursion.local_only_suffixes`) → NXDOMAIN
4. allow/block policy
5. conditional forwarding, then the default resolution
Hosts entries therefore win over a zone that contains the same name and are **not**
subject to the block lists (they are your own data, like zone records). A name that
leaves a local zone through a CNAME is looked up in the hosts files too before it is
forwarded.
## Changes and reload
* Every `reload_interval` (default 5 s) EasyDNS compares the modification time and size
of the files (and the list of files matched by the globs). On a change the files are
re-read in the background and swapped in atomically; cached answers are dropped at once.
No restart or reload is needed after editing `/etc/hosts`.
* `reload_interval: 0s` turns the check off; the files are then read at start and on
`easydns reload` / `systemctl reload easydns` / `kill -HUP` (dnsmasq behaviour).
* A configuration reload always re-reads the files.
Log line after each load:
```
INFO hosts files loaded files=2 names=17 skipped_lines=0
```
## Checking
```sh
easydig @127.0.0.1 nas A
easydig @127.0.0.1 nas.lan AAAA
easydig @127.0.0.1 -x 192.168.1.10
```
With `logging.query_log: true` these answers are logged with `source=local
note="hosts file"`.
## Migrating from dnsmasq
| dnsmasq | EasyDNS |
| --- | --- |
| reads `/etc/hosts` (default) | `hosts: { files: ["/etc/hosts"] }` |
| `no-hosts` | leave `hosts.files` empty (default) |
| `addn-hosts=/path/file` | add the file to `hosts.files` |
| `hostsdir=/path` | `hosts.files: ["/path/*"]` (re-read automatically) |
| `expand-hosts` + `domain=lan` | `hosts.domain: lan` |
| `local=/lan/` | `recursion.local_only_suffixes: [lan]` |
| `local-ttl=N` | `hosts.ttl: N` |
| `server=127.0.0.1#55` | `upstreams.servers: ["127.0.0.1:55"]` + `resolution.default: forward` |
| `server=/corp/10.0.0.1` | `forward_zones: [{ domain: corp, upstreams: ["10.0.0.1"] }]` |
| `no-resolv` | (EasyDNS never reads `/etc/resolv.conf`) |
| `port=54`, `listen-address=0.0.0.0`, `bind-interfaces` | `server.listen: ["0.0.0.0:54"]` |
| `bogus-priv` | built in: private reverse zones are local-only (RFC 6303) |
| `dnssec` | `recursion.dnssec_validation: true` (validation applies to recursion) |
| `clear-on-reload` | a configuration reload drops the answer cache; `easydns cache clear` empties the resolver cache |
| `enable-ra`, DHCP | not provided – EasyDNS is a DNS server only |
Example – a dnsmasq forwarder on port 54 in front of a resolver on 127.0.0.1:55,
answering `/etc/hosts` first:
```yaml
server:
mode: forwarder
listen: ["0.0.0.0:54"]
recursion:
allowed_clients: ["acl:lan", "::1/128"]
acls:
lan: ["192.168.0.0/16", "10.0.0.0/8", "127.0.0.1/32"]
hosts:
files: ["/etc/hosts"]
resolution:
default: forward
upstreams:
servers: ["127.0.0.1:55"]
```
## Docker
Inside a container `/etc/hosts` is the container's own file. Mount the host's file (or a
dedicated one) read-only and point `hosts.files` at it:
```yaml
volumes:
- /etc/hosts:/etc/easydns/hosts:ro
```
```yaml
hosts: { files: ["/etc/easydns/hosts"] }
```
A single-file bind mount keeps the original inode; editors that replace the file (write
a new file and rename it) break such a mount. Mount a directory instead
(`./hosts.d:/etc/easydns/hosts.d:ro` with `files: ["/etc/easydns/hosts.d/*"]`) if the
file is edited on the host.
+3 -1
View File
@@ -6,7 +6,7 @@ and recurse for everything else:
```yaml
recursion: { enabled: true, allowed_clients: ["acl:lan"] }
zones:
- { name: example.com, type: primary, file: zones/example.com.zone }
- { name: example.com, type: primary, file: zones/primary/example.com.zone }
- { name: example.net, type: secondary, primaries: ["192.0.2.10:53"] }
forward_zones:
- { domain: corp.internal, upstreams: ["10.0.0.53"] }
@@ -19,6 +19,8 @@ resolution:
## Precedence (tested in `crates/dns-server/tests/resolver.rs`)
0. **Hosts files** (`hosts.files`, only for clients in `recursion.allowed_clients`) – a name
listed there is answered from the files (NODATA for other types); see [hosts.md](hosts.md).
1. **Local authoritative zones** – the most specific zone visible in the client's view wins
(`example.com` beats a forward rule for `com`); NXDOMAIN inside a local zone is final and
the name is never sent upstream.
+2 -2
View File
@@ -14,7 +14,7 @@ rndc zonestatus example.com # type, serial, files, signing
| BIND (`named.conf`) | EasyDNS (`config.yaml`) |
|---|---|
| `listen-on port 53 { 192.0.2.1; };` / `listen-on-v6` | `server.listen: ["192.0.2.1:53", "[2001:db8::1]:53"]` |
| `directory "/var/named";` | `server.data_dir` (default install: `/etc/easydns/data`); zone `file:` paths are relative to it (`zones/example.com.zone`) |
| `directory "/var/named";` | `server.data_dir` (default install: `/etc/easydns/data`); zone `file:` paths are relative to it (`zones/primary/example.com.zone`) |
| `key "xfr" { algorithm hmac-sha256; secret "…"; };` | copy the BIND key file unchanged to `/etc/easydns/keys.d/` (included by default), or `keys: [ { name: xfr, secret: "file:…" } ]` |
| `acl lan { 10.0.0.0/8; };` | `acls: { lan: ["10.0.0.0/8"] }`, referenced as `acl:lan` |
| `zone "x" { type master; file "…"; };` | `zones: [ { name: x, type: primary, file: … } ]` |
@@ -105,7 +105,7 @@ secondary of an EasyDNS primary (standard AXFR/IXFR/NOTIFY/TSIG). Useful as a mi
stage: make EasyDNS a secondary first, then promote it (next section).
**Promote an EasyDNS secondary to primary:** copy the snapshot
`<data_dir>/secondary/ZONE.zone` to a zone file, change the zone to `type: primary` with
`<data_dir>/zones/secondary/ZONE.zone` to `<data_dir>/zones/primary/ZONE.zone`, change the zone to `type: primary` with
`file:` pointing to it, reload. The serial continues from the transferred one.
## 3. Recursive resolver (caching resolver for a LAN)
+3 -3
View File
@@ -24,13 +24,13 @@ api: { listen: "127.0.0.1:9953" } # the CLI uses the local control token aut
# /etc/easydns/zones.d/example.com.yaml
- name: example.com
type: primary
file: zones/example.com.zone # = /etc/easydns/data/zones/example.com.zone
file: zones/primary/example.com.zone # = /etc/easydns/data/zones/primary/example.com.zone
transfer_acl: ["198.51.100.20/32"] # IP only; a TSIG key is optional
notify: ["198.51.100.20:53"]
serial_strategy: date # YYYYMMDDnn for API/DDNS changes
```
```
; /etc/easydns/data/zones/example.com.zone
; /etc/easydns/data/zones/primary/example.com.zone
$TTL 3600
@ IN SOA ns1.example.com. hostmaster.example.com. (
2026112101 ; serial
@@ -100,7 +100,7 @@ All authentication variants: [zone-transfer-variants.md](zone-transfer-variants.
| status of all zones | `easydns zones list` / `easydns status` |
| details (serial, last change, errors) | `easydns zones show example.com` |
| force NOTIFY | `easydns zones notify example.com` |
| check a zone before reloading | `easyzone check /etc/easydns/data/zones/example.com.zone -o example.com` |
| check a zone before reloading | `easyzone check /etc/easydns/data/zones/primary/example.com.zone -o example.com` |
| compare primary with secondaries | `easydiff example.com SOA @192.0.2.10 @198.51.100.20` |
| DS for the registrar (signed zone) | `easydns dnssec ds --zone example.com --dir /etc/easydns/data/keys/example.com` |
| audit of changes | `GET /api/v1/audit` or `<data_dir>/audit.log` |
+6 -6
View File
@@ -1,7 +1,7 @@
# Primary (master)
A primary serves zones from zone files (BIND format) stored in
`/etc/easydns/data/zones/`, sends NOTIFY to its secondaries, serves AXFR/IXFR and accepts
`/etc/easydns/data/zones/primary/`, sends NOTIFY to its secondaries, serves AXFR/IXFR and accepts
RFC 2136 dynamic updates when allowed.
## Quick start
@@ -10,7 +10,7 @@ RFC 2136 dynamic updates when allowed.
easydns zone create example.com --ns ns1.example.com=192.0.2.10 --ns ns2.example.net \
--ip 192.0.2.80 --allow-transfer 198.51.100.20 --notify 198.51.100.20 --reload
```
This writes `/etc/easydns/data/zones/example.com.zone` and
This writes `/etc/easydns/data/zones/primary/example.com.zone` and
`/etc/easydns/zones.d/example.com.yaml` (see [cli-tools.md](cli-tools.md#creating-a-zone)).
## Zone definition
@@ -19,7 +19,7 @@ This writes `/etc/easydns/data/zones/example.com.zone` and
zones:
- name: example.com
type: primary
file: zones/example.com.zone # relative to data_dir → /etc/easydns/data/zones/example.com.zone
file: zones/primary/example.com.zone # relative to data_dir → /etc/easydns/data/zones/primary/example.com.zone
transfer_acl: ["198.51.100.20/32"] # secondaries allowed to AXFR/IXFR (default: nobody)
notify: ["198.51.100.20:53"] # NOTIFY after every change
serial_strategy: increment # increment | unixtime | date (YYYYMMDDnn)
@@ -71,7 +71,7 @@ Every accepted and refused update is written to the audit log
```yaml
- name: example.com
type: primary
file: zones/example.com.zone
file: zones/primary/example.com.zone
update_acl: ["198.51.100.50", "203.0.113.2"] # these hosts may change any record
```
```bash
@@ -93,7 +93,7 @@ Internet. `easydns check-config` refuses `update_acl: [any]` without a key.
```yaml
- name: example.com
type: primary
file: zones/example.com.zone
file: zones/primary/example.com.zone
update_keys: [ddns-key]
update_acl: ["192.168.1.0/24"] # optional extra restriction
```
@@ -149,7 +149,7 @@ EasyDNS – `/etc/easydns/zones.d/example.com.yaml`:
```yaml
- name: example.com
type: primary
file: zones/example.com.zone # copy of /etc/bind/example.com.conf into /etc/easydns/data/zones/
file: zones/primary/example.com.zone # copy of /etc/bind/example.com.conf into /etc/easydns/data/zones/primary/
transfer_acl: ["198.51.100.10", "198.51.100.11", "203.0.113.20", "127.0.0.1"]
notify: ["198.51.100.11:53", "203.0.113.20:53"] # notify yes + also-notify
update_policy:
+1
View File
@@ -15,6 +15,7 @@
| Rate limit | 200 qps / client (/32, /56), burst 400, no global cap (`global_qps: 0`), RRL-style slip |
| Listening | `0.0.0.0:53` and `[::1]:53` (default configuration); `[::]` sockets are IPv6-only |
| DoT / DoH | off until `tls.*_listen` is set; TLS 1.2/1.3 only; certificates reloaded on change |
| Hosts files | off (`hosts.files: []`); when set, answered only to clients in `recursion.allowed_clients`, never to other clients |
| Key files | BIND `keys.d/*.conf` read as is; warning when world-readable; installer creates `/etc/easydns` as root:easydns 0750 |
Risky configurations produce validation warnings/errors: open resolver (`any`), transfers
+3 -2
View File
@@ -1,6 +1,6 @@
# Feature status and known gaps (0.1.1)
# Feature status and known gaps (0.1.2)
What EasyDNS 0.1.1 does not do yet, does only partly, or has not been verified outside the
What EasyDNS 0.1.2 does not do yet, does only partly, or has not been verified outside the
automated tests. Everything not listed here is implemented and covered by tests
(see [testing.md](testing.md)). Planned work is in the README roadmap.
@@ -28,6 +28,7 @@ Status: **missing** – not implemented; **partial** – implemented with the li
| Policy | block list update schedule | partial | `easydns blocklists update` + systemd timer; no in-process scheduler |
| Policy | rules by record type | missing | blocking works by name and client, not by type |
| Policy | per-client/per-subnet policies | partial | exemptions (`exempt_clients`) and views for zones; no different block lists per subnet |
| Local data | hosts files (`/etc/hosts`, dnsmasq style) | done | A/AAAA/PTR from hosts-format files before zones and resolution, auto-reload on change; no DHCP-lease names – see [hosts.md](hosts.md) |
| Policy | RPZ | missing | conversion is described in [migration-from-bind.md](migration-from-bind.md) |
| Policy | response rate limiting (RRL) | partial | per client (/32, /56) + global with "slip"; no RRL per (qname, response) |
| Transports | DoH over HTTP/2 | done | server: HTTP/2 + HTTP/1.1 (ALPN), h2c behind a proxy |
+4 -3
View File
@@ -18,13 +18,14 @@ Linux x86_64 container with 2 vCPUs).
| Suite | What it covers |
|---|---|
| `dns-core` unit (20) | RFC 1982 serials + strategies, IDN names, zone file parse/emit incl. DNSKEY/RRSIG/NSEC/NSEC3/NSEC3PARAM/RFC 3597 round trip, TSIG request/response + multi-message chain with unsigned intermediates, UDP truncation, FORMERR, DNSSEC sign/verify/DS/tamper/expiry, NSEC logic, NSEC3 hash (RFC 5155 vector), HTTP parsing |
| `dns-config` unit (15) | sample config, unknown-field error with line, error paths, ENV/CLI precedence, open-resolver warning, upstream syntax, durations, includes, **BIND key files** (comments, multi-line secrets, errors with line numbers), **`update_policy`** rules (BIND strings and mappings, invalid rules), zone paths with `..` before the data directory exists |
| `dns-config` unit (16) | sample config, unknown-field error with line, error paths, ENV/CLI precedence, open-resolver warning, upstream syntax, durations, includes, **BIND key files** (comments, multi-line secrets, errors with line numbers), **`update_policy`** rules (BIND strings and mappings, invalid rules), zone paths with `..` before the data directory exists, `hosts` section (missing file warning, invalid domain) |
| `dns-cli` unit (4) | **`zone create`**: zone with glue from `--ip`, external + in-zone name servers, mailbox escaping, missing glue error, files written + loaded by the config, no overwrite without `--force` |
| `dns-server` unit (7) | query coalescing (50 identical → 1 resolution, cancelled leader releases waiters), **TLS certificate reload** (new pair picked up, broken pair rejected), **encoded-answer cache** (ID/0x20 case/TTL patching, profile/DO/name separation, generation and age invalidation, TTL 0 not cached, only plain queries – no TSIG, opcodes or trailing data, bounded memory) |
| `dns-authoritative` unit (12) | lookup: positive/additional/case, NODATA/NXDOMAIN/ENT, CNAME chains + loops, wildcards, delegation/glue/DS at cut, validation errors, diff/apply, lint, journal chain/persistence/gap, AXFR chunking/framing, IXFR incremental/up-to-date/fallback/wrong base, zone signing (every RRset verifies, no glue/delegation signatures, NSEC chain) |
| `dns-server` unit (13) | **hosts files** (names/aliases/comments, link-local zone index, NODATA for other types, PTR from the first name and line, `domain` for bare names, TTL, reload on change), query coalescing (50 identical → 1 resolution, cancelled leader releases waiters), **TLS certificate reload** (new pair picked up, broken pair rejected), **encoded-answer cache** (ID/0x20 case/TTL patching, profile/DO/name separation, generation and age invalidation, TTL 0 not cached, only plain queries – no TSIG, opcodes or trailing data, bounded memory) |
| `dns-authoritative` unit (13) | moving secondary copies and signed zones from pre-0.1.2 locations, lookup: positive/additional/case, NODATA/NXDOMAIN/ENT, CNAME chains + loops, wildcards, delegation/glue/DS at cut, validation errors, diff/apply, lint, journal chain/persistence/gap, AXFR chunking/framing, IXFR incremental/up-to-date/fallback/wrong base, zone signing (every RRset verifies, no glue/delegation signatures, NSEC chain) |
| `dns-cache` (7), `dns-policy` (5), `dns-forwarder` (2), `dns-recursive` (1), `dns-metrics` (1), `dns-tools` (3) | TTL clamp, negative caching, LRU/eviction, rank, namespaces; rules (exact/suffix/wildcard/regex/hosts), allow > block, rate limit + slip + /56, local-only, views; strategies, circuit breaker, failover; root hints; Prometheus output; dig argument parsing |
| `dns-server/tests/authoritative.rs` (6) | AA answers, negative TTL, wildcard, referral, MX additional, REFUSED, TCP, FORMERR; AXFR requires TSIG+ACL, wrong key → NOTAUTH, AXFR over UDP refused; **primary + secondary**: initial AXFR, change → NOTIFY → **IXFR**, unauthorised NOTIFY refused, restart of the secondary with the primary down serves the persisted copy; **EXPIRE → SERVFAIL**; **DDNS** unsigned refused, signed applied, prerequisites (YXDOMAIN), RRset delete, audit; **`update_policy`** with keys from an included BIND key file (granted name/type, wrong type/name/key/unsigned refused, wildcard strictly below), **IP-only updates** (`allow_update`) |
| `dns-server/tests/resolver.rs` (3) | **iterative resolution from a local root → TLD → authoritative fixture** (no Internet): A, cross-zone CNAME, glueless NS, QNAME minimisation over ENTs, NXDOMAIN/NODATA with SOA, non-existent TLD, cache hit without upstream queries, TCP, REFUSED for a client outside the ACL with **no upstream query**, local-only names never sent out; **hybrid** node: primary + secondary + forward zone + recursion + block list with **no leak** of private names to the root; **forwarder failover**, hot reload, invalid reload rolled back |
| `dns-server/tests/hosts.rs` (3) | **hosts files** in front of a forwarder: A/AAAA/PTR/NODATA, `domain`, hosts win over a local zone and the upstream, other names forwarded, edits and a file created later picked up without reload, no answers for clients outside `recursion.allowed_clients`, glob + config reload |
| `dns-server/tests/dnssec.rs` (2) | signed root/TLD/zone fixture: RRSIG with DO only, NSEC proofs; validating resolver: **secure** A (AD), secure CNAME chain, validated NXDOMAIN and NODATA, wildcard proof, **insecure** delegation (no AD), **bogus** → SERVFAIL, CD=1 returns data; signed zone change re-signs, source stays unsigned, restart reuses signatures |
| `dns-server/tests/transport.rs` (3 + 1 manual) | DoT query, 20 concurrent DoT connections, untrusted CA and wrong name rejected; DoH POST/GET, 404/405/400/415/413 (no hanging connection); **DoH over HTTP/2** – 50 concurrent GET/POST multiplexed, h2 negotiated; **pooled DoT** reuse; **secure forwarder** plain DNS → DoT/DoH upstream with private CA; manual `measure_pooled_vs_one_shot` |
| `dns-server/tests/performance.rs` (3) | coalescing of 40 identical cache misses into 1 upstream query, SO_REUSEPORT group on one port answering, **answer cache**: hit with other letter case echoes the client's spelling, DDNS change visible immediately, UDP answer stays truncated while TCP is complete, reload invalidates |
+6 -6
View File
@@ -53,7 +53,7 @@ Primary (`192.0.2.10`):
zones:
- name: example.com
type: primary
file: zones/example.com.zone # = /etc/easydns/data/zones/example.com.zone
file: zones/primary/example.com.zone # = /etc/easydns/data/zones/primary/example.com.zone
transfer_acl: ["198.51.100.20/32", "198.51.100.21/32"]
notify: ["198.51.100.20:53", "198.51.100.21:53"]
```
@@ -81,7 +81,7 @@ keys:
zones:
- name: example.com
type: primary
file: zones/example.com.zone
file: zones/primary/example.com.zone
transfer_acl: ["198.51.100.20/32", "198.51.100.21/32"]
transfer_tsig_key: xfr-key # optional
notify: ["198.51.100.20:53", "198.51.100.21:53"]
@@ -105,7 +105,7 @@ Generate a secret: `head -c 32 /dev/urandom | base64 > /etc/easydns/keys/xfr.sec
# primary
- name: example.com
type: primary
file: zones/example.com.zone
file: zones/primary/example.com.zone
transfer_tsig_key: xfr-key # no transfer_acl: any address with a valid key
notify: ["203.0.113.5:53"]
notify_tsig_key: xfr-key
@@ -133,7 +133,7 @@ server: { mode: primary, listen: ["10.0.0.10:53"] }
zones:
- name: example.com
type: primary
file: zones/example.com.zone
file: zones/primary/example.com.zone
transfer_acl: ["10.0.0.20/32", "10.0.0.21/32"]
notify: ["10.0.0.20:53", "10.0.0.21:53"]
resolution: { default: refuse }
@@ -215,8 +215,8 @@ keys:
- { name: provider-a, secret: "file:/etc/easydns/keys/provider-a.secret" }
- { name: provider-b, secret: "file:/etc/easydns/keys/provider-b.secret" }
zones:
- { name: example.com, type: primary, file: zones/example.com.zone, transfer_tsig_key: provider-a, notify: ["198.51.100.20:53"], notify_tsig_key: provider-a }
- { name: example.net, type: primary, file: zones/example.net.zone, transfer_tsig_key: provider-b, notify: ["203.0.113.7:53"], notify_tsig_key: provider-b }
- { name: example.com, type: primary, file: zones/primary/example.com.zone, transfer_tsig_key: provider-a, notify: ["198.51.100.20:53"], notify_tsig_key: provider-a }
- { name: example.net, type: primary, file: zones/primary/example.net.zone, transfer_tsig_key: provider-b, notify: ["203.0.113.7:53"], notify_tsig_key: provider-b }
```
## Key rotation (only when you use keys)
+1 -1
View File
@@ -55,7 +55,7 @@ for arch in ${ARCHES//,/ }; do
easydns --version
easydig -v
easydns check-config --config /etc/easydns/config.yaml >/dev/null 2>&1 || true
printf 'server: { listen: [\"127.0.0.1:5353\"], data_dir: /tmp/d }\napi: { enabled: false }\nmetrics: { enabled: false }\nzones: [ { name: example.com, type: primary, file: /usr/share/doc/easydns/zones/example.com.zone } ]\n' > /tmp/c.yaml
printf 'server: { listen: [\"127.0.0.1:5353\"], data_dir: /tmp/d }\napi: { enabled: false }\nmetrics: { enabled: false }\nzones: [ { name: example.com, type: primary, file: /usr/share/doc/easydns/zones/primary/example.com.zone } ]\n' > /tmp/c.yaml
easydns run --config /tmp/c.yaml >/tmp/log 2>&1 & sleep 1
easydig @127.0.0.1 -p 5353 www.example.com +short | grep -q 192.0.2.10
echo 'smoke test OK'
File renamed without changes.
File renamed without changes.