firefox 的 DoH(dns over https) 实际上 over http

2018-10-05 19:29:00 +08:00
 fangdingjun

我自己写了一个 DoH 服务器,然后配置到 firefox 上(firefox 62)

如下配置

network.trr.mode=3
network.trr.uri=https://dns.xxx.com/dns-query
network.trr.bootstrapAddress=1.0.0.1

firefox 一直报无法解析域名,我的服务器 443 端口没收到任何请求, 再一看 nginx 日志,请求全部在 80 端口上,

我把服务配置到 80 端口上,http 方式(非 https), firefox 就正常了

看了一下请求内容,确实是我访问的域名,但是就是请求的是 80 端口,http, 非加密的

在 firefox 里配置的确实是 https 地址

firefox 号称 dns over https, 实际请求是 over http, 我还一度怀疑我的 server 实现有问题

4358 次点击
所在节点    Firefox
7 条回复
shinko
2018-10-05 19:37:44 +08:00
你的发现,弥补了人类的空白
whoops
2018-10-05 19:46:37 +08:00
测试了一下
配置成 https://1.1.1.1/dns-query
然后用 wireshark 抓包,确实是通过 tls 1.2 访问的。
你的服务器上 https 证书放的是什么类型的,是自签名的吗?
whoops
2018-10-05 20:02:56 +08:00
如果是,重新生成一下证书,使用者可选名称把 IP 地址也加进去
1.1.1.1 的证书是这样的

DNS Name=*.cloudflare-dns.com
IP Address=1.1.1.1
IP Address=1.0.0.1
DNS Name=cloudflare-dns.com
IP Address=2606:4700:4700:0000:0000:0000:0000:1111
IP Address=2606:4700:4700:0000:0000:0000:0000:1001


参考一下这里
https://github.com/hardillb/dns-over-https/blob/master/README.md


First you need to SSL certificate for your server because the broker will only request DNS lookups from a secure server. Normally I'd go with Letsencrypt but unfortunately they won't issue a certificate for a raw IP address.

If you don't want to pay for a "real" certificate I've included a script to build a self signed for the IP address you are going to run this on.

./mkCert.sh 192.168.1.1
fangdingjun
2018-10-05 21:55:10 +08:00
@whoops 用的是 letsencrypt 证书
fangdingjun
2018-10-05 22:00:54 +08:00
我发现来源请求的 ip 地址不是我的公网 ip,而是一组美国 ip
whoops
2018-10-05 22:21:24 +08:00
@fangdingjun
1、发现你的 network.trr.bootstrapAddress=1.0.0.1,应该是你服务器的 IP 地址

2、证书中没有包含服务器 IP,参考一 3 楼的链接中的内容,如果可以试着用自签名,重新签名一下
Normally I'd go with Letsencrypt but unfortunately they won't issue a certificate for a raw IP address.
上面说 Letsencrypt 不能签 raw IP 的。

3、我觉得你应该在你的客户端,也就是 firefox 所在的 pc 机上抓包分析以下看,配置后访问其他网站,看看 firefox 进行 doh 的请求到底请求到哪里。

4,源请求的 ip 地址不是我的公网 ip,而是一组美国 ip,这是 nginx 看到的吧 ,可能是爬虫吧。
sadpencil
2020-04-26 01:12:45 +08:00
@fangdingjun 楼上说的对,你为什么要把 network.trr.bootstrapAddress 填成 1.0.0.1 而不是你服务器的 IP 地址,显然这个 IP 属于 cloudflare 而不是你服务器的 IP 。
你的服务器不需要一定配置昂贵的 IP 证书,只需要普通的域名证书即可,条件是配置 network.trr.uri 后必须正确配置 network.trr.bootstrapAddress 。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/495066

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX