In an era where online privacy is paramount, traditional DNS queries sent in plaintext expose users to surveillance, manipulation, and attacks. DNS over TLS (DoT) addresses this by encrypting the entire DNS communication channel using Transport Layer Security on port 853. This protocol, standardized in RFC 7858, ensures that domain resolution requests remain confidential between clients and resolvers.
Why Encrypt DNS Traffic?
Standard DNS operates over UDP port 53 without encryption, making it vulnerable to interception by ISPs, governments, or malicious actors. Eavesdroppers can track browsing habits, inject false responses (DNS spoofing), or amplify DDoS attacks. DoT mitigates these risks by wrapping queries in TLS, providing authentication, integrity, and confidentiality.
Beyond security, DoT enables persistent connections, reducing latency compared to UDP’s stateless nature. Research from RIPE Labs demonstrates that persistent TCP/TLS connections can handle millions of queries efficiently on modern hardware, improving end-user performance.
Choosing the Right Tools for Deployment
Unbound stands out as a lightweight, recursive DNS resolver with native DoT support. It’s ideal for both servers and clients due to its performance, security features, and active development by NLnet Labs. For the server, we’ll use CentOS 7 (or compatible RPM-based distros) on a VPS with a public IPv4/IPv6 address and FQDN.
- Server Requirements: Static IP, domain name (e.g., dns.example.com), firewall allowing TCP/853.
- Client Side: Local Unbound instance forwarding to DoT servers.
Alternatives like BIND exist, but Unbound’s simplicity and DoT integration make it preferable for privacy-focused setups.
Server Installation and Basic Configuration
Begin by updating your CentOS system and installing Unbound:
yum update -yyum install unbound epel-release -yEnable and start the service:
systemctl enable unboundsystemctl start unboundEdit /etc/unbound/unbound.conf for recursive operation with DoT:
server: interface: 0.0.0.0 interface: ::0 port: 53 do-tls-upstream: no tls-port: 853 do-ip4: yes do-ip6: yes do-udp: yes do-tcp: yes tls-cert-bundle: /etc/ssl/certs/ca-bundle.crt access-control: 0.0.0.0/0 allow access-control: ::0/0 allowValidate and restart: unbound-checkconf && systemctl restart unbound.
Securing with Let’s Encrypt Certificates
DoT requires valid TLS certificates for server authentication. Let’s Encrypt provides free, automated certificates via Certbot.
yum install certbot -ycertbot certonly --standalone -d dns.example.comConfigure Unbound to use these certificates by adding to unbound.conf:
server: tls-service-key: /etc/letsencrypt/live/dns.example.com/privkey.pem tls-service-pem: /etc/letsencrypt/live/dns.example.com/fullchain.pemSet up auto-renewal with a cron job:
0 12 * * * /usr/bin/certbot renew --quiet && systemctl reload unboundThis ensures uninterrupted service as certificates expire every 90 days.
Testing Your DoT Server
Verify functionality using dig or kdig (from knot-utils):
dig @your.server.ip example.com +tls-caOr test IPv6: dig @::1 www.example.com +tls-ca. Expect a valid response with no errors. Tools like DNS Privacy Test Servers list can confirm public visibility.
| Test Command | Expected Outcome | Purpose |
|---|---|---|
| dig @server www.google.com +tls-ca | NOERROR status, IP response | Basic resolution |
| openssl s_client -connect server:853 | Verify certificate chain | TLS handshake |
| kdig +tls-ca @server example.com | Secure query success | Advanced testing |
Client-Side: Local Resolver with Upstream Forwarding
On your local machine (Linux/Mac), install Unbound and configure it to forward queries over DoT to your server or public resolvers like Quad9 (9.9.9.9@853).
# Client unbound.confserver: do-ip4: yes do-ip6: yes do-udp: no do-tcp: yes tls-upstream: yes interface: 127.0.0.1 port: 53 access-control: 127.0.0.0/8 allowforward-zone: name: "." forward-addr: 91.239.96.35@853 # Example public DoT forward-addr: [2001:67c:27e4::35]@853 forward-tls-upstream: yesRestart Unbound and test: dig @127.0.0.1 example.com. All local queries now tunnel securely.
Advanced: Certificate Pinning and Multiple Upstream
For stricter security, pin upstream certificates. Fetch the digest:
echo | openssl s_client -connect server:853 -servername server 2>/dev/null |openssl x509 -pubkey -noout | openssl pkey -pubin -outform der |openssl dgst -sha256 -binary | openssl enc -base64Add to client config: forward-ssl-upstream: yes with the digest.
Support multiple providers for redundancy:
- Quad9: 9.9.9.9@853
- Cloudflare: 1.1.1.1@853
- Your custom server
Performance and Reliability Benefits
DoT’s TCP-based persistent connections outperform UDP in high-query scenarios. RIPE NCC labs reported handling 6.5 million connections per server, with lower latency due to connection reuse. This is crucial for stub-to-recursive traffic.
Firewall rules: Allow outbound TCP/853; block UDP/53 for strict enforcement.
Common Pitfalls and Troubleshooting
- Certificate Errors: Ensure fullchain.pem includes intermediates.
- Resolution Fails: Check unbound-checkconf, firewall (firewall-cmd –add-port=853/tcp).
- IPv6 Issues: Verify AAAA records and ::1 binding.
- Logs: tail -f /var/log/unbound/unbound.log
Integration with Modern OS and Apps
Android 9+, iOS 14+, and Firefox support DoT natively. Configure system resolvers to 127.0.0.1 for local Unbound. For routers, enable DoT in OpenWRT or pfSense.
FAQ
- What port does DNS over TLS use?
- Port 853 over TCP.
- Is DoT compatible with DNSSEC?
- Yes, Unbound supports both simultaneously.
- DoH vs DoT?
- DoT is DNS-native (port 853); DoH uses HTTPS (443). DoT allows easier network monitoring.
- Can I run DoT on shared hosting?
- No, requires root and port 853 access.
- How to list my server publicly?
- Email dns-privacy@ietf.org with details.
References
- Specification for DNS over Transport Layer Security (TLS) — IETF. 2016-05-26. https://datatracker.ietf.org/doc/html/rfc7858
- Persistent DNS Connections for Reliability and Performance — RIPE NCC Labs (Baptiste Jonglez). 2023-06-01. https://labs.ripe.net/author/baptiste_jonglez_1/persistent-dns-connections-for-reliability-and-performance/
- DNS Privacy Test Servers — DNS Privacy Wiki. 2024-01-15. https://dnsprivacy.org/wiki/display/DP/DNS+Privacy+Test+Servers
- Unbound Documentation — NLnet Labs. 2025-03-10. https://nlnetlabs.nl/documentation/unbound/unbound.conf/
- What is DNS over TLS (DoT)? — Infoblox (official glossary). 2024-11-05. https://www.infoblox.com/glossary/dns-over-tls-dot/

