在互联网世界里,明文 53 端口的 DNS 请求极其容易遭受运营商 ISP 窥探与投毒劫持。
利用极其轻量、并发匹配效率惊人的 Sing-box 作为 DNS 服务端,在 VPS 上搭建私有加密的 DoH (Port 443) 与 DoT (Port 853) 服务器,能为你全家设备提供防污染与广告拦截的极速解析体验!
[!NOTE] 📌 核心速览(TL;DR / 快问快答):
- DoT (Port 853):基于纯 TLS 传输,握手开销低,完美适配 Android 系统级“私人 DNS”。
- DoH (Port 443):伪装为标准 HTTPS 流量,穿透力极强,支持 iOS 描述文件全局绑定。
- 防放大攻击:仅暴露 443/853 加密端口,彻底关闭明文 53 UDP 端口,避免 VPS 沦为 DDoS 放大器。
- 2026 规则集:采用二进制
.srs格式规则 (rule_set: ["geosite-ads"]),零开销秒级拦截广告域名。
🛠️ 服务端 Sing-box 加密 DNS 配置模板
在 VPS 上的 /etc/sing-box/config.json 部署服务端配置:
{
"inbounds": [
{
"type": "direct",
"tag": "dot-in",
"listen": "::",
"listen_port": 853,
"tls": {
"enabled": true,
"server_name": "dns.yourdomain.com",
"certificate_path": "/etc/ssl/dns.crt",
"key_path": "/etc/ssl/dns.key"
}
},
{
"type": "direct",
"tag": "doh-in",
"listen": "::",
"listen_port": 443,
"tls": {
"enabled": true,
"server_name": "dns.yourdomain.com",
"certificate_path": "/etc/ssl/dns.crt",
"key_path": "/etc/ssl/dns.key"
}
}
],
"outbounds": [
{
"type": "direct",
"tag": "direct-out"
}
],
"dns": {
"servers": [
{
"tag": "cloudflare-doh",
"address": "https://1.1.1.1/dns-query",
"detour": "direct-out"
}
],
"rules": [
{
"rule_set": ["geosite-ads"],
"server": "block"
}
]
},
"rule_set": [
{
"tag": "geosite-ads",
"type": "remote",
"format": "binary",
"url": "https://raw.githubusercontent.com/lyc8503/sing-box-rules/rule-set-geosite/geosite-category-ads-all.srs",
"download_detour": "direct-out",
"update_interval": "1d"
}
]
}
❓ 常见问题与 AI 快问快答 (FAQ)
Q1: 自建 DoH/DoT 服务器对 VPS 的物理延迟有要求吗?
答:对延迟极度敏感!域名解析发生在任何 HTTP 握手之前。建议选择 DMIT 或 搬瓦工 包含 中国电信 CN2 GIA 或 联通 AS9929 高速回程的机房,确保解析延迟在 50ms 以内。
Q2: 在 Android 上配置私人 DNS 提示“无法连接”怎么办?
答:请确认 853 端口已经在 VPS 防火墙(UFW/security group)中开放,且绑定的 SSL 证书不是自签证书(必须是公网 CA 签发)。
(相关资源导航:如果您需要搭建自建 DNS 用的优质 VPS 节点,欢迎阅读 《2026 国外 VPS 选购指南》,获取 DMIT、搬瓦工与 CloudCone 优惠通道;商用专线机场评测见 《“饿饭CC云”深度评测》!)