The edge: hardening, monitoring and layout
The edges are the part of Salt the internet talks to. They are Knot DNS secondaries with no database, no signing keys and no control path from outside; the primary and the application stay behind their own controls: the primary may sit on a private network or be reachable from the internet, see the primary (getting started). This page says how the edges are hardened against abuse, how to watch them, and how to lay them out across networks and anycast.
Knot references are to the 3.6 documentation
(https://www.knot-dns.cz/docs/3.6/html/). Everything below that says "tested"
is tested against real Knot daemons in test/integration/edge_hardening_test.exs.
What an authoritative server is abused for
- Reflection and amplification. An attacker sends queries with the victim's address as the source; the server's (larger) answers hit the victim. The server cannot tell a spoofed query from a real one, so it limits what it sends to any one address.
- Resource exhaustion. Many TCP connections held open, slow clients, large
answers (
ANY), expensive queries. - Probing. Open recursion, zone transfers, version and zone-list leaks.
The settings below answer each. None of them is a substitute for upstream filtering when an attack exceeds your bandwidth: an authoritative server cannot out-rate-limit a saturated link. That is what several networks and anycast (below) are for.
Settings on the edge
They are in dev/knot/edge.conf (the development stack) and
deploy/examples/knot/edge.conf (the production template). A unit test
(test/salt_dns/edge_config_test.exs) keeps the two in step.
| Setting | Value | Why |
|---|---|---|
mod-rrl | rate 200, instant 500, slip 2 | Response rate limiting; see below. |
mod-cookies | defaults, global | DNS cookies (RFC 7873, RFC 9018); see below. |
mod-stats | request protocol, bytes, response codes, EDNS, query types | The counters the exporter publishes. |
server.udp-max-payload | 1232 | The EDNS buffer size that avoids IP fragmentation (DNS Flag Day 2020). It is also Knot's default (server section, udp-max-payload: "default 1232"); it is written down so that it is a decision, and tested: a client offering 512, 1232 or 4096 always sees 1232. |
server.tcp-idle-timeout | 5 s | Idle TCP connections are closed after 5 s (default 10 s). DNS over TCP is short-lived. Tested: an idle connection is closed after about 5 s. |
server.tcp-io-timeout | 500 ms | One DNS message must arrive within 500 ms of the previous byte (Knot's default, written down): slow-loris protection. |
server.tcp-max-clients | 1000 | At most 1000 TCP clients at once (default: half the process's file descriptor limit, which is effectively unlimited in a container). A limit makes the server shed load instead of exhausting file descriptors. Raise it if you serve many resolvers over TCP. |
Things Knot does without a setting
These were verified rather than assumed.
- No recursion. Knot is an authoritative-only server: there is nothing to
turn off. A name it does not serve is
REFUSED, and theRAflag is never set. Tested withkdig example.com A(REFUSED) against the edge. ANYgets one RRset. Since Knot 3.0.0 "queries with QTYPE ANY or RRSIG are always responded with at most one random RRSet"; before that (2.9.4) UDPANYalready got "one RRSet + possible RRSIG". This is the behaviour RFC 8482 section 4.2 allows (answer with a single RRset). There is no option to control it: the oldzone.disable-anyoption became obsolete in 3.1.0 (KnotNEWS, 3.1.0 "Compatibility"), and the 3.6 reference lists no replacement. Tested over UDP and TCP: the answer section holds one RRset type. (Which RRset is returned is random.)- Minimal responses. Knot 3.6's reference has no
minimal-responsesoption, and none is configured; we make no claim here. What Knot does isANYminimisation (above) and truncating limited answers (RRL slip).
Response rate limiting
mod-rrl (reference)
limits UDP responses per client address; TCP is limited by time per client
(time-rate-limit, default 5000 µs, left at the default).
| Option | Knot default | Salt | Reason |
|---|---|---|---|
rate-limit | 50 /s | 200 /s | A large resolver (an ISP, a public resolver) sends one address's worth of many users' queries for your zones. 50 would limit ordinary busy resolvers; 200 per address per second is far above a typical resolver for a zone you host and far below what reflection needs. |
instant-limit | 125 | 500 | A burst allowance: a resolver that refreshes many names at once is not limited. |
slip | 1 | 2 | "Sends every Nth rate-limited response as truncated": with 2, half the limited responses are small truncated (TC) answers and half are dropped. A real resolver that was limited sees TC and retries over TCP, which cannot be spoofed, so it gets its answer. A spoofing victim receives at most a trickle of small packets. With 1 every limited response is a (small) TC answer, which still reflects traffic; 0 would drop everything and starve legitimate resolvers behind the same address. |
Change them with KNOT_RRL_RATE_LIMIT, KNOT_RRL_INSTANT_LIMIT and
KNOT_RRL_SLIP (configuration).
rate-limit: 0 turns RRL off. To exempt your own monitoring or a known large
resolver add whitelist: [addresses] to mod-rrl; to see what a setting would
do before enforcing it, use dry-run: on and watch knot_stats_dropped.
What it does, measured. dev/loadtest/rrl.sh offers the same load with RRL
off and on and reports what the "victim" address receives. One run on a shared
development machine (2026-11-11), 4 seconds per row, Knot 3.6.2 edge, one
SOA query per packet:
| RRL | offered /s | sent | full answers | truncated (slipped) | dropped | bytes received / bytes sent |
|---|---|---|---|---|---|---|
| off | 2000 | 7999 | 7999 | 0 | 0 | 2.70 |
| on | 2000 | 7999 | 1273 | 3382 | 3344 | 0.85 |
| off | 6000 | 23999 | 23999 | 0 | 0 | 2.70 |
| on | 6000 | 23999 | 1188 | 11362 | 11449 | 0.61 |
Read it relatively: with RRL off every query is answered in full and the victim
receives 2.7 times what the attacker sent; with RRL on under 6% of the queries
get a full answer, slipped and dropped responses are about equal (slip 2), and
the victim receives less than the attacker sent. The sender is a Python script
(dev/loadtest/udp_flood.py) on a shared host. These numbers are not a
capacity claim about Knot or your hardware, and the amplification factor
depends on the record queried (a DNSKEY or large TXT answer amplifies far
more, which is why RRL matters). Reproduce, and compare on your own machine:
SALT_DNS_STACK=<n> dev/compose up -d --build --wait
SALT_DNS_STACK=<n> dev/loadtest/rrl.sh 4 2000 6000 # seconds per run, offered rates
(dev/loadtest/rrl.sh recreates the stack's edge with RRL off, then on, and
restores the shipped settings.) The same sender is used by the integration
test, which asserts that calm traffic (50 queries/s) is never limited while a
flood is limited and slipped, and that Knot's own mod-rrl.slipped and
mod-rrl.dropped counters rise. Knot also ships kxdpgun, an AF_XDP traffic
generator; it needs XDP support on the network interface and was not usable
over the virtual Docker network, so it is not used here.
DNS cookies
mod-cookies (reference)
implements RFC 7873. A client that sends a cookie and receives a server cookie
proves it can receive at its source address; a spoofed source cannot.
Behaviour, tested with kdig +cookie:
- A query without a cookie is answered normally. Nothing breaks for resolvers that do not use cookies.
- A query with only a client cookie gets
BADCOOKIEwith a server cookie; the client repeats the query with it and is answered. Cookie-aware resolvers do this automatically (kdigdoes too; use+nobadcookieto see the first answer). - A forged server cookie gets
BADCOOKIEand no data. badcookie-slip(default 1: answer every invalid-cookie query). Raise it on a server under cookie-guessing attack so that only every Nth is answered.- The server secret is regenerated every 26 hours by default. On anycast
every node must use the same secret (
secret:inmod-cookies, 16 bytes or 32 hex characters, a second secret for rollover), otherwise a cookie issued by one node is invalid on another. See the anycast section.
The primary: private or public
The primary is not in any NS record, so nobody is sent to it, and it does not
have to be hidden. Two set-ups work, and the example primary.conf is written
for the public one:
- Public. The primary's transfer port is open to the internet, so that
customers' own secondaries (and edges on other networks) can transfer from
it without a VPN. Set
SALT_DNS_TRANSFER_HOST(andSALT_DNS_TRANSFER_PORTif it is not 53) to the public address, so that the console shows the instructions your customers can use. Everything below protects it. - Private. It publishes no port to the internet. As an extra layer,
mod-queryaclcan make it answer ordinary queries only to the edges' addresses (anyone else getsNOTAUTH): the exampleprimary.confhas the block as a comment, to be uncommented together withmod-queryacl/edges-onlyin the default template'sglobal-modulelist.
What protects the primary in both set-ups (deploy/examples/knot/primary.conf):
- Transfers and NOTIFY only to known remotes, with a key. The ACL needs the
TSIG key (
hmac-sha256) and the secondary's address; an address alone never counts, so a spoofed address gets nothing. Each customer secondary has its own key and sees only its own organisation's zones and catalog. Notifies go only to the remotes you configured. Tested: anAXFRwithout the key is refused, with it succeeds. - The zone list is not readable by queries. Knot answers
NOTAUTHfor the catalog zone to a client that matches none of the zone's ACLs. - Limits.
tcp-max-clients: 100,tcp-idle-timeout: 10,tcp-io-timeout: 500,udp-max-payload: 1232, andmod-rrl(response rate limit, slip 2, the edges exempt) for the questions anyone may ask a public primary. If quick repeated queries to it are truncated or dropped, that is the rate limit: check records through the edges. A public primary serving customers' secondaries may need a highertcp-max-clients; raise it with the number of secondaries, never to "unlimited". Put a host firewall in front if you can name the addresses. - Control socket.
/run/knot/knot.sockis shared only with the application and the exporter through a volume; it is not a network port. - The configuration database is imported on first start only. To apply changes
to an existing deployment use
knotc conf-setor delete/storage/confdband restart (operations).
Keeping the edges current
A change reaches an edge in two ways: the primary sends a NOTIFY and the edge fetches the zone (usually within a second), and the edge asks the primary for the SOA again after a timer. The timer is the zone's SOA refresh, 3 hours, unless you cap it. Both settings below are in the example configuration; an installation that predates them needs them added.
Why NOTIFY alone is not enough. Knot sends a zone's NOTIFY to its remotes one after another, edges first and then the customers' secondaries. A secondary that drops packets (behind NAT, or a firewall that discards) holds that NOTIFY event until Knot's request timeout (5 s by default) runs out, and then retries only that secondary for a while. A change committed while the event is waiting is not announced again to the edges. Reproduced on Knot 3.6 with one primary, two edges and one unreachable remote: two changes a second apart left both edges on the first change for more than 100 s; the customer's server is not at fault, but nothing on the primary tells the edges. The same happens, more rarely, with a lost NOTIFY packet.
What the example does about it (measured on the development stack with a secondary registered at an address that never answers):
- the primary's
server.tcp-remote-io-timeout: 1000makes Knot give up on an unreachable remote after 1 s instead of 5 s, which shrinks the window; - the edges'
refresh-max-interval: 5(in thecatalog-membertemplate and on the catalog zone itself) makes every edge ask the primary for the SOA at least every 5 s, whatever happened to the NOTIFY. This is the guarantee: the edges have every change within about 5 s after the last one.
Measured with an unreachable secondary registered and both settings: two changes
1 s apart were on both edges 0.1 s after the second; ten changes 0.1 s apart
within 1.6 s after the last (the delay is the test's own knotc round trips);
without the edge setting a change was missing for more than 100 s. Without any
unreachable secondary the edges have a change within 0.8 s after the last one.
test/integration/edge_convergence_test.exs runs both cases with a black-hole
secondary and requires 9 s.
The same test was run once on the authors' production installation on 13 November 2026, after both settings were applied there, with a secondary registered at an address that drops NOTIFY. Two changes 1 s apart were on all four edge addresses 0.4 to 1.1 s after the last one. Ten changes 0.1 s apart, three runs: 0.4 to 1.2 s twice; once one edge needed 5.0 to 5.5 s, which is the backstop. No change was missing.
The cost of the 5 s timer is one SOA question per zone and edge every 5 s
(1000 zones: about 200 questions per second to the primary, each signed with the
transfer key). Raise refresh-max-interval for a very large installation, and
state the bound you get: the edges are never later than that interval.
To add the settings to a running installation:
# primary (its configuration lives in the confdb)
knotc conf-begin
knotc conf-set server.tcp-remote-io-timeout 1000
knotc conf-commit
# each edge: add refresh-max-interval: 5 to the "catalog-member" template and to
# the zone "edge.catalog.invalid" in its configuration, then restart it
The Name servers page shows an edge that is behind; if one stays behind, look at the transfer key and at the edge log.
Monitoring
Two sources, one Prometheus.
Knot: the exporter
Knot's stats module (mod-stats, "should be configured as the last
module") adds counters (request protocol, bytes, response codes, query types,
EDNS) to knotc stats, alongside the server's own and the rrl and cookies
modules' counters (mod-rrl.slipped, mod-rrl.dropped,
mod-cookies.presence). The knot-exporter from CZ.NIC publishes them, plus
every zone's serial and SOA timers, as Prometheus metrics.
Why the official exporter, not a custom collector: knot-exporter is
developed in the Knot source tree, versioned with Knot (PyPI knot-exporter
3.6.2 pairs with Knot 3.6.2), and talks to the daemon through libknot over
the control socket, so it keeps working when counters are added. A custom
Elixir collector would need access to every edge's control socket (the
application deliberately reaches only the primary) and would copy what the
exporter already does. A sidecar per daemon is also the natural unit: it
shares that daemon's socket volume and nothing else.
deploy/examples/knot-exporter/Dockerfile builds it on the same pinned Knot
image (the exporter's dependencies are pinned by version). The compose file
starts one per daemon; none publishes a host port.
Metrics the alerts use: knot_zone_serial{zone},
knot_stats_slipped{module="mod-rrl"}, knot_stats_dropped{module="mod-rrl"},
knot_stats_request_protocol{type}, knot_stats_response_code{type}.
The application: /metrics
SaltDns.Metrics defines about 20 metrics (reconciler, writers, ownership,
RFC 2136, DNSSEC, Oban, HTTP, the VM) and serves them at GET /metrics with
Telemetry.Metrics and telemetry_metrics_prometheus_core. Why not PromEx:
PromEx is a larger framework (plugin tree, bundled Grafana dashboards) for
generic Phoenix, Ecto and Oban metrics; here almost every metric is
domain-specific and a few lines of definitions, and the core reporter is a
small library maintained under beam-telemetry.
Protection: bearer token, SALT_DNS_METRICS_TOKEN (at least 32
characters). Without it the endpoint answers 404, with a wrong or missing
token 401 (constant-time compare, the token is never logged). /metrics is
excluded from the HTTPS redirect so that Prometheus can scrape it over the
private network. Do not expose it through the reverse proxy: Prometheus
should reach app:4000 directly on the private network, and the proxy should
refuse the path:
location = /metrics { return 404; }deploy/examples/prometheus/prometheus.yml shows the three scrape jobs
(salt-dns, knot-primary, knot-edge) and the token as a file
(credentials_file).
Alerts
deploy/examples/prometheus/alerts.yml (19 rules, unit-tested with
promtool test rules; run deploy/examples/prometheus/check.sh).
| Alert | Fires when | Source |
|---|---|---|
SaltDnsTargetDown | the app or an exporter is not scraped for 5 min | up |
SaltDnsServerErrors | more than 5% 5xx for 10 min | salt_dns_http_requests_total |
SaltDnsReconcilerDrift | the reconciler repaired Knot more than 3 times in an hour | salt_dns_knot_drift_total |
SaltDnsReconcilerCannotRepair | the last full sweep left zones unrepaired for 20 min | salt_dns_knot_sweep_failed_zones |
SaltDnsReconcilerNotRunning | no zone reconciled for an hour | salt_dns_knot_reconcile_total |
SaltDnsWriterFailing | zone writers fail for 10 min | salt_dns_knot_writer_failures_total |
SaltDnsWriterLag | a writer has had work not yet in Knot for 10 min straight | salt_dns_knot_writers_busy |
SaltDnsEdgeLagging | an edge's SOA serial is behind the primary's for 15 min | knot_zone_serial |
SaltDnsZoneMissingOnEdge | a zone is on fewer edges than there are edges | knot_zone_serial, up |
SaltDnsOwnershipChecksInconclusive | the resolvers do not answer ownership checks | salt_dns_ownership_checks_total |
SaltDnsOwnershipLost | an active zone lost its proof in the daily re-check | salt_dns_ownership_checks_total |
SaltDnsDnssecKskWaitingForDs | a KSK waits over a day for its DS to be confirmed | salt_dns_dnssec_ksk_ready_oldest_seconds |
SaltDnsDnssecDnskeyMissing | DNSSEC is on but Knot publishes no DNSKEY | salt_dns_dnssec_zones_unpublished |
SaltDnsDnssecStatusUnreadable | DNSSEC status cannot be read | salt_dns_dnssec_status_errors |
SaltDnsUpdateBadKey | many RFC 2136 requests with an unknown TSIG key | salt_dns_listener_requests_total |
SaltDnsUpdateBadSignature | many bad signatures or clock skews | idem |
SaltDnsUpdatesRefused | many updates REFUSED | idem |
SaltDnsEdgeRateLimiting | an edge drops over 50 responses/s for 10 min | knot_stats_dropped |
SaltDnsEdgeNoQueries | an edge gets no queries for 30 min | knot_stats_request_protocol |
"Writer lag" is measured with salt_dns_knot_writers_busy: the zone writers that have
changes not yet in Knot (dirty, or holding buffered change lists, or an unfinished removal).
A writer of an existing zone is not stopped when it is idle, so
salt_dns_knot_writers (writers alive) equals the number of zones written to and says nothing
about lag; the alert uses the busy gauge, which is read from the writer registry without
asking any writer. The DNSSEC alerts are driven by SaltDns.Metrics.measure_dnssec/0,
which asks Knot (knotc and keymgr) for the status of every zone with DNSSEC
on once a minute; with very many signed zones, lengthen that period.
Several networks for the nameservers
A zone's NS set is only as available as the networks behind it (RFC 2182 section 3 asks for secondary servers at topologically and geographically dispersed locations). With every NS in one provider's network a single outage or attack on that network takes the zone offline however many servers you run. So:
- Use at least two NS names on different networks, better three: different
providers, different autonomous systems, different IPv4
/24and IPv6/48prefixes, and both IPv4 and IPv6 for each. - Run one edge per network (
knot-edge-1,knot-edge-2on different hosts; operations). Every edge is identical: its configuration is rendered from the environment, its zones come from the primary. - List them all in
SALT_DNS_NAMESERVERS(zones delegated to two of them are verified as owned) andSALT_DNS_NS(the NS records of new zones), and delegate at the registrar to all of them. - Give the primary one address per edge (
KNOT_EDGE_n_ADDRESS); each edge needs a route to the primary on port 53 (a private link or VPN, never the open internet).
Adding a third-party secondary as an extra NS
A secondary run by someone else (a provider, a friendly operator, a registry service) adds a network you do not control. It transfers zones from the primary like an edge does.
A key of its own. Create a TSIG key for that secondary (
hmac-sha256,openssl rand -base64 32). Never reuseedge-transfer: revoking one secondary must not touch the others.Let it in. On the primary add its address to
remote(for NOTIFY), an ACL with its key andaction: transfer, and reference both from the templates your zones use, withknotc conf-set(see operations):K="knotc -s /run/knot/knot.sock" $K conf-begin $K conf-set key.id partner $K conf-set 'key[partner].algorithm' hmac-sha256 $K conf-set 'key[partner].secret' BASE64SECRET $K conf-set remote.id partner $K conf-set 'remote[partner].address' 198.51.100.10@53 $K conf-set 'remote[partner].key' partner $K conf-set acl.id partner $K conf-set 'acl[partner].key' partner $K conf-set 'acl[partner].action' transfer $K conf-set 'template[member].acl' partner $K conf-set 'template[member].notify' partner $K conf-commitThe transfer needs that address AND the TSIG key (the ACL). On a private primary also open its port to that address only (a firewall rule); on a public one the ACL and the rate limits are what protect it. The third party sees every zone in the
membertemplate if you also let it read the catalog zone; give it a per-zone setup instead if some zones must stay private (secondaries.md).DNSSEC needs nothing extra: zones are transferred already signed, and the secondary holds no keys.
Publish it. Add its NS name to
SALT_DNS_NAMESERVERSandSALT_DNS_NS, restart the app, and add the delegation at the registrar once the secondary serves the zones (check the SOA serial equals the primary's:dig @secondary example.org SOA +short). TheSaltDnsEdgeLaggingalert cannot see a third party's serial unless it exposes metrics; check it regularly or with a blackbox probe.The third party's answers are theirs: they must serve the zone, but RRL, cookies and limits on their servers are theirs too.
An anycast-ready layout
Anycast serves one IP address from several locations; routing sends each client to the nearest. Salt needs nothing special for it, because an edge is stateless, but a few things must be true:
- Identical edges. Same image, same
edge.confrendering, same transfer key; the zones come from the primary, so every node serves the same data. - Two kinds of address per node. The anycast service address (queries,
advertised by BGP) and a unicast management address (what the primary
NOTIFYs and the exporter scrapes). The primary's
remoteentries use the unicast addresses, so each node receives its own NOTIFY and fetches its own transfer. The edge'snotify-from-primaryACL names the primary, as now. - One cookie secret. Set the same
secretinmod-cookieson every anycast node (and a second one during rollover); otherwise a client moving between nodes seesBADCOOKIEchurn. - RRL is per node. Each node limits what it sends; the limit is not shared. That is fine: an attack is spread across nodes by routing, and each node sheds its share.
- Withdraw an unhealthy node. The routing daemon announces the anycast
address only while the node answers: a check that runs
kdig @127.0.0.1 <zone> SOA(and fails on anything but NOERROR, or on a serial older than a few refresh intervals) and withdraws the route otherwise. A node that cannot reach the primary keeps serving until the SOAexpireand should then be withdrawn. - TCP over anycast works for DNS: transfers use the unicast addresses, and
client TCP sessions are short. Keep
tcp-idle-timeoutshort. - Monitor each node through its unicast address (
knot-exporter-*), soSaltDnsEdgeLaggingandSaltDnsEdgeNoQueriesname the node.
Example (not enabled by default) for the cookie secret, added to the edge template:
mod-cookies:
- id: "default"
secret: ["0x@KNOT_COOKIE_SECRET@"] # 32 hex characters; the same on every nodeWhy the control plane stays separate
- Blast radius. The edges hold public data and nothing else. If one is compromised, an attacker has the zones (which are public anyway) and nothing that signs, writes or reads Postgres. The keys live on the primary, which the internet cannot reach.
- Attack surface. The application (a web UI, an API, a login, a database) is a far larger surface than a DNS daemon. It is not on port 53's path and can be firewalled to your operators and your reverse proxy.
- Availability. DNS keeps answering while the application, Postgres or the
primary is down, upgraded or being restored: the edges serve what they have
until the SOA
expire(a week by default). A DDoS on the edges cannot stop writes, and an outage of the control plane does not stop answers. - One writer. All changes go through the application into one primary, so there is one ordered history and one audit log. Edges never accept changes (they only transfer), which keeps the DNS data flow one-way.
- Scaling. Query load scales by adding edges and networks; the write path needs none of that.
The one place the planes meet is the primary's control socket, which is a file on a private volume, not a network service.
An edge on its own host
deploy/examples/edge-host/ is a compose file and Knot configuration for one
edge on a stand-alone host with host networking (so response rate limiting sees
real client addresses), explicit public IPv4 and IPv6 listen addresses, and the
primary's address and port taken from the environment. Use one per host and
provider. Read its README: it also covers the host firewall (host networking is
subject to it, published ports are not), systemd-resolved, and the source
address of NOTIFY when the primary is behind NAT.