【问题标题】:How do I make dig use a source IP other than localhost while querying a DNS server running locally on my machine?在查询我的机器上本地运行的 DNS 服务器时,如何让 dig 使用 localhost 以外的源 IP?
【发布时间】:2019-08-20 21:50:39
【问题描述】:

我正在尝试运行 coredns 插件 https://github.com/coredns/demo,它为 172.0.0.0/8 或 127.0.0.0/8 或 127.0.0.0/8 返回 1.1.1.1,为其他所有内容返回 8.8.8.8。

我运行二进制文件并尝试使用 dig example.org @localhost -p1053 +short 从 dig 发出请求,该请求返回 1.1.1.1,因为请求是从 localhost 发送的

无论如何我可以从 dig 向 coredns 发送一个请求,它可能看起来像是从另一个 IP 发送的 DNS 服务器,但它会返回 8.8.8.8?

【问题讨论】:

    标签: linux networking dns dig


    【解决方案1】:

    来自挖掘手册:

       -b address[#port]
           Set the source IP address of the query. The address must be a valid address on one of the host's network interfaces, or "0.0.0.0" or "::". An optional port may be
           specified by appending "#<port>"
    

    否则,如果服务器支持 ECS(EDNS 客户端子网),您可以使用 dig option +subnet=addr 将其提供给服务器并查看其回复的变化。

    【讨论】:

      猜你喜欢
      • 2012-08-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-05
      • 2021-08-25
      • 1970-01-01
      • 1970-01-01
      • 2023-03-03
      相关资源
      最近更新 更多