linux - 在查询我的计算机上本地运行的 DNS 服务器时,如何让 dig 使用 localhost 以外的源 IP?

标签 linux networking dns dig

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

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

我是否可以从 dig 向 coredns 发送一个请求,对于 DNS 服务器来说,它可能看起来像是从另一个 IP 发送的,并且会返回 8.8.8.8?

最佳答案

来自挖掘手册:

   -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 选项 +subnet=addr将其发送给服务器并查看其回复如何变化。

关于linux - 在查询我的计算机上本地运行的 DNS 服务器时,如何让 dig 使用 localhost 以外的源 IP?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55426163/

相关文章:

dns - 如何阻止 github 项目页面(或其他子页面)显示自定义域名?

c - DNS session 的结构是什么?

linux - 如何使用一个命令创建一组多个文件?

android - 如何在linux ubuntu中提取和设置android ndk .bin文件的路径?

c++ - 警告 : deprecated conversion from string constant to ‘ACE_TCHAR*’

c - Windows 自定义消息记录器的实现 : reports 10049 when ntwk cable unplugged

linux - 从文件中匹配模式的数组中删除元素

networking - 如何在 Fedora 19 中设置静态 IP

java - 如何限制传输速度?

dns - NS : got insecure response; parent indicates it should be secure