Skip to content
Sign inDashboard

Enroll a node

Enrollment connects a new node to your opdns account, so that you manage it from the dashboard. The node exchanges a one-time code for a node token (the long-lived credential of the node). It stores the token in its data directory and opens its link to opdns.

  1. In the dashboard, open the Nodes page of the profile and click Add node. While the profile has no node, the button is Add a node. Give the node a name and click Create enrollment code.

    You get a code that starts with opdnsenrol_. It works once and expires after 15 minutes. The dialog also shows the commands below, with the code filled in.

  2. On the node, use the code:

    Give the code in the environment on first start. The node then enrolls itself:

    Terminal window
    docker run ... -e OPDNS_ENROL_TOKEN=opdnsenrol_... ghcr.io/operomtl/opdns-node:<version>

    The full command is on Install with Docker.

  3. Start (or restart) the node. Within seconds, the Nodes page in the dashboard shows it online, with its versions.

  4. Point the DNS of your network at the LAN address of the node.

The node writes node.json (mode 0600) to its data directory. This file holds the node id, the node token (opdnsnode_…), the profile id, and the link and profile URLs that the cloud gave. The node does not store the one-time code, only its hash. If you enroll again with the same code, nothing happens and you get no error.

The node also writes profile_keys.json. It holds the keys that the cloud signs your profile with. From then on, the node makes sure that every profile matches these keys (Profile signing keys).

The node token is the only credential of the node, so it does not stay valid forever. A connected node replaces it with a new token every 90 days, by itself. link.token_rotation sets this interval, and 0 turns it off.

To rotate the token, the node asks the cloud for a new token over its link. It writes the token to node.json in one atomic step, so a power cut leaves either the old or the new token. Then it switches to the new token and confirms. The previous token keeps working for 10 minutes after that, so requests in progress do not fail.

The audit log records each rotation as node.token_rotated. The activity lists in the dashboard show it as Node token rotated. The record of the node holds the time of the last rotation (token_rotated_at in the API).

To rotate now, for example after someone copied the data directory to a place where it must not be, run:

Terminal window
sudo -u opdns opdns-node rotate-token
rotated the token of node 7c9e…. The new token is saved in /var/lib/opdns/node.json
the previous token keeps working for 10m0s. A running node switches to the new one within seconds

The command works whether or not the node is running. A running node reads the new token from node.json within about 10 seconds and reconnects with it. Only the current token can rotate. During its 10 minutes, the previous token gets the refusal node_token_superseded. The local page shows when the token was issued, how often it rotates and the last failed attempt, if there is one. If you think that a token leaked, use Revoke on the Nodes page instead. Revoke stops the token at once.

You can move a node to new hardware or a new container without a new code. Keep the data directory, which has the token, the last profile and the logs. Or enroll the new install with the old node token from node.json:

Terminal window
opdns-node enrol --token opdnsnode_...

The node asks the cloud which node the token belongs to. With --node-id <id>, it does not ask and enrolls offline.

A node can already run in standalone mode, with a profile_file, an inline profile: in its configuration, or the starter profile that it wrote to <data_dir>/profile.yaml. Such a node sends that local profile with the enrollment code. Your dashboard profile then starts as a copy of what the node was doing:

Terminal window
sudo -u opdns opdns-node enrol --token opdnsenrol_...

Before the node sends anything, it shows what it will upload and asks you to confirm:

enrolling uploads the local profile (profile_file /etc/opdns/profile.yaml) and replaces the dashboard profile of this code with it:
"Home": 3 deny and 1 allow rules, 1 rewrites, 2 lists, block mode nxdomain, logs on
if that profile already has settings or rules, the cloud keeps it and holds the local profile for review in the dashboard instead. --keep-cloud-profile enrolls without uploading
replace the dashboard profile with the local profile? [y/N]

Any answer other than y cancels. The node sends nothing, and the code stays valid. Without a terminal (a script, a provisioning tool), the command cannot ask the question. It then refuses to run unless you give --yes. If a script enrolled a standalone node without this flag, add the flag to the script.

After an upload that replaced the dashboard profile:

