如何在 Unix/Linux 上使用 perl 执行批量 DNS 查询?
我有一个正在尝试获取 IP 地址的系统列表。我已成功使用 Perl 的 Net::DNS 模块对单个主机名执行 IP 地址查询。然而,我有 1,000 个系统需要 IP 地址。
有没有办法通过一次查询获取所有这些 IP 地址?
如果没有,是否有办法获取整个 DNS 条目列表(例如单个域)?如果我知道了,那么我可以简单地将其放入哈希中并以这种方式引用 IP 地址。
I have a list of systems for which I'm trying to get IP addresses. I've successfully used the Net::DNS module for perl to perform an IP address query for a single hostname. I have 1,000 systems, however, that I need ip addresses for.
Is there a way to get all of these ip addresses with a single query?
If not, is there a way to get the entire DNS entry list, say, for a single domain? If I got that, then I could simply put that into a hash and reference the IP addresses that way.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
无需定制 Perl。这可以使用
dig
的-f
选项(BIND 工具的一部分)来完成:No need for custom Perl. This can be done using the
-f
option todig
(part of the BIND tools):对于大型域数据集,这将快速完成,而不需要真正解析结果; IP 始终位于
$results{$domain}[0][4]
中。这不是单个查询,但它们将同时完成(IIRC 一次最多进行 10 个查询),因此会很快完成。只需确保 DNS 服务器运营商在短时间内处理这么多请求不会出现问题。输出:
For a large domain dataset, this'll do it fast with no real need to parse the results; an IP will always be in
$results{$domain}[0][4]
. It's not a single query, but they'll be done concurrently (max of 10 queries in progress at any one time IIRC) so will be done quickly. Just make sure the DNS server operator doesn't have a problem with that many requests in a short period.Outputs: