DNS 加密的常用协议包括 DNS over HTTPS (DoH)、DNS over TLS (DoT) 和 DNSCrypt。以下是实现这些加密的步骤和工具建议:
1. 使用 DoH (DNS over HTTPS)
工具推荐:
- cloudflared(Cloudflare 提供的客户端)
- doh-client(轻量级 DoH 客户端)
- coredns(可配置 DoH 服务)
配置步骤:
安装工具: 例如,使用 cloudflared:
sudo apt update
sudo apt install cloudflared
配置 DNS 服务: 修改 /etc/cloudflared/config.yml:
proxy-dns: true
proxy-dns-port: 5053
proxy-dns-upstream:
– https://1.1.1.1/dns–query
– https://8.8.8.8/dns–query
启动服务:
sudo systemctl enable cloudflared
sudo systemctl start cloudflared
更改系统 DNS: 编辑 /etc/resolv.conf,将本地解析器指向 127.0.0.1:5053。
2. 使用 DoT (DNS over TLS)
工具推荐:
- Stubby
- Unbound
配置步骤(以 Stubby 为例):
安装 Stubby:
sudo apt install stubby
配置 Stubby: 编辑 /etc/stubby/stubby.yml:
resolution_type: GETDNS_RESOLUTION_STUB
dns_transport_list:
– GETDNS_TRANSPORT_TLS
tls_authentication: GETDNS_AUTHENTICATION_REQUIRED
upstream_recursive_servers:
– address_data: 1.1.1.1
tls_port: 853
tls_auth_name: "cloudflare-dns.com"
– address_data: 8.8.8.8
tls_port: 853
tls_auth_name: "dns.google"
启动服务:
sudo systemctl enable stubby
sudo systemctl start stubby
更改系统 DNS: 将 /etc/resolv.conf 配置为:
nameserver 127.0.0.1
3. 使用 DNSCrypt
工具推荐:
- dnscrypt-proxy
配置步骤:
安装 dnscrypt-proxy: 从官方 GitHub 页面下载并安装:
sudo apt install dnscrypt-proxy
配置 dnscrypt-proxy: 编辑 /etc/dnscrypt-proxy/dnscrypt-proxy.toml:
server_names = ['cloudflare', 'google']
listen_addresses = ['127.0.0.1:5353']
启动服务:
sudo systemctl enable dnscrypt-proxy
sudo systemctl start dnscrypt-proxy
更改系统 DNS: 修改 /etc/resolv.conf,指向 127.0.0.1:5353。
4. 验证 DNS 加密是否启用
使用以下工具检查 DNS 请求是否加密:
- dig(检查解析是否通过加密服务)
- tcpdump(捕获网络流量,验证是否走加密端口)
例如:
dig @127.0.0.1 -p 5053 google.com
如果需要进一步优化或解决问题,可以告诉我具体的场景或需求。 😊
评论前必须登录!
注册