This project is a high-performance DNS caching server written in Go. Its primary goal is microsecond-level response latency on cache hits. It supports both A and AAAA record types and uses an in-memory LRU cache. It forwards uncached queries to a trusted upstream DNS resolver.
- ⚡ Microsecond-level cache latency
- 📦 LRU cache with TTL-aware expiration
- 🔀 Supports A and AAAA DNS queries
- 🌐 Upstream fallback to
1.1.1.1(Cloudflare) - 🛠️ Deployable via systemd
- Provider: Cloudflare
- Address:
1.1.1.1 - Port:
53
- Tool:
dnsperf - Command:
dnsperf -s 127.0.0.1 -d formatted_domains.txt -l 20Queries sent: 2,611,659
Queries completed: 2,611,659
Queries lost: 0
Response codes: NOERROR 100%
QPS: 130,578
Average latency: 740 µs
Latency min: 23 µs
Latency max: 530 ms
This benchmark was conducted under ideal cache-hit conditions with optimized network stack settings on a local machine.
go build -o dnscache main.go./dnscacheListens on UDP port 5523.
- Install the binary
sudo cp dnscache /usr/bin/
sudo chmod +x /usr/bin/dnscache- Create a service file
# /etc/systemd/system/dnscache.service
[Unit]
Description=Ultra-fast DNS caching server written in Go
After=network.target
[Service]
ExecStart=/usr/bin/dnscache
Restart=on-failure
User=nobody
Group=nogroup
[Install]
WantedBy=multi-user.target- Enable and Start
sudo systemctl daemon-reexec
sudo systemctl daemon-reload
sudo systemctl enable dnscache
sudo systemctl start dnscache- Only queries with
AandAAAAtypes are currently cached. - Uncached queries are resolved via Cloudflare (
1.1.1.1:53). - Cache TTL is derived from the lowest TTL of all
AnswerRRs. - Default cache size is 1024 entries (LRU).