fangdingjun
V2EX  ›  Firefox

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

  •  
  •   fangdingjun · Oct 5, 2018 · 6003 views
    This topic created in 2962 days ago, the information mentioned may be changed or developed.

    我自己写了一个 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 replies  •  2020-04-26 01:12:45 +08:00
    shinko
    shinko
    Oct 5, 2018
    1
    你的发现,弥补了人类的空白
    whoops
    whoops
    Oct 5, 2018
    2
    测试了一下
    配置成 https://1.1.1.1/dns-query
    然后用 wireshark 抓包,确实是通过 tls 1.2 访问的。
    你的服务器上 https 证书放的是什么类型的,是自签名的吗?
    whoops
    whoops
    Oct 5, 2018
    3
    如果是,重新生成一下证书,使用者可选名称把 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
    fangdingjun
    OP
    Oct 5, 2018 via Android
    4
    @whoops 用的是 letsencrypt 证书
    fangdingjun
    fangdingjun
    OP
    Oct 5, 2018 via Android
    5
    我发现来源请求的 ip 地址不是我的公网 ip,而是一组美国 ip
    whoops
    whoops
    Oct 5, 2018
    6
    @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
    sadpencil
    Apr 26, 2020
    7
    @fangdingjun 楼上说的对,你为什么要把 network.trr.bootstrapAddress 填成 1.0.0.1 而不是你服务器的 IP 地址,显然这个 IP 属于 cloudflare 而不是你服务器的 IP 。
    你的服务器不需要一定配置昂贵的 IP 证书,只需要普通的域名证书即可,条件是配置 network.trr.uri 后必须正确配置 network.trr.bootstrapAddress 。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1142 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 18:03 · PVG 02:03 · LAX 10:03 · JFK 13:03
    ♥ Do have faith in what you're doing.