A high-performance DNS proxy with DNS-over-QUIC (DoQ) support, written in Rust.
- DNS-over-QUIC (DoQ): Forwards DNS queries over QUIC (RFC 9250) for improved privacy and performance
- In-Memory Caching: Built-in cache with configurable TTL to reduce latency and upstream load
- Connection Management: Single persistent QUIC connection with multiplexed streams for optimal performance
- Zero-Copy Mode: Minimal parsing overhead when debug mode is disabled
- Systemd Integration: Production-ready systemd service with security hardening
- Environment Configuration: Flexible configuration via environment variables
- Single QUIC connection with auto-reconnect capability
- Multiple bidirectional streams for concurrent queries
- Moka-based async cache (10,000 entries, 5-minute TTL by default)
- Cache key based on DNS question section for efficient deduplication
- SERVFAIL responses on upstream errors
- Rust 2024 edition or later
- Linux with systemd (for service deployment)
- CAP_NET_BIND_SERVICE capability (to bind to port 53 without root)
See INSTALL.md for detailed installation instructions.
Quick install:
make build
sudo make install
sudo systemctl enable --now doqxy.serviceConfiguration is done via environment variables:
| Variable | Default | Description |
|---|---|---|
UPSTREAM_SERVER |
dns.adguard-dns.com |
DNS-over-QUIC server hostname |
UPSTREAM_PORT |
853 |
DNS-over-QUIC server port |
UPSTREAM_IP |
(resolved) | Upstream server IP (avoids DNS resolution at startup) |
BIND_ADDR |
127.0.0.53:53 |
Loca A0F2 l address to bind the DNS proxy |
DEBUG |
0 |
Enable debug logging and DNS message parsing (1 to enable) |
Edit the systemd service:
sudo systemctl edit doqxy.serviceAdd custom environment variables:
[Service]
Environment="UPSTREAM_SERVER=dns.adguard-dns.com"
Environment="UPSTREAM_PORT=853"
Environment="UPSTREAM_IP=94.140.14.14"
Environment="BIND_ADDR=127.0.0.10:53"
Environment="DEBUG=0"# Start the service
sudo systemctl start doqxy.service
# Check status
systemctl status doqxy.service
# View logs
journalctl -u doqxy -f
# Stop the service
sudo systemctl stop doqxy.service# Test with dig
dig @127.0.0.53 example.com
# Test with nslookup
nslookup example.com 127.0.0.53
# Test with systemd-resolve
systemd-resolve --status# Set environment variables
export UPSTREAM_SERVER=dns.adguard-dns.com
export UPSTREAM_PORT=853
export UPSTREAM_IP=94.140.14.14
export BIND_ADDR=127.0.0.10:53
export DEBUG=1
# Run the proxy
cargo run --releaseIf you want to use doqxy as your system DNS resolver, you need to prevent NetworkManager from managing /etc/resolv.conf:
- Create NetworkManager configuration:
sudo mkdir -p /etc/NetworkManager/conf.d
sudo tee /etc/NetworkManager/conf.d/dns.conf > /dev/null << 'EOF'
[main]
dns=none
systemd-resolved=false
EOF- Restart NetworkManager:
sudo systemctl restart NetworkManager- Make
/etc/resolv.confwritable (if it's a symlink):
sudo rm /etc/resolv.conf- Create new
/etc/resolv.conf:
sudo tee /etc/resolv.conf > /dev/null << 'EOF'
nameserver 127.0.0.53
options edns0 trust-ad
EOF- Protect from modification:
sudo chattr +i /etc/resolv.conf- To revert protection (if needed):
sudo chattr -i /etc/resolv.confNote: Make sure doqxy is running and bound to the address specified in /etc/resolv.conf before making these changes.
The systemd service includes several security hardening features:
- DynamicUser: Runs as a temporary system user
- CAP_NET_BIND_SERVICE: Minimal capabilities (only bind to privileged ports)
- ProtectSystem: File system protection
- ProtectHome: Home directory isolation
- PrivateTmp: Private /tmp and /var/tmp
- NoNewPrivileges: Prevents privilege escalation
- RestrictAddressFamilies: Limited to AF_INET and AF_INET6
- Native CPU optimizations enabled by default (
RUSTFLAGS="-C target-cpu=native") - Zero-copy forwarding in non-debug mode
- Efficient caching reduces upstream queries
- Single QUIC connection minimizes connection overhead
- Async I/O with Tokio for high concurrency
- quinn - QUIC implementation
- rustls - TLS library
- hickory-proto - DNS protocol library
- moka - Fast concurrent cache
- tokio - Async runtime
Licensed under the MIT License. See LICENSE for details.
Contributions are welcome! Please feel free to submit issues or pull requests.