Open source · MIT license · Rust

A DNS proxy. Nothing more.

Plain DNS, DNS over TLS and DNS over HTTPS in. Only encrypted DNS out. Every listener is closed until you name who may use it.

Scope

What it does, and what it does not

A forwarder for one job: take DNS queries from clients you allow and pass them to resolvers you trust, encrypted. Everything else stays out, because every feature is code you have to trust.

Inbound

Four protocols

  • Plain DNS over UDP and TCP
  • DNS over TLS (RFC 7858)
  • DNS over HTTPS (RFC 8484), HTTP/1.1 and HTTP/2, GET and POST
  • Allowlist per listener: networks and hostnames
Outbound

Encrypted only

  • DoT or DoH upstreams, tried in order
  • A failing upstream is moved to the back for 30 s
  • Upstreams reached by configured IPs; no plain-DNS bootstrap
  • Certificates verified against Mozilla roots or your CA
Not included

By decision

  • No cache, no filtering, no statistics endpoint
  • No ACME; certificates come from files
  • No HTTP/3
  • No DNSSEC validation; the upstream resolver validates
Install

Three steps

Releases ship static binaries for x86_64 and aarch64 Linux. They have no runtime dependencies. Each archive is listed in SHA256SUMS and carries a build provenance attestation from GitHub Actions.

Download and verify

Check the checksum, then check that the archive was built by this repository's release workflow.

VERSION=v0.1.0
TARGET=x86_64-unknown-linux-musl   # or aarch64-unknown-linux-musl
BASE=https://github.com/nullthrone/dns-proxy/releases/download/$VERSION

curl -LO "$BASE/dns-proxy-$VERSION-$TARGET.tar.gz"
curl -LO "$BASE/SHA256SUMS"
sha256sum --ignore-missing -c SHA256SUMS
gh attestation verify "dns-proxy-$VERSION-$TARGET.tar.gz" --repo nullthrone/dns-proxy

Install and check the configuration

--check validates the configuration and loads all certificates without binding a socket.

tar xzf "dns-proxy-$VERSION-$TARGET.tar.gz" && cd "dns-proxy-$VERSION-$TARGET"
install -m 0755 dns-proxy /usr/local/bin/
install -d /etc/dns-proxy
install -m 0644 config.example.toml /etc/dns-proxy/config.toml
dns-proxy --config /etc/dns-proxy/config.toml --check

Run under systemd

The unit runs the proxy as a transient unprivileged user. Its only capability is binding ports below 1024, inside a strict sandbox. Certificates are passed in with LoadCredential=, so the private key can stay readable by root only.

install -m 0644 dist/dns-proxy.service /etc/systemd/system/
systemctl daemon-reload
systemctl enable --now dns-proxy
systemd-analyze security dns-proxy
Configure

One TOML file

Unknown keys are errors. Missing allowlists are errors. Nothing ambiguous is filled in with a default.

# Local clients, plain DNS
[[listen]]
proto = "udp"
addr = "127.0.0.1:53"
allow = ["127.0.0.0/8"]

# Remote clients, DNS over TLS
[[listen]]
proto = "dot"
addr = "0.0.0.0:853"
allow = ["192.168.0.0/16"]
allow_hosts = ["home.dyndns.example"]
cert = "${CREDENTIALS_DIRECTORY}/cert.pem"
key = "${CREDENTIALS_DIRECTORY}/key.pem"

[[upstream]]
type = "dot"
name = "dns.quad9.net"
addrs = ["9.9.9.9:853", "149.112.112.112:853"]

[[upstream]]
type = "doh"
url = "https://cloudflare-dns.com/dns-query"
addrs = ["1.1.1.1:443", "1.0.0.1:443"]
SectionKeys
[[listen]]proto (udp, tcp, dot, doh), addr, allow and/or allow_hosts. For dot and doh also cert and key; for doh optionally path.
[[upstream]]type = "dot" with name, or type = "doh" with url. Always addrs: the IPs to connect to. Optional ca_file.
[limits]Concurrency caps and timeouts. All optional.
[host_acl]Refresh timing for allow_hosts. All optional.

The full reference with all defaults is config.example.toml.

Dynamic client IPs

Admit clients that move

Clients on networks with a changing public IP can use the proxy over the internet. The upstreams then see one static address. There are two ways to admit such clients. They are not equally strong.

By hostname

allow_hosts IP-based

The proxy resolves DynDNS names in the background, through the encrypted upstreams. It never resolves per query and never uses the system resolver.

  • The refresh follows the record TTL. A rejected client triggers an early refresh, at most every 15 s.
  • Fail closed until the first answer. NXDOMAIN removes the addresses at once.
  • If lookups fail, the last addresses stay valid for one hour.
  • IPv4 matches the exact address. IPv6 matches its /64; adjust with v6_prefix.

What you trust: the DynDNS account becomes the credential. Behind CGNAT, the IPv4 is shared with strangers. After an IP change, the old address stays admitted until the next refresh. Use DoT or DoH for such listeners; plain UDP sources can be spoofed.

By token

Secret DoH path Stronger

Admission by credential, independent of the client's address. The path travels inside TLS and is compared in constant time.

[[listen]]
proto = "doh"
addr = "0.0.0.0:443"
allow = ["0.0.0.0/0", "::/0"]
path = "/dns-query/<token>"

Generate the token with openssl rand -hex 16. Treat the client configuration like a password.

Security model

Properties, stated plainly


Closed by default

A listener without allow or allow_hosts is a configuration error. An open resolver requires writing 0.0.0.0/0 on purpose.

No plain DNS of its own

Upstreams are reached by IP. Hostnames serve only SNI and certificate checks. Allowlist names resolve through the encrypted upstreams.

Verified responses

An upstream answer must repeat the question and the expected ID. DoT queries carry a fresh random ID; DoH queries use ID 0.

Bounded amplification

UDP answers never exceed the client's EDNS size or 1232 bytes. Larger answers are truncated, and the client retries over TCP.

Bounded resources

Connections, queries in flight, handshakes, idle time, headers and request bodies all have limits.

Private by default

Query names are never logged. Failures are logged once per outage, not once per query.

No unsafe code

#![forbid(unsafe_code)]. The DNS parser checks every bound and is tested against random input.

Verifiable releases

Static binaries, SHA-256 checksums and signed build provenance. Actions in the release workflow are pinned to commit hashes.