展示HN:我用Rust从头开始构建了一个DNS解析器 – 没有使用DNS库
Show HN: I built a DNS resolver from scratch in Rust – no DNS libraries

原始链接: https://github.com/razvandimescu/numa

## Numa:你的便携式、私密的DNS解析器 Numa是一个单文件二进制程序,使用Rust构建的DNS解析器,专为隐私和便捷性设计,直接在你的笔记本电脑上运行(macOS、Linux、Windows)——无需云服务或额外硬件。它提供全系统广告拦截(通过Hagezi Pro屏蔽超过38万个域名),本地服务命名(例如,`frontend.numa`用于5173端口),以及主机名覆盖,所有这些都不需要修改系统文件。 Numa有三种模式:转发(透明代理)、递归(直接从根服务器解析,具有完整的DNSSEC验证)和自动(智能回退)。它具有用于配置的网络仪表盘和用于开发者覆盖的REST API。 独特的功能包括自动局域网服务发现,允许运行Numa的机器相互查找和代理服务,以及“中心枢纽”模式,用于在网络上集中式广告拦截和`.numa`解析。 Numa优先考虑性能,关键路径上没有堆分配,并拥有令人印象深刻的速度——缓存往返延迟691纳秒,递归查询时间237毫秒。

一位开发者在Hacker News分享了他们的项目“numa”,一个用Rust从头构建的DNS解析器,不依赖现有的DNS库。目标是通过允许直接访问前端应用程序(例如运行在5173端口上的应用程序),简化本地开发,而无需使用像`mkcert`、`nginx`或修改`hosts`文件这样的工具。 该解析器包含自动TLS证书生成、WebSocket透传和路径路由等功能。它已扩展为包含递归解析、DNSSEC验证、广告拦截(包含超过38.5万个域名黑名单)和局域网服务发现。 目前,numa是一个约8MB的单个二进制文件,兼容macOS、Linux和Windows,通过简单的`sudo numa install`命令安装,并在`localhost:5380`提供实时仪表盘。开发者正在积极寻求反馈,并鼓励用户报告任何问题。
相关文章

原文

CI crates.io License: MIT

DNS you own. Everywhere you go.numa.rs

A portable DNS resolver in a single binary. Block ads on any network, name your local services (frontend.numa), and override any hostname with auto-revert — all from your laptop, no cloud account or Raspberry Pi required.

Built from scratch in Rust. Zero DNS libraries. RFC 1035 wire protocol parsed by hand. Caching, ad blocking, and local service domains out of the box. Optional recursive resolution from root nameservers with full DNSSEC chain-of-trust validation. One ~8MB binary, everything embedded.

Numa dashboard

# macOS
brew install razvandimescu/tap/numa

# Linux
curl -fsSL https://raw.githubusercontent.com/razvandimescu/numa/main/install.sh | sh

# Windows — download from GitHub Releases
# All platforms
cargo install numa
sudo numa                              # run in foreground (port 53 requires root/admin)

Open the dashboard: http://numa.numa (or http://localhost:5380)

Set as system DNS:

Platform Install Uninstall
macOS sudo numa install sudo numa uninstall
Linux sudo numa install sudo numa uninstall
Windows numa install (admin) + reboot numa uninstall (admin) + reboot

On macOS and Linux, numa runs as a system service (launchd/systemd). On Windows, numa auto-starts on login via registry.

Name your dev services instead of remembering port numbers:

curl -X POST localhost:5380/services \
  -d '{"name":"frontend","target_port":5173}'

Now https://frontend.numa works in your browser — green lock, valid cert, WebSocket passthrough for HMR. No mkcert, no nginx, no /etc/hosts.

Add path-based routing (app.numa/api → :5001), share services across machines via LAN discovery, or configure everything in numa.toml.

385K+ domains blocked via Hagezi Pro. Works on any network — coffee shops, hotels, airports. Travels with your laptop.

Three resolution modes:

  • forward (default) — transparent proxy to your existing system DNS. Everything works as before, just with caching and ad blocking on top. Captive portals, VPNs, corporate DNS — all respected.
  • recursive — resolve directly from root nameservers. No upstream dependency, no single entity sees your full query pattern. Add [dnssec] enabled = true for full chain-of-trust validation.
  • auto — probe root servers on startup, recursive if reachable, encrypted DoH fallback if blocked.

DNSSEC validates the full chain of trust: RRSIG signatures, DNSKEY verification, DS delegation, NSEC/NSEC3 denial proofs. Read how it works →

Run Numa on multiple machines. They find each other automatically via mDNS:

Machine A (192.168.1.5)              Machine B (192.168.1.20)
┌──────────────────────┐             ┌──────────────────────┐
│ Numa                 │    mDNS     │ Numa                 │
│  - api (port 8000)   │◄───────────►│  - grafana (3000)    │
│  - frontend (5173)   │  discovery  │                      │
└──────────────────────┘             └──────────────────────┘

From Machine B: curl http://api.numa → proxied to Machine A's port 8000. Enable with numa lan on.

Hub mode: run one instance with bind_addr = "0.0.0.0:53" and point other devices' DNS to it — they get ad blocking + .numa resolution without installing anything.

Pi-hole AdGuard Home Unbound Numa
Local service proxy + auto TLS .numa domains, HTTPS, WebSocket
LAN service discovery mDNS, zero config
Developer overrides (REST API) Auto-revert, scriptable
Recursive resolver Yes Yes, with SRTT selection
DNSSEC validation Yes Yes (RSA, ECDSA, Ed25519)
Ad blocking Yes Yes 385K+ domains
Web admin UI Full Full Dashboard
Encrypted upstream (DoH) Needs cloudflared Yes Native
Portable (laptop) No (appliance) No (appliance) Server Single binary, macOS/Linux/Windows
Community maturity 56K stars, 10 years 33K stars 20 years New

691ns cached round-trip. ~2.0M qps throughput. Zero heap allocations in the hot path. Recursive queries average 237ms after SRTT warmup (12x improvement over round-robin). ECDSA P-256 DNSSEC verification: 174ns. Benchmarks →

MIT

联系我们 contact @ memedata.com