input2output
V2EX  ›  问与答

dig 出来结果相同,但浏览器和 curl 在使用 DNS-Crypt 时都提示无法解析主机

  •  
  •   input2output · Feb 2, 2021 · 1248 views
    This topic created in 1925 days ago, the information mentioned may be changed or developed.

    用了 DNS-Crypt,对于 www.bilibili.com 和 其它国内网站 例如 www.baidu.com 写了 forward1.2.4.8 的配置
    使用 dig 出来的结果也一样

    $ dig www.bilibili.com @127.0.0.1 +short
    ....
    
    $ dig www.bilibili.com @1.2.4.8 +short
    ....
    

    /etc/resolv.conf 里配置 nameserver 127.0.0.1 时提示无法解析主机,Firefox 和 Chrome 都是相同错误:

    $ curl https://www.bilibili.com --proxy "" -v
    * Uses proxy env variable no_proxy == 'localhost, 127.0.0.1'
    * Could not resolve host: www.bilibili.com
    * Closing connection 0
    curl: (6) Could not resolve host: www.bilibili.com
    

    但是可以访问 https://www.baidu.com

    $ curl https://www.baidu.com --proxy "" -v
    ....
    

    如果 /etc/resolv.conf 里配置 nameserver 1.2.4.8,都可以正常访问。


    也 Google 过,可以使用

    $ sudo dhclient
    

    解决,但每次重启都要重来一次,很烦
    还有就是感觉这个问题并没有被真正解决,明明 dig 出来了,浏览器和 curl 却说不能解析主机,感到很困惑


    系统:openSUSE

    提前祝各位新春快乐

    Supplement 1  ·  Feb 2, 2021
    似乎是 dnscrypt-proxy 的问题,其它人也有类似的情况:
    https://github.com/DNSCrypt/dnscrypt-proxy/issues/898
    3 replies    2021-02-02 11:09:19 +08:00
    recall704
        1
    recall704  
       Feb 2, 2021   ❤️ 1
    我没看懂楼主的用法,但从我自己的测试情况来看。

    dig 执行的时候会对 /etc/resolv.conf 中的内容进行重试,即第一个 nameserver 失败会用第二个试试。

    而 curl 不会,第一个失败就不重试了。

    这个时候,就需要在 /etc/resolv.conf 中增加

    ```
    options timeout:2 attempts:1 rotate
    ```
    input2output
        2
    input2output  
    OP
       Feb 2, 2021
    strace 出来的内容:
    https://pastebin.pl/view/raw/e6ccc9f0
    input2output
        3
    input2output  
    OP
       Feb 2, 2021
    @recall704
    我每次都是保证 /etc/resolv.conf 里只有一个 nameserver 的,
    刚刚 strace 了一下,出来的结果好象是 dnscrypt-proxy 的 DNS 转发功能有问题
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1065 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 18:22 · PVG 02:22 · LAX 11:22 · JFK 14:22
    ♥ Do have faith in what you're doing.