the local profile (profile_file /etc/opdns/profile.yaml) is now the cloud profile. From now on, edit it in the dashboard
the local profile is archived in /var/lib/opdns/archive/standalone-profile-<time>.json. The node now pulls the cloud profile
note: the node no longer reads profile_file (it follows the cloud profile). Remove profile_file from the config

The node keeps the uploaded profile in <data_dir>/archive/, and node.json records where it came from.

A node that runs from its starter profile names it in both messages (the starter profile /var/lib/opdns/profile.yaml). It has no profile_file to remove. In both cases, remove mode: standalone (or OPDNS_MODE=standalone) from the configuration before the next start. If you do not, the node stays standalone. In a container, stop the node. Then enroll its volume from a one-off container of the same image. Start the node again without OPDNS_MODE:

Terminal window
docker stop opdns-node
docker run --rm -v opdns-node:/var/lib/opdns -e OPDNS_MODE=standalone \
ghcr.io/operomtl/opdns-node:<version> enrol --token opdnsenrol_... --yes

The cloud takes the local profile only while its own profile is unchanged (never edited, no rules). If it changed, the node still enrolls, but the dashboard profile does not change. The local profile waits for your review on the Nodes page of the dashboard. There, you adopt it (into that profile or a new one), or you keep the dashboard profile. The command tells you this, instead of reporting an upload:

the cloud profile already has settings or rules, so it was not replaced. The local profile (profile_file /etc/opdns/profile.yaml) waits for review in the dashboard (Nodes page). Adopt it into this profile or a new one, or keep the cloud profile
the local profile was not archived and stays in /etc/opdns/profile.yaml, unchanged. The node follows the cloud profile, which changes only if you adopt the local profile
note: the node no longer reads profile_file (it follows the cloud profile). When you decide on the adoption, remove profile_file from the config

In that case, the node archives nothing. The local profile stays where it was until you remove it. To leave the local profile out completely, enroll with --keep-cloud-profile. The node then follows the dashboard profile as it is. If someone edits the dashboard profile while you enroll, the cloud can refuse the enrollment with profile_not_empty. Nothing is enrolled and the code stays valid. Enroll with --keep-cloud-profile, or reset the profile in the dashboard and enroll again.

Only a new enrollment code uploads the profile. Re-installing with a node token (opdnsnode_…) and enrolling from OPDNS_ENROL_TOKEN never upload it.

After you enroll, remove profile_file (and mode: standalone, if set) from the configuration. The enrol command reminds you. If the profile of a profile_file was uploaded, the node no longer reads that file and follows the dashboard. This is true when it replaced the dashboard profile and when it waits for review. A profile_file that was not uploaded still wins over the dashboard profile for as long as it is set. This happens with --keep-cloud-profile, or when you re-install with a node token.

To unenroll a node, stop it first (sudo systemctl stop opdns-node, or stop the container). Then run:

Terminal window
sudo -u opdns opdns-node unenrol
unenrolled node 7c9e…: revoked in the cloud. Token, log cursor and learned list keys removed
query logs, the last profile and lists are kept (--purge-logs deletes the logs)

First, the command revokes the node in the cloud with its own token. This also closes its link session, as Revoke on the Nodes page does. Then the command removes the node token (node.json), the log cursor and the signing keys that the node learned from the cloud (lists_keys.json for lists, profile_keys.json for profiles). The logs, the last profile and the list artifact stay on disk. --purge-logs also deletes the logs.

The call to the cloud stops after a few seconds. If opdns is not reachable, unenrol continues locally. It prints a note that asks you to revoke the node on the Nodes page, so that its token stops working. If the dashboard already revoked or deleted the node, the command counts it as done. --local-only skips the call to the cloud.

After you unenroll the node, it does not serve DNS on its next start. Like a new install, it prints how to enroll and exits with status 2. Enroll it again with a new code, or give it a profile for standalone mode. It never falls back to unfiltered resolution. If OPDNS_ENROL_TOKEN (enrol.token) is still set, the next start enrolls the node again with it. The unenrol command tells you this. To stay unenrolled, remove the variable.

A node with no identity, no enrollment code and no standalone profile does not serve DNS. opdns-node run prints:

