V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
input2output
V2EX  ›  问与答

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

  •  
  •   input2output · 2021-02-02 09:03:06 +08:00 · 787 次点击
    这是一个创建于 1190 天前的主题,其中的信息可能已经有所发展或是发生改变。

    用了 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

    提前祝各位新春快乐

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

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

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

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

    ```
    options timeout:2 attempts:1 rotate
    ```
    input2output
        2
    input2output  
    OP
       2021-02-02 11:07:11 +08:00
    strace 出来的内容:
    https://pastebin.pl/view/raw/e6ccc9f0
    input2output
        3
    input2output  
    OP
       2021-02-02 11:09:19 +08:00
    @recall704
    我每次都是保证 /etc/resolv.conf 里只有一个 nameserver 的,
    刚刚 strace 了一下,出来的结果好象是 dnscrypt-proxy 的 DNS 转发功能有问题
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3887 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 00:12 · PVG 08:12 · LAX 17:12 · JFK 20:12
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.