为什么我的 vps 即使没有 dns 服务器 运行 也会回复 dns 查询?

Why does my vps reply to dns queries even if it has no dns server running?

我有一个便宜的 openvz Ubuntu vps 我正在尝试 运行 我自己的 dns 服务器用于学习目的。

dns 服务器在本地主机(在 vps 上通过 ssh)工作正常,我可以使用 dig google.com @127.0.0.1 查询它,我得到了预期的结果(这不是 [=33 的 IP =] 但一个自定义的)。

当我尝试使用相同的命令从 vps 外部查询 dns 服务器时,我确实得到了回复,但 IP 不是我所期望的(这是一个实际的 google.com IP ).

经过进一步调查,我发现当从 vps 外部完成查询时,我的 dns 服务器不是 receiving/sending 数据包。所以答案是由其他东西发送的,似乎目标端口为53的入站数据包发生了偏差,它们甚至没有到达我的dns服务器。

我试图查询我的 dns 服务器,仍然是从外部,但这次 VPS 处于关闭状态。神奇的是我收到了天知道是谁的回复。

将端口从 53 更改为 54 一切正常。 问题是我需要它来使用端口 53。

我没有 iptables 规则,也没有任何其他防火墙做与端口 53 相关的事情

我还尝试从不同的托管服务提供商那里随机查询 vps,似乎每个人都有一个 dns 服务器 运行ning!为什么大家都回复?

当然问了技术支持,他们是这么说的:

Hello, Sorry but we don't do "software" technical support on VPS. We deliver the hosting and the operating systems, customers that order VPS are their own admins, and have to know how to manage a linux server. We don't block any port on our side. Best regards, Support

Mybe 你的 dns 服务器只绑定到环回接口(所以它只监听 localhost)。您可以使用 netstat 检查当前使用的服务端口(DNS 的 udp)和过滤器(grep)使用的 udp 端口​​

netstat -an | grep ":53"

您还可以使用 nslookup 命令测试相同的 dns 查询,并在结果输出中检查响应您的 dns 查询的 dns 服务器 ip:

nslookup google.com [dns_server_ip]

同样在没有 dns_server_ip 的情况下进行测试,以检查当指定的名称服务器没有响应时是否存在默认名称服务器。

问题已解决,是我的 ISP 拦截并回复了 dns 查询。 我可以做到 dig google.com @1.2.3.4 并得到回复 :D

谁想了解更多:

ISP Intercepting DNS Lookups