redlemonbe/Runbound

GitHub: redlemonbe/Runbound

Runbound 是一款用 Rust 编写的高性能 DNS 服务器,通过 API 实时管理配置,解决了 Unbound 需重启更新的痛点。

Stars: 0 | Forks: 0

# Runbound **直接替换 Unbound —— 带有 REST API 和 80,000 q/s 的性能。** [![License: PolyForm NC](https://img.shields.io/badge/License-PolyForm_NC_1.0-blue)](LICENSE) [![GitHub release](https://img.shields.io/github/v/release/redlemonbe/Runbound)](https://github.com/redlemonbe/Runbound/releases/latest) [![GitHub Sponsors](https://img.shields.io/github/sponsors/redlemonbe?style=flat&logo=github&label=Sponsor)](https://github.com/sponsors/redlemonbe) 您运行着 Unbound。它工作正常。但每次需要添加 DNS 条目、屏蔽域名或订阅屏蔽列表时,您都得编辑配置文件、重载守护进程,并祈祷一切顺利。 **Runbound 执行同样的任务 —— 并让您通过 REST API 实时管理一切,无需重启。** 您现有的 `unbound.conf` 无需修改即可工作。零迁移成本。 ## 您将获得 | | Unbound | Runbound | |---|:---:|:---:| | 直接兼容配置 | ✅ | ✅ | | UDP / TCP / DoT / DoH | ✅ | ✅ | | 实时添加 DNS 条目 | ❌ 需要重启 | ✅ API | | 实时屏蔽域名 | ❌ 需要重启 | ✅ API | | 订阅屏蔽列表源 | ❌ 手动操作 | ✅ API | | 实时查询统计 | ❌ | ✅ API | | 实时查询日志 | ❌ | ✅ API | | SSE 实时统计流 | ❌ | ✅ API | | 上游健康监控 | ❌ | ✅ API | | 主从复制 | ❌ | ✅ 内置 | | 热配置重载 | ❌ | ✅ API | | AF/XDP 内核旁路快速路径 | ❌ | ✅ 可选 | | 静态二进制文件(无依赖) | ❌ | ✅ musl 构建 | | 吞吐量(本地区域) | ~50k q/s | **~80k q/s** | ## 60 秒内启动运行 ``` # 1 — 下载静态二进制文件(无依赖项) # 将 vX.Y.Z 替换为 releases 页面上的最新版本标签 curl -LO https://github.com/redlemonbe/Runbound/releases/latest/download/runbound-v0.3.0-x86_64-linux-musl chmod +x runbound-v0.3.0-x86_64-linux-musl # 2 — 单行命令安装(自动下载,配置 systemd): # sudo bash <(curl -fsSL https://github.com/redlemonbe/Runbound/releases/latest/download/install.sh) # 3 — 或指向您现有的 Unbound 配置 sudo ./runbound-v0.3.0-x86_64-linux-musl /etc/unbound/unbound.conf # 4 — 测试 dig @127.0.0.1 google.com ``` DNS 在 **端口 53** 上运行。REST API 在 **端口 8081** 上运行(仅限 localhost,需要 Bearer 令牌)。无需更改配置。 REST API 端口可通过在 `runbound.conf` 中设置 `api-port: 9090` 来配置。请参阅 [配置参考](docs/configuration.md#api-key-and-port)。 ## 无需修改文件即可管理 DNS ``` API="http://localhost:8081" TOKEN="your-api-key" # 添加 DNS 记录 — 实时生效,无需重启 curl -s -X POST "$API/dns" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{"name":"nas.home.","type":"A","value":"192.168.1.10","ttl":300}' # 屏蔽域名 — 实时生效 curl -s -X POST "$API/blacklist" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{"domain":"ads.example.com"}' # 订阅 URLhaus 恶意软件源 — 自动刷新 curl -s -X POST "$API/feeds" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{"name":"urlhaus","url":"https://urlhaus.abuse.ch/downloads/hostfile/"}' # 实时查询统计 curl -s "$API/stats" -H "Authorization: Bearer $TOKEN" ``` ## 性能 在 4 核 VPS(KVM,8 GB RAM)上使用 [dnsperf](https://www.dns-oarc.net/tools/dnsperf) 进行测量: | 场景 | 吞吐量 | 平均延迟 | |---|---|---| | 本地区域 — 1 个客户端 | **82,000 q/s** | 83 ms | | 本地区域 — 8 个客户端 | **75,000 q/s** | ~1 秒(服务器饱和) | | 转发(Cloudflare) | 受网络限制 | < 5 毫秒 | | AF/XDP(物理机,DRV 模式) | **500k – 1M+ q/s** | < 1 毫秒 | → 完整的方法论和原始结果:[docs/performance.md](docs/performance.md) ## 下载 | 平台 | 构建类型 | 文件名 | |---|---|---| | Linux x86_64 | 静态(musl)— 无依赖 | `runbound-vX.Y.Z-x86_64-linux-musl` | | Linux x86_64 | 动态(glibc) | `runbound-vX.Y.Z-x86_64-linux-gnu` | | Linux ARM64 | 静态(musl)— Raspberry Pi,服务器 | `runbound-vX.Y.Z-aarch64-linux-musl` | | Linux ARM64 | 动态(glibc) | `runbound-vX.Y.Z-aarch64-linux-gnu` | 所有发布版本:[github.com/redlemonbe/Runbound/releases](https://github.com/redlemonbe/Runbound/releases) 或从源代码构建:`cargo build --release` 使用 AF/XDP 快速路径:`cargo build --release --features xdp` ## 示例配置 常见场景的开箱即用配置: | 配置 | 使用场景 | |---|---| | [examples/home.conf](examples/home.conf) | Raspberry Pi / 家庭实验室 — 替代 Pi-hole | | [examples/office.conf](examples/office.conf) | 中小型企业办公室 — 分离视界 DNS,VPN,企业区域 | | [examples/server.conf](examples/server.conf) | 公共递归解析器 — VPS / 数据中心 | | [examples/secure.conf](examples/secure.conf) | 隔离网络 / 军事级安全 — 严格 ACL,无公共转发 | | [examples/master.conf](examples/master.conf) | 主节点 — 写入 + 复制到从节点 | | [examples/slave.conf](examples/slave.conf) | 从节点副本 — 只读,TOFU TLS,自动增量同步 | ## 文档 | | | |---|---| | [家庭实验室指南](docs/homelab.md) | Raspberry Pi / 家庭服务器设置 — 本地名称,广告屏蔽,路由器配置 | | [快速入门](docs/quick-start.md) | 5 分钟内安装、配置、运行 | | [配置参考](docs/configuration.md) | 每个指令的解释,从/主节点同步,Unbound 兼容性表 | | [REST API 参考](docs/api.md) | 所有端点及 curl 示例和 JSON 响应 | | [性能指南](docs/performance.md) | 基准测试,方法论,如何重现 | | [TLS 设置](docs/tls.md) | 端口 853 上的 DoT — Let's Encrypt 或内部 CA | | [AF/XDP 快速路径](docs/xdp.md) | 内核旁路网络 — 500k+ q/s | | [Systemd 设置](docs/systemd.md) | 生产环境服务,加固的单元文件,热重载 | | [Unbound 迁移](docs/unbound-migration.md) | 配置兼容性,功能映射,注意事项 | | [安全架构](docs/security.md) | ACL,速率限制,API 认证,审计发现 | ## 许可证 [PolyForm 非商业许可 1.0.0](LICENSE) 用于非商业用途。 商业使用:[COMMERCIAL_LICENSE.md](COMMERCIAL_LICENSE.md) — 联系 redlemonbe@codix.be。 版权所有 (c) 2026 RedlemonBe ## 开发方法 Runbound 的安全态势通过在每个版本发布时使用 AI 辅助工具得到加强: - **安全审计** — 涵盖 SSRF、注入、时序攻击、DoS 向量和 RFC 合规性的白盒代码审查(参见 [`docs/security-audit.md`](docs/security-audit.md)) - **渗透测试** — 黑盒 API 和 DNS 协议测试(输入验证、放大攻击、信息泄露、认证绕过) - **性能分析** — 热路径分析和内存分配审查 AI 工具被专门用作对抗性审查层。所有发现均由维护者进行分类和修补。 *Runbound 与 NLnet Labs Unbound 项目无关。*
标签:AF/XDP, API管理, ARM架构, DNS服务器, DoH, DoT, Linux部署, REST API, Rust语言, Unbound替代, x86_64架构, 主从复制, 动态配置, 可视化界面, 域名阻止, 查询统计, 系统服务, 网络安全, 网络性能优化, 跨平台支持, 通知系统, 阻止列表, 隐私保护, 静态二进制, 高吞吐量, 高性能计算