DNS区域文本文件中的“反向查找”

有一个现有的工具或一个很酷或有趣的方式来查找DNS区域文件中的所有项目,这是“解决”给定的IP? (根本不使用任何DNS服务器)

例如,我们可能会有以下不完善的DNSconfiguration:

example.org. 60 IN A 10.0.0.1 new.example.org. 60 IN A 10.0.0.10 www.example.org. 60 IN CNAME example.org. old.example.org. 60 IN CNAME www.example.org. toaster.example.org. 60 IN CNAME bigbox.example.org. cutebox.example.org. 60 IN A new.example.org. bigbox.example.org. 60 IN A 10.0.0.1 

该工具对问题10.0.0.1的回答应该是example.org, www.example.org, old.example.org, toaster.example.org, bigbox.example.org

更新 :要清楚:我们有可用的域的区域文件

更新 :我刚刚被扼杀的下面的脚本几乎完全是我想要的(期望在标准input上的DNS区域文件)(没有IPv6支持:-P):

 #! /usr/bin/env python import re import sys cols = (0, 4) type_col = 3 types = ('A', 'CNAME') if len(sys.argv) != 2: sys.exit('query not given (IP or hostname)') query = sys.argv[1] rex_not = re.compile(r'^\s*;') relations = [] found = set([query]) def filter_pairs(l, f): for itm in l: if itm[1] in f: yield itm in_pairs = [] for line in sys.stdin: if rex_not.match(line): continue itms = re.split(r'\s+', line.strip()) try: typ = itms[type_col] if typ not in types: continue a, b = (itms[cols[0]], itms[cols[1]]) except IndexError: continue if a and b: in_pairs.append((a, b)) oldpairs = in_pairs[:] while True: pairs = list(filter_pairs(in_pairs, found)) for itm in pairs: found.add(itm[0]) if len(pairs) == len(oldpairs): break oldpairs = pairs found = found.difference(set([query])) for x in found: print(x) 

除非每个DNS都有一个反向DNS条目,否则无法完成。 当然,有些人会告诉你,这是可以做到的,甚至会指向一大堆网站,声称这样做,但事实是,这是不可能的。