opdns-node: this node is not set up yet, so it is not serving DNS.
1. In the opdns dashboard, open Nodes → Add node and copy the enrollment code.
2. Enroll: opdns-node enrol --token <code>
(containers: set OPDNS_ENROL_TOKEN=<code> instead. The node enrolls on start.)
3. Start: opdns-node run

Then it exits with status 2. The systemd unit does not restart the node on this status.

An enrolled node opens two types of outbound connection:

  • HTTPS to cloud.api_url (https://api.opdns.io), for enrollment and for profile and list pulls.
  • The WebSocket link to cloud.link_url (wss://link.opdns.net/link).

Both connections, and list artifact downloads, use TLS 1.3 only. The node verifies them against the certificate authorities of the system (plus cloud.ca_file). cloud.proxy sends them through an HTTP proxy, instead of HTTPS_PROXY. The node never prints or logs the password of the proxy.

cloud.spki_pins also pins the keys of those two hosts. It is a list of sha256/<base64> hashes of the SubjectPublicKeyInfo of a certificate. At least one of them must be in the verified chain. It is off by default. A TLS-inspecting proxy or a change of certificate authority breaks a pinned node until you update the pins. List artifacts are never pinned. Their Ed25519 signature protects them, wherever they come from.

/etc/opdns/node.yaml
cloud:
spki_pins:
- sha256/<base64 of the SPKI hash>

On the Nodes page of the dashboard, the card of each node shows its status and versions. It also shows:

  • Link RTT: the round trip of the link, as the node last measured it (the handshake, then keepalive pings), while it is online. Older node versions do not report it.
  • Profile key: whether the node trusts the key that opdns now signs profiles with, and the ids of the keys that it trusts. A node learns new keys from profiles signed with a key that it already trusts. If a node missed a key change, the card shows current key not trusted and a warning. The node refuses profile changes and keeps resolving with the last profile that it accepted. Revoke the node and enroll it again. Enrollment gives it the current keys.
  • Location: the approximate place that the node links from (near Montréal, Canada, or only the country). opdns looks it up from the public address that the node connects from. The card shows unknown when that is a private address, or an address that the location database does not know. Only you see it, as on the Analytics globe. opdns does not store the address itself.
Symptom Cause
enrollment code refused: expired (token_expired) The code is older than 15 minutes. Create a new code and enroll at once.
enrollment code refused: already used (token_used) A code enrolls one node, one time, or its node was removed in the dashboard. For another node, create a new code. To re-install the node that the code enrolled, keep its data directory, or enroll with its node token from node.json.
enrollment code refused: not known to this opdns cloud (invalid_token) The code has a typing error or is cut short. Or it comes from an opdns environment other than the one that cloud.api_url points at (the message prints it). Copy the code again from the correct dashboard.
could not reach the opdns cloud at … A DNS, network or proxy problem between the node and cloud.api_url. The node saved nothing. When the cloud is reachable, run the same command again.
node stays offline in the dashboard Outbound HTTPS to api.opdns.io and link.opdns.net is blocked, or a TLS-inspecting proxy is in the way (connections to opdns). If you need a proxy, set cloud.proxy.
dashboard says current key not trusted The node missed a change of the profile signing key and refuses new profiles (what the Nodes page shows). Revoke the node and enroll it again.
status says “revoked” Someone revoked the node in the dashboard. It keeps resolving with its last profile. Enroll it again or switch to standalone.
exits with status 2 and “this node is not set up yet” No identity and no enrollment code (also with mode: enrolled set). Enroll the node.
exits with status 1 right after start with OPDNS_ENROL_TOKEN set The cloud refused the code (see the enrollment code refused rows above), or the cloud was unreachable. The log says which.
pass --yes to upload the local profile when enrolling from a script The node has a local profile and no terminal to confirm the upload. Add --yes, or add --keep-cloud-profile to leave the profile out (Enrol a standalone node).
node_token_superseded A request used the previous node token after a rotation (a copy of an old node.json, or a second install). Use the current token, or rotate again from the running node.
profile_not_empty when enrolling a standalone node The dashboard profile already has settings or rules. Enroll with --keep-cloud-profile, or reset the profile first.
unenrol prints a note about the dashboard The cloud was not reachable. Revoke the node on the Nodes page.