Standalone mode
A standalone node has no account and no link to opdns. Its profile is in its configuration file. It downloads the same public list artifact (the signed file of filter lists) as everyone else.
Start in one command
Section titled “Start in one command”The node needs only an empty data volume and OPDNS_MODE=standalone:
docker run -d --name opdns-node --restart unless-stopped --read-only \ -p 53:53/udp -p 53:53/tcp \ -p 127.0.0.1:8053:8053 \ -v opdns-node:/var/lib/opdns \ -e OPDNS_MODE=standalone \ ghcr.io/operomtl/opdns-node:<version>On its first run, the node writes a starter profile to
/var/lib/opdns/profile.yaml (below). It fetches the public lists and
filters from then on. The local page (http://127.0.0.1:8053/) shows the
local API token one time. Without Docker, set
mode: standalone in the configuration and run opdns-node run.
Configure
Section titled “Configure”mode: standalone
lists: url: https://lists.opdns.net/lists/public/latest.json # the default; none: no lists poll: 6h
profile: id: home01 # any 6 characters, [a-z0-9] version: 1 # bump when you change the profile name: Home lists: [1, 10] # list ids from the catalogue (GET /v1/lists) deny: - pattern: "*.ads.example" allow: - pattern: "=cdn.example.net" rewrites: - {name: nas.home.arpa, type: A, value: 192.168.1.2} security: {threat_intel: true, nrd: true} parental: {safe_search: false} settings: block_mode: nxdomain logs_enabled: true log_client_ip: true log_domains: true retention_days: 30 cname_uncloak: true linked_ips: []mode: standalone is enough to start. If you set neither profile: nor
profile_file:, the node writes a starter profile to
<data_dir>/profile.yaml on its first run. This profile has the cloud
defaults for a new profile: security protections on, no list subscribed,
and logs kept on the node for 30 days. The node uses it as its profile file
and logs where it is. Edit it, or write it through the
local API. The node never overwrites it. Without lists.url,
the node fetches the public lists (see below). With lists.url: none, it
filters with the rules of the profile only.
The profile block uses the same field names as the profile document that
the cloud publishes. See the ProfileDocument schema in the
API reference. Unknown fields are errors. Instead
of an inline profile:, you can point profile_file: (or
--profile-file) at a JSON or YAML file with the same content.
Without lists.url, a standalone node polls the public list artifact that
opdns publishes for standalone nodes,
https://lists.opdns.net/lists/public/latest.json. It polls every
lists.poll (6 hours by default). You do not need an account. The
endpoint limits each client network (an IPv4 /24 or an IPv6 /48). Over the
limit, it answers 429 Too Many Requests with Retry-After. The node
then waits at least that long before it tries again. To fetch no lists and
filter with the rules of the profile only, set lists.url: none.
lists.url can also name another artifact (…/v<N>.bin) or the
latest.json pointer next to it, such as your own mirror. On every poll,
the node follows the pointer to the newest artifact. The artifact must
verify with a trusted Ed25519 key. By default
(lists.trust_cloud_key: true), the node trusts the pubkey published in
that latest.json, which it fetches over HTTPS from the same place. It
keeps the key in lists_keys.json for offline restarts. On a key
rotation, the node trusts the old key until the next fetch confirms the
new one. To pin the key yourself, set lists.public_keys and
lists.trust_cloud_key: false.
Instead of writing the profile by hand, you can use the profile.json of
any profile from an
account export. It
has the same format.
List ids come from the public catalog.
GET /v1/lists needs no
account.
To test the result without starting the node, run:
opdns-node config check /etc/opdns/node.yamlThe command makes sure that the file is valid. Unknown keys are errors, also in the profile. It then prints the effective configuration, with the source of every value (Configuration).
Edit the profile file
Section titled “Edit the profile file”With profile_file, the node watches the file. It applies an edit within
about two seconds, with no restart and no signal. It polls the
modification time, the size and the inode of the file. It therefore also
sees an editor that writes a new file and renames it over the old one.
This also works on bind mounts and network shares. An edit that does not
parse or is not valid changes nothing. The node keeps the last good
profile and shows the error, with its line and field, on the local page.
The node reads an inline profile: in node.yaml at start only. After
you change it, restart the node. You can also move it to a
profile_file.
Start from a cloud profile
Section titled “Start from a cloud profile”The data export of an
opdns account holds each profile as profiles/<id>/profile.json, in the
format that the node reads. To run a cloud profile on a standalone node,
run:
opdns-node import-export opdns-export.zip --profile abc123The command takes the profile from the archive. If the archive holds one
profile, you can leave out --profile. The command makes sure that the
profile parses and compiles. It then writes the profile to profile_file
(or --profile-file) with mode 0600, because the profile lists your
linked addresses. A running node applies it like any edit.
What is different from enrolled mode
Section titled “What is different from enrolled mode”- There is no dashboard. Logs stay in the SQLite file of the node. Read
them with
sqlite3. The local API does not serve logs yet. - The node fetches the list artifact again every
lists.poll, with a conditional request. The default is 6 hours, plus or minus 10 %, so that nodes do not all ask at the same time. When the download endpoint answers 429 or 503, the node keeps its current lists. It waits at least theRetry-Aftertime that the endpoint sent before it tries again. - opdns sees only the artifact downloads (address and time).
Local page
Section titled “Local page”http://<node>:8053/ shows the health, the versions, the loaded profile
and lists, the path of the configuration file, the SQLite size, and the
network guard. /api/status gives the
same information as JSON. /healthz is the health check. /metrics
serves Prometheus metrics, on by default
(Metrics). A
password can
protect the page. These pages answer only devices on your network. See
Network access.
Local API
Section titled “Local API”A standalone node has a small REST API on the same port, for scripts and home automation.
| Request | Does |
|---|---|
GET /api/profile |
the profile in use, with its version as ETag |
PUT /api/profile |
replace the profile (JSON or YAML, the same format as the file). The node validates it, rewrites the profile file (as JSON) and applies it at once. It answers with the stored profile and its new version. |
GET /api/lists |
the loaded list artifact: version, entries, when it was built and fetched, its source, the last error, and every list with its category and whether the profile applies it |
POST /api/lists/refresh |
fetch the list artifact now instead of at the next lists.poll (202) |
Every request needs Authorization: Bearer <token>. Set the token with
web.api_token (at least 16 characters), or leave it empty. If it is
empty, the node makes a token (opdnslocal_…) on its first run. It keeps
the token in <data_dir>/secrets/api_token and shows it one time on the
local page.
TOKEN=$(sudo cat /var/lib/opdns/secrets/api_token)curl -H "Authorization: Bearer $TOKEN" http://192.168.1.2:8053/api/profileWrites are protected against lost updates. Send the ETag of your GET
back as If-Match, or leave the version that you read in the body. If
the profile changed in between, by another write or by hand in the file,
the answer is 409 version_mismatch and nothing changes. If the node
refuses a profile, the answer is 422 validation_failed, with the reason.
The API writes a profile only when the profile is in its own file. If the
profile is inline in node.yaml, PUT /api/profile answers 409. It asks
you to move the profile to a file named by profile_file. An enrolled
node answers 404 on every /api/profile and /api/lists route, because
you configure it from the dashboard.