DNS over HTTPS

DNS over HTTPS用于解决DNS解析的隐私问题

Debian
可以使用dnscrypt-proxy

MacOSX
建议使用dnscrypt-proxy

安装cloudflared

1
2
3
$ brew install cloudflare/cloudflare/cloudflared
$ cloudflared --version
cloudflared version 2019.7.0 (built 2019-07-11-1655 UTC)

添加配置文件config.yaml

1
2
3
4
5
6
7
$ mkdir -p /usr/local/etc/cloudflared
$ cat << EOF > /usr/local/etc/cloudflared/config.yml
proxy-dns: true
proxy-dns-upstream:
- https://1.1.1.1/dns-query
- https://1.0.0.1/dns-query
EOF

安装服务

1
2
3
$ sudo cloudflared service install
INFO\[0000\] Installing Argo Tunnel client as a system launch daemon. Argo Tunnel client will run at boot
INFO\[0000\] Outputs are logged to /Library/Logs/com.cloudflare.cloudflared.err.log and /Library/Logs/com.cloudflare.cloudflared.out.log

卸载cloudflare

1
2
$ sudo cloudflared service uninstall
$ brew uninstall cloudflare/cloudflare/cloudflared

校验

1
2
3
4
5
6
$ dig +short @127.0.0.1 cloudflare.com A
198.41.214.162
198.41.215.162
$ dig +short @127.0.0.1 cloudflare.com AAAA
2606:4700::c629:d7a2
2606:4700::c629:d6a2

设置系统dns

将系统DNS设置为127.0.0.1

Firefox浏览器

DOH设置

地址栏输入about:config进入配置界面,修改以下参数配置DOH:

network.trr.mode = 3
#3为只使用DOH,1为关闭DOH特性,2为优先使用DOH,还可以fallback到传统dns

network.trr.uri = https://1.1.1.1/dns-query
#cloudflare提供的DOH公共服务器

ESNI设置

同一个IP地址可以托管很多的站点,在建立TLS链接时SNI域名会明文发送,Encrypted SNI就是为了解决这个问题,防止第三方窃取隐私。

network.security.esni.enabled设置为true打开Encrypted SNI浏览器支持

服务器端

OpenSSL尚未支持ESNI,因此下游的nginx当前亦不支持,相信很快就会支持。
DEfO是一个为OpenSSL添加ENSI支持的项目github地址

chrome浏览器

即将支持:-(,参考[5]
今年10月晚期发布的chrome 78会开始实验性的支持DOH,参见[9]
ESNI一样尚未支持

版本78以后,打开Secure DNS lookups
(chrome://flags/#dns-over-https)标志,并将系统dns设置为1.1.1.1和/或1.0.0.1

References:
[1]对比4种强化域名安全的协议——DNSSEC,DNSCrypt,DNS over TLS,DNS over HTTPS
[2]Browsing Experience Security Check
[3]DNS over HTTPS
[4]Trusted Recursive Resolver
[5]Add DNS-over-HTTPS to chrome://flags
[6]Running a DNS over HTTPS Client
[7]dnscrypt-proxy
[8]MacOS 开启 DNS over HTTPS (DoH)
[9]Google to run DNS-over-HTTPS (DoH) experiment in Chrome
[10]Trusted Recursive Resolver