linux - 在查询我的机器上本地运行的 DNS 服务器时,如何让 dig 使用 localhost 以外的源 IP?
问题描述
我正在尝试运行一个 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 发出请求,使用dig example.org @localhost -p1053 +short
它返回 1.1.1.1,因为请求是从 localhost 发送的
无论如何我可以从 dig 向 coredns 发送一个请求,它可能看起来像是从另一个 IP 发送的 DNS 服务器,它会返回 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
将其提供给服务器并查看其回复如何变化。
推荐阅读
- angular - 模块范围的 css 文件
- angular - 带有角度选项的 Google Places 自动完成功能不起作用
- python - 如何通过循环将字典和列表嵌套到字典中?
- sql - SQL:一2多行,多行合并为一列
- python - Python程序无异常无提示退出
- javascript - 默认 onClick 事件或 fromEvent(button, 'click')
- javascript - webpack 3:如何配置 webpack 以防止在由另一个 Web 应用程序加载时与其他包发生冲突?
- android - 在库模块中禁用 Firebase 数据收集?
- machine-learning - 逻辑回归机器学习?
- node.js - promis.all 中每个函数需要多少时间?