Skip to content
Sign inDashboard

Command line (opdns CLI)

opdns is a small DNS forwarder (a program that passes DNS queries on to a resolver). It answers on 127.0.0.1:53 and [::1]:53. It sends every query to opdns over encrypted DNS, with your profile id and a device name. Use it if the system has no encrypted DNS setting of its own (Windows 10, most Linux without systemd-resolved, routers). Also use it if you want more than the system setting gives you:

  • Every transport, with fallback: DNS-over-HTTPS over HTTP/3, then over HTTP/2, then DNS-over-TLS, then DNS-over-QUIC. If a network blocks one transport, the next one answers. The forwarder tries the faster one again in the background.
  • A device name from the host name, or the name that you choose.
  • Named LAN devices on a router: each device behind the router appears under its own name in your logs.
  • Local names forwarded to your router (home.arpa, a company domain).
  • Captive portals in hotels and cafés still show their login page.
  • A self-hosted node at home, for when the cloud is out of reach.

If the system already supports encrypted DNS (Android, iOS, macOS, Windows 11, systemd-resolved, the browsers), its own setting needs no extra software. See the other setup guides.

Before you start, get your profile id from the Setup page of the dashboard. You also need administrator rights, because the forwarder binds port 53 and sets the resolver of the system.

The binaries are on the releases page, with the names opdns_v<version>_<os>_<arch>. Next to them is a SHA256SUMS file that lists the checksum of every file in the release. In the commands below, replace <version> with the newest version on that page, without the leading v (for example 0.1.23 for v0.1.23).

  1. Download the binary for your machine (linux_amd64 for x86-64, linux_arm64 for 64-bit ARM). Make sure that the checksum is correct, then install it:

    Terminal window
    V=<version>; A=linux_amd64
    curl -fLO https://github.com/operomtl/opdns/releases/download/v$V/opdns_v${V}_$A
    curl -fLO https://github.com/operomtl/opdns/releases/download/v$V/SHA256SUMS
    sha256sum --ignore-missing -c SHA256SUMS
    sudo install -m 0755 opdns_v${V}_$A /usr/local/bin/opdns

    sha256sum must print OK for the file.

  2. Install it as a service for your profile:

    Terminal window
    sudo opdns install --profile <profile-id>

    This command writes /etc/opdns/client.yaml. It installs and starts the systemd unit opdns.service. While the service runs, the system uses it. With systemd-resolved, the command adds a drop-in (/etc/systemd/resolved.conf.d/opdns.conf). Without systemd-resolved, it keeps a copy of /etc/resolv.conf and then replaces the file.

  3. Check it works, and see what the forwarder does:

    Terminal window
    opdns status

The device name is the first label of the host name (Annas-MacBook.local becomes annas-macbook). To choose a different name, use --device. Names follow the rules of the resolver (Your endpoints).

For profile abc123 and device laptop, the forwarder uses, in this order:

Transport Address
DNS-over-HTTPS, HTTP/3 then HTTP/2 https://dns.opdns.net/abc123/laptop
DNS-over-TLS (port 853) laptop-abc123.dns.opdns.net
DNS-over-QUIC (port 853) laptop-abc123.dns.opdns.net

The forwarder looks up dns.opdns.net one time, through the resolver that your network gave you (the one in use before activation). It keeps its connections open between queries. It caches answers for their TTL.

If a transport fails, the forwarder skips it for 15 seconds. Each time the transport fails again, the forwarder skips it for twice as long, up to 5 minutes. It tests the transport again in the background, on the unfiltered public path. It never delays one of your queries for this test. When you move to a different network, the forwarder starts again from the beginning. To change the order or to leave out transports, use --transports doh2,dot.

Command Does
opdns status Shows the service, the transport in use, the state of every transport, the cache and the counters.
opdns stop / opdns start Stops or starts the service. When it stops, it puts back the system resolver.
opdns deactivate Puts back the system resolver. The forwarder continues to run.
opdns activate Points the system resolver at the forwarder again. It refuses if the forwarder does not answer.
opdns config Shows the configuration in use. opdns config set --device tv changes the file.
opdns run Runs in the foreground, for tests or your own init system.
opdns uninstall Stops the service, puts back the system resolver, and removes the service. --purge also removes the configuration file.

To run the service without a change to the system resolver, install with --auto-activate=false. Then point programs at 127.0.0.1 yourself.

On a router or a small server for the full network, listen on the LAN side. Name the devices behind it from the DHCP lease file (dnsmasq, ISC dhcpd, Kea) or by address:

Terminal window
sudo opdns install --profile <profile-id> --device home-router \
--listen 192.168.1.1:53 --listen 127.0.0.1:53 \
--lease-file /tmp/dhcp.leases \
--client 192.168.1.20=kids-tablet \
--forward home.arpa=192.168.1.1 \
--auto-activate=false

Then give out the address of the router as the DNS server. Usually, the router already does this. Turn off the own resolver of the router on that address. Each device appears in the logs under its lease name. If a device also has a --client name, the --client name wins. A device without a name appears as the device of the router. --forward sends the names of a domain to a different server in plain DNS. The home.arpa names of the router never leave your network.

There is no OpenWrt or other router package yet. On an ARM64 router, use the linux_arm64 binary. For a different architecture, build the binary from the source code of the release, as in the Windows tab. For example, use GOOS=linux GOARCH=mipsle for most MT7621 routers. Then start opdns run from the init system of the router, with the same flags. opdns install supports only systemd, launchd and Windows.

A captive portal is a sign-in page that a network shows before it lets you on. If no transport answers, the forwarder looks for a captive portal on the network. If it finds one, it asks the resolver of the network, in plain DNS, for two kinds of names. The first are the names that your system uses to find portals (the names of Apple, Android, Windows, Firefox and NetworkManager). The second is the host of the portal. Then the login page appears. The forwarder resolves nothing else until you are signed in. Then it goes back to encrypted DNS within seconds. To turn this off, use --captive-portal=false.

If you have a self-hosted node, the forwarder can use it when the cloud is out of reach:

Terminal window
sudo opdns config set --node 192.168.1.2 --node-server-name node.home.arpa

The forwarder tries the node after every cloud transport, over DNS-over-TLS (or plain DNS with --node-transport dns). The certificate of the node must be valid for the server name. For a private certificate, add its root with --ca-file.

/etc/opdns/client.yaml (C:\ProgramData\opdns\client.yaml) holds the same keys as the flags. Every flag also has an OPDNS_* environment variable (opdns --help):

profile: <profile-id>
device: laptop
transports: [doh3, doh2, dot, doq]
listen: ["127.0.0.1:53", "[::1]:53"]
forward: ["home.arpa=192.168.1.1"]
clients: ["192.168.1.20=kids-tablet"]
lease_files: [/tmp/dhcp.leases]
node: { addr: 192.168.1.2, server_name: node.home.arpa }
auto_activate: true

The logs of the forwarder never hold the names that you look up or the addresses of your devices. --log-queries adds one line for each query, with its name, for debugging on your own machine. The forwarder serves its status and Prometheus metrics on 127.0.0.1:9853 only. To turn them off, use --metrics off.