V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
fangdingjun
V2EX  ›  Firefox

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

  •  
  •   fangdingjun · 2018-10-05 19:29:00 +08:00 · 4308 次点击
    这是一个创建于 2000 天前的主题,其中的信息可能已经有所发展或是发生改变。

    我自己写了一个 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 实现有问题

    7 条回复    2020-04-26 01:12:45 +08:00
    shinko
        1
    shinko  
       2018-10-05 19:37:44 +08:00
    你的发现,弥补了人类的空白
    whoops
        2
    whoops  
       2018-10-05 19:46:37 +08:00
    测试了一下
    配置成 https://1.1.1.1/dns-query
    然后用 wireshark 抓包,确实是通过 tls 1.2 访问的。
    你的服务器上 https 证书放的是什么类型的,是自签名的吗?
    whoops
        3
    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
        4
    fangdingjun  
    OP
       2018-10-05 21:55:10 +08:00 via Android
    @whoops 用的是 letsencrypt 证书
    fangdingjun
        5
    fangdingjun  
    OP
       2018-10-05 22:00:54 +08:00 via Android
    我发现来源请求的 ip 地址不是我的公网 ip,而是一组美国 ip
    whoops
        6
    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
        7
    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 。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5255 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 09:36 · PVG 17:36 · LAX 02:36 · JFK 05:36
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.