【问题标题】:CURL --interface not working: "Couldn't bind to ..." errorCURL --interface not working:“无法绑定到...”错误
【发布时间】:2013-08-20 16:12:46
【问题描述】:

我正在尝试将 curl 与服务器中可用的 IP 地址中的另一个 IP 地址一起使用,但我收到此错误:

curl --interface 41.141.41.23 http://www.google.com

curl: (45) 无法绑定到 41.141.41.23(它只是一个示例地址)

它只能让我用主要的并且只能通过接口名称来做:

curl --interface eth0 http://www.google.com

我正在使用:

Ubuntu 12.04

curl 7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3

【问题讨论】:

    标签: curl


    【解决方案1】:

    如果请求的域同时使用 ipv4 和 ipv6 而不是仅使用 ipv4,则使用 --interface 时,Curl 中似乎存在错误,您必须添加 --ipv4 才能工作。

    www.google.com 就是这种情况,所以要让它发挥作用:

    curl --interface 41.141.41.23 --ipv4 http://www.google.com
    

    【讨论】:

      【解决方案2】:

      您能说得更具体些吗?

      1. 您使用的是什么 curl 版本?
      2. 您运行的是什么操作系统?
      3. curl --verbose --interface 41.141.41.23 http://www.google.com 是否显示了更具体的内容?

      这表明您对 /proc 目录的访问受到限制...

      【讨论】:

      • 感谢您的帮助。我将版本添加到答案的底部。关于详细信息,没有提供更多信息:* Trying 2a00:1450:4007:804::1010... getaddrinfo(3) failed for 41.141.41.23:0 * Couldn't bind to '41.141.41.23' * 关闭连接 #0 curl:(45) 无法绑定到 '41.141.41.23'
      • hmmm... 您能否显示ls -ald /proc/netls -ald /proc/self/net 的输出? stackoverflow.com/questions/8955724/… 听起来像一个类似的问题。是否也是启用了 GrSecurity 的内核?
      【解决方案3】:

      正确的用法是curl --interface iface-name ....,例如curl --interface tun0 google.com

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2022-08-19
        • 2017-07-08
        • 2019-05-14
        • 1970-01-01
        • 1970-01-01
        • 2021-07-11
        • 1970-01-01
        • 2023-03-19
        相关资源
        最近更新 更多