Install the static binary
Each release carries static
binaries named opdns-node_<version>_<os>_<arch> for linux_amd64,
linux_arm64 and darwin_arm64, with a SHA256SUMS file. The binary has
no dependencies except Unbound, which it starts and supervises. Without
Unbound, it refuses to start.
Install on Linux with systemd
Section titled “Install on Linux with systemd”These steps are for Debian, Ubuntu and Raspberry Pi OS, on amd64 or
arm64. The node runs as a dedicated opdns user, from the systemd unit
in The unit file below.
-
Install Unbound. Stop the Unbound service of the distribution, because it takes port 53. The node runs its own instance on
127.0.0.1:5353, with a generated configuration.Terminal window sudo apt install unboundsudo systemctl disable --now unboundTerminal window sudo apk add unboundAlpine has no systemd. Run the node from your init system, with the same user and data directory.
The node looks for
unboundon thePATHand in/usr/sbin,/usr/local/sbin,/opt/homebrew/sbinand/sbin. If Unbound is in another place, setunbound.binary. The node needs Unbound 1.17.0 or newer. With an older one, it refuses to start and names the version that it found. Debian 12 and Raspberry Pi OS 12 ship 1.17.1, Ubuntu 24.04 ships 1.19, and current Alpine releases ship newer ones. -
Download and verify the binary:
Terminal window V=<version>; A=linux_arm64curl -fLO https://github.com/operomtl/opdns/releases/download/v$V/opdns-node_v${V}_$Acurl -fLO https://github.com/operomtl/opdns/releases/download/v$V/SHA256SUMSsha256sum --ignore-missing -c SHA256SUMSsudo install -m 0755 opdns-node_v${V}_$A /usr/local/bin/opdns-node -
Create the
opdnsuser and its data directory, and install the unit:Terminal window sudo useradd --system --user-group --home-dir /var/lib/opdns --shell /usr/sbin/nologin opdnssudo install -d -o opdns -g opdns -m 0700 /var/lib/opdnsSave the unit file as
opdns-node.servicein the current directory, then:Terminal window sudo install -m 0644 opdns-node.service /etc/systemd/system/opdns-node.servicesudo systemctl daemon-reload -
Free port 53 from the stub listener of systemd-resolved. The host continues to resolve through the upstream servers of systemd-resolved:
Terminal window sudo mkdir -p /etc/systemd/resolved.conf.dprintf '[Resolve]\nDNSStubListener=no\n' | sudo tee /etc/systemd/resolved.conf.d/opdns.confsudo systemctl restart systemd-resolvedsudo ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf -
Enroll the node. In the dashboard, open Nodes → Add node and create a code. Then run:
Terminal window sudo -u opdns opdns-node enrol --token <enrolment-code>You can also put
OPDNS_ENROL_TOKEN=<enrolment-code>in/etc/opdns/node.env(mode 0600). The node then enrolls on its first start and ignores the variable after that. See Enroll a node. To run without an account, see standalone mode. -
Start the node and make sure that it runs:
Terminal window sudo systemctl enable --now opdns-nodeopdns-node statusjournalctl -u opdns-node -fThe status page is on port 8053.
An enrolled node needs no configuration file. The list signing key comes
from the cloud (list signing keys).
Put configuration keys in /etc/opdns/node.yaml, or as
OPDNS_<SECTION>_<KEY> variables in /etc/opdns/node.env. A command-line
flag wins over the environment, and the environment wins over the file.
The configuration reference lists every
key.
The unit file
Section titled “The unit file”# opdns-node: the self-hosted opdns node as a hardened systemd service.## binary /usr/local/bin/opdns-node (static; runs the distribution's unbound)# config /etc/opdns/node.yaml (optional), /etc/opdns/node.env (optional,# OPDNS_* variables such as OPDNS_ENROL_TOKEN)# data /var/lib/opdns (owned by the opdns user)# user opdns, the same name as in the container image; the ids# `useradd --system` picks here do not matter## Exit status 2 means "not set up yet" or "invalid configuration": the unit# does not restart on it; enrol the node (or fix the config) and start it.[Unit]Description=opdns self-hosted DNS nodeDocumentation=https://opdns.io/docs/self-hosted/install-binary/Wants=network-online.targetAfter=network-online.target# Port 53 must be free: disable systemd-resolved's stub listener first# (DNSStubListener=no).Conflicts=dnsmasq.service
[Service]Type=execUser=opdnsGroup=opdnsDynamicUser=noEnvironmentFile=-/etc/opdns/node.envEnvironment=OPDNS_DATA_DIR=/var/lib/opdnsExecStart=/usr/local/bin/opdns-node runExecReload=kill -HUP $MAINPIDRestart=on-failureRestartSec=5sRestartPreventExitStatus=2TimeoutStopSec=20sLimitNOFILE=65536UMask=0077
StateDirectory=opdnsStateDirectoryMode=0700ConfigurationDirectory=opdnsReadWritePaths=/var/lib/opdns
# Bind port 53 (and 853/443) as an unprivileged user, and nothing else.AmbientCapabilities=CAP_NET_BIND_SERVICECapabilityBoundingSet=CAP_NET_BIND_SERVICENoNewPrivileges=yes
ProtectSystem=strictProtectHome=yesPrivateTmp=yesPrivateDevices=yesProtectHostname=yesProtectClock=yesProtectKernelTunables=yesProtectKernelModules=yesProtectKernelLogs=yesProtectControlGroups=yesProtectProc=invisibleProcSubset=pidRestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 AF_NETLINKRestrictNamespaces=yesRestrictRealtime=yesRestrictSUIDSGID=yesLockPersonality=yesMemoryDenyWriteExecute=yesRemoveIPC=yesSystemCallArchitectures=nativeSystemCallFilter=@system-serviceSystemCallFilter=~@privilegedSystemCallErrorNumber=EPERM
[Install]WantedBy=multi-user.targetThe unit has Conflicts=dnsmasq.service. When the node starts, systemd
stops dnsmasq, which otherwise holds port 53. If you need dnsmasq for DHCP,
remove that line. Then set port=0 in the configuration of dnsmasq
instead.
What the unit does
Section titled “What the unit does”| Runs as | the opdns user, with only CAP_NET_BIND_SERVICE (ports 53, 443, 853), no new privileges |
| Files | reads /etc/opdns/node.yaml and /etc/opdns/node.env if they exist. Writes only /var/lib/opdns (ProtectSystem=strict, private /tmp, no home directories) |
| Restarts | on failure after 5 seconds, except on exit status 2 |
systemctl reload opdns-node |
sends SIGHUP: applies the reloadable keys of the configuration, pulls the profile and lists again and reloads the TLS certificate |
| Stops | on SIGTERM, within 20 seconds: drains listeners, flushes pending log records, closes the link, stops Unbound |
With systemd 252 on Debian 12, the systemd-analyze security exposure
level of the unit is 1.7 (“OK”). To test it on your host, run
systemd-analyze security --offline=yes /etc/systemd/system/opdns-node.service
(systemd 252 or newer). Older versions test the loaded unit with
systemd-analyze security opdns-node. The unit leaves open only what a DNS
server needs. That is the host network, Internet and local sockets (Unix
sockets for the control of Unbound, netlink for the IPv6 route test), and
the capability to bind port 53.
Exit status 2 means that the node is not set up, or that its configuration is not valid. A node that is not set up has no identity, no enrollment code and no standalone profile. The node prints what to do, and systemd does not restart it. Correct the cause and start the node. A node that is not set up never serves unfiltered DNS.
Certificates for encrypted DNS
Section titled “Certificates for encrypted DNS”If you set listen.dot, listen.doh, listen.doq or listen.doh3, the
node needs listen.tls_cert and listen.tls_key. The node reads both
files every second. When a renewed pair appears, it loads the pair at once,
with no restart. If a pair fails to load, the node logs it and keeps the
previous certificate. A renewal hook must only write the files where the
opdns user can read them (for example under /etc/opdns).
systemctl reload opdns-node forces a reload. See also
Encrypted DNS on the node.
macOS and other systems
Section titled “macOS and other systems”On macOS, run brew install unbound. Then run opdns-node run from a
terminal or from your own launchd job. There is no packaged service yet.
The node must bind port 53, so run it as root, or on another port
(listen.udp, listen.tcp).
Commands
Section titled “Commands”opdns-node run [--config FILE] [--data-dir DIR] [--log-level L] [--enrol-token CODE] [--profile-file FILE] [--lists-url URL] [--print-config]opdns-node enrol --token CODE|TOKEN [--node-id ID] [--replace] [--keep-cloud-profile] [--yes] [--config FILE] [--data-dir DIR]opdns-node unenrol [--purge-logs] [--local-only] [--config FILE] [--data-dir DIR]opdns-node rotate-token [--config FILE] [--data-dir DIR]opdns-node status [--config FILE] [--addr HOST:PORT] [--json]opdns-node config check [--config FILE | FILE]opdns-node config referenceopdns-node backup [--config FILE] [--data-dir DIR] ARCHIVEopdns-node restore [--force] [--config FILE] [--data-dir DIR] ARCHIVEopdns-node import-export [--profile ID] [--profile-file FILE] [--config FILE] EXPORT.zipopdns-node hash-passwordopdns-node versionrun is the default command. These pages explain the other commands:
enrol,unenrolandrotate-token: Enroll a node.config checkandconfig reference: Configuration.backupandrestore: Upgrade and back up.import-export: Standalone mode.hash-password: Network access.
status asks the status page of the running node. If the node is not
running, status reads the data directory (exit status 3).