Skip to content

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.

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.0 or v0.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 main whose checks pass makes a pre-release of its last commit, once the maintainer has turned releases on. Its tag is such as v0.2.0-dev.42, and the tag of its image is 0.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:

Terminal window
gh auth login
gh release download v0.2.0 -R bitcldr/tadoru -p 'tadoru-0.2.0-linux-amd64.tar.gz' -p SHA256SUMS
sha256sum --check --ignore-missing SHA256SUMS
mkdir tadoru-0.2.0
tar -xzf tadoru-0.2.0-linux-amd64.tar.gz -C tadoru-0.2.0
cd tadoru-0.2.0 && sudo ./install.sh

For 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:

Terminal window
gh auth token | docker login ghcr.io -u <your GitHub user> --password-stdin
docker pull ghcr.io/bitcldr/tadoru:0.2.0

There 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.

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:

Terminal window
git clone https://github.com/bitcldr/tadoru.git
cd tadoru
just build-server

The 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:

Terminal window
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.

Terminal window
TADORU_COMMIT=$(git rev-parse --short HEAD) cargo build --release

A 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.

Build the image from a checkout, make the directory it writes to, and start it:

Terminal window
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 data
sudo chown -R 65532:65532 data
docker run -d --name tadoru --restart unless-stopped \
--network host -v ./data:/data tadoru:local

The 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.

Terminal window
sudo sed -i 's/^# *listen = .*/listen = ["127.0.0.1:53", "192.168.1.2:53"]/' data/config/node.toml
docker stop tadoru
docker rm tadoru
docker run -d --name tadoru --restart unless-stopped \
--network host --cap-add NET_BIND_SERVICE -v ./data:/data tadoru:local

The 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.

Terminal window
docker exec tadoru /usr/bin/tadoru health

For 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:

Terminal window
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:local

In compose.yaml, the same mount is a tmpfs: entry of the service:

tmpfs:
- /run/tadoru:size=80m,uid=65532,gid=65532,mode=0750

The 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.

Terminal window
sudo cat data/state/setup-token

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.

Terminal window
cargo build --release
sudo ./packaging/install.sh --binary target/release/tadoru
sudo systemctl enable tadoru
sudo systemctl start tadoru
sudo tadoru health

The 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.

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.

/etc/fstab
tmpfs /run/tadoru tmpfs size=80m,mode=0750,uid=tadoru,gid=tadoru,nosuid,nodev,noexec,x-systemd.before=tadoru.service 0 0
Terminal window
sudo mkdir -p /run/tadoru
sudo systemctl daemon-reload
sudo mount /run/tadoru
sudo systemctl restart tadoru

The 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.

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:

Terminal window
echo 'net.core.rmem_max = 4194304' | sudo tee /etc/sysctl.d/60-tadoru.conf
sudo sysctl --system

Then 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.

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:

Terminal window
sudo systemctl edit tadoru
[Unit]
After=wg-quick@wg0.service
Wants=wg-quick@wg0.service

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.

Run the binary and name a directory for it to write. Nothing else is installed, and deleting that directory undoes the whole thing.

Terminal window
tadoru --data-dir ./data --runtime-dir ./data/run

The 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.

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.

Terminal window
cat ./data/state/setup-token # from a checkout
sudo cat data/state/setup-token # a container, in the directory you mounted
sudo cat /var/lib/tadoru/setup-token # the systemd unit

The 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.

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.

  1. 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.
  2. Put the new binary in place and start it, as below.
  3. Watch the log. A first start of a new build can bring each database up to its schema. Wait for the migrated line after each migrating line, and do not stop the server in between (The first start says how long that can take).
  4. 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:

Terminal window
sudo install -m 0600 -o 65532 -g 65532 ./passphrase data/passphrase
docker exec tadoru /usr/bin/tadoru backup --data-dir /data --output /data/before.tar.gz \
--passphrase-file /data/passphrase
sudo rm -f data/passphrase
ls -l data/before.tar.gz

Move data/before.tar.gz to a safe place that is not in data/, and then go on:

Terminal window
docker pull ghcr.io/bitcldr/tadoru:0.2.1
docker stop tadoru
docker rm tadoru
docker run -d --name tadoru --restart unless-stopped \
--network host --cap-add NET_BIND_SERVICE -v ./data:/data ghcr.io/bitcldr/tadoru:0.2.1
docker exec tadoru /usr/bin/tadoru health

For 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.

Terminal window
sudo install -d -m 0700 -o tadoru /tmp/tadoru-upgrade
sudo install -m 0600 -o tadoru ./passphrase /tmp/tadoru-upgrade/passphrase
sudo -u tadoru tadoru backup --output /tmp/tadoru-upgrade/before.tar.gz \
--passphrase-file /tmp/tadoru-upgrade/passphrase
sudo rm -f /tmp/tadoru-upgrade/passphrase
ls -l /tmp/tadoru-upgrade/before.tar.gz

Move the archive to a safe place, and remove the directory. Then go on:

Terminal window
sudo mv /tmp/tadoru-upgrade/before.tar.gz ~/before.tar.gz
sudo rmdir /tmp/tadoru-upgrade
sudo ./packaging/install.sh --binary target/release/tadoru
sudo systemctl restart tadoru
sudo tadoru health

For 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:

Terminal window
tadoru backup --data-dir ./data --output ./before.tar.gz --passphrase-file ./passphrase
tadoru --data-dir ./data --runtime-dir ./data/run
tadoru health --data-dir ./data --runtime-dir ./data/run

A 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.

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.

  1. Write into query_from of [zones] in server.toml each 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.

  2. 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.

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 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.

Terminal window
sudo cp packaging/tadoru-clock-chrony.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now tadoru-clock-chrony

Then 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:

Terminal window
-v /run/systemd/timesync:/run/systemd/timesync:ro

On 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.

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:

Terminal window
umask 027
mkdir -p home-arpa
printf 'name = "home.arpa"\nkind = "primary"\n' > home-arpa/zone.toml
cat > 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.1
nas IN A 192.168.1.10
EOF

From a checkout, the config root is yours:

Terminal window
mkdir -p ./data/config/zones
mv home-arpa ./data/config/zones/

For a container, user 65532 owns data/, so move the directory as root and hand it over:

Terminal window
sudo mkdir -p data/config/zones
sudo mv home-arpa data/config/zones/
sudo chown -R 65532:65532 data/config/zones/home-arpa

For the systemd unit, the config root is /etc/tadoru, and the tadoru account owns it:

Terminal window
sudo mkdir -p /etc/tadoru/zones
sudo mv home-arpa /etc/tadoru/zones/
sudo chown -R tadoru:tadoru /etc/tadoru/zones/home-arpa

The 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.

Terminal window
SERVER=127.0.0.1
PORT=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 A

Local 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.

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.

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:

  1. The timer of the checkpoints, and a checkpoint that runs.
  2. The watcher of the config root, which finishes the pass it runs.
  3. 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 finish
  • the stop waits for the watcher to finish a pass
  • the 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.

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.

Terminal window
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.

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:

Terminal window
dig @192.168.1.2 nas.home.arpa A
dig @192.168.1.2 example.com A

The 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:

Terminal window
dig example.com A

If 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.