Install and run
Three ways in. Each needs the binary, and the binary comes from a release or from a build of your own. A release says where a release is and how to check it. There is no package yet.
| Way | Pick it when |
|---|---|
| A container | You already run containers, and you want one file to keep |
| The systemd unit | This machine is a Linux server, and the server must survive a boot |
| From a checkout | You are trying it out, or changing it |
The container and the unit both keep the server running after a power cut. A checkout does not: it dies with the terminal.
For a house with one router, A home network, start to end is one path from the install to the router.
A release
Section titled “A release”The releases page of the repository lists each
release. A release holds three files of its own. GitHub adds two archives of the source, which
SHA256SUMS does not list.
| File | What it holds |
|---|---|
tadoru-<version>-linux-amd64.tar.gz |
The binary for 64-bit x86, install.sh, its unit tadoru.service, and LICENSE |
tadoru-<version>-linux-arm64.tar.gz |
The same for 64-bit ARM, such as a Raspberry Pi with a 64-bit system |
SHA256SUMS |
The SHA-256 of each archive |
The binary of a release holds the web console. You turn the console on with a setting, and
Console and remote API says how. The image of the release is
ghcr.io/bitcldr/tadoru:<version>. One tag serves both machines, and the image holds the same
binary as the archive, console included.
The binary needs Linux with the GNU C library 2.31 or later. Debian 11, the 64-bit Raspberry Pi OS 11 and Ubuntu 20.04 have it, and so does each later release of them. A system with another C library, such as Alpine Linux, cannot run the binary. Use the image there.
There are two kinds of release:
- A version tag, such as
v0.2.0orv0.2.0-beta.1, makes the release of that version. Only a version without a part after-is marked as the latest release. - Each push to
mainwhose checks pass makes a pre-release of its last commit, once the maintainer has turned releases on. Its tag is such asv0.2.0-dev.42, and the tag of its image is0.2.0-dev.42. The number at the end is the number of the run that made it. A pre-release is for a test, so do not keep a host on one.
The release workflow aims to keep the 20 newest pre-releases of main, by the number at the end.
Each run that publishes deletes older ones, a batch at a time, and later runs delete the rest. A
release of a version tag is never deleted. To keep a build of main, copy its files and its image
before 20 newer ones exist.
Some old pre-releases stay: a draft, a pre-release whose image GitHub refuses to delete (only GitHub support can delete it), and an image that has another tag beside its old version.
Do not delete a pre-release of main by hand. The run that made it could then publish it again.
The summary of each run names the tags and images of old pre-releases that have no release. The
workflow never deletes those, so delete them by hand.
A tag of the image is always one version. There is no latest tag, and a tag never moves to
another image.
The repository is private for now. So a download and a pull need the login of an account that can
read it, and the update check of the server reports unavailable.
To install version 0.2.0 on 64-bit x86 with the systemd unit:
gh auth logingh release download v0.2.0 -R bitcldr/tadoru -p 'tadoru-0.2.0-linux-amd64.tar.gz' -p SHA256SUMSsha256sum --check --ignore-missing SHA256SUMSmkdir tadoru-0.2.0tar -xzf tadoru-0.2.0-linux-amd64.tar.gz -C tadoru-0.2.0cd tadoru-0.2.0 && sudo ./install.shFor a pre-release, name its tag in gh release download, such as v0.2.0-dev.42, and its
version in the file names, such as tadoru-0.2.0-dev.42-linux-amd64.tar.gz.
sha256sum must print OK for the archive. If it prints anything else, delete the files and do
not install them. The release page also shows the SHA-256 of each file. The archive has no top
directory, so it goes into a directory of its own. install.sh installs the tadoru next to it.
The systemd unit says what the script does, and how to start the service.
For a container, log in to the registry once. The token of gh needs the scope read:packages,
and gh auth refresh -s read:packages adds it. Then use the image of the release in place of
tadoru:local in A container:
gh auth token | docker login ghcr.io -u <your GitHub user> --password-stdindocker pull ghcr.io/bitcldr/tadoru:0.2.0There is no one-line curl | sh form and there will not be one. A script piped from a URL runs
whatever answers that URL at that moment. You cannot read it first, and no checksum says you got
what the project published. The check of SHA256SUMS above is the step that such a form skips.
What you need to build
Section titled “What you need to build”There are two builds. The build of the server alone has no web console in it. The build with the console has it, as the binary of a release does.
| Build | Command | What it needs |
|---|---|---|
| The server alone | cargo build --release, or just build-server |
Rust. just only for the second form |
| The server and console | just build-all |
Rust, just, mise, Node and pnpm, and the network |
just build-server runs cargo build --release, so the plain command gives the same build. For
the server alone, Tadoru needs the version of Rust that rust-toolchain.toml names at the root of
the repository. rustup installs that version and cargo uses it, so you do not pick one. The
binary is static apart from the system C library, and SQLite is built in. For the console, you
also need just, mise, and Node and pnpm at the versions of mise.toml. You also need the
network, because the build downloads the packages of the console.
Build and test from source says how to get the tools. A server built without the console refuses a revision
that sets console_listen.
The repository is private for now, so the clone needs a login, such as gh auth login or a token
of GitHub:
git clone https://github.com/bitcldr/tadoru.gitcd tadorujust build-serverThe binary lands in target/release/tadoru. This manual calls it tadoru. From a
checkout that is ./target/release/tadoru, or put it on your path once:
export PATH="$PWD/target/release:$PATH"To give the build its commit, set TADORU_COMMIT to the hash, short or whole, in lower case.
tadoru --version and GET /api/info then name it. Any other text stops the build. Without the
variable the build names no commit, because the build runs no git.
TADORU_COMMIT=$(git rev-parse --short HEAD) cargo build --releaseA build names the version in Cargo.toml, such as 0.1.0. The release workflow sets
TADORU_RELEASE_VERSION to give a build of main a version of its own, such as 0.1.0-dev.42.
The 42 is the number of the run. tadoru --version, GET /api/info, the startup log and the
user agent of the server then name it. The value must be the version in Cargo.toml, or that
version and -dev.N. A version that is already a pre-release, such as 3.0.0-alpha.2, takes
.dev.N. Any other value stops the build. A backup archive always names the version in
Cargo.toml.
A container
Section titled “A container”Build the image from a checkout, make the directory it writes to, and start it:
docker build -f packaging/Dockerfile -t tadoru:local \ --build-arg TADORU_COMMIT=$(git rev-parse --short HEAD) \ --build-arg SOURCE_DATE_EPOCH=$(git log -1 --format=%ct) .mkdir -p datasudo chown -R 65532:65532 datadocker run -d --name tadoru --restart unless-stopped \ --network host -v ./data:/data tadoru:localThe two build arguments give the image its commit and the time of the commit. Build and test from source says what each one does.
The image holds the web console. Its build compiles the console from the console/ directory of the checkout, in a
stage of its own. So the build needs no Node on your machine, but it downloads the packages of the console. A
console/out/ of your checkout never goes into the image. An empty console_listen, the default, serves nothing. Console and remote API says how to turn it
on.
Four things in the docker run command need the reason said.
The image runs as user 65532, which is why you own the directory to that number first. A bind
mount keeps the host directory’s owner. A directory the container cannot write stops the first
start at /data/config/bootstrap.toml: Permission denied (os error 13).
One directory holds everything you keep: data/config is the config root and data/state is
the state root. The management socket is not in there, because a socket is not something to keep.
--restart unless-stopped is what brings the server back after a reboot. Without it a power cut
leaves the container stopped, and nothing says so until somebody asks a name.
--network host is the part to think about. The server listens on 127.0.0.1:5300 until you
name an address, and a published port cannot reach loopback inside a container. On the host’s
network namespace that same default answers on the host’s own loopback. Name the host’s address
in data/config/node.toml to answer the rest of your network. What you give up is the
network namespace: the container sees every interface of the host. A bridge network with
-p 53:5300 does not answer yet.
To answer on port 53, name port 53 in listen. Name the address of this machine on your network,
such as 192.168.1.2 in the example below, so that other machines can ask. Replace it with your
own. Keep 127.0.0.1:53 as well, so that this machine can ask too. The binary in the image carries the capability
that lets an unprivileged process bind it, so the process stays uid 65532. The capability on its
own changes no port.
sudo sed -i 's/^# *listen = .*/listen = ["127.0.0.1:53", "192.168.1.2:53"]/' data/config/node.tomldocker stop tadorudocker rm tadorudocker run -d --name tadoru --restart unless-stopped \ --network host --cap-add NET_BIND_SERVICE -v ./data:/data tadoru:localThe docker stop and docker rm are there because the name is taken by the container you already
started. Stop it first, and do not force the removal. A stop lets the server finish its writes,
which can take a few seconds. Docker kills a container that has not stopped after 10 seconds, so
use docker stop -t 60 tadoru where you want it to wait longer.
The capability NET_BIND_SERVICE is the right to bind a privileged port, and it is the only
privilege the server takes. The server never runs as root. Docker allows the capability by default,
and --cap-add keeps it allowed where a setup drops the rest.
If you start the container with --cap-drop ALL, also give --cap-add NET_BIND_SERVICE. Without
it the container does not start, and Docker reports operation not permitted for
/usr/bin/tadoru. The binary asks for the capability when it starts, and a container that
allows none refuses to run it.
packaging/compose.yaml is the same thing as a compose file. Run it from the packaging
directory, because compose reads its relative paths from where that file is. The image also
declares its own health check, so docker ps says healthy or unhealthy without you asking.
docker exec tadoru /usr/bin/tadoru healthFor a query log in memory (telemetry_storage = "memory"), give the container a tmpfs of its own
at /run/tadoru, writable by uid 65532. The room of 64 MiB, the default of telemetry_memory_mib,
holds 204 days of hourly counts. Set stats_retention_days = 204 or fewer in server.toml. Or
raise the room, and the mount with it (The query log in memory).
The default of 1826 days needs a room of 571 MiB. Without either, the query log is off with the
reason unfit:
docker run -d --name tadoru --restart unless-stopped --network host \ --tmpfs /run/tadoru:rw,size=80m,uid=65532,gid=65532,mode=0750,nosuid,nodev,noexec \ -v ./data:/data tadoru:localIn compose.yaml, the same mount is a tmpfs: entry of the service:
tmpfs: - /run/tadoru:size=80m,uid=65532,gid=65532,mode=0750The mount must be private to the container: --tmpfs, or a tmpfs: entry of compose, and never a
named volume. A named volume can be mounted by a second container, which then reaches the socket of
the API. Without such a mount, /run/tadoru is on the layer of the image. That is no tmpfs, so
the query log is off with the reason not_memory. Docker empties a tmpfs when the container
stops, so a restart of the container, and a new container, start with an empty query log.
The first start also writes a one-time setup token, because nobody can use the management API yet. It is in the directory you mounted, and The first start says what it is for.
sudo cat data/state/setup-tokenThe systemd unit
Section titled “The systemd unit”packaging/install.sh creates the service account, both roots, and the unit. It does not start
the service, because the first start writes files and mints a token you have to read.
This build has no web console, as What you need to build says. To get the console, build with
just build-all in place of cargo build --release. The binary of a release has it already.
cargo build --releasesudo ./packaging/install.sh --binary target/release/tadorusudo systemctl enable tadorusudo systemctl start tadorusudo tadoru healthThe service runs as the tadoru account and never as root. It gets one capability,
CAP_NET_BIND_SERVICE, which is the right to bind port 53. The rest of the filesystem is
read-only to it. It writes three places: /etc/tadoru, /var/lib/tadoru, and its own
/run/tadoru. That last one holds the management socket, stays from a stop to the next start,
and goes with a reboot. It also gets a private /tmp that no other process sees.
The unit allows the service 16384 open files (LimitNOFILE), and a unit that you write by hand
needs as many. With the default of 1024, one busy listener runs out. With 8192, the number of
earlier releases, a revision that replaces busy listening addresses can run out, and the server
refuses it. A listener that cannot read or
accept says how the number is made.
One file inside the config root stays read-only even to the service: bootstrap.toml, which
names the other two roots. It belongs to root, and only you change it.
Running the script twice is safe, and it is not a no-op. It makes the account and the two roots
only where they are absent, and an existing root keeps its own owner and mode. It always replaces
the binary and the unit, which is what makes it the upgrade path. After an upgrade, run sudo systemctl restart tadoru. A running service keeps the old binary until it stops. Where the old
build lets a command change the files of a dynamic zone, stop that server cleanly before you start
the new binary. A crash of the old build can leave a change staged, and the new build then finishes
it at its start.
journalctl -u tadoru is the log. systemctl status tadoru says whether it is running, and
tadoru health says whether it is serving. The two answer different questions: a process that
is up and a server that answers are not the same thing.
The query log in memory
Section titled “The query log in memory”With telemetry_storage = "memory" in node.toml, the query log and the statistics live on a
tmpfs at the runtime root, /run/tadoru, and a reboot empties them
(The query log in memory).
The unit keeps /run/tadoru from a stop to the next start (RuntimeDirectoryPreserve=yes), so a
restart, or a stop and a start, keeps the store. A start takes over the socket that a stopped
server left there.
The shared /run of the machine is a tmpfs with a size, so the store runs there with no mount of
its own. But every service of the machine shares its room, which is often a small part of the
memory. A tmpfs of its own gives the store its room alone. Mount it at /run/tadoru itself, the
runtime root. A mount below it is refused, because the directory of the store must be on the
mount of the runtime root. Size it past telemetry_memory_mib, with a few MiB for the sockets:
80 MiB for the default 64. That room holds 204 days of hourly counts. Set
stats_retention_days = 204 or fewer in server.toml. Or give the default 1826 days a room of 571
MiB and a tmpfs of about 600 MiB (The query log in memory).
Where the days do not fit, the query log is off with the reason unfit.
tmpfs /run/tadoru tmpfs size=80m,mode=0750,uid=tadoru,gid=tadoru,nosuid,nodev,noexec,x-systemd.before=tadoru.service 0 0sudo mkdir -p /run/tadorusudo systemctl daemon-reloadsudo mount /run/tadorusudo systemctl restart tadoruThe kernel can still write the pages of a tmpfs to a swap device. A store in memory means no file of the query log on a disk, not that no page of it ever reaches one.
The buffers of the kernel
Section titled “The buffers of the kernel”udp_receive_buffer_kib, udp_send_buffer_kib and tcp_backlog of node.toml ask the kernel for
larger buffers and a longer queue (The backlog and the UDP buffers).
The kernel caps each, and the unit has no right to pass the caps, so raise them on the host. The
server writes a warning that names the sysctl where a cap cut a setting.
| Sysctl | Caps | Default of Linux |
|---|---|---|
net.core.rmem_max |
udp_receive_buffer_kib |
208 KiB |
net.core.wmem_max |
udp_send_buffer_kib |
208 KiB |
net.core.somaxconn |
tcp_backlog |
4096, and 128 before Linux 5.4 |
The buffer caps are in bytes. For a receive buffer of 4 MiB:
echo 'net.core.rmem_max = 4194304' | sudo tee /etc/sysctl.d/60-tadoru.confsudo sysctl --systemThen restart the server, so each socket asks again. A revision asks again only where it changes the setting. A container shares these caps with its host, so set them on the host.
A listener on a device
Section titled “A listener on a device”An entry of a DNS listen list can name a network device or a VRF on Linux
(A listener on a device). It needs Linux 5.7 or later. Linux 5.6
and older give a socket a device only for a process with CAP_NET_RAW, and the unit grants
CAP_NET_BIND_SERVICE alone. A newer kernel needs no more than that, so the unit stays as it is.
The device must exist when the server starts, or the start fails. The unit starts after
network-online.target, and a device that a service of its own makes, such as WireGuard, can come
later. Order the server after that service with a drop-in:
sudo systemctl edit tadoru[Unit]After[email protected]Wants[email protected]A socket keeps the index of the device of its bind. A device that is deleted and made again under
its name, as wg-quick down and wg-quick up do, is a new device with another index. A socket
that keeps the old index takes no packet until the server restarts. The server reads the sockets
every 10 seconds. The log warns where they hold an index that no device has, or a device of another
name (A listener on a device that answers nothing).
A container sees the devices of its own network namespace. With network_mode: host, as in
packaging/compose.yaml, those are the devices of the host.
From a checkout
Section titled “From a checkout”Run the binary and name a directory for it to write. Nothing else is installed, and deleting that directory undoes the whole thing.
tadoru --data-dir ./data --runtime-dir ./data/runThe server runs in the foreground and holds the terminal. Open a second terminal for the commands below. To stop the server, press Ctrl-C in its own terminal.
The first start
Section titled “The first start”This part is the same whichever of the three ways you took.
The first start writes the configuration files, adopts them as revision 1, and serves. A start after that reads them and changes nothing. Every setting is in the files, commented out at its default, with prose above it saying what it does and which values it takes.
Out of the box the server answers on 127.0.0.1:5300 and forwards nothing, so every name
it does not hold itself gets NXDOMAIN. Port 5300 rather than 53, because 53 needs a
privilege a development run does not have. Name 127.0.0.1:53 in node.toml and the server
binds it wherever the operating system allows that, which means with CAP_NET_BIND_SERVICE.
The unit grants it, and a container gets it from --cap-add NET_BIND_SERVICE. From a checkout
you grant it once with sudo setcap cap_net_bind_service=+ep target/release/tadoru, and a
rebuild drops it again.
The first start also writes a one-time setup token, because nobody can use the management
API yet. It goes to a file at mode 0600 in the state root, and the server prints it to a
terminal only. A secret printed to a log lives in journalctl and in docker logs for as
long as those are kept. A paused terminal shows it when its output goes on while the server runs.
A terminal that never reads it does not hold the start, and the file holds the token all the same.
Accounts says what to do with it.
Where the file is depends on which way you installed, because each one puts the state root somewhere else.
cat ./data/state/setup-token # from a checkoutsudo cat data/state/setup-token # a container, in the directory you mountedsudo cat /var/lib/tadoru/setup-token # the systemd unitThe first start of a new build can bring each database under the state root up to the schema of
that build. The log shows a migrating line before each step and a migrated line after it. On
a large ledger, this start takes longer. On the test machine, a
control.sqlite of 1,000,000 commands took about 7 seconds with the file already in memory, and
about 10 seconds where it came from a build before the prune of the ledger. A first start reads the whole file
from disk, so on slow storage, such as an SD card, it can take many times longer.
Wait for the migrated line, and do not stop the server. While the steps run, each database can
take up to about 256 MiB more memory. A step undoes itself if the server stops during it, and the
next start runs it again. If a step fails, the server does not start.
Troubleshooting says what the message means.
The server deletes old commands of dynamic updates, of ACME, of aging, of
serial witness moves and of expiry sweeps from control.sqlite.
It deletes none in the first 7 days and 1 hour after each start. So the ledger stops growing only
on a server that runs that long. After an upgrade, the first start stamps up to 1,000 finished
commands, and each later tick goes on with the rest. Each command then waits that long from its own
stamp. A ledger that keeps growing says more.
Upgrade
Section titled “Upgrade”An upgrade replaces the binary and keeps the files you wrote. The steps are the same for the three ways, apart from how the new binary arrives.
- Take a backup first, with the command of your way below. Backup and restore says what it holds. A new build can change the schema of a database, and an older build does not open it again. Do this before you replace the binary.
- Put the new binary in place and start it, as below.
- Watch the log. A first start of a new build can bring each database up to its schema. Wait for
the
migratedline after eachmigratingline, and do not stop the server in between (The first start says how long that can take). - Check with the health command of your way below.
The server follows no symbolic link at zones in the state root or at the folder of a zone under
it. Where one of them is a link, make it the directory itself, or a bind mount, before you start
the new build. Otherwise each zone behind the link stops, and takes no update.
Read Zones answer the private ranges below before the first
upgrade to a build with the narrow default of query_from. A zone that answered clients outside
your network can stop doing so.
A container. The directory data/ keeps your files. Take the backup inside the container,
into data/. Then pull the new version, stop and remove the container, and start a new one on
the same directory. The passphrase file is a file that you wrote, with one line of text in it (The
passphrase says what it is for). The container runs as user 65532, so
the file must belong to that user, with mode 0600. Do not go on if the backup fails, or if
before.tar.gz is not in data/: the old container must stay as it is. Use the version of the
new release in place of 0.2.1:
sudo install -m 0600 -o 65532 -g 65532 ./passphrase data/passphrasedocker exec tadoru /usr/bin/tadoru backup --data-dir /data --output /data/before.tar.gz \ --passphrase-file /data/passphrasesudo rm -f data/passphrasels -l data/before.tar.gzMove data/before.tar.gz to a safe place that is not in data/, and then go on:
docker pull ghcr.io/bitcldr/tadoru:0.2.1docker stop tadorudocker rm tadorudocker run -d --name tadoru --restart unless-stopped \ --network host --cap-add NET_BIND_SERVICE -v ./data:/data ghcr.io/bitcldr/tadoru:0.2.1docker exec tadoru /usr/bin/tadoru healthFor an image that you built from a checkout, run git pull and the docker build again, with the
same name for the image. Then stop, remove and start the container. Use the same docker run
command as before, and keep each flag that you added, such as the tmpfs.
The systemd unit. Take the backup as the service account, in a private directory. Then
run install.sh again with the new binary, and restart the service. The script replaces the binary
and the unit, and keeps the account and both roots. The passphrase file is a file that you wrote,
with one line of text in it. It goes into a directory that only the tadoru account reads, and you
remove it after the backup, whether the backup worked or not. Do not go on if the backup fails.
sudo install -d -m 0700 -o tadoru /tmp/tadoru-upgradesudo install -m 0600 -o tadoru ./passphrase /tmp/tadoru-upgrade/passphrasesudo -u tadoru tadoru backup --output /tmp/tadoru-upgrade/before.tar.gz \ --passphrase-file /tmp/tadoru-upgrade/passphrasesudo rm -f /tmp/tadoru-upgrade/passphrasels -l /tmp/tadoru-upgrade/before.tar.gzMove the archive to a safe place, and remove the directory. Then go on:
sudo mv /tmp/tadoru-upgrade/before.tar.gz ~/before.tar.gzsudo rmdir /tmp/tadoru-upgradesudo ./packaging/install.sh --binary target/release/tadorusudo systemctl restart tadorusudo tadoru healthFor a release, unpack the new archive in a directory of its own, as in A release, and
run its install.sh.
A checkout. Take the backup, then stop the server with Ctrl-C, run git pull, build again, and
start the server on the same ./data. Run the health command in a second terminal:
tadoru backup --data-dir ./data --output ./before.tar.gz --passphrase-file ./passphrasetadoru --data-dir ./data --runtime-dir ./data/runtadoru health --data-dir ./data --runtime-dir ./data/runA downgrade. An older build does not run on the files of a newer one. Do not start the old binary on the same files. Going back to an older build says what to do. It takes the older binary and a restore of an archive that the older build made. Each change after that archive is lost. So keep the backup of step 1 until the new build has run well for a while.
Zones answer the private ranges
Section titled “Zones answer the private ranges”A zone used to answer every address where nobody wrote query_from. From this build, such a zone
answers the default ranges of allow_recursion alone, not the list you wrote there: 127.0.0.0/8,
::1, 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 169.254.0.0/16, fe80::/10 and
fc00::/7. The start logs one line while a zone takes that default. The start and each change of
the configuration also warn about each network that the default leaves out. The warning covers
allow_recursion, and encrypted_allow_recursion where the node has an encrypted listener.
-
Write into
query_fromof[zones]inserver.tomleach network that may ask your zones and that the default leaves out. Examples are the IPv6 prefix of your provider, a VPN range, and the addresses of phones that roam over TLS. -
For a zone that the internet asks, write this line in its
zone.toml, or in[zones]for every zone:query_from = ["0.0.0.0/0", "::/0"]
What else follows the same list, for a zone that writes none:
- A node with
acme_challenge = "dns-01", whose record goes into such a zone, does not start. The error names the zone and the line to write. Write it with the server stopped, then start it. - An ANAME whose own zone writes a wider list than the zone of its target is refused the same way, and the server does not start. Write the same list in the zone of the target.
- A secondary outside the list can no longer transfer the zone. The NOTIFY to it still goes out, without the SOA, and the transfer that follows is refused. The start warns about each such target.
- A dynamic update from outside the list gets REFUSED.
Over plain UDP, a client outside allow_recursion that asks your zones too often now gets empty
answers with the TC bit set. It then asks again over TCP. An answer to ANY over UDP holds one record
set. Troubleshooting has both.
Who the server resolves for
Section titled “Who the server resolves for”The server resolves names for the machine it runs on and for the private ranges. Every other
client gets REFUSED. The list is allow_recursion in node.toml, and
Configuration holds it.
Where it listens is the other half, and it is a separate setting. A new install listens on
127.0.0.1:5300, which no other machine can reach. To answer the rest of your network, add this
machine’s own address to listen in node.toml. Name each address you mean. A wildcard such as
0.0.0.0 is refused, because an answer can then leave from an address the client never asked.
Open the range your own network uses, and open nothing else. A server that resolves for the whole internet is found within hours. An attacker then sends a query with a forged source address, and this server sends the answer to the victim.
If your internet provider gives you IPv6, add your own prefix. The default list holds the private IPv6 ranges, and a provider gives you global addresses that no default can guess.
A name in a zone of your own needs no recursion, so allow_recursion does not decide it.
query_from does, and by default it holds the same private ranges
(Zones answer the private ranges).
This list is not a firewall rule. A client that asks another resolver never reaches this server, and the rule that stops that client belongs on your router.
The time client
Section titled “The time client”The server needs a file that says a time client set the clock. A signed name is judged against the clock, and a board with no clock battery, such as a Raspberry Pi, starts in 1970. So until that file appears, the server does not trust the clock.
While the clock is not trusted, the names of the time servers answer without validation, so the
time client can reach them. That lasts for clock_grace_minutes, 10 minutes by default. After
that time the server uses a clock that reads later than the build of this binary. An earlier clock
is wrong for certain. The names of the time servers then keep their answers, and every other signed
name fails until the clock is set.
| Time client | What to do |
|---|---|
| systemd-timesyncd | Nothing. It writes /run/systemd/timesync/synchronized, the default file |
| chrony | Install the unit below, and name its file in clock_synchronized_file |
| A container | Mount the directory of the host’s file read-only |
| None | Set clock_synchronized_file = "" and clock_grace_minutes = 0 |
chrony writes no such file, so packaging/tadoru-clock-chrony.service writes one. It waits with
chronyc waitsync and then creates /run/tadoru-clock/synchronized.
sudo cp packaging/tadoru-clock-chrony.service /etc/systemd/system/sudo systemctl daemon-reloadsudo systemctl enable --now tadoru-clock-chronyThen name the file in node.toml:
clock_synchronized_file = "/run/tadoru-clock/synchronized"A container reads the clock of its host, so the host’s time client is the one that counts. Mount
the directory of the host’s file at the same path, read-only. packaging/compose.yaml mounts the
directory of systemd-timesyncd. With docker run, add this flag:
-v /run/systemd/timesync:/run/systemd/timesync:roOn a host with chrony, mount /run/tadoru-clock in the same way. A file created later in the
mounted directory appears inside the container. A directory that is deleted and made again does
not. If the file never appears inside the container, restart the container.
Every name that your time client asks for must be in clock_grace_names. Read the names from
/etc/systemd/timesyncd.conf or /etc/chrony/chrony.conf. The default holds the NTP Pool, which
covers the pools of Debian, Raspberry Pi OS and Fedora, and the public servers of most operating
systems. A time client with NTS (Network Time Security) also asks for its key server, and that
name needs an entry too.
Do not make the server wait for the time. Do not add After=time-sync.target to its unit. The
server can be the resolver that the time client asks, and then each of the two waits for the
other. tadoru health says what the server thinks of the clock, and
Troubleshooting says what each state means.
Ask it something
Section titled “Ask it something”A new install holds no name and forwards to nobody, so every name answers NXDOMAIN. Give it one name of its own. Write two files under the config root, and the running server picks them up.
The directory of the config root, and its owner, depend on the way you took. Build the two files in a directory of your own first, with a mode that the config root accepts. Then put the directory in place with the commands of your way:
umask 027mkdir -p home-arpaprintf 'name = "home.arpa"\nkind = "primary"\n' > home-arpa/zone.tomlcat > home-arpa/records.zone <<'EOF'$TTL 300@ IN SOA ns.home.arpa. admin.home.arpa. ( 1 3600 600 604800 300 )@ IN NS ns.home.arpa.ns IN A 127.0.0.1nas IN A 192.168.1.10EOFFrom a checkout, the config root is yours:
mkdir -p ./data/config/zonesmv home-arpa ./data/config/zones/For a container, user 65532 owns data/, so move the directory as root and hand it over:
sudo mkdir -p data/config/zonessudo mv home-arpa data/config/zones/sudo chown -R 65532:65532 data/config/zones/home-arpaFor the systemd unit, the config root is /etc/tadoru, and the tadoru account owns it:
sudo mkdir -p /etc/tadoru/zonessudo mv home-arpa /etc/tadoru/zones/sudo chown -R tadoru:tadoru /etc/tadoru/zones/home-arpaThe umask 027 gives the directory mode 750 and each file mode 640, the modes that the rest of
the config root has. Without it, your shell makes a file that everybody can read, and a broad mode
is not a refusal. The server narrows a config file’s mode only where it rewrites that file. A
zone needs both files, and the directory arrives as a whole, so the server does not see one file
alone.
Now ask. Say where the server listens: use 127.0.0.1 and 5300 until you name another address
in listen. The container example above listens on port 53, so a container started with it
answers on 127.0.0.1 and 53.
SERVER=127.0.0.1PORT=5300
# The name the zone holds, answered by this server.dig @$SERVER -p $PORT nas.home.arpa A
# The same over TCP.dig +tcp @$SERVER -p $PORT nas.home.arpa A
# A name the zone does not hold: NXDOMAIN, with the zone's SOA.dig @$SERVER -p $PORT nothing.home.arpa ALocal Zones has the record format and what a refusal means. Every other name stays
NXDOMAIN until you name an upstream, because the forwarder list starts empty.
Configuration shows how, and then
dig @$SERVER -p $PORT example.com A reaches that upstream. Make your network use it
puts this server to work for the whole network.
Where every file lands
Section titled “Where every file lands”| Directory | Holds | Flag |
|---|---|---|
| Config root | The TOML files you edit | --config-dir |
| State root | Revisions, the databases, the secrets | --state-dir |
| Runtime root | The API socket | --runtime-dir |
--data-dir DIR sets the config root to DIR/config and the state root to DIR/state,
which is what a container uses: one volume, two subdirectories. It leaves the runtime root
alone, because a socket does not belong in a data volume.
With no flag at all, the three roots on Linux are /etc/tadoru, /var/lib/tadoru and
/run/tadoru. On macOS they are ./data/config, ./data/state and ./data/run.
bootstrap.toml in the config root can name the state root and the runtime root. The
server reads it before anything else runs, it holds nothing but those two paths, and no
revision carries it. It cannot name the config root, because it lives in the config root.
Only a flag moves that root, because a flag is read before the file is looked for.
The server writes the answer cache to STATE/cache/snapshot.bin every 15 minutes and at a stop,
so a restart starts warm. cache_snapshot_minutes in node.toml sets how often, and 0 turns it
off. The file is at mode 0600, because it holds the names the house asked. You can delete it
while the server is stopped. That costs one start with an empty cache and nothing else.
The server keeps the root keys it trusts in STATE/trust-anchors.toml, at mode 0640. It writes
the file at the first start and after each refresh of the keys, about once a day. You can delete
it while the server is stopped. The next start then begins again from the root keys built into
the server. A root key that the server learned after its build waits its 30 days again. The file
belongs to one machine, so a backup does not carry it and a restore does not replace it.
The server keeps the serial witness in STATE/serials.sqlite, at mode 0600: the first and the
last serial that each zone served. The first start of a build with the witness makes it, and the
log says made the serial witness, and the zones start their history now. Do not delete it. A
start that finds it gone stops every zone until tadoru zone witness accept or raise names it,
as A zone that the serial witness stops
says. The file belongs to one machine: a backup carries a copy, and a restore merges the copy into
it and never replaces it. A start moves a file that does not read aside to
STATE/serials.sqlite.damaged, which the server never reads.
With log_file_days above 0 in node.toml, the server writes the log to STATE/logs/. It writes
one file a day, tadoru-YYYY-MM-DD.log, at mode 0600, in a directory at mode 0700. It keeps
log_file_days days, within log_file_mib in all. You can delete a file while the server runs.
The file of the day keeps its room until the day ends, because the server holds it open. No backup holds the
directory, and a restore leaves it as it is. Logs and metrics
says what the files hold.
The API socket is RUNTIME/api.sock at mode 0660, owned by the user and the group the
server runs as. That user and that group reach it, and nobody else does. Reaching it also
needs a runtime root the group can enter, which is how the server makes that directory. A
directory that was there already keeps its own owner, group and mode. The socket is not on
a port. api_listen serves the API on a network address, over TLS, and
Console and remote API says how.
Logging and stopping
Section titled “Logging and stopping”The log goes to standard output, so journalctl -u tadoru reads it under the systemd unit, and
docker logs reads it in a container. Set log_level in node.toml to change what is logged. The default is
info. Set log_format = "json" to write one JSON object to a line, for a log collector. The
environment variables TADORU_LOG and TADORU_LOG_FORMAT do the same and win over the file.
Logs and metrics says how to read a line and how to choose what is logged.
SIGTERM and SIGINT both stop the server through the same path, which writes the cache
snapshot once more and flushes the query log. The snapshot write has three seconds of its own,
and one that is not ready by then keeps the previous file.
Then the stop waits for each writer of the configuration, in this order:
- The timer of the checkpoints, and a checkpoint that runs.
- The watcher of the config root, which finishes the pass it runs.
- The change that holds the lock of the command applier: an API change or an update.
After the third wait, every change is refused and writes nothing. An API change answers 503 with
the type stopping, and an update answers SERVFAIL. A wait that takes longer than 30 seconds logs
one warning, and then waits on with no bound:
the stop waits for a checkpoint to finishthe stop waits for the watcher to finish a passthe stop waits for a change of the configuration to finish
A second SIGTERM or SIGINT during the stop ends the process within half a second, with the
warning asked again to stop, so the stop ends here. The stop goes on in that half second, while
the log writes the lines that wait. The writer that the stop waited for is cut off then, so send
it only to a stop that does not end.
NOTIFY stops at a step of the stop, and not at the signal. An update that commits between the signal and that step can still send its NOTIFY, and after that step no NOTIFY goes out.
A reader of the log that stops reading does not hold the stop. At its end, the stop waits, for 2 seconds at most, until the lines that wait reach standard output. A full queue does not keep the stop out. After a second signal they get half a second, and the process ends with exit status 1, also where the stop ends first. Lines that still wait then are lost, and no counter counts them.
A signal that comes while the server starts stops it before the management API serves anybody and
before any NOTIFY goes out. The log says stopping before the start ends. A request that waited
on api.sock during the start gets no answer, and changes nothing. A dynamic update that waited is
not applied. A start that cannot bind api.sock takes the same stop, and then ends with the error
the management API failed. So does a start that cannot write the setup token, with the error
the setup token file could not be written.
The server hears a signal from the moment its log is up. It says so with the line asked to stop, so the server stops after the step that runs. A long step of the start lets that step
finish. Such steps are the replay of the journals of the zones, the moves of the serial witness and
the prune. The start then stops with the line stopping before the start ends and exit status 0.
Each of those steps writes, and a step cut half way would leave the next start a repair to make.
The load of the blocklists writes nothing, so a signal cuts it.
A second signal during the start cuts the step that runs. The process ends within half a second
with exit status 1 and the warning asked again to stop, so the stop ends here. Send it only to a
step that does not end. A signal in the first moments, before the log is up, still ends the process
where it stands, before the server has opened any of its stores.
A writer cut off half way is what the stop exists to avoid. The queries in flight then get up to five seconds, and the stop abandons them after that. A stop that never finishes is worse than one that loses the last answer. Troubleshooting has the answers a stop gives.
Metrics
Section titled “Metrics”Prometheus metrics are served at http://127.0.0.1:9153/metrics. The default is the
loopback address, because these numbers describe the inside of the server.
curl -s http://127.0.0.1:9153/metrics | grep dns_Set metrics_listen to move the endpoint, or set it to an empty string to turn it off.
An address that a running server did not serve yet takes effect at once. A move and turning it
off take effect at the next start, because the exporter takes one address for the life of the
process. The log records the change. Logs and metrics lists every metric,
with a scrape job and the alerts to set.
dns_blocklist_ and dns_blocked_total are the blocking half, and Blocking says
which of those to alert on.
The metrics report what is happening now. The hourly aggregates in The query log report what happened, on disk, by range. Neither replaces the other: the metrics have no history, and the aggregates have no immediacy.
Make your network use it
Section titled “Make your network use it”Until now only you asked the server. This step makes the other machines of your house ask it. That is what turns on blocking and your local names for everyone. It has five parts: the address, the listen address, the forwarders, the router, and a check.
1. Give the machine a fixed address. The router will name this address to every device, so it
must not change. Set a static address on the machine. Or tell the router to hand out the same
address to it every time, which a router calls a “reservation” or a “static lease”. The rest of this
section uses 192.168.1.2. Use your own.
2. Listen on that address, at port 53. Port 53 is the port that every DNS client uses, and a
router or a phone cannot ask another one. Name the address of the machine in listen in
node.toml, as the container example above does. Keep the loopback entry, so this machine can
ask too:
listen = ["127.0.0.1:53", "192.168.1.2:53"]A new address in listen takes effect at once. Port 53 needs the right to bind it, which the
unit and the container grant, and The first start says how a checkout gets it.
Who the server resolves for says which clients the server answers. The default list holds the private
ranges, so a machine of your house is answered. If your network uses another range, add it to
allow_recursion.
3. Name the forwarders. A forwarder is a resolver that this server asks for every name that it
does not hold itself. With an empty list, every other name answers NXDOMAIN, and your devices lose
the internet. Name one or two resolvers, in server.toml:
forwarders = ["1.1.1.1", "9.9.9.9"]Configuration says how this list works, and what resolution = "recurse" does
in its place.
4. Point the router at the server. Open the settings of your router, and find where it sets the DNS server that it gives to the devices. It is often in the page of the DHCP server or of the LAN. It may be named “DNS server”, “DHCP DNS” or “LAN DNS”. Put the address of this machine there. Leave the second entry empty, or use another Tadoru. A second resolver of another kind answers some of the questions, and those skip your blocking and your local names. A device takes the new setting when it renews its lease, which can take hours. To take it at once, turn the network of the device off and on. If your network also hands out an IPv6 DNS server, set that one in the router too. A device that has an IPv6 address of the router may ask that one instead.
A router that cannot change this setting is a limit of the router. Then set the DNS server on each device by hand, in its network settings. Do one device first, to check.
5. Check from another machine. Use a machine that is not the server. Ask the server directly, by its address. Neither command names a port, because the port is 53:
dig @192.168.1.2 nas.home.arpa Adig @192.168.1.2 example.com AThe first command answers with the address in your zone, and the second with the address of
example.com. Then check that the machine uses the server on its own. Ask with no @, and read the
line SERVER: of the answer:
dig example.com AIf the SERVER: line names the address of this machine, the router is set. If it names the router,
the device has not renewed its lease yet. The query log of the server shows the query, and
The query log says how to read it.
If a command times out, a firewall on the server blocks port 53, or listen does not name the
address. Open UDP and TCP on port 53 for your network, and no more. If the first command answers
and the second is REFUSED, the address of the machine is not in allow_recursion. If the second
is NXDOMAIN, the forwarders are empty. If it is SERVFAIL, they cannot be reached. Troubleshooting has an entry
for each message. The entry Nothing resolves is the place
to start.